FastUIDraw
Public Member Functions | Protected Member Functions | Friends | List of all members
fastuidraw::ImageAtlas Class Referenceabstract

An ImageAtlas is a common location to place images of an application. More...

#include <image_atlas.hpp>

Inheritance diagram for fastuidraw::ImageAtlas:
Inheritance graph
[legend]

Public Member Functions

const reference_counted_ptr< const AtlasColorBackingStoreBase > & color_store (void) const
 
int color_tile_size (void) const
 
reference_counted_ptr< Imagecreate (int w, int h, const ImageSourceBase &image_data, enum Image::type_t type=Image::bindless_texture2d)
 
reference_counted_ptr< Imagecreate_non_atlas (int w, int h, const ImageSourceBase &image_data)
 
void flush (void) const
 
const reference_counted_ptr< const AtlasIndexBackingStoreBase > & index_store (void) const
 
int index_tile_size (void) const
 
void lock_resources (void)
 
void queue_resource_release_action (const reference_counted_ptr< Image::ResourceReleaseAction > &action)
 
void unlock_resources (void)
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

Protected Member Functions

 ImageAtlas (int pcolor_tile_size, int pindex_tile_size, reference_counted_ptr< AtlasColorBackingStoreBase > pcolor_store, reference_counted_ptr< AtlasIndexBackingStoreBase > pindex_store)
 

Friends

class Image
 

Additional Inherited Members

- Static Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
static void add_reference (const reference_counted_base< T, Counter > *p)
 
static void remove_reference (const reference_counted_base< T, Counter > *p)
 

Detailed Description

An ImageAtlas is a common location to place images of an application.

Ideally, all images are placed into a single ImageAtlas (changes of ImageAtlas force draw-call breaks). Methods of ImageAtlas are thread safe, locked behind a mutex of the ImageAtlas.

Definition at line 233 of file image_atlas.hpp.

Constructor & Destructor Documentation

◆ ImageAtlas()

fastuidraw::ImageAtlas::ImageAtlas ( int  pcolor_tile_size,
int  pindex_tile_size,
reference_counted_ptr< AtlasColorBackingStoreBase pcolor_store,
reference_counted_ptr< AtlasIndexBackingStoreBase pindex_store 
)
protected

Ctor.

Parameters
pcolor_tile_sizesize of each color tile, a value of 0 indicates that atlased Images are not allowed.
pindex_tile_sizesize of each index tile, a value of 0 indicates that atlased Images are not allowed.
pcolor_storecolor data backing store for atlas, the width and height of the backing store must be divisible by pcolor_tile_size.
pindex_storeindex backing store for atlas, the width and height of the backing store must be divisible by pindex_tile_size.

Member Function Documentation

◆ color_store()

const reference_counted_ptr<const AtlasColorBackingStoreBase>& fastuidraw::ImageAtlas::color_store ( void  ) const

Returns a handle to the backing store for the image data.

◆ color_tile_size()

int fastuidraw::ImageAtlas::color_tile_size ( void  ) const

Returns the size (in texels) used for the color tiles.

◆ create()

reference_counted_ptr<Image> fastuidraw::ImageAtlas::create ( int  w,
int  h,
const ImageSourceBase image_data,
enum Image::type_t  type = Image::bindless_texture2d 
)

Construct an Image

Parameters
wwidth of the image
hheight of the image
image_dataimage data to which to initialize the image
typethe preferred value for Image::type() for the returned Image Image::bindless_texture2d will fallback to Image::on_atlas and Image::on_atlas will fallback to Image::context_texture2d

◆ create_non_atlas()

reference_counted_ptr<Image> fastuidraw::ImageAtlas::create_non_atlas ( int  w,
int  h,
const ImageSourceBase image_data 
)

Construct an Image whose Image::type() is NOT Image::on_atlas. Will first try to construct an Image whose Image::type() is Image::bindless_texture2d and if that failes will instead construct an Image whose Image::type() is Image::context_texture2d

Parameters
wwidth of the image
hheight of the image
image_dataimage data to which to initialize the image

◆ flush()

void fastuidraw::ImageAtlas::flush ( void  ) const

Calls AtlasIndexBackingStoreBase::flush() on the index backing store (see index_store()) and AtlasColorBackingStoreBase::flush() on the color backing store (see color_store()).

◆ index_store()

const reference_counted_ptr<const AtlasIndexBackingStoreBase>& fastuidraw::ImageAtlas::index_store ( void  ) const

Returns a handle to the backing store for the index data.

◆ index_tile_size()

int fastuidraw::ImageAtlas::index_tile_size ( void  ) const

Returns the size (in texels) used for the index tiles.

◆ lock_resources()

void fastuidraw::ImageAtlas::lock_resources ( void  )

Increments an internal counter. If this internal counter is greater than zero, then the reurning of tiles to the free store for later use is -delayed- until the counter reaches zero again (see unlock_resources()). The use case is for buffered painting where the GPU calls are delayed for later (to batch commands) and an Image may go out of scope before the GPU commands are sent to the GPU. By delaying the return of an Image's tiles to the freestore, the image data is valid still for rendering.

◆ queue_resource_release_action()

void fastuidraw::ImageAtlas::queue_resource_release_action ( const reference_counted_ptr< Image::ResourceReleaseAction > &  action)

Queue a ResourceReleaseAction to be executed when resources are not locked down, see lock_resources() and unlock_resources().

◆ unlock_resources()

void fastuidraw::ImageAtlas::unlock_resources ( void  )

Decrements an internal counter. If this internal counter reaches zero, those tiles from Image's that were deleted while the counter was non-zero, are then returned to the tile free store. See lock_resources() for more details.


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