ScummVM API documentation
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_GFX_RENDERSURFACE_H
23 #define ULTIMA8_GFX_RENDERSURFACE_H
24 
25 #include "graphics/managed_surface.h"
26 
27 namespace Ultima {
28 namespace Ultima8 {
29 
30 class Shape;
31 
32 //
33 // RenderSurface
34 //
35 // Desc: The base class for rendering in Pentagram
36 //
38 private:
39  // Frame buffer
40  uint8 *_pixels; // Pointer to logical pixel 0,0
41 
42  // Dimensions
43  int32 _ox, _oy; // Physical Pixel for Logical Origin
44  int32 _pitch; // Frame buffer pitch (bytes) (could be negated)
45  bool _flipped;
46 
47  // Clipping Rectangle
48  Common::Rect _clipWindow;
49 
50  // Locking count
51  uint32 _lockCount; // Number of locks on surface
52 
53  Graphics::ManagedSurface *_surface;
54  DisposeAfterUse::Flag _disposeAfterUse;
55 
56  // Update the Pixels Pointer
57  void SetPixelsPointer();
58 
59 public:
60  // Create a render surface
61  RenderSurface(int width, int height, const Graphics::PixelFormat &format);
62 
63  // Create from a managed surface
64  RenderSurface(Graphics::ManagedSurface *s, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
65 
66  ~RenderSurface();
67 
68  //
69  // Being/End Painting
70  //
71 
73  // \note Can be called multiple times
74  // \return true on success, false on failure
75  bool BeginPainting();
76 
78  // \note MUST BE CALLED FOR EACH CALL TO BeginPainting()
79  // \return true on success, false on failure
80  bool EndPainting();
81 
82  //
83  // Surface Properties
84  //
85 
87  void SetOrigin(int32 x, int32 y);
88 
90  void GetOrigin(int32 &x, int32 &y) const;
91 
94 
97 
99  void setClippingRect(const Common::Rect32 &);
100 
102  void SetFlipped(bool flipped);
103 
105  bool IsFlipped() const;
106 
109  return _surface;
110  };
111 
113  void fillRect(const Common::Rect32 &r, uint32 color);
114 
116  void frameRect(const Common::Rect32 &r, uint32 color);
117 
118  // Draw a line with a color in the pixel format
119  void drawLine(int32 sx, int32 sy, int32 ex, int32 ey, uint32 color);
120 
122  void fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
123  fill32(rgb, Common::Rect32(sx, sy, sx + w, sy + h));
124  }
125 
127  void fill32(uint32 rgb, const Common::Rect32 &r);
128 
130  void fillBlended(uint32 rgba, const Common::Rect32 &r);
131 
133  void frameRect32(uint32 rgb, const Common::Rect32 &r);
134 
135  // Draw a line with a color in the TEX32_PACK_RGB format
136  void drawLine32(uint32 rgb, int32 sx, int32 sy, int32 ex, int32 ey);
137 
138  //
139  // The rule for painting methods:
140  //
141  // First arg are the source object to 'draw' with
142  // Next args are any other required data to define the 'source'
143  // Next args are the destination position
144  //
145 
146  //
147  // Basic Shape Painting
148  //
149 
151  void Paint(const Shape *s, uint32 frame, int32 x, int32 y, bool mirrored = false);
152 
154  void PaintTranslucent(const Shape *s, uint32 frame, int32 x, int32 y, bool mirrored = false);
155 
157  void PaintInvisible(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored);
158 
160  void PaintHighlight(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
161 
163  void PaintHighlightInvis(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
164 
165  //
166  // Basic Texture Blitting
167  //
168 
170  void Blit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend = false);
171 
172  void CrossKeyBlitMap(const Graphics::Surface &src, const Common::Rect &srcRect, int32 dx, int32 dy, const uint32 *map, const uint32 key);
173 
175  void FadedBlit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false);
176 
178  void MaskedBlit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false);
179 
180 };
181 
182 } // End of namespace Ultima8
183 } // End of namespace Ultima
184 
185 #endif
Definition: managed_surface.h:51
Definition: rect.h:526
void fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h)
Fill the region with a color in the TEX32_PACK_RGB format.
Definition: render_surface.h:122
void frameRect(const Common::Rect32 &r, uint32 color)
Fill the region with a color in the pixel format.
Definition: surface.h:67
void Paint(const Shape *s, uint32 frame, int32 x, int32 y, bool mirrored=false)
Paint a Shape.
void fillBlended(uint32 rgba, const Common::Rect32 &r)
Fill the region doing alpha blending with a color in the TEX32_PACK_RGBA format.
void MaskedBlit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32, bool alpha_blend=false)
Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDes...
void PaintHighlight(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32)
Paint a Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level) ...
Definition: pixelformat.h:138
Graphics::ManagedSurface * getRawSurface() const
Get a reference to the underlying surface that&#39;s being encapsulated.
Definition: render_surface.h:108
void FadedBlit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, uint32 col32, bool alpha_blend=false)
Blit a region from a Texture with a Colour blend (AlphaTex == 0 -> skipped. AlphaCol32 -> Blend Facto...
void PaintHighlightInvis(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32)
Paint a Invisible Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level...
void frameRect32(uint32 rgb, const Common::Rect32 &r)
Fill the region with a color in the TEX32_PACK_RGB format.
Definition: rect.h:524
Definition: render_surface.h:37
bool EndPainting()
Finish paining to the buffer.
void PaintTranslucent(const Shape *s, uint32 frame, int32 x, int32 y, bool mirrored=false)
Paint a Translucent Shape.
Definition: detection.h:27
void fillRect(const Common::Rect32 &r, uint32 color)
Fill the region with a color in the pixel format.
void SetFlipped(bool flipped)
Flip the surface.
Common::Rect32 getClippingRect() const
Get Clipping Rectangle.
Common::Rect32 getSurfaceDims() const
Get the Surface Dimensions.
void setClippingRect(const Common::Rect32 &)
Set Clipping Rectangle.
bool IsFlipped() const
Has the render surface been flipped?
bool BeginPainting()
Begin painting to the buffer. MUST BE CALLED BEFORE DOING ANYTHING TO THE SURFACE! ...
void PaintInvisible(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored)
Paint an Invisible Shape.
void SetOrigin(int32 x, int32 y)
Set the Origin of the Surface.
Definition: shape.h:37
void GetOrigin(int32 &x, int32 &y) const
Set the Origin of the Surface.
void Blit(const Graphics::ManagedSurface &src, const Common::Rect &srcRect, int32 dx, int32 dy, bool alpha_blend=false)
Blit a region from a Texture (Alpha == 0 -> skipped)