ScummVM API documentation
surface_area.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 TITANIC_SURFACE_OBJ_H
23 #define TITANIC_SURFACE_OBJ_H
24 
25 #include "titanic/support/rect.h"
26 #include "titanic/support/video_surface.h"
27 #include "titanic/star_control/fpoint.h"
28 #include "titanic/star_control/frect.h"
29 
30 namespace Titanic {
31 
32 enum SurfaceAreaMode {
33  SA_SOLID = 0, SA_MODE1 = 1, SA_MODE2 = 2, SA_XOR = 3, SA_MODE4 = 4
34 };
35 
36 class CSurfaceArea {
37  template<typename T>
38  static void plotPoint(int x, int y, int color, void *data) {
39  CSurfaceArea *sa = (CSurfaceArea *)data;
40  if (x >= 0 && x < sa->_width && y >= 0 && y < sa->_height) {
41  T *ptr = (T *)sa->_surface->getBasePtr(x, y);
42  *ptr = (*ptr & sa->_colorMask) ^ sa->_color;
43  }
44  }
45 private:
49  void initialize();
50 
54  void setColor(uint rgb);
55 
56  void pixelToRGB(uint pixel, uint *rgb);
57 
58  Graphics::PixelFormat getPixelFormat() const;
59 public:
60  int _field0;
61  int _width;
62  int _height;
63  int _pitch;
64  int _bpp;
65  byte *_pixelsPtr;
66  FPoint _centroid;
67  uint _pixel;
68  byte _field24;
69  byte _field25;
70  byte _field26;
71  byte _field27;
72  uint _rgb;
73  int _field2C;
74  uint _colorMask;
75  uint _color;
76  SurfaceAreaMode _mode;
77  Rect _bounds;
78  Graphics::Surface *_surface;
79 public:
80  CSurfaceArea(CVideoSurface *surface);
81 
85  SurfaceAreaMode setMode(SurfaceAreaMode mode);
86 
90  void setColorFromPixel();
91 
95  double drawLine(const FPoint &pt1, const FPoint &pt2);
96 
101  double drawLine(const FRect &rect) {
102  return drawLine(FPoint(rect.left, rect.top), FPoint(rect.right, rect.bottom));
103  }
104 };
105 
106 } // End of namespace Titanic
107 
108 #endif /* TITANIC_STAR_CONTROL_SUB16_H */
Definition: surface_area.h:36
Definition: surface.h:67
Definition: frect.h:30
Definition: pixelformat.h:138
double drawLine(const FRect &rect)
Definition: surface_area.h:101
const void * getBasePtr(int x, int y) const
Definition: surface.h:138
Definition: rect.h:35
Definition: arm.h:30
SurfaceAreaMode setMode(SurfaceAreaMode mode)
double drawLine(const FPoint &pt1, const FPoint &pt2)
Definition: video_surface.h:43
Definition: fpoint.h:32