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 MEDIASTATION_GRAPHICS_H
23 #define MEDIASTATION_GRAPHICS_H
24 
25 #include "common/rect.h"
26 #include "common/array.h"
27 #include "graphics/managed_surface.h"
28 #include "graphics/screen.h"
29 
30 #include "mediastation/mediascript/scriptvalue.h"
31 
32 namespace MediaStation {
33 
34 class MediaStationEngine;
35 struct DissolvePattern;
36 class Bitmap;
37 
38 enum BlitMode {
39  kUncompressedBlit = 0x00,
40  kRle8Blit = 0x01,
41  kClipEnabled = 0x04,
42  kUncompressedTransparentBlit = 0x08,
43  kPartialDissolve = 0x10,
44  kFullDissolve = 0x20,
45  kCccBlit = 0x40,
46  kCccTransparentBlit = 0x80
47 };
48 
49 enum TransitionType {
50  kTransitionFadeToBlack = 300,
51  kTransitionFadeToPalette = 301,
52  kTransitionSetToPalette = 302,
53  kTransitionSetToBlack = 303,
54  kTransitionFadeToColor = 304,
55  kTransitionSetToColor = 305,
56  kTransitionSetToPercentOfPalette = 306,
57  kTransitionFadeToPaletteObject = 307,
58  kTransitionSetToPaletteObject = 308,
59  kTransitionSetToPercentOfPaletteObject = 309,
60  kTransitionColorShiftCurrentPalette = 310,
61  kTransitionCircleOut = 328
62 };
63 
65 public:
68 
69  void updateScreen() { _screen->update(); }
70  Graphics::Palette *getRegisteredPalette() { return _registeredPalette; }
71  void setRegisteredPalette(Graphics::Palette *palette) { _registeredPalette = palette; }
72 
73  void imageBlit(
74  const Common::Point &destinationPoint,
75  const Bitmap *image,
76  const double dissolveFactor,
77  const Common::Array<Common::Rect> &dirtyRegion,
78  Graphics::ManagedSurface *destinationImage = nullptr);
79 
80  void imageDeltaBlit(
81  const Common::Point &deltaFramePos,
82  const Common::Point &keyFrameOffset,
83  const Bitmap *deltaFrame,
84  const Bitmap *keyFrame,
85  const double dissolveFactor,
86  const Common::Array<Common::Rect> &dirtyRegion);
87 
88  void effectTransition(Common::Array<ScriptValue> &args);
89  void setTransitionOnSync(Common::Array<ScriptValue> &args) { _scheduledTransitionOnSync = args; }
90  void doTransitionOnSync();
91 
92 private:
93  static const uint SCREEN_WIDTH = 640;
94  static const uint SCREEN_HEIGHT = 480;
95 
96  MediaStationEngine *_vm = nullptr;
97  Graphics::Screen *_screen = nullptr;
98  Graphics::Palette *_registeredPalette = nullptr;
99  Common::Array<ScriptValue> _scheduledTransitionOnSync;
100 
101  // Blitting methods.
102  // blitRectsClip encompasses the functionality of both opaqueBlitRectsClip
103  // and transparentBlitRectsClip in the disasm.
104  void blitRectsClip(
106  const Common::Point &destLocation,
107  const Graphics::ManagedSurface &source,
108  const Common::Array<Common::Rect> &dirtyRegion);
109  void rleBlitRectsClip(
111  const Common::Point &destLocation,
112  const Bitmap *source,
113  const Common::Array<Common::Rect> &dirtyRegion);
114  Graphics::ManagedSurface decompressRle8Bitmap(
115  const Bitmap *source,
116  const Graphics::ManagedSurface *keyFrame = nullptr,
117  const Common::Point *keyFrameOffset = nullptr);
118  void dissolveBlitRectsClip(
120  const Common::Point &destPos,
121  const Bitmap *source,
122  const Common::Array<Common::Rect> &dirtyRegion,
123  const uint dissolveFactor);
124  void dissolveBlit1Rect(
126  const Common::Rect &areaToRedraw,
127  const Common::Point &originOnScreen,
128  const Bitmap *source,
129  const Common::Rect &dirtyRegion,
130  const DissolvePattern &pattern);
131  void fullDeltaRleBlitRectsClip(
132  Graphics::ManagedSurface *destinationImage,
133  const Common::Point &deltaFramePos,
134  const Common::Point &keyFrameOffset,
135  const Bitmap *deltaFrame,
136  const Bitmap *keyFrame,
137  const Common::Array<Common::Rect> &dirtyRegion);
138  void deltaRleBlitRectsClip(
139  Graphics::ManagedSurface *destinationImage,
140  const Common::Point &deltaFramePos,
141  const Bitmap *deltaFrame,
142  const Bitmap *keyFrame,
143  const Common::Array<Common::Rect> &dirtyRegion);
144  void deltaRleBlit1Rect(
145  Graphics::ManagedSurface *destinationImage,
146  const Common::Point &destinationPoint,
147  const Bitmap *sourceImage,
148  const Bitmap *deltaImage,
149  const Common::Rect &dirtyRect);
150 
151  // Transition methods.
152  const double DEFAULT_FADE_TRANSITION_TIME_IN_SECONDS = 0.5;
153  const byte DEFAULT_PALETTE_TRANSITION_START_INDEX = 0x01;
154  const byte DEFAULT_PALETTE_TRANSITION_COLOR_COUNT = 0xFE;
155  void fadeToBlack(Common::Array<ScriptValue> &args);
156  void fadeToRegisteredPalette(Common::Array<ScriptValue> &args);
157  void setToRegisteredPalette(Common::Array<ScriptValue> &args);
158  void setToBlack(Common::Array<ScriptValue> &args);
159  void fadeToColor(Common::Array<ScriptValue> &args);
160  void setToColor(Common::Array<ScriptValue> &args);
161  void setToPercentOfPalette(Common::Array<ScriptValue> &args);
162  void fadeToPaletteObject(Common::Array<ScriptValue> &args);
163  void setToPaletteObject(Common::Array<ScriptValue> &args);
164  void setToPercentOfPaletteObject(Common::Array<ScriptValue> &args);
165  void colorShiftCurrentPalette(Common::Array<ScriptValue> &args);
166  void circleOut(Common::Array<ScriptValue> &args);
167 
168  void _setPalette(Graphics::Palette &palette, uint startIndex, uint colorCount);
169  void _setPaletteToColor(Graphics::Palette &targetPalette, byte r, byte g, byte b);
170  uint _limitColorRange(uint &startIndex, uint &colorCount);
171  byte _interpolateColorComponent(byte source, byte target, double progress);
172 
173  void _fadeToColor(byte r, byte g, byte b, double fadeTime, uint startIndex, uint colorCount);
174  void _setToColor(byte r, byte g, byte b, uint startIndex, uint colorCount);
175  void _setPercentToColor(double percent, byte r, byte g, byte b, uint startIndex, uint colorCount);
176 
177  void _fadeToPalette(double fadeTime, Graphics::Palette &targetPalette, uint startIndex, uint colorCount);
178  void _setToPercentPalette(double percent, Graphics::Palette &currentPalette, Graphics::Palette &targetPalette,
179  uint startIndex, uint colorCount);
180  void _fadeToRegisteredPalette(double fadeTime, uint startIndex, uint colorCount);
181  void _setToRegisteredPalette(uint startIndex, uint colorCount);
182  void _colorShiftCurrentPalette(uint startIndex, uint shiftAmount, uint colorCount);
183  void _fadeToPaletteObject(uint paletteId, double fadeTime, uint startIndex, uint colorCount);
184  void _setToPaletteObject(uint paletteId, uint startIndex, uint colorCount);
185  void _setPercentToPaletteObject(double percent, uint paletteId, uint startIndex, uint colorCount);
186 };
187 
188 } // End of namespace MediaStation
189 
190 #endif
Definition: managed_surface.h:51
Definition: graphics.h:64
Definition: asset.h:32
Definition: dissolvepatterns.h:726
Definition: rect.h:524
Definition: screen.h:48
Definition: bitmap.h:50
Definition: mediastation.h:65
Definition: rect.h:144
virtual void update()
Simple class for handling a palette data.
Definition: palette.h:55