Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
svg_dom_cache.hpp
Go to the documentation of this file.
1#pragma once
2
37
38#ifdef PULP_HAS_SKIA
39
40#include <cstddef>
41#include <cstdint>
42#include <functional>
43#include <string>
44
45#include "include/core/SkRefCnt.h"
46
47class SkSVGDOM;
48
49namespace pulp::canvas {
50
51class SvgDomCache {
52public:
53 static SvgDomCache& instance();
54
62 sk_sp<SkSVGDOM> get_or_build(const std::string& svg_document);
63
67 sk_sp<SkSVGDOM> get_or_build(
68 const std::string& svg_document,
69 const std::function<sk_sp<SkSVGDOM>()>& build);
70
71 struct Stats {
72 std::uint64_t hits = 0;
73 std::uint64_t builds = 0;
74 std::size_t size = 0;
75 };
76 Stats stats() const;
77 void reset_stats();
78 void clear();
79
83 void set_enabled(bool enabled);
84 bool enabled() const;
85
86 void set_capacity(std::size_t capacity);
87
88private:
89 SvgDomCache() = default;
90 struct Impl;
91 // Defined in svg_dom_cache.cpp; stateful members live there to keep this
92 // header free of <mutex>/<list>/<unordered_map> and the full SkSVGDOM type.
93 static Impl& impl();
94};
95
96} // namespace pulp::canvas
97
98#endif // PULP_HAS_SKIA
Definition affine_transform.hpp:24
@ size
Definition config.hpp:216