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  // Move an already-added object to its new place in the draw order
48  void reorderObject(RenderObject *object);
49  void clearObjects();
50 
51  void redrawAll();
52  void suppressNextDraw();
53 
54  const Font *getFont(uint id) const { return id < _fonts.size() ? &_fonts[id] : nullptr; }
55  const Graphics::Screen *getScreen() { return &_screen; }
56 
57  const Graphics::PixelFormat &getInputPixelFormat(uint bpp = 0);
58  const Graphics::PixelFormat &getScreenPixelFormat();
59  const Graphics::PixelFormat &getTransparentPixelFormat();
60  uint32 getTransColor() { return _transColor; }
61 
62  Graphics::ManagedSurface &getAutotextSurface(uint16 id) { return _autotextSurfaces.getOrCreateVal(id); }
63  Common::Rect &getAutotextSurfaceBounds(uint16 id) { return _autotextSurfaceBounds.getOrCreateVal(id); }
64 
65  void grabViewportObjects(Common::Array<RenderObject *> &inArray);
66  void screenshotScreen(Graphics::ManagedSurface &inSurf);
67 
68  static void loadSurfacePalette(Graphics::ManagedSurface &inSurf, const Common::Path &paletteFilename, uint paletteStart = 0, uint paletteSize = 256);
69  static void copyToManaged(const Graphics::Surface &src, Graphics::ManagedSurface &dst, bool verticalFlip = false, bool doubleSize = false);
70  static void copyToManaged(void *src, Graphics::ManagedSurface &dst, uint srcW, uint srcH, const Graphics::PixelFormat &format, bool verticalFlip = false, bool doubleSize = false);
71 
72  static void rotateBlit(const Graphics::ManagedSurface &src, Graphics::ManagedSurface &dest, byte rotation);
73  static void crossDissolve(const Graphics::ManagedSurface &from, const Graphics::ManagedSurface &to, byte alpha, const Common::Rect &rect, Graphics::ManagedSurface &inResult);
74 
75  bool getIsSuppressed() const { return _isSuppressed; }
76 
77  // Debug
78  void debugDrawToScreen(const Graphics::ManagedSurface &surf);
79 
80  Graphics::ManagedSurface _object0;
81 
82 
83 private:
84  void blitToScreen(const RenderObject &src, Common::Rect dest);
85 
86  static int objectComparator(const void *a, const void *b);
87 
89 
90  Graphics::PixelFormat _inputPixelFormat16, _inputPixelFormat24, _inputPixelFormat32;
91  Graphics::PixelFormat _screenPixelFormat16, _screenPixelFormat32;
92  Graphics::PixelFormat _clut8Format;
93  Graphics::PixelFormat _transparentPixelFormat;
94 
95  Graphics::Screen _screen;
96  Common::Array<Font> _fonts;
97 
98  Common::List<Common::Rect> _dirtyRects;
99 
101  Common::HashMap<uint16, Common::Rect> _autotextSurfaceBounds;
102 
103  uint32 _transColor = 0;
104 
105  bool _isSuppressed;
106 };
107 
108 } // End of namespace Nancy
109 
110 #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:536
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