stmm-games-doc  0.32.0
Classes | Public Member Functions | List of all members
stmg::CachedSurfaces Class Reference

Cairo cached surfaces for an image. More...

Public Member Functions

void addSize (int32_t nW, int32_t nH) noexcept
 Tells to keep a ref counted cache with a certain size. More...
 
void subSize (int32_t nW, int32_t nH) noexcept
 Decrement the ref count for a cached surface. More...
 
const Cairo::RefPtr< Cairo::Surface > & getCachedRgba (int32_t nW, int32_t nH, bool &bCreated) noexcept
 Returns a cached rgba surface. More...
 
Cairo::RefPtr< Cairo::Surface > getRgba (int32_t nW, int32_t nH, bool &bCreated) noexcept
 Return a rgba (possibly cached) surface of a certain size. More...
 
const Cairo::RefPtr< Cairo::Surface > & getCachedA (int32_t nW, int32_t nH, bool &bCreated) noexcept
 Returns a cached alpha channel surface. More...
 
Cairo::RefPtr< Cairo::Surface > getA (int32_t nW, int32_t nH, bool &bCreated) noexcept
 Return a possibly cached alpha channel surface of a certain size. More...
 
void clear () noexcept
 Clears all ref counted sized surfaces. More...
 

Detailed Description

Cairo cached surfaces for an image.

Keeps sized surfaces to avoid redrawing the same image. The creation is done lazily.

Member Function Documentation

◆ addSize()

void stmg::CachedSurfaces::addSize ( int32_t  nW,
int32_t  nH 
)
noexcept

Tells to keep a ref counted cache with a certain size.

The surface isn't created right away but only when first requested by getRgba() or getA().

Parameters
nWThe width of the cached surface(s).
nHThe height of the cached surface(s).

◆ clear()

void stmg::CachedSurfaces::clear ( )
noexcept

Clears all ref counted sized surfaces.

Also resets all the ref counts.

◆ getA()

Cairo::RefPtr<Cairo::Surface> stmg::CachedSurfaces::getA ( int32_t  nW,
int32_t  nH,
bool &  bCreated 
)
noexcept

Return a possibly cached alpha channel surface of a certain size.

Parameters
nWThe width of the surface in pixel.
nHThe height of the surface in pixel.
bCreatedWhether the surface had to be created.
Returns
The alpha channel surface.

◆ getCachedA()

const Cairo::RefPtr<Cairo::Surface>& stmg::CachedSurfaces::getCachedA ( int32_t  nW,
int32_t  nH,
bool &  bCreated 
)
noexcept

Returns a cached alpha channel surface.

Parameters
nWThe width in pixels.
nHThe height in pixels.
bCreatedWhether the surface had to be created.
Returns
The alpha surface or null if the size is not cached.

◆ getCachedRgba()

const Cairo::RefPtr<Cairo::Surface>& stmg::CachedSurfaces::getCachedRgba ( int32_t  nW,
int32_t  nH,
bool &  bCreated 
)
noexcept

Returns a cached rgba surface.

Parameters
nWThe width in pixels.
nHThe height in pixels.
bCreatedWhether the surface had to be created.
Returns
The surface or null if the size is not cached.

◆ getRgba()

Cairo::RefPtr<Cairo::Surface> stmg::CachedSurfaces::getRgba ( int32_t  nW,
int32_t  nH,
bool &  bCreated 
)
noexcept

Return a rgba (possibly cached) surface of a certain size.

Parameters
nWThe width of the cached surface.
nHThe height of the cached surface.
bCreatedWhether the surface had to be created.
Returns
The rgba surface.

◆ subSize()

void stmg::CachedSurfaces::subSize ( int32_t  nW,
int32_t  nH 
)
noexcept

Decrement the ref count for a cached surface.

If the ref count reaches 0 the cached surface is removed.

Parameters
nWThe width of the cached surface(s).
nHThe height of the cached surface(s).