[Panel-devel] rfc: Plasma::Theme and Plasma::Svg

Aaron J. Seigo aseigo at kde.org
Tue Mar 6 22:55:26 CET 2007


On March 6, 2007, Zack Rusin wrote:
> On Tuesday 06 March 2007 13:46, Aaron J. Seigo wrote:
> <snip>
>
> > i sat down last night and put together a design that will provide for
> > these use cases to avoid duplicating this pattern over and over in the
> > code.
>
> Sounds like a great idea.

=)

> > Plasma::Svg will provide the following public methods:
> >
> > - Svg(const QString& imagePath, const QSize& size)
> > 	constructor that takes a path to be used with Plasma::Theme
>
> Right on.

ah, and of course just Svg(const QString& imagePath) which will use the 
default size of the svg file.

> > - paint( QPainter*, const QRect& )
> > 	pretty obvious =)
>
> If Svg has a native size then I think the natural paint method for it would
> simply take a point. Otherwise if you'd like to extand to the whole rect
> (which will imply rerendering on the fly anyway) I'd suggest following the
> Qt's scenario where you both accept the source rectangle and destination
> rectangle. But yeah, the QPoint method would be enough.

yeah, i considered adding a source rect as well. i'm holding off on that to 
see if have use cases first. it's easier to add API in these cases than it is 
to remove them later.

i will add a QPoint version however.

> Spot Waldo? :) When rendering the pixmap on the widget the painter is

dammit; i always forget about transformations. pffft! who needs them! ;-P

> > profiling should later show if/when/how the shared renderer should be
> > instantiated and removed. e.g. it may make sense to create the renderer
> > and after a certain amount of time w/out calls to resize to delete it to
> > conserve memory.
>
> Sounds like a great plan. I'm not sure how well the refcounting of pixmaps
> would work, but it's not a burning thing.

in common use cases outside of this particular set, probably with highly 
varying results. but looking at the code that is already emerging there are 
patterns that are pretty obvious: the same svg gets used to paint a number of 
identical items.

so as long as the Plasma::Svg's lifespan is matched with the need to paint 
that svg to screen, it should work out ok. the code will need to check that 
the item actually -does- exist in the cache, of course; the refcounting will 
only be there as a hint for when we know we can remove it because it simply 
isn't being used anymore.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

Full time KDE developer sponsored by Trolltech (http://www.trolltech.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20070306/5aa4d564/attachment.pgp 


More information about the Panel-devel mailing list