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 NancyEngine;
34 class RenderObject;
35 
36 // Graphics class that handles multilayered surface rendering with minimal redraw
38  friend class NancyEngine;
39 public:
41 
42  void init();
43  void draw(bool updateScreen = true);
44 
45  void loadFonts(Common::SeekableReadStream *chunkStream);
46 
47  void addObject(RenderObject *object);
48  void removeObject(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();
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  // 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 _inputPixelFormat;
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: nancy.h:74
Definition: surface.h:67
Definition: array.h:52
Definition: pixelformat.h:138
Definition: graphics.h:37
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: screen.h:48
Definition: renderobject.h:36
Definition: array.h:558
size_type size() const
Definition: array.h:315
Definition: font.h:37
Val & getOrCreateVal(const Key &key)
Definition: hashmap.h:622
Definition: actionmanager.h:32