aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/graphics.h
diff options
context:
space:
mode:
authorMatthew Hoops2010-11-19 21:25:36 +0000
committerMatthew Hoops2010-11-19 21:25:36 +0000
commit7fb352e38a8dcfb8a980c60d15b071ad1a427386 (patch)
tree4970ac0fec0bdce750a85e7a30dbeefa39c6bd61 /engines/mohawk/graphics.h
parent199a1c761960f1928d8ce80d607f6eedadc67957 (diff)
downloadscummvm-rg350-7fb352e38a8dcfb8a980c60d15b071ad1a427386.tar.gz
scummvm-rg350-7fb352e38a8dcfb8a980c60d15b071ad1a427386.tar.bz2
scummvm-rg350-7fb352e38a8dcfb8a980c60d15b071ad1a427386.zip
MOHAWK: Implement an image cache system
This should greatly improve the performance in Myst (especially Myst ME, which uses the slow JPEG decoder). This should also slightly improve the Riven performance; the sliders now work a bit better. svn-id: r54388
Diffstat (limited to 'engines/mohawk/graphics.h')
-rw-r--r--engines/mohawk/graphics.h38
1 files changed, 35 insertions, 3 deletions
diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h
index e44bba213b..31a31aa237 100644
--- a/engines/mohawk/graphics.h
+++ b/engines/mohawk/graphics.h
@@ -30,6 +30,7 @@
#include "mohawk/livingbooks.h"
#include "common/file.h"
+#include "common/hashmap.h"
#include "graphics/pict.h"
#include "graphics/video/codecs/mjpeg.h"
@@ -90,7 +91,28 @@ public:
byte *_palette;
};
-class MystGraphics {
+class GraphicsManager {
+public:
+ GraphicsManager();
+ virtual ~GraphicsManager();
+
+ // Free all surfaces in the cache
+ void clearCache();
+
+protected:
+ // findImage will search the cache to find the image.
+ // If not found, it will call decodeImage to get a new one.
+ Graphics::Surface *findImage(uint16 id);
+
+ // decodeImage will always return a new image.
+ virtual Graphics::Surface *decodeImage(uint16 id) = 0;
+
+private:
+ // An image cache that stores images until clearCache() is called
+ Common::HashMap<uint16, Graphics::Surface *> _cache;
+};
+
+class MystGraphics : public GraphicsManager {
public:
MystGraphics(MohawkEngine_Myst*);
~MystGraphics();
@@ -104,6 +126,10 @@ public:
void updateScreen();
void drawRect(Common::Rect rect, bool active);
+
+protected:
+ Graphics::Surface *decodeImage(uint16 id);
+
private:
MohawkEngine_Myst *_vm;
MystBitmap *_bmpDecoder;
@@ -141,7 +167,7 @@ struct SFXERecord {
uint32 lastFrameTime;
};
-class RivenGraphics {
+class RivenGraphics : public GraphicsManager {
public:
RivenGraphics(MohawkEngine_Riven *vm);
~RivenGraphics();
@@ -169,6 +195,9 @@ public:
void showInventory();
void hideInventory();
+protected:
+ Graphics::Surface *decodeImage(uint16 id);
+
private:
MohawkEngine_Riven *_vm;
MohawkBitmap *_bitmapDecoder;
@@ -191,7 +220,7 @@ private:
Graphics::PixelFormat _pixelFormat;
};
-class LBGraphics {
+class LBGraphics : public GraphicsManager {
public:
LBGraphics(MohawkEngine_LivingBooks *vm);
~LBGraphics();
@@ -199,6 +228,9 @@ public:
void copyImageToScreen(uint16 image, uint16 left = 0, uint16 top = 0);
void setPalette(uint16 id);
+protected:
+ Graphics::Surface *decodeImage(uint16 id);
+
private:
MohawkBitmap *_bmpDecoder;
MohawkEngine_LivingBooks *_vm;