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 copyBuffer(Graphics::ManagedSurface *src);
106 
107  void copyTo(BaseSurface *dest);
108 
109  void saveBlock(const Common::Rect &bounds);
110 
111  void moveBufferLeft();
112 
113  void moveBufferRight();
114 
115  void moveBufferUp();
116 
117  void moveBufferDown();
118 
119  bool clip(Common::Rect &r);
120 };
121 
122 class ASurface : public BaseSurface {
123 protected:
128  void addDirtyRect(const Common::Rect &r) override {}
129 public:
130  ASurface() : BaseSurface() {}
131 };
132 
133 class SpriteFrame : public ASurface {
134 public:
135  SpriteFrame(const AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize);
136  ~SpriteFrame() override;
137 };
138 
140 public:
142 public:
143  SpriteResource(const AccessEngine *vm, Resource *res);
144  ~SpriteResource();
145 
146  int getCount() { return _frames.size(); }
147 
148  const SpriteFrame *getFrame(int idx) const { return _frames[idx]; }
149 };
150 
151 enum ImageFlag {
152  IMGFLAG_NONE = 0,
153  IMGFLAG_CROPPED = 1,
154  IMGFLAG_BACKWARDS = 2,
155  IMGFLAG_DRAWN = 4,
156  IMGFLAG_UNSCALED = 8
157 };
158 
159 class ImageEntry {
160 public:
161  int _frameNumber;
162  SpriteResource *_spritesPtr;
163  int _offsetY;
164  Common::Point _position;
165  int _flags;
166 public:
167  ImageEntry();
168 };
169 
170 class ImageEntryList : public Common::Array<ImageEntry> {
171 public:
172  void addToList(ImageEntry &ie);
173 };
174 
175 } // End of namespace Access
176 
177 #endif /* ACCESS_ASURFACE_H */
Definition: managed_surface.h:51
Definition: asurface.h:170
void sPlotB(const SpriteFrame *frame, const Common::Rect &bounds)
Definition: surface.h:67
Definition: access.h:139
Definition: array.h:52
Definition: rect.h:524
Definition: stream.h:745
Definition: screen.h:48
Definition: asurface.h:42
Definition: asurface.h:133
void addDirtyRect(const Common::Rect &r) override
Definition: asurface.h:128
Definition: files.h:54
Definition: asurface.h:139
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:122
Definition: access.h:62
void plotF(const SpriteFrame *frame, const Common::Point &pt)
Definition: asurface.h:159