ScummVM API documentation
graphics.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MOHAWK_GRAPHICS_H
23 #define MOHAWK_GRAPHICS_H
24 
25 #include "mohawk/bitmap.h"
26 
27 #include "common/hashmap.h"
28 #include "common/rect.h"
29 
30 namespace Graphics {
31 struct Surface;
32 }
33 
34 namespace Mohawk {
35 
36 class MohawkEngine;
37 class MohawkEngine_LivingBooks;
38 class MohawkBitmap;
39 
41 public:
42  MohawkSurface();
43  explicit MohawkSurface(Graphics::Surface *surface, byte *palette = nullptr, int offsetX = 0, int offsetY = 0);
44  ~MohawkSurface();
45 
46  // getSurface() returns the surface in the current format
47  // This will be the initial format unless convertToTrueColor() is called
48  Graphics::Surface *getSurface() const { return _surface; }
49  byte *getPalette() const { return _palette; }
50 
51  // Convert the 8bpp image to the current screen format
52  // Does nothing if _surface is already >8bpp
53  void convertToTrueColor();
54 
55  // Functions for OldMohawkBitmap offsets
56  // They both default to 0
57  int getOffsetX() const { return _offsetX; }
58  int getOffsetY() const { return _offsetY; }
59  void setOffsetX(int x) { _offsetX = x; }
60  void setOffsetY(int y) { _offsetY = y; }
61 
62 private:
63  Graphics::Surface *_surface;
64  byte *_palette;
65  int _offsetX, _offsetY;
66 };
67 
69 public:
71  virtual ~GraphicsManager();
72 
73  // Free all surfaces in the cache
74  void clearCache();
75 
76  // findImage will search the cache to find the image.
77  // If not found, it will call decodeImage to get a new one.
78  MohawkSurface *findImage(uint16 id);
79 
80  void preloadImage(uint16 image);
81  virtual void setPalette(uint16 id);
82  void copyAnimImageToScreen(uint16 image, int left = 0, int top = 0);
83  void copyAnimImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
84  void copyAnimSubImageToScreen(uint16 image, uint16 subimage, int left = 0, int top = 0);
85 
86  void getSubImageSize(uint16 image, uint16 subimage, uint16 &width, uint16 &height);
87 
88 protected:
89  void copyAnimImageSectionToScreen(MohawkSurface *image, Common::Rect src, Common::Rect dest);
90 
91  // decodeImage will always return a new image.
92  virtual MohawkSurface *decodeImage(uint16 id) = 0;
93  virtual Common::Array<MohawkSurface *> decodeImages(uint16 id);
94 
95  virtual MohawkEngine *getVM() = 0;
96  void addImageToCache(uint16 id, MohawkSurface *surface);
97 
98 private:
99  // An image cache that stores images until clearCache() is called
102 };
103 
104 } // End of namespace Mohawk
105 
106 #endif
Definition: graphics.h:40
Definition: surface.h:67
Definition: array.h:52
Definition: rect.h:144
Definition: graphics.h:68
Definition: hashmap.h:85
Definition: formatinfo.h:28
Definition: mohawk.h:54
Definition: bitmap.h:32