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 (SDL_Surface *surface_=nullptr) | |
SDLSurfacePtr (SDLSurfacePtr &&other) noexcept | |
SDLSurfacePtr (const SDLSurfacePtr &)=delete | |
SDLSurfacePtr & | operator= (const SDLSurfacePtr &)=delete |
~SDLSurfacePtr () | |
void | reset (SDL_Surface *surface_=nullptr) |
SDL_Surface * | get () |
const SDL_Surface * | get () const |
void | swap (SDLSurfacePtr &other) noexcept |
SDLSurfacePtr & | operator= (SDLSurfacePtr &&other) noexcept |
SDL_Surface & | operator* () |
const SDL_Surface & | operator* () const |
SDL_Surface * | operator-> () |
const SDL_Surface * | operator-> () const |
operator bool () 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 34 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 39 of file SDLSurfacePtr.hh.
References openmsx::MemBuffer< T, ALIGNMENT >::data(), and openmsx::MemBuffer< T, ALIGNMENT >::resize().
|
inlineexplicit |
Definition at line 54 of file SDLSurfacePtr.hh.
|
inlinenoexcept |
Definition at line 59 of file SDLSurfacePtr.hh.
|
delete |
|
inline |
Definition at line 69 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 80 of file SDLSurfacePtr.hh.
Referenced by operator bool(), openmsx::TTFFont::render(), and openmsx::PNG::saveRGBA().
|
inline |
Definition at line 84 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 125 of file SDLSurfacePtr.hh.
Referenced by getLinePtr(), openmsx::PNG::load(), and openmsx::PNG::saveRGBA().
|
inline |
Definition at line 130 of file SDLSurfacePtr.hh.
References getLinePtr().
|
inlineexplicit |
Definition at line 120 of file SDLSurfacePtr.hh.
References get().
|
inline |
Definition at line 102 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 106 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 111 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 115 of file SDLSurfacePtr.hh.
|
delete |
|
inlinenoexcept |
Definition at line 95 of file SDLSurfacePtr.hh.
|
inline |
Definition at line 74 of file SDLSurfacePtr.hh.
References swap().
|
inlinenoexcept |
Definition at line 89 of file SDLSurfacePtr.hh.
Referenced by reset().