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 // Main rendering loop - private header
24 
25 #ifndef SAGA_RENDER_H
26 #define SAGA_RENDER_H
27 
28 #include "saga/sprite.h"
29 #include "saga/gfx.h"
30 #include "common/list.h"
31 
32 namespace Saga {
33 
34 enum RENDER_FLAGS {
35 	RF_RENDERPAUSE      = (1 << 0),
36 	RF_MAP              = (1 << 1),
37 	RF_DISABLE_ACTORS   = (1 << 2),
38 	RF_DEMO_SUBST       = (1 << 3)
39 };
40 
41 // Extra render flags used for debugging
42 #ifdef SAGA_DEBUG
43 enum RENDER_DEBUG_FLAGS {
44 	RF_SHOW_FPS         = (1 << 4),
45 	RF_PALETTE_TEST     = (1 << 5),
46 	RF_TEXT_TEST        = (1 << 6),
47 	RF_OBJECTMAP_TEST   = (1 << 7),
48 	RF_ACTOR_PATH_TEST  = (1 << 8)
49 };
50 #endif
51 
52 class Render {
53 public:
54 	Render(SagaEngine *vm, OSystem *system);
55 	~Render();
56 	bool initialized();
57 	void drawScene();
58 
getFlags()59 	unsigned int getFlags() const {
60 		return _flags;
61 	}
62 
setFlag(unsigned int flag)63 	void setFlag(unsigned int flag) {
64 		_flags |= flag;
65 	}
66 
clearFlag(unsigned int flag)67 	void clearFlag(unsigned int flag) {
68 		_flags &= ~flag;
69 	}
70 
toggleFlag(unsigned int flag)71 	void toggleFlag(unsigned int flag) {
72 		_flags ^= flag;
73 	}
74 
getBackGroundSurface()75 	Surface *getBackGroundSurface() {
76 		return &_backGroundSurface;
77 	}
78 
79 	void addDirtyRect(Common::Rect rect);
80 
clearDirtyRects()81 	void clearDirtyRects() {
82 		_dirtyRects.clear();
83 	}
84 
setFullRefresh(bool flag)85 	void setFullRefresh(bool flag) {
86 		_fullRefresh = flag;
87 	}
88 
isFullRefresh()89 	bool isFullRefresh() {
90 		return _fullRefresh;
91 	}
92 
93 	void drawDirtyRects();
94 	void scale2xAndMergeOverlay(int x, int y, int w, int h);
95 	void restoreChangedRects();
96 
97 private:
98 #ifdef SAGA_DEBUG
99 	static void fpsTimerCallback(void *refCon);
100 	void fpsTimer();
101 	unsigned int _fps;
102 	unsigned int _renderedFrameCount;
103 #endif
104 
105 	SagaEngine *_vm;
106 	OSystem *_system;
107 	bool _initialized;
108 	Common::List<Common::Rect> _dirtyRects;
109 	bool _fullRefresh;
110 	bool _dualSurface;
111 
112 	// Module data
113 	Surface _backGroundSurface;
114 	Surface _mergeSurface;
115 
116 	uint32 _flags;
117 };
118 
119 } // End of namespace Saga
120 
121 #endif
122