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

Internal image cache. More...

#include <imagecache.h>

Public Member Functions

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

Static Protected Member Functions

static std::string id (const std::string &name, float hscale, float vscale)
 
static Surface resize (const Surface &surface, const Size &size)
 
static float round (float v, float fraction)
 

Protected Attributes

std::map< std::string, std::shared_ptr< Surface > > m_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()

std::shared_ptr< Surface > 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

◆ resize()

static Surface resize ( const Surface surface,
const Size size 
)
staticprotected

◆ round()

static float round ( float  v,
float  fraction 
)
staticprotected

Member Data Documentation

◆ m_cache

std::map<std::string, std::shared_ptr<Surface> > m_cache
protected