Skia
2D Graphics Library
SkGraphics.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkGraphics_DEFINED
9 #define SkGraphics_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/private/base/SkAPI.h"
13 
14 #include <cstddef>
15 #include <cstdint>
16 #include <memory>
17 
18 class SkData;
19 class SkImageGenerator;
21 class SkTraceMemoryDump;
22 
23 class SK_API SkGraphics {
24 public:
30  static void Init();
31 
37  static size_t GetFontCacheLimit();
38 
46  static size_t SetFontCacheLimit(size_t bytes);
47 
51  static size_t GetFontCacheUsed();
52 
57  static int GetFontCacheCountUsed();
58 
63  static int GetFontCacheCountLimit();
64 
70  static int SetFontCacheCountLimit(int count);
71 
77  static void PurgeFontCache();
78 
84  static void PurgePinnedFontCache();
85 
90 
97  static size_t SetResourceCacheTotalByteLimit(size_t newLimit);
98 
103  static void PurgeResourceCache();
104 
114  static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit);
115 
121 
128  static void PurgeAllCaches();
129 
130  typedef std::unique_ptr<SkImageGenerator>
131  (*ImageGeneratorFromEncodedDataFactory)(sk_sp<SkData>);
132 
140  static ImageGeneratorFromEncodedDataFactory
141  SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory);
142 
151  std::unique_ptr<SkOpenTypeSVGDecoder> (*)(const uint8_t* svg, size_t length);
154 };
155 
156 #endif
SkData holds an immutable data buffer.
Definition: SkData.h:25
Definition: SkGraphics.h:23
static int GetFontCacheCountLimit()
Return the current limit to the number of entries in the font cache.
std::unique_ptr< SkOpenTypeSVGDecoder >(*)(const uint8_t *svg, size_t length) OpenTypeSVGDecoderFactory
To draw OpenType SVG data, Skia will look at this runtime function pointer.
Definition: SkGraphics.h:151
static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit)
static size_t SetResourceCacheTotalByteLimit(size_t newLimit)
static size_t SetFontCacheLimit(size_t bytes)
Specify the max number of bytes that should be used by the font cache.
static ImageGeneratorFromEncodedDataFactory SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory)
To instantiate images from encoded data, first looks at this runtime function-ptr.
static void PurgeFontCache()
For debugging purposes, this will attempt to purge the font cache.
static void PurgeResourceCache()
For debugging purposes, this will attempt to purge the resource cache.
static void PurgePinnedFontCache()
If the strike cache is above the cache limit, attempt to purge strikes with pinners.
static OpenTypeSVGDecoderFactory GetOpenTypeSVGDecoderFactory()
static int SetFontCacheCountLimit(int count)
Set the limit to the number of entries in the font cache, and return the previous value.
static int GetFontCacheCountUsed()
Return the number of entries in the font cache.
static size_t GetFontCacheUsed()
Return the number of bytes currently used by the font cache.
static void PurgeAllCaches()
Free as much globally cached memory as possible.
static OpenTypeSVGDecoderFactory SetOpenTypeSVGDecoderFactory(OpenTypeSVGDecoderFactory)
static size_t GetFontCacheLimit()
Return the max number of bytes that should be used by the font cache.
static void DumpMemoryStatistics(SkTraceMemoryDump *dump)
Dumps memory usage of caches using the SkTraceMemoryDump interface.
static size_t GetResourceCacheSingleAllocationByteLimit()
When the cachable entry is very lage (e.g.
static size_t GetResourceCacheTotalBytesUsed()
This function returns the memory used for temporary images and other resources.
static size_t GetResourceCacheTotalByteLimit()
These functions get/set the memory usage limit for the resource cache, used for temporary bitmaps and...
static void Init()
Call this at process initialization time if your environment does not permit static global initialize...
Definition: SkImageGenerator.h:28
Definition: SkOpenTypeSVGDecoder.h:19
Interface for memory tracing.
Definition: SkTraceMemoryDump.h:20