ScummVM API documentation
gfxdriver_intern.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
23#ifndef SCI_GRAPHICS_DRIVERS_GFXDRIVER_INTERN_H
24#define SCI_GRAPHICS_DRIVERS_GFXDRIVER_INTERN_H
25
26#include "common/platform.h"
27#include "sci/graphics/drivers/gfxdriver.h"
28
29namespace Sci {
30
32public:
33 GfxDefaultDriver(uint16 screenWidth, uint16 screenHeight, bool isSCI0, bool rgbRendering);
34 ~GfxDefaultDriver() override;
35 bool initScreen(const Graphics::PixelFormat *srcRGBFormat) override; // srcRGBFormat: expect incoming data to have the specified rgb pixel format (used for Mac hicolor videos)
36 void setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod *palMods, const byte *palModMapping) override;
37 void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod *palMods, const byte *palModMapping) override;
38 void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
39 void replaceMacCursor(const Graphics::Cursor*) override;
40 void copyCurrentBitmap(byte *dest, uint32 size) const override;
41 void copyCurrentPalette(byte *dest, int start, int num) const override;
42 void drawTextFontGlyph(const byte*, int, int, int, int, int, int, const PaletteMod*, const byte*) override; // Only for HiRes fonts. Not implemented here.
43 bool supportsPalIntensity() const override { return true; }
44 bool supportsHiResGraphics() const override { return false; }
45 bool driverBasedTextRendering() const override { return false; }
46protected:
47 void updatePalette(const byte *colors, uint start, uint num);
48 byte *_compositeBuffer;
49 byte *_currentBitmap;
50 byte *_currentPalette;
51 byte *_internalPalette;
52 uint16 _virtualW;
53 uint16 _virtualH;
55 byte _srcPixelSize;
56 bool _cursorUsesScreenPalette;
57 const bool _alwaysCreateBmpBuffer;
58 const bool _requestRGBMode;
59 typedef void (*ColorConvProc)(byte*, const byte*, int, int, int, const byte*);
60 ColorConvProc _colorConv;
61 typedef void (*ColorConvModProc)(byte*, const byte*, int, int, int, const byte*, const byte*, Graphics::PixelFormat&, const PaletteMod*, const byte*);
62 ColorConvModProc _colorConvMod;
63private:
64 void generateOutput(byte *dst, const byte *src, int pitch, int w, int h, const PaletteMod *palMods, const byte *palModMapping);
65};
66
68public:
69 SCI0_DOSPreVGADriver(int numColors, int screenW, int screenH, bool rgbRendering);
70 ~SCI0_DOSPreVGADriver() override;
71 bool initScreen(const Graphics::PixelFormat*) override;
72 void setPalette(const byte*, uint, uint, bool, const PaletteMod*, const byte*) override {}
73 void replaceMacCursor(const Graphics::Cursor*) override;
74 void copyCurrentBitmap(byte*, uint32) const override;
75 void drawTextFontGlyph(const byte*, int, int, int, int, int, int, const PaletteMod*, const byte*) override; // Only for HiRes fonts. Not implemented here.
76 void copyCurrentPalette(byte *dest, int start, int num) const override;
77 bool supportsPalIntensity() const override { return false; }
78 bool supportsHiResGraphics() const override { return false; }
79 bool driverBasedTextRendering() const override { return false; }
80protected:
81 void assignPalette(const byte *colors);
82 byte *_compositeBuffer;
83 const byte *_internalPalette;
84private:
85 virtual void setupRenderProc() = 0;
86 const bool _requestRGBMode;
87 const byte *_colors;
88};
89
91public:
92 UpscaledGfxDriver(int16 textAlignX, bool scaleCursor, bool rgbRendering);
93 ~UpscaledGfxDriver() override;
94 bool initScreen(const Graphics::PixelFormat *format) override;
95 void setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod *palMods, const byte *palModMapping) override;
96 void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod *palMods, const byte *palModMapping) override;
97 void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
98 Common::Point getMousePos() const override;
99 void setMousePos(const Common::Point &pos) const override;
100 void setShakePos(int shakeXOffset, int shakeYOffset) const override;
101 void clearRect(const Common::Rect &r) const override;
102 Common::Point getRealCoords(Common::Point &pos) const override;
103 void drawTextFontGlyph(const byte *src, int pitch, int hiresDestX, int hiresDestY, int hiresW, int hiresH, int transpColor, const PaletteMod *palMods, const byte *palModMapping) override; // For HiRes fonts.
104 bool driverBasedTextRendering() const override { return true; }
105protected:
106 UpscaledGfxDriver(uint16 scaledW, uint16 scaledH, int16 textAlignX, bool scaleCursor, bool rgbRendering);
107 void updateScreen(int destX, int destY, int w, int h, const PaletteMod *palMods, const byte *palModMapping);
108 void adjustCursorBuffer(uint16 newWidth, uint16 newHeight);
109 typedef void (*GlyphRenderProc)(byte*, int, const byte*, int, int, int, int);
110 GlyphRenderProc _renderGlyph;
111 typedef void (*ScaledRenderProc)(byte*, const byte*, int, int, int);
112 ScaledRenderProc _renderScaled;
113 uint16 _textAlignX;
114 uint16 _hScaleMult;
115 uint16 _vScaleMult;
116 uint16 _vScaleDiv;
117 byte *_scaledBitmap;
118private:
119 virtual void renderBitmap(const byte *src, int pitch, int dx, int dy, int w, int h, int &realWidth, int &realHeight);
120 const bool _scaleCursor;
121 uint16 _cursorWidth;
122 uint16 _cursorHeight;
123 bool _needCursorBuffer;
124};
125
126class SCI1_EGADriver : public GfxDriver {
127public:
128 SCI1_EGADriver(bool rgbRendering);
129 ~SCI1_EGADriver() override;
130 bool initScreen(const Graphics::PixelFormat*) override;
131 void setPalette(const byte *colors, uint start, uint num, bool update, const PaletteMod*, const byte*) override;
132 void copyRectToScreen(const byte *src, int srcX, int srcY, int pitch, int destX, int destY, int w, int h, const PaletteMod*, const byte*) override;
133 void replaceCursor(const void *cursor, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor) override;
134 void replaceMacCursor(const Graphics::Cursor *cursor) override {}
135 void copyCurrentBitmap(byte *dest, uint32 size) const override;
136 void copyCurrentPalette(byte *dest, int start, int num) const override;
137 void drawTextFontGlyph(const byte*, int, int, int, int, int, int, const PaletteMod*, const byte*) override; // Only for HiRes fonts. Not implemented here.
138 Common::Point getMousePos() const override;
139 void setMousePos(const Common::Point &pos) const override;
140 void setShakePos(int shakeXOffset, int shakeYOffset) const override;
141 void clearRect(const Common::Rect &r) const override;
142 Common::Point getRealCoords(Common::Point &pos) const override;
143 bool supportsPalIntensity() const override { return false; }
144 bool supportsHiResGraphics() const override { return false; }
145 bool driverBasedTextRendering() const override { return false; }
146 static bool validateMode(Common::Platform p) { return (p == Common::kPlatformDOS || p == Common::kPlatformWindows) && checkDriver(&_driverFile, 1); }
147protected:
148 typedef void (*LineProc)(byte*&, const byte*, int, const byte*, const byte*, bool);
149 LineProc _renderLine;
150 const byte *_convPalette;
151 uint16 _vScaleMult, _vScaleDiv;
152 const byte *_egaMatchTable;
153 byte *_egaColorPatterns;
154 uint8 _colAdjust;
155 byte *_compositeBuffer;
156 byte *_currentPalette;
157private:
158 virtual void loadData();
159 virtual void renderBitmap(byte *dst, const byte *src, int pitch, int y, int w, int h, const byte *patterns, const byte *palette, uint16 &realWidth, uint16 &realHeight);
160 byte *_currentBitmap;
161 const byte *_internalPalette;
162 const bool _requestRGBMode;
163 static const char *_driverFile;
164};
165
166#define GFXDRV_ASSERT_READY \
167 if (!_ready) \
168 error("%s(): initScreen() must be called before using this method", __FUNCTION__)
169
170#define GFXDRV_ERR_OPEN(x) \
171 error("%s(): Failed to open '%s'", __FUNCTION__, x)
172
173#define GFXDRV_ERR_VERSION(x) \
174 error("%s(): Driver file '%s' unknown version", __FUNCTION__, x)
175
176#define SCI_GFXDRV_VALIDATE_IMPL(name) \
177 bool name##Driver_validateMode(Common::Platform platform) { \
178 return name##Driver::validateMode(platform); \
179 }
180
181} // End of namespace Sci
182
183namespace SciGfxDrvInternal {
184 template <typename T> void updateRGBPalette(byte *dest, const byte *src, uint start, uint num, Graphics::PixelFormat &f);
185 template <typename T> void scale2x(byte *dst, const byte *src, int pitch, int w, int h);
186 void updateBitmapBuffer(byte *dst, int dstPitch, const byte *src, int srcPitch, int x, int y, int w, int h);
187 byte findColorInPalette(uint32 rgbTriplet, const byte *palette, int numColors);
188 void renderWinMonochromeCursor(byte *dst, const void *src, const byte *palette, uint &w, uint &h, int &hotX, int &hotY, byte blackColor, byte whiteColor, uint32 &keycolor, bool noScale);
189 void renderPC98GlyphFat(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h, int transpCol);
190 const byte *monochrInit(const char *drvFile, bool &earlyVersion);
191
192} // End of namespace SciGfxDrvInternal
193
194#endif // SCI_GRAPHICS_DRIVERS_GFXDRIVER_INTERN_H
Definition: cursor.h:42
Definition: gfxdriver_intern.h:31
Definition: gfxdriver.h:39
Definition: gfxdriver_intern.h:67
Definition: gfxdriver_intern.h:126
Definition: gfxdriver_intern.h:90
Platform
Definition: platform.h:93
Definition: console.h:28
Definition: rect.h:144
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: helpers.h:269