1.9
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
ImageCache Class Reference

Internal image cache. More...

Public Member Functions

void clear ()
 Clear the image cache. More...
 
shared_cairo_surface_t get (const std::string &uri, float hscale=1.0, float vscale=1.0, bool approximate=true)
 Get an image surface. More...
 

Static Public Member Functions

static shared_cairo_surface_t scale_surface (const shared_cairo_surface_t &old_surface, float old_width, float old_height, float new_width, float new_height)
 

Static Protected Member Functions

static std::string id (const std::string &name, float hscale, float vscale)
 
static float round (float v, float fraction)
 

Protected Attributes

std::map< std::string, shared_cairo_surface_tm_cache
 

Detailed Description

Internal image cache.

Provides an in-memory cache for images based on name and scale. This prevents multiple attempts at loading the same file as well as re-scaling the image to the same scale multiple times.

This is a trade off in consuming more memory instead of possibly constantly reloading or scaling the same image.

Member Function Documentation

◆ clear()

void clear ( )

Clear the image cache.

◆ get()

shared_cairo_surface_t get ( const std::string &  uri,
float  hscale = 1.0,
float  vscale = 1.0,
bool  approximate = true 
)

Get an image surface.

◆ id()

static std::string id ( const std::string &  name,
float  hscale,
float  vscale 
)
staticprotected

◆ round()

static float round ( float  v,
float  fraction 
)
staticprotected

◆ scale_surface()

static shared_cairo_surface_t scale_surface ( const shared_cairo_surface_t old_surface,
float  old_width,
float  old_height,
float  new_width,
float  new_height 
)
static

Member Data Documentation

◆ m_cache

std::map<std::string, shared_cairo_surface_t> m_cache
protected