ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

A derived graphics surface, which handles automatically managing the allocated surface data block, as well as introducing several new blitting methods. More...

#include <managed_surface.h>

Inheritance diagram for Graphics::ManagedSurface:
Collaboration diagram for Graphics::ManagedSurface:

List of all members.

Public Member Functions

 ManagedSurface ()
 Create the managed surface.
 ManagedSurface (ManagedSurface &surf)
 Create a managed surface from another one.
 ManagedSurface (int width, int height)
 Create the managed surface.
 ManagedSurface (int width, int height, const Graphics::PixelFormat &pixelFormat)
 Create the managed surface.
 ManagedSurface (ManagedSurface &surf, const Common::Rect &bounds)
 Create the managed surface.
virtual ~ManagedSurface ()
 Destroy the managed surface.
 operator const Surface & () const
 Implements automatic conversion to a Graphics::Surface by simply returning the inner surface.
const SurfacerawSurface () const
ManagedSurfaceoperator= (ManagedSurface &surf)
 Reassign one managed surface to another one Note that if the source has a managed surface, it will be duplicated.
bool empty () const
 Returns true if the surface has not yet been allocated.
DisposeAfterUse::Flag disposeAfterUse () const
 Returns true if the surface is managing its own pixels.
const void * getBasePtr (int x, int y) const
 Return a pointer to the pixel at the specified point.
void * getBasePtr (int x, int y)
 Return a pointer to the pixel at the specified point.
void * getPixels ()
 Get a reference to the pixel data.
const void * getPixels () const
virtual void setPixels (void *newPixels)
 Sets the pixel data.
virtual void create (uint16 width, uint16 height)
 Allocate memory for the pixel data of the surface.
virtual void create (uint16 width, uint16 height, const PixelFormat &pixelFormat)
 Allocate memory for the pixel data of the surface.
virtual void create (ManagedSurface &surf, const Common::Rect &bounds)
 Sets up the surface as a sub-section of another passed parent surface.
virtual void free ()
 Release the memory used by the pixels memory of this surface.
virtual void clearDirtyRects ()
 Clears any pending dirty rects that have been generated for the surface.
const Common::Point getOffsetFromOwner () const
 When the managed surface is a sub-section of a parent surface, returns the the offset in the parent surface that the surface starts at.
const Common::Rect getBounds () const
 Return a rect giving the bounds of the surface.
void blitFrom (const Surface &src)
 Copies another surface into this one.
void blitFrom (const Surface &src, const Common::Point &destPos)
 Copies another surface into this one at a given destination position.
void blitFrom (const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos)
 Copies another surface into this one at a given destination position.
void transBlitFrom (const Surface &src, uint transColor=0, bool flipped=false, uint overrideColor=0)
 Copies another surface into this one ignoring pixels of a designated transparent color.
void transBlitFrom (const Surface &src, const Common::Point &destPos, uint transColor=0, bool flipped=false, uint overrideColor=0)
 Copies another surface into this one ignoring pixels of a designated transparent color.
void transBlitFrom (const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, uint transColor=0, bool flipped=false, uint overrideColor=0)
 Copies another surface into this one ignoring pixels of a designated transparent color.
void transBlitFrom (const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, uint transColor=0, bool flipped=false, uint overrideColor=0)
 Copies another surface into this one ignoring pixels of a designated transparent color.
void clear (uint color=0)
 Clear the entire surface.
void markAllDirty ()
 Mark the entire surface as dirty.
void copyRectToSurface (const void *buffer, int srcPitch, int destX, int destY, int width, int height)
 Copies a bitmap to the Surface internal buffer.
void copyRectToSurface (const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect)
 Copies a bitmap to the Surface internal buffer.
void copyFrom (const ManagedSurface &surf)
 Copy the data from another Surface, reinitializing the surface to match the dimensions of the passed surface.
void drawLine (int x0, int y0, int x1, int y1, uint32 color)
 Draw a line.
void drawThickLine (int x0, int y0, int x1, int y1, int penX, int penY, uint32 color)
 Draw a thick line.
void hLine (int x, int y, int x2, uint32 color)
 Draw a horizontal line.
void vLine (int x, int y, int y2, uint32 color)
 Draw a vertical line.
void fillRect (Common::Rect r, uint32 color)
 Fill a rect with a given color.
void frameRect (const Common::Rect &r, uint32 color)
 Draw a frame around a specified rect.
