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 
13 class SkData;
14 class SkImageGenerator;
15 class SkTraceMemoryDump;
16 
18 public:
24  static void Init();
25 
26  // We're in the middle of cleaning this up.
27  static void Term() {}
28 
34  static size_t GetFontCacheLimit();
35 
43  static size_t SetFontCacheLimit(size_t bytes);
44 
48  static size_t GetFontCacheUsed();
49 
54  static int GetFontCacheCountUsed();
55 
60  static int GetFontCacheCountLimit();
61 
67  static int SetFontCacheCountLimit(int count);
68 
69  /*
70  * Returns the maximum point size for text that may be cached.
71  *
72  * Sizes above this will be drawn directly from the font's outline.
73  * Setting this to a large value may speed up drawing larger text (repeatedly),
74  * but could cause the cache to purge other sizes more often.
75  *
76  * This value is a hint to the font engine, and the actual limit may be different due to
77  * implementation specific details.
78  */
80 
81  /*
82  * Set the maximum point size for text that may be cached, returning the previous value.
83  *
84  * Sizes above this will be drawn directly from the font's outline.
85  * Setting this to a large value may speed up drawing larger text (repeatedly),
86  * but could cause the cache to purge other sizes more often.
87  *
88  * This value is a hint to the font engine, and the actual limit may be different due to
89  * implementation specific details.
90  */
91  static int SetFontCachePointSizeLimit(int maxPointSize);
92 
98  static void PurgeFontCache();
99 
108 
115  static size_t SetResourceCacheTotalByteLimit(size_t newLimit);
116 
121  static void PurgeResourceCache();
122 
132  static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit);
133 
139 
146  static void PurgeAllCaches();
147 
156  static void SetFlags(const char* flags);
157 
158  typedef std::unique_ptr<SkImageGenerator>
159  (*ImageGeneratorFromEncodedDataFactory)(sk_sp<SkData>);
160 
168  static ImageGeneratorFromEncodedDataFactory
169  SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory);
170 
174  static void AllowJIT();
175 };
176 
178 public:
181  }
182 };
183 
184 #endif
SkGraphics::GetResourceCacheTotalBytesUsed
static size_t GetResourceCacheTotalBytesUsed()
Scaling bitmaps with the kHigh_SkFilterQuality setting is expensive, so the result is saved in the gl...
SkImageGenerator
Definition: SkImageGenerator.h:28
SkGraphics::SetFontCacheLimit
static size_t SetFontCacheLimit(size_t bytes)
Specify the max number of bytes that should be used by the font cache.
SkGraphics::DumpMemoryStatistics
static void DumpMemoryStatistics(SkTraceMemoryDump *dump)
Dumps memory usage of caches using the SkTraceMemoryDump interface.
SkGraphics::PurgeResourceCache
static void PurgeResourceCache()
For debugging purposes, this will attempt to purge the resource cache.
SkTraceMemoryDump
Interface for memory tracing.
Definition: SkTraceMemoryDump.h:20
SkGraphics::SetResourceCacheSingleAllocationByteLimit
static size_t SetResourceCacheSingleAllocationByteLimit(size_t newLimit)
SkGraphics::GetFontCacheLimit
static size_t GetFontCacheLimit()
Return the max number of bytes that should be used by the font cache.
SkGraphics::SetResourceCacheTotalByteLimit
static size_t SetResourceCacheTotalByteLimit(size_t newLimit)
SkGraphics::GetFontCacheCountUsed
static int GetFontCacheCountUsed()
Return the number of entries in the font cache.
SkData
SkData holds an immutable data buffer.
Definition: SkData.h:22
SkRefCnt.h
SkGraphics::PurgeAllCaches
static void PurgeAllCaches()
Free as much globally cached memory as possible.
sk_sp< SkData >
SkGraphics
Definition: SkGraphics.h:17
SkGraphics::GetResourceCacheTotalByteLimit
static size_t GetResourceCacheTotalByteLimit()
These functions get/set the memory usage limit for the resource cache, used for temporary bitmaps and...
SK_API
#define SK_API
Definition: SkTypes.h:181
SkGraphics::SetFlags
static void SetFlags(const char *flags)
Applications with command line options may pass optional state, such as cache sizes,...
SkGraphics::GetFontCacheCountLimit
static int GetFontCacheCountLimit()
Return the current limit to the number of entries in the font cache.
SkAutoGraphics
Definition: SkGraphics.h:177
SkGraphics::Init
static void Init()
Call this at process initialization time if your environment does not permit static global initialize...
SkGraphics::AllowJIT
static void AllowJIT()
Call early in main() to allow Skia to use a JIT to accelerate CPU-bound operations.
SkGraphics::SetFontCachePointSizeLimit
static int SetFontCachePointSizeLimit(int maxPointSize)
SkGraphics::Term
static void Term()
Definition: SkGraphics.h:27
SkGraphics::GetFontCachePointSizeLimit
static int GetFontCachePointSizeLimit()
SkAutoGraphics::SkAutoGraphics
SkAutoGraphics()
Definition: SkGraphics.h:179
SkGraphics::SetImageGeneratorFromEncodedDataFactory
static ImageGeneratorFromEncodedDataFactory SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory)
To instantiate images from encoded data, first looks at this runtime function-ptr.
SkGraphics::GetResourceCacheSingleAllocationByteLimit
static size_t GetResourceCacheSingleAllocationByteLimit()
When the cachable entry is very lage (e.g.
SkGraphics::PurgeFontCache
static void PurgeFontCache()
For debugging purposes, this will attempt to purge the font cache.
SkGraphics::SetFontCacheCountLimit
static int SetFontCacheCountLimit(int count)
Set the limit to the number of entries in the font cache, and return the previous value.
SkGraphics::GetFontCacheUsed
static size_t GetFontCacheUsed()
Return the number of bytes currently used by the font cache.