FastUIDraw
Classes | Public Member Functions | List of all members
fastuidraw::GlyphCache Class Reference

A GlyphCache represents a cache of glyphs and manages the uploading of the data to a GlyphAtlas. The methods of GlyphAtlas are thread safe because it maintains an internal mutex lock for the durations of its methods. More...

#include <glyph_cache.hpp>

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

Classes

class  AllocationHandle
 

Public Member Functions

 GlyphCache (reference_counted_ptr< GlyphAtlas > patlas)
 
enum return_code add_glyph (Glyph glyph, bool upload_to_atlas=true)
 
AllocationHandle allocate_data (c_array< const uint32_t > pdata)
 
void clear_atlas (void)
 
void clear_cache (void)
 
void deallocate_data (AllocationHandle h)
 
void delete_glyph (Glyph glyph)
 
Glyph fetch_glyph (GlyphRenderer render, const FontBase *font, uint32_t glyph_code, bool upload_to_atlas=true)
 
GlyphMetrics fetch_glyph_metrics (const FontBase *font, uint32_t glyph_code)
 
void fetch_glyph_metrics (const FontBase *font, c_array< const uint32_t > glyph_codes, c_array< GlyphMetrics > out_metrics)
 
void fetch_glyph_metrics (c_array< const GlyphSource > glyph_sources, c_array< GlyphMetrics > out_metrics)
 
void fetch_glyphs (GlyphRenderer render, const FontBase *font, c_array< const uint32_t > glyph_codes, c_array< Glyph > out_glyphs, bool upload_to_atlas=true)
 
void fetch_glyphs (GlyphRenderer render, c_array< const GlyphSource > glyph_sources, c_array< Glyph > out_glyphs, bool upload_to_atlas=true)
 
void fetch_glyphs (GlyphRenderer render, c_array< const GlyphMetrics > glyph_metrics, c_array< Glyph > out_glyphs, bool upload_to_atlas=true)
 
unsigned int number_times_atlas_cleared (void)
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

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

A GlyphCache represents a cache of glyphs and manages the uploading of the data to a GlyphAtlas. The methods of GlyphAtlas are thread safe because it maintains an internal mutex lock for the durations of its methods.

Definition at line 43 of file glyph_cache.hpp.

Constructor & Destructor Documentation

◆ GlyphCache()

fastuidraw::GlyphCache::GlyphCache ( reference_counted_ptr< GlyphAtlas patlas)
explicit

Ctor

Parameters
patlasGlyphAtlas to store glyph data

Member Function Documentation

◆ add_glyph()

enum return_code fastuidraw::GlyphCache::add_glyph ( Glyph  glyph,
bool  upload_to_atlas = true 
)

Add a Glyph created with Glyph::create_glyph() to this GlyphCache. Will fail if a Glyph with the same glyph_code (GlyphMetrics::glyph_code()), font (GlyphMetrics::font()) and renderer (Glyph::renderer()) is already present in the GlyphCache.

Parameters
glyphGlyph to add to cache
upload_to_atlasif true, upload to atlas

◆ allocate_data()

AllocationHandle fastuidraw::GlyphCache::allocate_data ( c_array< const uint32_t >  pdata)

Allocate and set data in the GlyphAtlas of this GlyphCache.

◆ clear_atlas()

void fastuidraw::GlyphCache::clear_atlas ( void  )

Call to clear the backing GlyphAtlas. In doing so, the glyphs will lose their backing store in the GlyphAtlas and will need to be re-uploaded (see Glyph::upload_to_atlas()). The glyphs however are NOT removed from this GlyphCache. Thus, the return values of previous calls to create_glyph() are still valie, but they need to be re-uploaded to the GlyphAtlas with Glyph::upload_to_atlas().

◆ clear_cache()

void fastuidraw::GlyphCache::clear_cache ( void  )

Clear this GlyphCache and the GlyphAtlas backing the glyphs. Thus all previous Glyph and GlyphMetrics values returned are no longer valid. In addition, as a side-effect of clearing all Glyph and GlyphMetrics values, all references to FontBase objects are also released.

◆ deallocate_data()

void fastuidraw::GlyphCache::deallocate_data ( AllocationHandle  h)

Deallocate data in the GlyphAtlas of this GlyphCache previously allocated with allocate_data().

◆ delete_glyph()

void fastuidraw::GlyphCache::delete_glyph ( Glyph  glyph)

