FastUIDraw
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
fastuidraw::Image Class Reference

An Image represents an image comprising of RGBA8 values. The texel values themselves are stored in a ImageAtlas. More...

#include <image.hpp>

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

Classes

class  ResourceReleaseAction
 

Public Types

enum  format_t { rgba_format, premultipied_rgba_format }
 
enum  type_t { on_atlas, bindless_texture2d, context_texture2d }
 

Public Member Functions

uint64_t bindless_handle (void) const
 
ivec2 dimensions (void) const
 
float dimensions_index_divisor (void) const
 
enum format_t format (void) const
 
ivec3 master_index_tile (void) const
 
vec2 master_index_tile_dims (void) const
 
unsigned int number_index_lookups (void) const
 
unsigned int number_mipmap_levels (void) const
 
type_t type (void) const
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

Protected Member Functions

 Image (ImageAtlas &atlas, int w, int h, unsigned int m, enum type_t type, uint64_t handle, enum format_t fmt, const reference_counted_ptr< ResourceReleaseAction > &action=reference_counted_ptr< ResourceReleaseAction >())
 

Friends

class ImageAtlas
 

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 Image represents an image comprising of RGBA8 values. The texel values themselves are stored in a ImageAtlas.

Definition at line 44 of file image.hpp.

Member Enumeration Documentation

◆ format_t

Enumeration to describe the format of an image

Enumerator
rgba_format 

Image is non-premultiplied RGBA format (each color channel of each pixel taking 8-bits).

premultipied_rgba_format 

Image is RGBA format (each color channel of each pixel taking 8-bits) with the RGB channels pre-multiplied by the alpha channel.

Definition at line 50 of file image.hpp.

◆ type_t

Gives the image-type of an Image

Enumerator
on_atlas 

Indicates that the Image is on an ImageAtlas. Such images will not introcude draw-breaks, but are more complicated to sample from.

bindless_texture2d 

Indicates that the Image is backed by a gfx API texture via a bindless interface. Such images do not introduce draw-breaks and are simple from. The only draw back, is that not all 3D API implementations support bindless texruing (for example the GL/GLES backends require that the GL/GLES implementation support an extension.

context_texture2d 

Indicates to source the Image data from a currently bound texture of the 3D API context. These image are simple to sample from but introduce draw breaks. Using images of these types should be avoided at all costs since whenever one uses Image objects of these types the 3D API state needs to change which induces a stage change and draw break, harming performance.

Definition at line 69 of file image.hpp.

Constructor & Destructor Documentation

◆ Image()

fastuidraw::Image::Image ( ImageAtlas atlas,
int  w,
int  h,
unsigned int  m,
enum type_t  type,
uint64_t  handle,
enum format_t  fmt,
const reference_counted_ptr< ResourceReleaseAction > &  action = reference_counted_ptrResourceReleaseAction >() 
)
protected

Protected ctor for creating an Image backed by a bindless texture; Backends should use this ctor for Image deried classes that do cleanup (for example releasing the handle and/or deleting the texture).

Parameters
atlasImageAtlas atlas onto which to place the image.
wwidth of underlying texture
hheight of underlying texture
mnumber of mipmap levels of the image
typethe type of the bindless texture, must NOT have value on_atlas.
fmtthe format of the image
handlethe bindless handle value used by the Gfx API in shaders to reference the texture.
actionaction to call to release backing resources of the created Image.

Member Function Documentation

◆ bindless_handle()

uint64_t fastuidraw::Image::bindless_handle ( void  ) const

Returns the bindless handle for the Image.

Only applies when type() does NOT return on_atlas.

◆ dimensions()

ivec2 fastuidraw::Image::dimensions ( void  ) const

Returns the dimensions of the image, i.e the width and height.

◆ dimensions_index_divisor()

float fastuidraw::Image::dimensions_index_divisor ( void  ) const

Returns the quotient of dimensions() divided by master_index_tile_dims().

Only applies when type() returns on_atlas.

◆ format()

enum format_t fastuidraw::Image::format ( void  ) const

Returns the format of the image.

◆ master_index_tile()

ivec3 fastuidraw::Image::master_index_tile ( void  ) const

Returns the "head" index tile as returned by ImageAtlas::add_index_tile() or ImageAtlas::add_index_tile_index_data().

Only applies when type() returns on_atlas.

◆ master_index_tile_dims()

vec2 fastuidraw::Image::master_index_tile_dims ( void  ) const

If number_index_lookups() > 0, returns the number of texels in each dimension of the master index tile this Image lies. If number_index_lookups() is 0, the returns the same value as dimensions().

Only applies when type() returns on_atlas.

◆ number_index_lookups()

unsigned int fastuidraw::Image::number_index_lookups ( void  ) const

Returns the number of index look-ups to get to the image data.

Only applies when type() returns on_atlas.

◆ number_mipmap_levels()

unsigned int fastuidraw::Image::number_mipmap_levels ( void  ) const

Returns the number of mipmap levels the image supports.

◆ type()

type_t fastuidraw::Image::type ( void  ) const

Returns the image type.


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