Surface getSubArea (const Common::Rect &area)
 Returns a sub-area of the screen, but only adds a single initial dirty rect for the retrieved area.

Public Attributes

uint16w
uint16h
uint16pitch
PixelFormatformat

Protected Member Functions

bool clip (Common::Rect &srcBounds, Common::Rect &destBounds)
 Clips the given source bounds so the passed destBounds will be entirely on-screen.
virtual void addDirtyRect (const Common::Rect &r)
 Base method that descendent classes can override for recording affected dirty areas of the surface.

Private Attributes

Surface _innerSurface
 The Graphics::Surface that the managed surface encapsulates.
DisposeAfterUse::Flag _disposeAfterUse
 If set, the inner surface will be freed when the surface is recreated, as well as when the surface is destroyed.
ManagedSurface_owner
 Stores the owning surface if this If this managed surface represents a sub-section of another.
Common::Point _offsetFromOwner
 For sub-section areas of an owning parent managed surface, this represents the offset from the parent's top-left corner this sub-surface starts at.

Friends

class Font

Detailed Description

A derived graphics surface, which handles automatically managing the allocated surface data block, as well as introducing several new blitting methods.

Definition at line 39 of file managed_surface.h.


Constructor & Destructor Documentation

Graphics::ManagedSurface::ManagedSurface (  ) 

Create the managed surface.

Definition at line 31 of file managed_surface.cpp.

Graphics::ManagedSurface::ManagedSurface ( ManagedSurface surf  ) 

Create a managed surface from another one.

If the source surface is maintaining it's own surface data, then this surface will create it's own surface of the same size and copy the contents from the source surface

Definition at line 36 of file managed_surface.cpp.

Graphics::ManagedSurface::ManagedSurface ( int  width,
int  height 
)

Create the managed surface.

Definition at line 42 of file managed_surface.cpp.

Graphics::ManagedSurface::ManagedSurface ( int  width,
int  height,
const Graphics::PixelFormat pixelFormat 
)

Create the managed surface.

Definition at line 48 of file managed_surface.cpp.

Graphics::ManagedSurface::ManagedSurface ( ManagedSurface surf,
const Common::Rect bounds 
)

Create the managed surface.

Definition at line 54 of file managed_surface.cpp.

Graphics::ManagedSurface::~ManagedSurface (  )  [virtual]

Destroy the managed surface.

Definition at line 60 of file managed_surface.cpp.


Member Function Documentation

void Graphics::ManagedSurface::addDirtyRect ( const Common::Rect r  )  [protected, virtual]

Base method that descendent classes can override for recording affected dirty areas of the surface.

Reimplemented in Graphics::Screen.

Definition at line 328 of file managed_surface.cpp.

void Graphics::ManagedSurface::blitFrom ( const Surface src  ) 

Copies another surface into this one.

Definition at line 156 of file managed_surface.cpp.

void Graphics::ManagedSurface::blitFrom ( const Surface src,
const Common::Point destPos 
)

Copies another surface into this one at a given destination position.

Definition at line 160 of file managed_surface.cpp.

void Graphics::ManagedSurface::blitFrom ( const Surface src,
const Common::Rect srcRect,
const Common::Point destPos 
)

Copies another surface into this one at a given destination position.

Definition at line 164 of file managed_surface.cpp.

void Graphics::ManagedSurface::clear ( uint  color = 0  ) 

Clear the entire surface.

Definition at line 337 of file managed_surface.cpp.

virtual void Graphics::ManagedSurface::clearDirtyRects (  )  [inline, virtual]

Clears any pending dirty rects that have been generated for the surface.

Reimplemented in Graphics::Screen.

Definition at line 200 of file managed_surface.h.

bool Graphics::ManagedSurface::clip ( Common::Rect srcBounds,
Common::Rect destBounds 
) [protected]

Clips the given source bounds so the passed destBounds will be entirely on-screen.

Definition at line 127 of file managed_surface.cpp.

void Graphics::ManagedSurface::copyFrom ( const ManagedSurface surf  )  [inline]

Copy the data from another Surface, reinitializing the surface to match the dimensions of the passed surface.

Definition at line 310 of file managed_surface.h.

void Graphics::ManagedSurface::copyRectToSurface ( const void *  buffer,
int  srcPitch,
int  destX,
int  destY,
int  width,
int  height 
) [inline]

Copies a bitmap to the Surface internal buffer.

