1.10
imagecache.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_DETAIL_IMAGECACHE_H
7#define EGT_DETAIL_IMAGECACHE_H
8
9#include <egt/detail/meta.h>
10#include <egt/painter.h>
11#include <map>
12#include <memory>
13#include <string>
14
15namespace egt
16{
17inline namespace v1
18{
19namespace detail
20{
21
32class EGT_API ImageCache
33{
34public:
35
39 shared_cairo_surface_t get(const std::string& uri,
40 float hscale = 1.0, float vscale = 1.0,
41 bool approximate = true);
42
46 void clear();
47
49 float old_width, float old_height,
50 float new_width, float new_height);
51
52protected:
53
54 static float round(float v, float fraction);
55
56 static std::string id(const std::string& name, float hscale, float vscale);
57
58 std::map<std::string, shared_cairo_surface_t> m_cache;
59};
60
65
66}
67}
68}
69
70#endif
Internal image cache.
Definition imagecache.h:33
static float round(float v, float fraction)
static std::string id(const std::string &name, float hscale, float vscale)
std::map< std::string, shared_cairo_surface_t > m_cache
Definition imagecache.h:58
shared_cairo_surface_t get(const std::string &uri, float hscale=1.0, float vscale=1.0, bool approximate=true)
Get an image surface.
void clear()
Clear the image cache.
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)
EGT_API ImageCache & image_cache()
Global image cache instance.
std::shared_ptr< cairo_surface_t > shared_cairo_surface_t
Shared pointer for a cairo surface.
Definition types.h:29
EGT framework namespace.
Definition animation.h:24