ScummVM API documentation
surface_manager.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 * Additional copyright for this file:
8 * Copyright (C) 1999-2000 Revolution Software Ltd.
9 * This code is based on source code created by Revolution Software,
10 * used with permission.
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#ifndef ICB_SURFACE_MANAGER
28#define ICB_SURFACE_MANAGER
29
30#include "engines/icb/p4_generic.h"
31#include "engines/icb/common/px_array.h"
32#include "engines/icb/common/px_types.h"
33
34#include "graphics/surface.h"
35
36namespace ICB {
37
38#define SURFACE_MANAGER_LOG "surface_manager_log.txt"
39
40// If this is passed in as an id to the Blit_surface_to_surface() the blit is performed to the backbuffer.
41#define SURFACE_MANAGER_USE_BACKBUFFER 0xffffffff
42
43#define EITHER 0x00000002 // Surface can be in vram or system
44#define SYSTEM 0x00000000 // Surface is in system
45#define VIDEO 0x00000001 // Surface must be in vram
46
47extern uint32 effect_time; // Time spent doing postprocessing effects (fades etc)
48extern uint32 working_buffer_id;
49extern uint32 bg_buffer_id;
50
51// Define this here so we can get rid of the <ddraw.h> include
52#define DDBLT_KEYSRC 0x00008000l
53
54class _surface {
55public:
56 Graphics::Surface *m_dds;
57 pxString m_name; // The surface name
58 uint32 m_width; // The surface width
59 uint32 m_height; // The surface height
60 bool8 m_locked; // Is the surface locked ?
61 uint32 m_colorKey;
62
63 _surface();
64 ~_surface();
65};
66
68
69private:
70 Graphics::Surface *screenSurface;
71 LRECT m_screen_rect; // The screen rectangle
72public:
73 rcAutoPtrArray<_surface> m_Surfaces; // List of client surface
74private:
75 bool8 m_hasMMX; // True if the processor has MMX capabilities
76
77public:
80
81 uint32 Init_direct_draw();
82 void Flip();
83 void Reset_Effects();
84
85 /* Public Surface Functions */
86 uint32 Create_new_surface(const char *name, uint32 width, uint32 height, uint32 type);
87 void Kill_surface(uint32 s_id);
88
89 uint8 *Lock_surface(uint32 s_id);
90 void Unlock_surface(uint32 s_id);
91
92 void PrintDebugLabel(const char *mess, uint32 c);
93 void PrintTimer(char label, uint32 time, uint32 limit);
94
95 int32 Get_pitch(uint32 s_id);
96 inline uint32 Get_width(uint32 nSurfaceID) const;
97 inline uint32 Get_height(uint32 nSurfaceID) const;
98 inline uint32 Get_BytesPP(uint32 nSurfaceID) const;
99 void Clear_surface(uint32 s_id) { Fill_surface(s_id, 0x00000000); }
100 void Fill_surface(uint32 s_id, uint32 rgb_value);
101 void Blit_fillfx(uint32 surface_id, LRECT *rect, uint32 col);
102 void Blit_surface_to_surface(uint32 from_id, uint32 to_id, LRECT *rect_from, LRECT *rect_to, uint32 nFlags = 0);
103 void Set_transparent_colour_key(uint32 nSurfaceID, uint32 nKey);
104 bool8 &HasMMX() { return m_hasMMX; }
105 void RecordFrame(const char *path);
106 void Unlock_all_surfaces();
107
108public:
109 void DrawEffects(uint32 surface_id);
110
111 LRECT &BorderRect() {
112 return m_borders; // Access to the border rect
113 }
114 uint8 &BorderRed() {
115 return m_borderRed; // Access to the border colour
116 }
117 uint8 &BorderGreen() {
118 return m_borderGreen; // Access to the border colour
119 }
120 uint8 &BorderBlue() {
121 return m_borderBlue; // Access to the border colour
122 }
123 uint8 &BorderAlpha() {
124 return m_borderAlpha; // Access to the border colour
125 }
126 uint32 &BorderMode() { return m_borderMode; }
127
128 void LoadGFXInfo(Common::SeekableReadStream *stream);
129 void SaveGFXInfo(Common::WriteStream *stream);
130
131private:
132 LRECT m_borders; // The border to add to the screen
133 uint8 m_borderRed; // The colour of the border
134 uint8 m_borderGreen; // The colour of the border
135 uint8 m_borderBlue; // The colour of the border
136 uint8 m_borderAlpha; // The colour of the border
137 uint32 m_borderMode;
138
139public: /* FADE */
140 uint32 &FadeMode() {
141 return m_fadeMode; // Access to the fade mode
142 }
143 uint8 &FadeToRed() {
144 return m_fadeToRed; // Access to the red fade component
145 }
146 uint8 &FadeToGreen() {
147 return m_fadeToGreen; // Access to the red fade component
148 }
149 uint8 &FadeToBlue() {
150 return m_fadeToBlue; // Access to the red fade component
151 }
152 uint8 &FadeFromRed() {
153 return m_fadeFromRed; // Access to the red fade component
154 }
155 uint8 &FadeFromGreen() {
156 return m_fadeFromGreen; // Access to the red fade component
157 }
158 uint8 &FadeFromBlue() {
159 return m_fadeFromBlue; // Access to the red fade component
160 }
161 uint8 &FadeAlpha() {
162 return m_fadeAlpha; // Access to the red fade component
163 }
164
165private:
166 uint32 m_fadeMode; // The type of fade (additive / subtractive / alpha )
167 uint8 m_fadeToRed; // The red component to fade to
168 uint8 m_fadeToGreen; // The green component to fade to
169 uint8 m_fadeToBlue; // The blue component to fade to
170 uint8 m_fadeFromRed; // The red component to fade from
171 uint8 m_fadeFromGreen; // The green component to fade from
172 uint8 m_fadeFromBlue; // The blue component to fade from
173 uint8 m_fadeAlpha; // The alpha component of the fade
174
175private: /* Private Helper Functions */
176 /* Let the MouseDraw function get at the back buffer */
177 friend int32 DrawMouse();
178
179private:
181 void operator=(const _surface_manager &) { ; }
182};
183
184inline uint32 _surface_manager::Get_width(uint32 nSurfaceID) const {
185 assert(nSurfaceID < m_Surfaces.GetNoItems());
186
187 return (m_Surfaces[nSurfaceID]->m_width);
188}
189
190inline uint32 _surface_manager::Get_height(uint32 nSurfaceID) const {
191 assert(nSurfaceID < m_Surfaces.GetNoItems());
192
193 return (m_Surfaces[nSurfaceID]->m_height);
194}
195
196inline uint32 _surface_manager::Get_BytesPP(uint32 nSurfaceID) const {
197 assert(nSurfaceID < m_Surfaces.GetNoItems());
198
199 return ((m_Surfaces[nSurfaceID]->m_dds->format.bytesPerPixel));
200}
201
202} // End of namespace ICB
203
204#endif
Definition: stream.h:745
Definition: stream.h:77
Definition: surface_manager.h:67
Definition: surface_manager.h:54
Definition: px_string.h:34
Definition: px_array.h:153
Definition: surface.h:67
Definition: px_types.h:32