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 
32 namespace Access {
33 
34 class SpriteResource;
35 class SpriteFrame;
36 
42 class BaseSurface : virtual public Graphics::Screen {
43 private:
44  Graphics::Surface _savedBlock;
45 
46  void flipHorizontal(BaseSurface &dest);
47 protected:
48  Common::Rect _savedBounds;
49 public:
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;
59 public:
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;
64 public:
65  BaseSurface();
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 
129 class ASurface : public BaseSurface {
130 protected:
135  void addDirtyRect(const Common::Rect &r) override {}
136 public:
137  ASurface() : BaseSurface() {}
138 };
139 
140 class SpriteFrame : public ASurface {
141 public:
142  SpriteFrame(const AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize);
143  ~SpriteFrame() override;
144 };
145 
147 public:
149 public:
150  SpriteResource(const AccessEngine *vm, Resource *res);
151  ~SpriteResource();
152 
153  int getCount() { return _frames.size(); }
154 
155  const SpriteFrame *getFrame(int idx) const { return _frames[idx]; }
156 };
157 
158 enum ImageFlag {
159  IMGFLAG_NONE = 0,
160  IMGFLAG_CROPPED = 1,
161  IMGFLAG_BACKWARDS = 2,
162  IMGFLAG_DRAWN = 4,
163  IMGFLAG_UNSCALED = 8
164 };
165 
166 class ImageEntry {
167 public:
168  int _frameNumber;
169  SpriteResource *_spritesPtr;
170  int _offsetY; // offset to apply to y position when sorting draw order
171  Common::Point _position;
172  int _flags;
173  int _scaleOverride;
174  Common::Point _sizeOverride;
175 public:
176  ImageEntry();
177 };
178 
179 class ImageEntryList : public Common::Array<ImageEntry> {
180 public:
181  void addToList(ImageEntry &ie);
182 };
183 
184 } // End of namespace Access
185 
186 #endif /* ACCESS_ASURFACE_H */
Definition: managed_surface.h:51
Definition: asurface.h:179
void sPlotB(const SpriteFrame *frame, const Common::Rect &bounds)
Definition: surface.h:67
Definition: access.h:141
Definition: array.h:52
Definition: rect.h:524
Definition: stream.h:745
Definition: screen.h:47
Definition: asurface.h:42
Definition: asurface.h:140
void addDirtyRect(const Common::Rect &r) override
Definition: asurface.h:135
Definition: files.h:55
Definition: asurface.h:146
void dump(const char *fname) const
void plotB(const SpriteFrame *frame, const Common::Point &pt)
Definition: rect.h:144
size_type size() const
Definition: array.h:316
void sPlotF(const SpriteFrame *frame, const Common::Rect &bounds)
Definition: asurface.h:129
Definition: access.h:62
void plotF(const SpriteFrame *frame, const Common::Point &pt)
Definition: asurface.h:166