[Kde-games-devel] Proposing KGameRenderer
Parker Coates
parker.coates at kdemail.net
Sun Jun 13 00:04:02 CEST 2010
On Sat, Jun 12, 2010 at 04:40, Ian Wadham wrote:
> I would suggest that the creation of a KSvgRenderer, SVG loading and
> SVG rendering can all be postponed until it is found that there is no cache
> or that it is invalid (e.g. SVG file more recent than cache) or that there is
> no cached pixmap with a required identity and size. Also, loading is needed
> only when there is a theme change, as opposed to a size change.
> KGoldrunner::KGrTheme does that (i.e. it uses the cache alone in many
> runs of KGr) and that saves a *lot* of startup time (after the first run).
In LibKCardGame, I do something even better. The loading of the SVG is
delayed as you recommend, but then a low priority rendering thread is
launched. The first thing the thread does is load the SVG after
checking it hasn't already been loaded. (It then goes on to render
all card fronts and backs at the current size, but that's a separate
topic.)
Originally, I was just delaying the loading, but I found that was
often less desirable then preloading since the SVG would sometimes
have to be loaded in the middle of game play causing a noticeable
pause. At least at startup the user is already waiting, so what are a
few extra milliseconds.. From my experience, loading the SVG in
parallel is definitely the ideal way of handling this.
Parker
More information about the kde-games-devel
mailing list