Deletes and removes a glyph from the GlyphCache, thus to use that glyph again requires calling fetch_glyph() (and thus fetching a new value for Glyph). The underlying memory of the Glyph will be reused by a later glyph, thus the Glyph value passed should be discarded.

Parameters
glyphGlyph to delete and remove from cache

◆ fetch_glyph()

Glyph fastuidraw::GlyphCache::fetch_glyph ( GlyphRenderer  render,
const FontBase font,
uint32_t  glyph_code,
bool  upload_to_atlas = true 
)

Fetch, and if necessay create and store, a glyph given a glyph code of a font and a GlyphRenderer specifying how to render the glyph.

Parameters
renderrenderer of fetched Glyph
fontfont from which to take the glyph
glyph_codeglyph code
upload_to_atlasif true, upload to atlas

◆ fetch_glyph_metrics() [1/3]

GlyphMetrics fastuidraw::GlyphCache::fetch_glyph_metrics ( const FontBase font,
uint32_t  glyph_code 
)

Fetch, and if necessay create and store, the metrics of given a glyph code of a font.

Parameters
fontfont from which to take the glyph
glyph_codeglyph code

◆ fetch_glyph_metrics() [2/3]

void fastuidraw::GlyphCache::fetch_glyph_metrics ( const FontBase font,
c_array< const uint32_t >  glyph_codes,
c_array< GlyphMetrics out_metrics 
)

Fetch, and if necessay create and store, the metrics of given a set of glyph codes of a font.

Parameters
fontfont from which to take the glyph
glyph_codesglyph codes to fetch
out_metricslocation to which to write the Glyph

◆ fetch_glyph_metrics() [3/3]

void fastuidraw::GlyphCache::fetch_glyph_metrics ( c_array< const GlyphSource glyph_sources,
c_array< GlyphMetrics out_metrics 
)

Fetch, and if necessay create and store, the metrics of given a set of glyph codes of a font.

Parameters
glyph_sourcessequence of GlyphSource values
out_metricslocation to which to write the Glyph

◆ fetch_glyphs() [1/3]

void fastuidraw::GlyphCache::fetch_glyphs ( GlyphRenderer  render,
const FontBase font,
c_array< const uint32_t >  glyph_codes,
c_array< Glyph out_glyphs,
bool  upload_to_atlas = true 
)

Fetch, and if necessay create and store, a sequence of glyphs given a sequence of glyph codes of a font and a GlyphRenderer specifying how to render the glyph.

Parameters
renderrenderer of fetched Glyph
fontfont from which to take the glyph
glyph_codessequence of glyph codes
[out]out_glyphslocation to which to write the glyphs; the size must be the same as glyph_codes
upload_to_atlasif true, upload glyphs to atlas

◆ fetch_glyphs() [2/3]

void fastuidraw::GlyphCache::fetch_glyphs ( GlyphRenderer  render,
c_array< const GlyphSource glyph_sources,
c_array< Glyph out_glyphs,
bool  upload_to_atlas = true 
)

Fetch, and if necessay create and store, a sequence of glyphs given a sequence of glyph codes of a font and a GlyphRenderer specifying how to render the glyph.

Parameters
renderrenderer of fetched Glyph
glyph_sourcessequence of GlyphSource values
[out]out_glyphslocation to which to write the glyphs; the size must be the same as glyph_codes
upload_to_atlasif true, upload glyphs to atlas

◆ fetch_glyphs() [3/3]

void fastuidraw::GlyphCache::fetch_glyphs ( GlyphRenderer  render,
c_array< const GlyphMetrics glyph_metrics,
c_array< Glyph out_glyphs,
bool  upload_to_atlas = true 
)

Fetch, and if necessay create and store, a sequence of glyphs given a sequence of GlyphMetrics values and a GlyphRenderer specifying how to render the glyph.

Parameters
renderrenderer of fetched Glyph
glyph_metricssequence of GlyphMetrics values
[out]out_glyphslocation to which to write the glyphs; the size must be the same as glyph_codes
upload_to_atlasif true, upload glyphs to atlas

◆ number_times_atlas_cleared()

unsigned int fastuidraw::GlyphCache::number_times_atlas_cleared ( void  )

Returns the number of times that this GlyphCache cleared its GlyphAtlas (i.e. the number of times clear_atlas() or clear_cache() have been called).


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