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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NANCY_GRAPHICS_H
24 #define NANCY_GRAPHICS_H
25 
26 #include "graphics/screen.h"
27 
28 #include "engines/nancy/font.h"
29 
30 namespace Nancy {
31 
32 class NancyEngine;
33 class RenderObject;
34 
35 // Graphics class that handles multilayered surface rendering with minimal redraw
36 class GraphicsManager {
37 public:
38 	GraphicsManager();
39 
40 	void init();
41 	void draw();
42 
43 	void addObject(RenderObject *object);
44 	void removeObject(RenderObject *object);
45 	void clearObjects();
46 
47 	void redrawAll();
48 
getFont(uint id)49 	const Font *getFont(uint id) const { return id < _fonts.size() ? &_fonts[id] : nullptr; }
getScreen()50 	const Graphics::Screen *getScreen() { return &_screen; }
51 
52 	const Graphics::PixelFormat &getInputPixelFormat();
53 	const Graphics::PixelFormat &getScreenPixelFormat();
54 	uint getTransColor();
55 
56 	static void loadSurfacePalette(Graphics::ManagedSurface &inSurf, const Common::String paletteFilename);
57 	static void loadSurfacePalette(Graphics::ManagedSurface &inSurf, const Common::String paletteFilename, uint paletteStart, uint paletteSize);
58 	static void copyToManaged(const Graphics::Surface &src, Graphics::ManagedSurface &dst, bool verticalFlip = false, bool doubleSize = false);
59 	static void copyToManaged(void *src, Graphics::ManagedSurface &dst, uint srcW, uint srcH, const Graphics::PixelFormat &format, bool verticalFlip = false, bool doubleSize = false);
60 
61 	// Debug
62 	void debugDrawToScreen(const Graphics::Surface &surf);
63 
64 	Graphics::ManagedSurface _object0;
65 
66 	Graphics::PixelFormat _screenPixelFormat;
67 
68 private:
69 	void loadFonts();
70 	void blitToScreen(const RenderObject &src, Common::Rect dest);
71 
72 	static int objectComparator(const void *a, const void *b);
73 
74 	Common::SortedArray<RenderObject *> _objects;
75 
76 	Graphics::PixelFormat _inputPixelFormat;
77 	Graphics::PixelFormat _clut8Format;
78 
79 	Graphics::Screen _screen;
80 	Common::Array<Font> _fonts;
81 };
82 
83 } // End of namespace Nancy
84 
85 #endif // NANCY_GRAPHICS_H
86