ScummVM API documentation
base_soft_render_surface.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 ULTIMA8_GRAPHICS_BASESOFTRENDERSURFACE_H
23 #define ULTIMA8_GRAPHICS_BASESOFTRENDERSURFACE_H
24 
25 #include "ultima/ultima8/graphics/render_surface.h"
26 #include "ultima/ultima8/misc/rect.h"
27 #include "graphics/managed_surface.h"
28 
29 namespace Ultima {
30 namespace Ultima8 {
31 
32 //
33 // Class BaseSoftRenderSurface
34 //
35 // Desc: The base abstact class for software rendering in Pentagram
36 //
38 protected:
39  // Frame buffer
40  uint8 *_pixels; // Pointer to logical pixel 0,0
41  uint8 *_pixels00; // Pointer to physical pixel 0,0
42 
43  // Pixel Format (also see 'Colour shifting values' later)
44  int _bytesPerPixel; // 2 or 4
45  int _bitsPerPixel; // 16 or 32
46  int _formatType; // 16, 555, 565, 32 or 888
47 
48  // Dimensions
49  int32 _ox, _oy; // Physical Pixel for Logical Origin
50  int32 _width, _height; // Width and height
51  int32 _pitch; // Frame buffer pitch (bytes) (could be negated)
52  bool _flipped;
53 
54  // Clipping Rectangle
55  Rect _clipWindow;
56 
57  // Locking count
58  uint32 _lockCount; // Number of locks on surface
59 
60  Graphics::ManagedSurface *_surface;
61 
62  // Create from a managed surface
64 
65  // Update the Pixels Pointer
66  void SetPixelsPointer() {
67  uint8 *pix00 = _pixels00;
68 
69  if (_flipped) {
70  pix00 += -_pitch * (_height - 1);
71  }
72 
73  _pixels = pix00 + _ox * _bytesPerPixel + _oy * _pitch;
74  }
75 
76 public:
77 
78  // Virtual Destructor
79  ~BaseSoftRenderSurface() override;
80 
81  //
82  // Being/End Painting
83  //
84 
85  // Begin painting to the buffer. MUST BE CALLED BEFORE DOING ANYTHING TO THE SURFACE!
86  // Can be called multiple times
87  // Returns Error Code on error. Check return code.....
88  bool BeginPainting() override;
89 
90  // Finish paining to the buffer. MUST BE CALLED FOR EACH CALL TO BeginPainting()
91  // Returns Error Code on error. Check return code.....
92  bool EndPainting() override;
93 
94  //
95  // Surface Properties
96  //
97 
98  // Set the Origin of the Surface
99  void SetOrigin(int32 x, int32 y) override;
100 
101  // Set the Origin of the Surface
102  void GetOrigin(int32 &x, int32 &y) const override;
103 
104  // Get the Surface Dimensions
105  void GetSurfaceDims(Rect &) const override;
106 
107  // Get Clipping Rectangle
108  void GetClippingRect(Rect &) const override;
109 
110  // Set Clipping Rectangle
111  void SetClippingRect(const Rect &) override;
112 
113  // Check Clipped. -1 if off screen, 0 if not clipped, 1 if clipped
114  int16 CheckClipped(const Rect &) const override;
115 
116  // Flip the surface
117  void SetFlipped(bool flipped) override;
118 
119  // Has the render surface been flipped?
120  bool IsFlipped() const override;
121 
122  //
123  // Surface Palettes
124  //
125  // TODO: Make a Palette class
126  // TODO: Handle Ultima8 and Crusader Xforms
127  //
128 
129  // Set The Surface Palette
130  // virtual void SetPalette(uint8 palette[768]);
131 
132  // Set The Surface Palette to be the one used by another surface
133  // TODO: virtual void SetPalette(RenderSurface &);
134 
135  // Get The Surface Palette
136  // TODO: virtual void GetPalette(uint8 palette[768]);
137 
138  void CreateNativePalette(Palette *palette, int maxindex = 0) override;
139 
141  return _surface;
142  }
143 };
144 
145 } // End of namespace Ultima8
146 } // End of namespace Ultima
147 
148 #endif
Definition: managed_surface.h:45
void SetClippingRect(const Rect &) override
Set Clipping Rectangle.
int16 CheckClipped(const Rect &) const override
Check Clipped. -1 if off screen, 0 if not clipped, 1 if clipped.
void SetOrigin(int32 x, int32 y) override
Set the Origin of the Surface.
Definition: rect.h:32
Definition: render_surface.h:64
Definition: base_soft_render_surface.h:37
void GetSurfaceDims(Rect &) const override
Get the Surface Dimensions.
Definition: detection.h:27
bool BeginPainting() override
Begin painting to the buffer. MUST BE CALLED BEFORE DOING ANYTHING TO THE SURFACE! ...
void GetClippingRect(Rect &) const override
Get Clipping Rectangle.
Definition: palette.h:59
bool EndPainting() override
Finish paining to the buffer.
bool IsFlipped() const override
Has the render surface been flipped?
Graphics::ManagedSurface * getRawSurface() const override
Get a reference to the underlying surface that&#39;s being encapsulated.
Definition: base_soft_render_surface.h:140
void GetOrigin(int32 &x, int32 &y) const override
Set the Origin of the Surface.
void SetFlipped(bool flipped) override
Flip the surface.