The pixel format of buffer must match the pixel format of the Surface.

Definition at line 294 of file managed_surface.h.

void Graphics::ManagedSurface::copyRectToSurface ( const Graphics::Surface srcSurface,
int  destX,
int  destY,
const Common::Rect  subRect 
) [inline]

Copies a bitmap to the Surface internal buffer.

The pixel format of buffer must match the pixel format of the Surface.

Definition at line 302 of file managed_surface.h.

void Graphics::ManagedSurface::create ( uint16  width,
uint16  height 
) [virtual]

Allocate memory for the pixel data of the surface.

Definition at line 93 of file managed_surface.cpp.

void Graphics::ManagedSurface::create ( uint16  width,
uint16  height,
const PixelFormat pixelFormat 
) [virtual]

Allocate memory for the pixel data of the surface.

Definition at line 97 of file managed_surface.cpp.

void Graphics::ManagedSurface::create ( ManagedSurface surf,
const Common::Rect bounds 
) [virtual]

Sets up the surface as a sub-section of another passed parent surface.

This surface will not own the pixels, and any dirty rect notifications will automatically be passed to the original parent surface.

Remarks:
Note that this differs from Graphics::Surface::getSubArea, in that that method only adds a single initial dirty rect for the whole area, and then none further

Definition at line 105 of file managed_surface.cpp.

DisposeAfterUse::Flag Graphics::ManagedSurface::disposeAfterUse (  )  const [inline]

Returns true if the surface is managing its own pixels.

Definition at line 137 of file managed_surface.h.

void Graphics::ManagedSurface::drawLine ( int  x0,
int  y0,
int  x1,
int  y1,
uint32  color 
) [inline]

Draw a line.

Definition at line 318 of file managed_surface.h.

void Graphics::ManagedSurface::drawThickLine ( int  x0,
int  y0,
int  x1,
int  y1,
int  penX,
int  penY,
uint32  color 
) [inline]

Draw a thick line.

Definition at line 326 of file managed_surface.h.

bool Graphics::ManagedSurface::empty (  )  const [inline]

Returns true if the surface has not yet been allocated.

Definition at line 132 of file managed_surface.h.

void Graphics::ManagedSurface::fillRect ( Common::Rect  r,
uint32  color 
) [inline]

Fill a rect with a given color.

Definition at line 350 of file managed_surface.h.

void Graphics::ManagedSurface::frameRect ( const Common::Rect r,
uint32  color 
) [inline]

Draw a frame around a specified rect.

Definition at line 358 of file managed_surface.h.

void Graphics::ManagedSurface::free (  )  [virtual]

Release the memory used by the pixels memory of this surface.

This is the counterpart to create().

Definition at line 118 of file managed_surface.cpp.

const void* Graphics::ManagedSurface::getBasePtr ( int  x,
int  y 
) const [inline]

Return a pointer to the pixel at the specified point.

Parameters:
x The x coordinate of the pixel.
y The y coordinate of the pixel.
Returns:
Pointer to the pixel.

Definition at line 146 of file managed_surface.h.

void* Graphics::ManagedSurface::getBasePtr ( int  x,
int  y 
) [inline]

Return a pointer to the pixel at the specified point.

Parameters:
x The x coordinate of the pixel.
y The y coordinate of the pixel.
Returns:
Pointer to the pixel.

Definition at line 157 of file managed_surface.h.

const Common::Rect Graphics::ManagedSurface::getBounds (  )  const [inline]

Return a rect giving the bounds of the surface.

Definition at line 211 of file managed_surface.h.

const Common::Point Graphics::ManagedSurface::getOffsetFromOwner (  )  const [inline]

When the managed surface is a sub-section of a parent surface, returns the the offset in the parent surface that the surface starts at.

Definition at line 206 of file managed_surface.h.

void* Graphics::ManagedSurface::getPixels (  )  [inline]

Get a reference to the pixel data.

Definition at line 164 of file managed_surface.h.

const void* Graphics::ManagedSurface::getPixels (  )  const [inline]

Definition at line 165 of file managed_surface.h.

Surface Graphics::ManagedSurface::getSubArea ( const Common::Rect area  )  [inline]

Returns a sub-area of the screen, but only adds a single initial dirty rect for the retrieved area.

Definition at line 367 of file managed_surface.h.

void Graphics::ManagedSurface::hLine ( int  x,
int  y,
int  x2,
uint32  color 
) [inline]

