From aac238cec9cab9efe7319d8397b95e7a77bdb5cd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 1 Aug 2011 21:05:48 +0300 Subject: Fix perfomance issue with caching complex sprites. --- src/compoundsprite.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/compoundsprite.h') diff --git a/src/compoundsprite.h b/src/compoundsprite.h index 834ccd835..0841bcfb8 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -24,10 +24,26 @@ #include "sprite.h" +#include #include class Image; +typedef std::list VectorPointers; + +class CompoundItem +{ + public: + CompoundItem(); + + ~CompoundItem(); + +// float alpha; + VectorPointers data; + Image *image; + Image *alphaImage; +}; + class CompoundSprite : public Sprite, private std::vector { public: @@ -101,9 +117,18 @@ public: virtual void setAlpha(float alpha); private: - void redraw() const; + void updateImages() const; + + bool updateFromCache() const; + + void initCurrentCacheItem() const; + + typedef std::list ImagesCache; + mutable ImagesCache imagesCache; + mutable CompoundItem *mCacheItem; + mutable Image *mImage; mutable Image *mAlphaImage; -- cgit v1.2.3-60-g2f50