diff options
author | Matthew Hoops | 2010-11-25 02:59:56 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-11-25 02:59:56 +0000 |
commit | 4c733c427862fa45315e56bcba07e03bb3872ed2 (patch) | |
tree | 52e6978c5d80ee87a0c60b22a1c2ef0c88aa2168 /engines/mohawk/graphics.h | |
parent | 3abab136da51b9dcb5589052c8645a8d30d904bb (diff) | |
download | scummvm-rg350-4c733c427862fa45315e56bcba07e03bb3872ed2.tar.gz scummvm-rg350-4c733c427862fa45315e56bcba07e03bb3872ed2.tar.bz2 scummvm-rg350-4c733c427862fa45315e56bcba07e03bb3872ed2.zip |
MOHAWK: Cleanup image surface handling
- Renamed ImageData to MohawkSurface
- Added offset x/y fields to MohawkSurface
- The image cache now stores MohawkSurface pointers
- Switched Living Books to 8bpp mode (it requires that in the end anyway)
svn-id: r54468
Diffstat (limited to 'engines/mohawk/graphics.h')
-rw-r--r-- | engines/mohawk/graphics.h | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h index 31a31aa237..f90c792d25 100644 --- a/engines/mohawk/graphics.h +++ b/engines/mohawk/graphics.h @@ -68,27 +68,32 @@ enum { kMystZipModeCursor = 999 // Zip Mode cursor }; -// A simple struct to hold necessary image info -class ImageData { +class MohawkSurface { public: - ImageData() : _surface(0), _palette(0) {} - ImageData(Graphics::Surface *surface, byte *palette = NULL) : _surface(surface), _palette(palette) {} - ~ImageData() { - if (_palette) - free(_palette); - if (_surface) { - _surface->free(); - delete _surface; - } - } - - // getSurface() will convert to the current screen format, if it's not already - // in that format. Makes it easy to support both 8bpp and 24bpp images. - Graphics::Surface *getSurface(); - - // These are still public in case the 8bpp surface needs to be accessed + MohawkSurface(); + MohawkSurface(Graphics::Surface *surface, byte *palette = NULL, int offsetX = 0, int offsetY = 0); + ~MohawkSurface(); + + // getSurface() returns the surface in the current format + // This will be the initial format unless convertToTrueColor() is called + Graphics::Surface *getSurface() const { return _surface; } + byte *getPalette() const { return _palette; } + + // Convert the 8bpp image to the current screen format + // Does nothing if _surface is already >8bpp + void convertToTrueColor(); + + // Functions for OldMohawkBitmap offsets + // They both default to 0 + int getOffsetX() const { return _offsetX; } + int getOffsetY() const { return _offsetY; } + void setOffsetX(int x) { _offsetX = x; } + void setOffsetY(int y) { _offsetY = y; } + +private: Graphics::Surface *_surface; byte *_palette; + int _offsetX, _offsetY; }; class GraphicsManager { @@ -102,14 +107,14 @@ public: 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); + MohawkSurface *findImage(uint16 id); // decodeImage will always return a new image. - virtual Graphics::Surface *decodeImage(uint16 id) = 0; + virtual MohawkSurface *decodeImage(uint16 id) = 0; private: // An image cache that stores images until clearCache() is called - Common::HashMap<uint16, Graphics::Surface *> _cache; + Common::HashMap<uint16, MohawkSurface*> _cache; }; class MystGraphics : public GraphicsManager { @@ -128,7 +133,7 @@ public: void drawRect(Common::Rect rect, bool active); protected: - Graphics::Surface *decodeImage(uint16 id); + MohawkSurface *decodeImage(uint16 id); private: MohawkEngine_Myst *_vm; @@ -196,7 +201,7 @@ public: void hideInventory(); protected: - Graphics::Surface *decodeImage(uint16 id); + MohawkSurface *decodeImage(uint16 id); private: MohawkEngine_Riven *_vm; @@ -229,12 +234,11 @@ public: void setPalette(uint16 id); protected: - Graphics::Surface *decodeImage(uint16 id); + MohawkSurface *decodeImage(uint16 id); private: MohawkBitmap *_bmpDecoder; MohawkEngine_LivingBooks *_vm; - byte *_palette; }; } // End of namespace Mohawk |