ScummVM API documentation
scalerplugin.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#ifndef GRAPHICS_SCALERPLUGIN_H
22#define GRAPHICS_SCALERPLUGIN_H
23
24#include "base/plugins.h"
25#include "graphics/pixelformat.h"
26#include "graphics/surface.h"
27
28class Scaler {
29public:
30 Scaler(const Graphics::PixelFormat &format) : _format(format) {}
31 virtual ~Scaler() {}
32
45 void scale(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
46 uint32 dstPitch, int width, int height, int x, int y);
47
52 virtual uint increaseFactor() = 0;
53
58 virtual uint decreaseFactor() = 0;
59
60 virtual uint getFactor() const { return _factor; }
61
69 virtual uint setFactor(uint factor) {
70 uint oldFactor = _factor;
71 _factor = factor;
72 return oldFactor;
73 }
74
81 virtual void setSource(uint pitch, int width, int height, int padding) {
82 // Should not be called unless overriden
83 assert(0);
84 }
85
92 virtual void enableSource(bool enable) {
93 // Should not be called unless overriden
94 assert(0);
95 }
96
97protected:
101 virtual void scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
102 uint32 dstPitch, int width, int height, int x, int y) = 0;
103
104 uint _factor;
105 Graphics::PixelFormat _format;
106};
107
112class SourceScaler : public Scaler {
113
114public:
115
116 SourceScaler(const Graphics::PixelFormat &format);
117 virtual ~SourceScaler();
118
119 virtual void setSource(uint pitch, int width, int height, int padding) final;
120
121 virtual void enableSource(bool enable) final { _enable = enable; }
122
123 virtual uint setFactor(uint factor) final;
124
125protected:
126
127 virtual void scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
128 uint32 dstPitch, int width, int height, int x, int y) final;
129
137 virtual void internScale(const uint8 *srcPtr, uint32 srcPitch,
138 uint8 *dstPtr, uint32 dstPitch,
139 const uint8 *oldSrcPtr, uint32 oldSrcPitch,
140 int width, int height, const uint8 *buffer, uint32 bufferPitch) = 0;
141
142private:
143
144 int _width, _height, _padding;
145 bool _enable;
146 byte *_oldSrc;
147 Graphics::Surface _bufferedOutput;
148};
149
151public:
152
153 virtual ~ScalerPluginObject() {}
154
155 virtual Scaler *createInstance(const Graphics::PixelFormat &format) const = 0;
156
157 const Common::Array<uint> &getFactors() const { return _factors; }
158
159 bool hasFactor(uint factor) const {
160 const Common::Array<uint> &factors = getFactors();
161 for (const auto &curFactor : factors) {
162 if (curFactor == factor)
163 return true;
164 }
165
166 return false;
167 }
168
173 virtual uint extraPixels() const = 0;
174
179 virtual bool canDrawCursor() const = 0;
180
184 virtual const char *getPrettyName() const = 0;
185
189 virtual uint getDefaultFactor() const { return 2; }
190
200 virtual bool useOldSource() const { return false; }
201
202protected:
203 Common::Array<uint> _factors;
204};
205
209class ScalerManager : public Common::Singleton<ScalerManager> {
210private:
212
213public:
214 const PluginList &getPlugins() const;
215
221 uint getMaxExtraPixels() const;
222
226 Plugin *findScalerPlugin(const char *name) const;
227
231 uint findScalerPluginIndex(const char *name) const;
232
237
242};
243
245#define ScalerMan ScalerManager::instance()
246
247#endif
Definition: singleton.h:42
Definition: str.h:59
Definition: plugins.h:157
Definition: plugins.h:143
Definition: scalerplugin.h:28
virtual void scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y)=0
virtual uint setFactor(uint factor)
Definition: scalerplugin.h:69
virtual void enableSource(bool enable)
Definition: scalerplugin.h:92
virtual uint decreaseFactor()=0
virtual uint increaseFactor()=0
void scale(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y)
virtual void setSource(uint pitch, int width, int height, int padding)
Definition: scalerplugin.h:81
Definition: scalerplugin.h:209
uint findScalerPluginIndex(const char *name) const
void updateOldSettings()
bool isOldGraphicsSetting(const Common::String &gfxMode)
uint getMaxExtraPixels() const
Plugin * findScalerPlugin(const char *name) const
Definition: scalerplugin.h:150
virtual const char * getPrettyName() const =0
virtual bool canDrawCursor() const =0
virtual uint getDefaultFactor() const
Definition: scalerplugin.h:189
virtual uint extraPixels() const =0
virtual bool useOldSource() const
Definition: scalerplugin.h:200
Definition: scalerplugin.h:112
virtual uint setFactor(uint factor) final
virtual void scaleIntern(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height, int x, int y) final
virtual void setSource(uint pitch, int width, int height, int padding) final
virtual void enableSource(bool enable) final
Definition: scalerplugin.h:121
virtual void internScale(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, const uint8 *oldSrcPtr, uint32 oldSrcPitch, int width, int height, const uint8 *buffer, uint32 bufferPitch)=0
Definition: pixelformat.h:138
Definition: surface.h:67