1.11
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
47 void clear();
48
49protected:
50
51 static Surface resize(const Surface& surface, const Size& size);
52
53 static float round(float v, float fraction);
54
55 static std::string id(const std::string& name, float hscale, float vscale);
56
57 std::map<std::string, std::shared_ptr<Surface>> m_cache;
58};
59
64
65}
66}
67}
68
69#endif
Definition surface.h:34
Internal image cache.
Definition imagecache.h:34
std::shared_ptr< Surface > get(const std::string &uri, float hscale=1.0, float vscale=1.0, bool approximate=true)
Get an image surface.
std::map< std::string, std::shared_ptr< Surface > > m_cache
Definition imagecache.h:57
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)
void clear()
Clear the image cache.
EGT_API ImageCache & image_cache()
Global image cache instance.
EGT framework namespace.
Definition animation.h:24