|
openMSX
|
Wrapper around a SDL_Surface. More...
#include <SDLSurfacePtr.hh>
Public Member Functions | |
| SDLSurfacePtr (unsigned width, unsigned height, unsigned depth, Uint32 rMask, Uint32 gMask, Uint32 bMask, Uint32 aMask) | |
| Create a (software) surface with uninitialized pixel content. | |
| SDLSurfacePtr (const SDLSurfacePtr &) | |
| SDLSurfacePtr & | operator= (const SDLSurfacePtr &) |
| SDLSurfacePtr (SDL_Surface *surface_=nullptr, void *buffer_=nullptr) | |
| SDLSurfacePtr (SDLSurfacePtr &&other) | |
| ~SDLSurfacePtr () | |
| void | reset (SDL_Surface *surface_=nullptr) |
| SDL_Surface * | get () |
| const SDL_Surface * | get () const |
| void | swap (SDLSurfacePtr &other) |
| SDLSurfacePtr & | operator= (SDLSurfacePtr &&other) |
| SDL_Surface & | operator* () |
| const SDL_Surface & | operator* () const |
| SDL_Surface * | operator-> () |
| const SDL_Surface * | operator-> () const |
| void * | getLinePtr (unsigned y) |
| const void * | getLinePtr (unsigned y) const |
Wrapper around a SDL_Surface.
Makes sure SDL_FreeSurface() is called when this object goes out of scope. It's modeled after std::unique_ptr, so it has the usual get(), reset() and release() methods. Like unique_ptr it can be moved but not copied.
In addition to the SDL_Surface pointer, this wrapper also (optionally) manages an extra memory buffer. Normally SDL_CreateRGBSurface() will allocate/free an internal memory buffer for the surface. On construction of the surface this buffer will be zero-initialized. Though in many cases the surface will immediately be overwritten (so zero-initialization is only extra overhead). It's possible to avoid this by creating the surface using SDL_CreateRGBSurfaceFrom(). Though the downside of this is that you have to manage the lifetime of the memory buffer yourself. And that's exactly what this wrapper can do.
As a bonus this wrapper has a getLinePtr() method to hide some of the casting. But apart from this it doesn't try to abstract any SDL functionality.
Definition at line 30 of file SDLSurfacePtr.hh.
|
inline |
Create a (software) surface with uninitialized pixel content.
throws: bad_alloc (no need to check for nullptr).
Definition at line 35 of file SDLSurfacePtr.hh.
References utf8::unchecked::size().
| SDLSurfacePtr::SDLSurfacePtr | ( | const SDLSurfacePtr & | ) |
|
inlineexplicit |
Definition at line 57 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 64 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 72 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 86 of file SDLSurfacePtr.hh.
Referenced by openmsx::SDLImage::draw(), openmsx::TTFFont::render(), openmsx::PNG::save(), openmsx::SDLOffScreenSurface::SDLOffScreenSurface(), and openmsx::VisibleSurface::VisibleSurface().
|
inline |
Definition at line 90 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 128 of file SDLSurfacePtr.hh.
Referenced by getLinePtr(), openmsx::PNG::load(), and openmsx::PNG::save().
|
inline |
Definition at line 133 of file SDLSurfacePtr.hh.
References getLinePtr().
|
inline |
Definition at line 110 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 114 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 119 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 123 of file SDLSurfacePtr.hh.
| SDLSurfacePtr& SDLSurfacePtr::operator= | ( | const SDLSurfacePtr & | ) |
|
inline |
Definition at line 101 of file SDLSurfacePtr.hh.
References swap().
|
inline |
Definition at line 80 of file SDLSurfacePtr.hh.
References swap().
Referenced by openmsx::SDLOffScreenSurface::SDLOffScreenSurface(), and openmsx::SDLOffScreenSurface::~SDLOffScreenSurface().
|
inline |
Definition at line 95 of file SDLSurfacePtr.hh.
Referenced by operator=(), and reset().
1.8.1.2