ScummVM API documentation
asurface.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 ACCESS_ASURFACE_H
23#define ACCESS_ASURFACE_H
24
25#include "common/scummsys.h"
26#include "common/array.h"
27#include "common/memstream.h"
28#include "common/rect.h"
29#include "graphics/screen.h"
30#include "access/data.h"
31
32namespace Access {
33
34class SpriteResource;
35class SpriteFrame;
36
42class BaseSurface : virtual public Graphics::Screen {
43private:
44 Graphics::Surface _savedBlock;
45
46 void flipHorizontal(BaseSurface &dest);
47protected:
48 Common::Rect _savedBounds;
49public:
50 int _leftSkip, _rightSkip;
51 int _topSkip, _bottomSkip;
52 int _orgX1, _orgY1;
53 int _orgX2, _orgY2;
54 int _lColor;
55
56 Common::Point _printOrg;
57 Common::Point _printStart;
58 int _maxChars;
59public:
60 // These values need to be shared between the buffers
61 static int _lastBoundsX, _lastBoundsY;
62 static int _lastBoundsW, _lastBoundsH;
63 static int _clipWidth, _clipHeight;
64public:
66
67 ~BaseSurface() override;
68
69 void clearBuffer();
70
71 void plotImage(const SpriteResource *sprite, int frameNum, const Common::Point &pt);
72
76 void sPlotF(const SpriteFrame *frame, const Common::Rect &bounds);
77
81 void sPlotB(const SpriteFrame *frame, const Common::Rect &bounds);
82
86 void plotF(const SpriteFrame *frame, const Common::Point &pt);
87
91 void plotB(const SpriteFrame *frame, const Common::Point &pt);
92
93 virtual void copyBlock(const BaseSurface *src, const Common::Rect &bounds);
94
95 virtual void restoreBlock();
96
97 virtual void drawRect();
98
99 virtual void drawLine(int x1, int y1, int x2, int y2, int col);
100
101 virtual void drawLine();
102
103 virtual void drawBox();
104
105 virtual void drawBox(int x1, int y1, int x2, int y2, int color);
106
107 virtual void copyBuffer(Graphics::ManagedSurface *src);
108
109 void copyTo(BaseSurface *dest);
110
111 void saveBlock(const Common::Rect &bounds);
112
113 void moveBufferLeft();
114
115 void moveBufferRight();
116
117 void moveBufferUp();
118
119 void moveBufferDown();
120
121 bool clip(Common::Rect &r);
122
126 void dump(const char *fname) const;
127};
128
129class ASurface : public BaseSurface {
130protected:
135 void addDirtyRect(const Common::Rect &r) override {}
136public:
137 ASurface() : BaseSurface() {}
138};
139
140class SpriteFrame : public ASurface {
141public:
142 SpriteFrame(const AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize);
143 ~SpriteFrame() override;
144};
145
147public:
149public:
150 SpriteResource(const AccessEngine *vm, Resource *res);
151 SpriteResource(const AccessEngine *vm, int fileNum, int subfile);
153
154 int getCount() const { return _frames.size(); }
155
156 const SpriteFrame *getFrame(int idx) const { return _frames[idx]; }
157
158private:
159 void loadFromResource(const AccessEngine *vm, Resource *res);
160};
161
162enum ImageFlag {
163 IMGFLAG_NONE = 0,
164 IMGFLAG_CROPPED = 1,
165 IMGFLAG_BACKWARDS = 2,
166 IMGFLAG_DRAWN = 4,
167 IMGFLAG_UNSCALED = 8
168};
169
171public:
172 int _frameNumber;
173 SpriteResource *_spritesPtr;
174 int _offsetY; // offset to apply to y position when sorting draw order
175 Common::Point _position;
176 int _flags;
177 int _scaleOverride;
178 Common::Point _sizeOverride;
179public:
180 ImageEntry();
181};
182
183class ImageEntryList : public Common::Array<ImageEntry> {
184public:
185 void addToList(ImageEntry &ie);
186};
187
188} // End of namespace Access
189
190#endif /* ACCESS_ASURFACE_H */
Definition: asurface.h:129
void addDirtyRect(const Common::Rect &r) override
Definition: asurface.h:135
Definition: access.h:141
Definition: asurface.h:42
void dump(const char *fname) const
void sPlotF(const SpriteFrame *frame, const Common::Rect &bounds)
void plotB(const SpriteFrame *frame, const Common::Point &pt)
void sPlotB(const SpriteFrame *frame, const Common::Rect &bounds)
void plotF(const SpriteFrame *frame, const Common::Point &pt)
Definition: asurface.h:170
Definition: asurface.h:183
Definition: files.h:55
Definition: asurface.h:140
Definition: asurface.h:146
Definition: array.h:52
size_type size() const
Definition: array.h:316
Definition: stream.h:745
Definition: managed_surface.h:51
Definition: screen.h:47
Definition: access.h:62
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67