ScummVM API documentation
render_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 * 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 ZVISION_RENDER_MANAGER_H
23#define ZVISION_RENDER_MANAGER_H
24
25#include "common/hashmap.h"
26#include "common/rect.h"
27#include "graphics/framelimiter.h"
28#include "graphics/managed_surface.h"
29#include "graphics/screen.h"
30#include "graphics/surface.h"
31#include "zvision/graphics/graphics_effect.h"
32#include "zvision/graphics/render_table.h"
33#include "zvision/text/truetype_font.h"
34
35class OSystem;
36
37namespace Common {
38class String;
39class SeekableReadStream;
40}
41
42namespace Video {
43class VideoDecoder;
44}
45
46namespace ZVision {
47
49public:
50 RenderManager(ZVision *engine, const ScreenLayout layout, const Graphics::PixelFormat pixelFormat, bool doubleFPS, bool widescreen = false);
52
53
55
56private:
57 ZVision *_engine;
58 OSystem *_system;
59 const Graphics::PixelFormat _pixelFormat;
60 const ScreenLayout _layout;
61 bool _hiRes = false;
62 Graphics::FrameLimiter _frameLimiter;
63
67 Common::Rect _screenArea;
68
69 Common::Rect _HDscreenArea = Common::Rect(800, 600);
70 Common::Rect _HDscreenAreaWide = Common::Rect(720, 377);
71
72 Common::Point _textOffset; //Position vector of text area origin relative to working window origin
73
79 Common::Rect _workingArea;
80
81 Common::Point _workingAreaCenter; //Center of the working area in working area coordinates
82
86 Graphics::Screen _screen;
87
89 Graphics::Surface _currentBackgroundImage;
90 Common::Rect _backgroundDirtyRect;
91
96 int16 _backgroundOffset;
98 uint16 _backgroundWidth;
100 uint16 _backgroundHeight;
101
102 // A buffer that holds the portion of the background that is used to render the final image
103 // If it's a normal scene, the pixels will be blitted directly to the screen
104 // If it's a panorma / tilt scene, the pixels will be first warped to _warpedSceneSurface
105 Graphics::Surface _backgroundSurface;
106 Graphics::ManagedSurface _workingManagedSurface;
107 Common::Rect _backgroundSurfaceDirtyRect;
108
109//TODO: Migrate this functionality to SubtitleManager to improve encapsulation
110//*
111 // Buffer for drawing subtitles & other messages
112 Graphics::Surface _textSurface;
113 Graphics::ManagedSurface _textManagedSurface;
114 Common::Rect _textSurfaceDirtyRect;
115//*/
116
117 // Rectangle for subtitles & other messages
118 Common::Rect _textArea; //NB Screen coordinates
119 Common::Rect _textLetterbox; //Section of text area outside working window, to be filled with black when blanked
120 Common::Rect _textOverlay; //Section of text area to be filled with colorkey when blanked (may potentially intersect text letterbox area if screen/window is wider than working area!)
121
122 // Buffer for drawing menu
123 Graphics::Surface _menuSurface;
124 Graphics::ManagedSurface _menuManagedSurface;
125 Common::Rect _menuSurfaceDirtyRect; //subrectangle of menu area outside working area
126
127 // Rectangle for menu area
128 Common::Rect _menuArea; //Screen coordinates
129 Common::Rect _menuLetterbox; //Section of menu area to be filled with black when blanked
130 Common::Rect _menuOverlay; //Section of menu area to be filled with colorkey when blanked (may potentially intersect menu letterbox area if screen/window is wider than working area!)
131
132 //Buffer for streamed video playback
133//*
134 Graphics::ManagedSurface _vidManagedSurface;
135 /*/
136 Graphics::Surface _vidSurface;
137 //*/
138
139 //Area of streamed video playback
140 Common::Rect _vidArea;
141
142 // A buffer used for apply graphics effects
143 Graphics::Surface _effectSurface;
144
145 // A buffer to store the result of the panorama / tilt warps
146 Graphics::Surface _warpedSceneSurface;
147
148
150 RenderTable _renderTable;
151
152
153
154 // Visual effects list
155 EffectsList _effects;
156
157 //Pointer to currently active backbuffer output surface
158 Graphics::Surface *_outputSurface;
159 bool _doubleFPS;
160 bool _widescreen;
161
162public:
163 Common::Error initialize(bool hiRes = false);
164
170 bool renderSceneToScreen(bool immediate = false, bool overlayOnly = false, bool preStream = false);
171
172 Graphics::ManagedSurface &getVidSurface(Common::Rect dstRect); //dstRect is defined relative to working area origin
173
174 const Common::Rect &getMenuArea() const {
175 return _menuArea;
176 }
177 const Common::Rect &getWorkingArea() const {
178 return _workingArea;
179 }
180
188 void renderImageToBackground(const Common::Path &fileName, int16 destinationX, int16 destinationY);
189
198 void renderImageToBackground(const Common::Path &fileName, int16 destX, int16 destY, uint32 colorkey);
199
209 void renderImageToBackground(const Common::Path &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY);
210
217 void setBackgroundImage(const Common::Path &fileName);
218
229 void setBackgroundPosition(int offset);
230
238
239 // Return pointer of RenderTable object
240 RenderTable *getRenderTable();
241
242 // Return current background offset
243 uint32 getCurrentBackgroundOffset();
244
255
256 // Scale buffer (nearest)
257 void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight);
258
269 void blitSurfaceToSurface(const Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, int _x, int _y);
270 void blitSurfaceToSurface(const Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, int _x, int _y, uint32 colorkey);
271 void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int _x, int _y) {blitSurfaceToSurface(src, Common::Rect(src.w, src.h), dst, _x, _y);}
272 void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int _x, int _y, uint32 colorkey) {blitSurfaceToSurface(src, Common::Rect(src.w, src.h), dst, _x, _y, colorkey);}
273
274 // Blitting surface-to-background methods
275 void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey = -1);
276
277 // Blitting surface-to-background methods with scale
278 void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &dstRect, int32 colorkey = -1);
279
287 void blitSurfaceToMenu(const Graphics::Surface &src, int16 x, int16 y, int32 colorkey = 0);
288
296 void blitSurfaceToText(const Graphics::Surface &src, int16 x, int16 y, int32 colorkey = 0);
297
298 // Return background size
299 Common::Point getBkgSize();
300
301 // Return portion of background as new surface
302 Graphics::Surface *getBkgRect(Common::Rect &rect);
303
304 // Load image into new surface
305 Graphics::Surface *loadImage(const Common::Path &file);
306 Graphics::Surface *loadImage(const Common::Path &file, bool transposed);
307
308 // Clear whole/area of menu backbuffer
309 void clearMenuSurface(bool force = false, int32 colorkey = -1);
310
311 // Clear whole/area of subtitle backbuffer
312 void clearTextSurface(bool force = false, int32 colorkey = -1);
313
314 // Copy needed portion of background surface to workingArea surface
315 void prepareBackground();
316
326 void readImageToSurface(const Common::Path &fileName, Graphics::Surface &destination);
327
338 void readImageToSurface(const Common::Path &fileName, Graphics::Surface &destination, bool transposed);
339
340 // Add visual effect to effects list
341 void addEffect(GraphicsEffect *_effect);
342
343 // Delete effect(s) by ID (ID equal to slot of action:region that create this effect)
344 void deleteEffect(uint32 ID);
345
346 // Create "mask" for effects - (color +/- depth) will be selected as not transparent. Like color selection
347 // xy - base color
348 // depth - +/- of base color
349 // rect - rectangle where select pixels
350 // minD - if not NULL will receive real bottom border of depth
351 // maxD - if not NULL will receive real top border of depth
352 EffectMap *makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *minD, int8 *maxD);
353
354 // Create "mask" for effects by simple transparent color
355 EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp);
356
357 // Return background rectangle in screen coordinates
358 Common::Rect transformBackgroundSpaceRectToScreenSpace(const Common::Rect &src);
359
360 // Mark whole background surface as dirty
361 void markDirty();
362
363/*
364 // Fill background surface by color
365 void bkgFill(uint8 r, uint8 g, uint8 b);
366*/
367
368 void checkBorders();
369 void rotateTo(int16 to, int16 time);
370 void updateRotation();
371 void upscaleRect(Common::Rect &rect);
372};
373
374} // End of namespace ZVision
375
376#endif
Definition: error.h:81
Definition: path.h:52
Definition: framelimiter.h:40
Definition: managed_surface.h:51
Definition: screen.h:47
Definition: system.h:166
Definition: graphics_effect.h:34
Definition: render_manager.h:48
bool renderSceneToScreen(bool immediate=false, bool overlayOnly=false, bool preStream=false)
void renderImageToBackground(const Common::Path &fileName, int16 destinationX, int16 destinationY)
void readImageToSurface(const Common::Path &fileName, Graphics::Surface &destination, bool transposed)
void blitSurfaceToText(const Graphics::Surface &src, int16 x, int16 y, int32 colorkey=0)
void blitSurfaceToSurface(const Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, int _x, int _y)
void readImageToSurface(const Common::Path &fileName, Graphics::Surface &destination)
void setBackgroundImage(const Common::Path &fileName)
void blitSurfaceToMenu(const Graphics::Surface &src, int16 x, int16 y, int32 colorkey=0)
const Common::Point screenSpaceToImageSpace(const Common::Point &point)
void renderImageToBackground(const Common::Path &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY)
static Graphics::Surface * tranposeSurface(const Graphics::Surface *surface)
void setBackgroundPosition(int offset)
void renderImageToBackground(const Common::Path &fileName, int16 destX, int16 destY, uint32 colorkey)
Definition: render_table.h:71
Definition: algorithm.h:29
Definition: focus_list.h:27
Definition: rect.h:144
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: surface.h:67
int16 h
Definition: surface.h:76
int16 w
Definition: surface.h:71
Definition: zvision.h:72