Draw a horizontal line.

Definition at line 334 of file managed_surface.h.

void Graphics::ManagedSurface::markAllDirty (  ) 

Mark the entire surface as dirty.

Definition at line 324 of file managed_surface.cpp.

Graphics::ManagedSurface::operator const Surface & (  )  const [inline]

Implements automatic conversion to a Graphics::Surface by simply returning the inner surface.

This must be const, because we don't want changes being done directly to it, since it would bypass dirty rect handling

Definition at line 120 of file managed_surface.h.

ManagedSurface & Graphics::ManagedSurface::operator= ( ManagedSurface surf  ) 

Reassign one managed surface to another one Note that if the source has a managed surface, it will be duplicated.

Definition at line 64 of file managed_surface.cpp.

const Surface& Graphics::ManagedSurface::rawSurface (  )  const [inline]

Definition at line 121 of file managed_surface.h.

void Graphics::ManagedSurface::setPixels ( void *  newPixels  )  [virtual]

Sets the pixel data.

Definition at line 88 of file managed_surface.cpp.

void Graphics::ManagedSurface::transBlitFrom ( const Surface src,
uint  transColor = 0,
bool  flipped = false,
uint  overrideColor = 0 
)

Copies another surface into this one ignoring pixels of a designated transparent color.

Parameters:
src Source surface
transColor Transparency color to ignore copying
flipped Specifies whether to horizontally flip the image
overrideColor Optional color to use instead of non-transparent pixels from the source surface

Definition at line 228 of file managed_surface.cpp.

void Graphics::ManagedSurface::transBlitFrom ( const Surface src,
const Common::Point destPos,
uint  transColor = 0,
bool  flipped = false,
uint  overrideColor = 0 
)

Copies another surface into this one ignoring pixels of a designated transparent color.

Parameters:
src Source surface
destPos Destination position to draw the surface
transColor Transparency color to ignore copying
flipped Specifies whether to horizontally flip the image
overrideColor Optional color to use instead of non-transparent pixels from the source surface

Definition at line 233 of file managed_surface.cpp.

void Graphics::ManagedSurface::transBlitFrom ( const Surface src,
const Common::Rect srcRect,
const Common::Rect destRect,
uint  transColor = 0,
bool  flipped = false,
uint  overrideColor = 0 
)

Copies another surface into this one ignoring pixels of a designated transparent color.

Parameters:
src Source surface
srcRect Sub-section of source surface to draw
destRect Destination area to draw the surface in. This can be sized differently then srcRect, allowing for arbitrary scaling of the image
transColor Transparency color to ignore copying
flipped Specifies whether to horizontally flip the image
overrideColor Optional color to use instead of non-transparent pixels from the source surface

Definition at line 306 of file managed_surface.cpp.

void Graphics::ManagedSurface::transBlitFrom ( const Surface src,
const Common::Rect srcRect,
const Common::Point destPos,
uint  transColor = 0,
bool  flipped = false,
uint  overrideColor = 0 
)

Copies another surface into this one ignoring pixels of a designated transparent color.

Parameters:
src Source surface
srcRect Sub-section of source surface to draw
destPos Destination position to draw the surface
transColor Transparency color to ignore copying
flipped Specifies whether to horizontally flip the image
overrideColor Optional color to use instead of non-transparent pixels from the source surface

Definition at line 239 of file managed_surface.cpp.

void Graphics::ManagedSurface::vLine ( int  x,
int  y,
int  y2,
uint32  color 
) [inline]

Draw a vertical line.

Definition at line 342 of file managed_surface.h.


Friends And Related Function Documentation

friend class Font [friend]

Definition at line 40 of file managed_surface.h.


Member Data Documentation

If set, the inner surface will be freed when the surface is recreated, as well as when the surface is destroyed.

Definition at line 51 of file managed_surface.h.

The Graphics::Surface that the managed surface encapsulates.

Definition at line 45 of file managed_surface.h.

For sub-section areas of an owning parent managed surface, this represents the offset from the parent's top-left corner this sub-surface starts at.

Definition at line 63 of file managed_surface.h.

Stores the owning surface if this If this managed surface represents a sub-section of another.

Definition at line 57 of file managed_surface.h.


The documentation for this class was generated from the following files:


Generated on Sat Jan 12 2019 05:04:19 for ResidualVM by doxygen 1.7.1
curved edge   curved edge