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 NANCY_GRAPHICS_H
23 #define NANCY_GRAPHICS_H
24 
25 #include "common/path.h"
26 
27 #include "graphics/screen.h"
28 
29 #include "engines/nancy/font.h"
30 
31 namespace Nancy {
32 
33 class RenderObject;
34 
35 // Graphics class that handles multilayered surface rendering with minimal redraw
37 public:
39 
40  void init();
41  void draw(bool updateScreen = true);
42 
43  void loadFonts(Common::SeekableReadStream *chunkStream);
44 
45  void addObject(RenderObject *object);
46  void removeObject(RenderObject *object);
47  void clearObjects();
48 
49  void redrawAll();
50  void suppressNextDraw();
51 
52  const Font *getFont(uint id) const { return id < _fonts.size() ? &_fonts[id] : nullptr; }
53  const Graphics::Screen *getScreen() { return &_screen; }
54 
55  const Graphics::PixelFormat &getInputPixelFormat(uint bpp = 16);
56  const Graphics::PixelFormat &getScreenPixelFormat();
57  const Graphics::PixelFormat &getTransparentPixelFormat();
58  uint32 getTransColor() { return _transColor; }
59 
60  Graphics::ManagedSurface &getAutotextSurface(uint16 id) { return _autotextSurfaces.getOrCreateVal(id); }
61  Common::Rect &getAutotextSurfaceBounds(uint16 id) { return _autotextSurfaceBounds.getOrCreateVal(id); }
62 
63  void grabViewportObjects(Common::Array<RenderObject *> &inArray);
64  void screenshotScreen(Graphics::ManagedSurface &inSurf);
65 
66  static void loadSurfacePalette(Graphics::ManagedSurface &inSurf, const Common::Path &paletteFilename, uint paletteStart = 0, uint paletteSize = 256);
67  static void copyToManaged(const Graphics::Surface &src, Graphics::ManagedSurface &dst, bool verticalFlip = false, bool doubleSize = false);
68  static void copyToManaged(void *src, Graphics::ManagedSurface &dst, uint srcW, uint srcH, const Graphics::PixelFormat &format, bool verticalFlip = false, bool doubleSize = false);
69 
70  static void rotateBlit(const Graphics::ManagedSurface &src, Graphics::ManagedSurface &dest, byte rotation);
71  static void crossDissolve(const Graphics::ManagedSurface &from, const Graphics::ManagedSurface &to, byte alpha, const Common::Rect &rect, Graphics::ManagedSurface &inResult);
72 
73  bool getIsSuppressed() const { return _isSuppressed; }
74 
75  // Debug
76  void debugDrawToScreen(const Graphics::ManagedSurface &surf);
77 
78  Graphics::ManagedSurface _object0;
79 
80 
81 private:
82  void blitToScreen(const RenderObject &src, Common::Rect dest);
83 
84  static int objectComparator(const void *a, const void *b);
85 
87 
88  Graphics::PixelFormat _inputPixelFormat16, _inputPixelFormat24, _inputPixelFormat32;
89  Graphics::PixelFormat _screenPixelFormat;
90  Graphics::PixelFormat _clut8Format;
91  Graphics::PixelFormat _transparentPixelFormat;
92 
93  Graphics::Screen _screen;
94  Common::Array<Font> _fonts;
95 
96  Common::List<Common::Rect> _dirtyRects;
97 
99  Common::HashMap<uint16, Common::Rect> _autotextSurfaceBounds;
100 
101  uint32 _transColor = 0;
102 
103  bool _isSuppressed;
104 };
105 
106 } // End of namespace Nancy
107 
108 #endif // NANCY_GRAPHICS_H
Definition: managed_surface.h:51
Definition: surface.h:67
Definition: array.h:52
Definition: pixelformat.h:138
Definition: graphics.h:36
Definition: rect.h:524
Definition: path.h:52
Definition: stream.h:745
Definition: screen.h:47
Definition: renderobject.h:36
Definition: array.h:559
size_type size() const
Definition: array.h:316
Definition: font.h:37
Val & getOrCreateVal(const Key &key)
Definition: hashmap.h:626
Definition: actionmanager.h:32