1.12
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 <egt/surface.h>
12#include <map>
13#include <memory>
14#include <string>
15
16namespace egt
17{
18inline namespace v1
19{
20namespace detail
21{
22
33class EGT_API ImageCache
34{
35public:
36
40 std::shared_ptr<Surface> get(const std::string& uri,
41 float hscale = 1.0, float vscale = 1.0,
42 bool approximate = true,
43 bool is_cached = false);
44
48 void clear();
49
50protected:
51
52 static Surface resize(const Surface& surface, const Size& size);
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, std::shared_ptr<Surface>> m_cache;
59};
60
65
66}
67}
68}
69
70#endif
Definition surface.h:34
Internal image cache.
Definition imagecache.h:34
std::map< std::string, std::shared_ptr< Surface > > m_cache
Definition imagecache.h:58
static Surface resize(const Surface &surface, const Size &size)
static float round(float v, float fraction)
static std::string id(const std::string &name, float hscale, float vscale)
std::shared_ptr< Surface > get(const std::string &uri, float hscale=1.0, float vscale=1.0, bool approximate=true, bool is_cached=false)
Get an image surface.
void clear()
Clear the image cache.
EGT_API ImageCache & image_cache()
Global image cache instance.
EGT framework namespace.
Definition animation.h:24