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