Class · aurore

aurore::ThemeImages

On this page
aurore/core/theme_image.hpp
#include <aurore/core/theme_image.hpp>

class aurore::ThemeImages

Description

The one loader of theme pictures. load() hands back the image at once, still loading: it is decoded on the decode thread (Threading::asyncDecode), made smaller when larger than MAX_WIDTH x MAX_HEIGHT (its ratio kept), and its texture is made on the UI thread (aurore::sync), which draws again. A file that cannot be read is logged once and stays FAILED.

The images are shared by path and flags while someone holds them, and freed when the last holder lets go: whoever draws a theme's picture keeps the shared_ptr while that theme is in use (Application does for the background), and drops it when the theme changes.

PNG and JPEG (what stb_image decodes; not WebP). Paths are files, resources ("@res/...") or romfs files.

Static functions 8

static std::shared_ptr< ThemeImage > load(const std::string &path,int flags = 0)

The image at path, made with flags (NVG_IMAGE_REPEATX...): loading, or ready when someone holds it already. From the UI thread.

theme_image.hpp:117
static std::shared_ptr< ThemeImage > load(const std::string &path,const ThemeImageOptions &options)

The same, with its size cap and mask (ThemeImageOptions): shared by path and options.

theme_image.hpp:123
static Event< const ThemeImage * > * getLoadedEvent()

Fired on the UI thread when an image loaded with load() is ready or failed (its texture made), before the frame that can draw it.

theme_image.hpp:129
static bool meanColor(const std::string &path, NVGcolor *color)

The average colour of the picture at path (opaque), for the contrast checks: remembered once known (a load() computes it on the decode thread); else decoded here, on the calling thread: not from the UI thread (a check, a test). False when the file cannot be read.

theme_image.hpp:137
static bool knownMeanColor(const std::string &path, NVGcolor *color)

The same, only when already known: never decodes.

theme_image.hpp:142
static bool exists(const std::string &path)

Whether there is a file at path (a resource, or a file on disk), without reading it.

theme_image.hpp:148
static int decoding()

How many pictures the decode thread is decoding now. A test waits for none, in real time, before it counts frames: the frames drawn while a picture decodes then do not depend on the machine's speed.

theme_image.hpp:155
static void releaseAll()

Deletes every texture still held, before the NVG context goes away (Application::exit): an image held afterwards is FAILED, empty.

theme_image.hpp:161

Static attributes 5

static constexpr constexpr int MAX_WIDTH = 1920
static constexpr constexpr int MAX_HEIGHT = 1080
static constexpr constexpr int LOGO_SIZE = 256
static constexpr constexpr int ICON_SIZE = 128
static constexpr constexpr int PREVIEW_SIZE = 128

Read from Aurore's headers by Doxygen at each build · library/include