2009-12-29 23:18:24 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOHAWK_GRAPHICS_H
|
|
|
|
#define MOHAWK_GRAPHICS_H
|
|
|
|
|
|
|
|
#include "mohawk/bitmap.h"
|
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
#include "common/hashmap.h"
|
2012-03-10 18:50:27 +00:00
|
|
|
#include "common/rect.h"
|
2011-01-18 16:18:10 +00:00
|
|
|
|
|
|
|
namespace Graphics {
|
2012-03-10 18:50:27 +00:00
|
|
|
struct Surface;
|
2011-01-18 16:18:10 +00:00
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
namespace Mohawk {
|
|
|
|
|
2010-12-02 21:25:15 +00:00
|
|
|
class MohawkEngine;
|
2010-11-30 09:04:47 +00:00
|
|
|
class MohawkEngine_LivingBooks;
|
2009-12-29 23:18:24 +00:00
|
|
|
class MohawkBitmap;
|
2010-11-29 20:55:11 +00:00
|
|
|
|
2010-11-25 02:59:56 +00:00
|
|
|
class MohawkSurface {
|
2009-12-29 23:18:24 +00:00
|
|
|
public:
|
2010-11-25 02:59:56 +00:00
|
|
|
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:
|
2009-12-29 23:18:24 +00:00
|
|
|
Graphics::Surface *_surface;
|
|
|
|
byte *_palette;
|
2010-11-25 02:59:56 +00:00
|
|
|
int _offsetX, _offsetY;
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
class GraphicsManager {
|
|
|
|
public:
|
|
|
|
GraphicsManager();
|
|
|
|
virtual ~GraphicsManager();
|
|
|
|
|
|
|
|
// Free all surfaces in the cache
|
|
|
|
void clearCache();
|
|
|
|
|
2010-12-02 21:25:15 +00:00
|
|
|
void preloadImage(uint16 image);
|
|
|
|
virtual void setPalette(uint16 id);
|
|
|
|
void copyAnimImageToScreen(uint16 image, int left = 0, int top = 0);
|
|
|
|
void copyAnimImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
|
2010-12-25 19:52:54 +00:00
|
|
|
void copyAnimSubImageToScreen(uint16 image, uint16 subimage, int left = 0, int top = 0);
|
2010-12-02 21:25:15 +00:00
|
|
|
|
2011-01-19 20:53:28 +00:00
|
|
|
void getSubImageSize(uint16 image, uint16 subimage, uint16 &width, uint16 &height);
|
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
protected:
|
2010-12-25 19:52:54 +00:00
|
|
|
void copyAnimImageSectionToScreen(MohawkSurface *image, Common::Rect src, Common::Rect dest);
|
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
// findImage will search the cache to find the image.
|
|
|
|
// If not found, it will call decodeImage to get a new one.
|
2010-11-25 02:59:56 +00:00
|
|
|
MohawkSurface *findImage(uint16 id);
|
2010-11-19 21:25:36 +00:00
|
|
|
|
|
|
|
// decodeImage will always return a new image.
|
2010-11-25 02:59:56 +00:00
|
|
|
virtual MohawkSurface *decodeImage(uint16 id) = 0;
|
2010-12-25 19:52:54 +00:00
|
|
|
virtual Common::Array<MohawkSurface *> decodeImages(uint16 id);
|
2010-11-19 21:25:36 +00:00
|
|
|
|
2010-12-02 21:25:15 +00:00
|
|
|
virtual MohawkEngine *getVM() = 0;
|
2011-03-09 18:54:15 +00:00
|
|
|
void addImageToCache(uint16 id, MohawkSurface *surface);
|
2010-12-02 21:25:15 +00:00
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
private:
|
|
|
|
// An image cache that stores images until clearCache() is called
|
2012-02-15 06:06:13 +00:00
|
|
|
Common::HashMap<uint16, MohawkSurface *> _cache;
|
|
|
|
Common::HashMap<uint16, Common::Array<MohawkSurface *> > _subImageCache;
|
2010-11-19 21:25:36 +00:00
|
|
|
};
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
} // End of namespace Mohawk
|
|
|
|
|
|
|
|
#endif
|