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 "graphics/screen.h"
26 
27 #include "engines/nancy/font.h"
28 
29 namespace Nancy {
30 
31 class NancyEngine;
32 class RenderObject;
33 
34 // Graphics class that handles multilayered surface rendering with minimal redraw
36  friend class NancyEngine;
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();
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  // Debug
74  void debugDrawToScreen(const Graphics::ManagedSurface &surf);
75 
76  Graphics::ManagedSurface _object0;
77 
78 
79 private:
80  void blitToScreen(const RenderObject &src, Common::Rect dest);
81 
82  static int objectComparator(const void *a, const void *b);
83 
85 
86  Graphics::PixelFormat _inputPixelFormat;
87  Graphics::PixelFormat _screenPixelFormat;
88  Graphics::PixelFormat _clut8Format;
89  Graphics::PixelFormat _transparentPixelFormat;
90 
91  Graphics::Screen _screen;
92  Common::Array<Font> _fonts;
93 
94  Common::List<Common::Rect> _dirtyRects;
95 
97  Common::HashMap<uint16, Common::Rect> _autotextSurfaceBounds;
98 
99  uint32 _transColor = 0;
100 
101  bool _isSuppressed;
102 };
103 
104 } // End of namespace Nancy
105 
106 #endif // NANCY_GRAPHICS_H
Definition: managed_surface.h:51
Definition: nancy.h:74
Definition: surface.h:66
Definition: array.h:52
Definition: pixelformat.h:138
Definition: graphics.h:35
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: screen.h:50
Definition: renderobject.h:35
Definition: array.h:518
Definition: font.h:37
Val & getOrCreateVal(const Key &key)
Definition: hashmap.h:620
Definition: actionmanager.h:32