[Kde-games-devel] SVG and MainWindow resize handling

Luciano Montanaro mikelima at gmail.com
Sat Jan 19 15:50:33 CET 2008


Il Saturday 19 January 2008 15:22:42 Andreas Pakulat ha scritto:
> On 20.01.08 00:21:17, Ian Wadham wrote:
> > On Sat, 19 Jan 2008 11:52 pm, Andreas Pakulat wrote:
> > > Unrelated question: Do the svg games already use KPixmapCache for
> > > caching the rendered svg's?
> >
> > Not sure if any do.  KGoldrunner does not.  It was the next thing I
> > was going to try: mainly to save pixmaps between closes and
> > re-opens of main window and avoid SVG loads on startup.
>
> Nice :)
>
> > > IMHO that could speed up re-resizing the
> > > app, i.e. if you change from maximization to "normal" size and back, as
> > > in that case it would only reload a QPixmap instead of rerendering the
> > > svg.
> >
> > Within one session of the game, possibly.  But KMainWindow and friends
> > forget "normal" size when a maximized main window closes ... ;-)
>
> But as soon as the user uses the same size again he could get it from
> the cache. Ideally the apps would be able to specify some kind of
> "ratio" in which the pixmap will just be scaled with QImage, instead of
> re-rendering the whole svg. I suspect even with the
> qpixmap->qimage->qpixmap conversion its faster and for small
> numbers of the ratio (i.e. little size difference between the actual
> cached image and the currently needed size) I doubt anybody can see a
> difference between the scaled and a freshly rendered version.
>
> > BTW, the KDE Games team did kick around ideas like KPixmapCache
> > before the release of KDE 4.0, but mostly decided to leave refinements
> > till KDE 4.1.  I think we did well to produce a large slab of working
> > KDE 4.0 apps, Andreas, don't you?
>
> Uhm, I wasn't saying anything like "the 4.0 games are bad", I wasn't
> even thinking of that. I regularly play two or three of them, even
> though they have a kde3 version, simply because they look a lot nicer :)
>
> You people did a great job, I'm just thinking out loud what comes to my
> mind to speed up the rendering-stuff. Maybe thats because I've got a
> poor 4-year old laptop with a relatively low-end cpu/gpu...
>
> Andreas

Speaking of rendering speed...

I have added an experimental direct-top pixmap mode rendering to KGoldrunner.

On my hardware, it seems to be quite helpful with complex backgrounds 
rendering (the Egypt theme, for example) while the rendering of the runners 
is faster with the old method. However, the performance is probably heavily 
dependent on how fast render acceleration is in the X11 driver.

So it would help if a few people could try running kgoldrunner with and 
without the experimental feature and drop me an email with the results...

To do this test you have to run kgoldrunner from a terminal.

To enable the experimental code you have to set KGOLDRUNNER_USE_PIXMAPS to 1 
before running kgoldrunner, so type:

KGOLDRUNNER_USE_PIXMAPS=1 kgoldrunner

start a level, pause it; then change the theme to something different from the 
egypt theme, then to the egypt theme.

I'm interested in the last lines that are output to the console, that should 
read something like those at the bottom of my message.

I need samples with
KGOLDRUNNER_USE_PIXMAPS=0 kgoldrunner
and 
KGOLDRUNNER_USE_PIXMAPS=0 kgoldrunner

to see if it is useful...
If the numbers are close, it does not have sense to leave this code in. But at 
least here, the background takes half the time with the pixmap code...

Cheers,
Luciano

kgoldrunner(32299) KGrCanvas::changeTheme: 1918 msec.  Finish loading new 
theme.
kgoldrunner(32299) KGrCanvas::drawTheScene: 0 msec.  Start drawTheScene
kgoldrunner(32299) KGrCanvas::drawTheScene: Images: 28 x 28
kgoldrunner(32299) KGrCanvas::loadBackground: loadBackground called
kgoldrunner(32299) renderBackground: Trying to load background "background0"
background took 618 ms to render
kgoldrunner(32299) KGrCanvas::drawTheScene: 845 msec.  Tiles + background 
done.
rendering frames took  345 ms
rendering frames took  125 ms
rendering frames took  134 ms
kgoldrunner(32299) KGrCanvas::drawTheScene: 604 msec.  Hero + enemies done.
kgoldrunner(32299) KGrCanvas::drawTheScene: 0 msec.  Finished drawTheScene.
kgoldrunner(32299) KMenuBar::paintEvent: QRegion(size=1), bounds = QRect(168,3 
67x23)
 -  0 QRect(168,3 67x23)
kgoldrunner(32299) KMenuBar::paintEvent: QRect(168,3 67x23)



More information about the kde-games-devel mailing list