1use skia_bindings::SkGraphics;
2
3pub fn init() {
4 unsafe { SkGraphics::Init() };
5}
6
7pub fn font_cache_limit() -> usize {
8 unsafe { SkGraphics::GetFontCacheLimit() }
9}
10
11pub fn set_font_cache_limit(bytes: usize) -> usize {
12 unsafe { SkGraphics::SetFontCacheLimit(bytes) }
13}
14
15pub fn font_cache_used() -> usize {
16 unsafe { SkGraphics::GetFontCacheUsed() }
17}
18
19pub fn font_cache_count_used() -> i32 {
20 unsafe { SkGraphics::GetFontCacheCountUsed() }
21}
22
23pub fn font_cache_count_limit() -> i32 {
24 unsafe { SkGraphics::GetFontCacheCountLimit() }
25}
26
27pub fn set_font_cache_count_limit(count: i32) -> i32 {
28 unsafe { SkGraphics::SetFontCacheCountLimit(count) }
29}
30
31pub fn typeface_cache_count_limit() -> i32 {
32 unsafe { SkGraphics::GetTypefaceCacheCountLimit() }
33}
34
35pub fn set_typeface_cache_count_limit(count: i32) -> i32 {
36 unsafe { SkGraphics::SetTypefaceCacheCountLimit(count) }
37}
38
39pub fn purge_font_cache() {
40 unsafe { SkGraphics::PurgeFontCache() }
41}
42
43pub fn purge_pinned_font_cache() {
44 unsafe { SkGraphics::PurgePinnedFontCache() }
45}
46
47pub fn resource_cache_total_bytes_used() -> usize {
48 unsafe { SkGraphics::GetResourceCacheTotalBytesUsed() }
49}
50
51pub fn resource_cache_total_bytes_limit() -> usize {
52 unsafe { SkGraphics::GetResourceCacheTotalByteLimit() }
53}
54
55pub fn set_resource_cache_total_bytes_limit(new_limit: usize) -> usize {
56 unsafe { SkGraphics::SetResourceCacheTotalByteLimit(newLimit:new_limit) }
57}
58
59pub fn purge_resource_cache() {
60 unsafe { SkGraphics::PurgeResourceCache() }
61}
62
63pub fn resource_cache_single_allocation_byte_limit() -> Option<usize> {
64 let size: usize = unsafe { SkGraphics::GetResourceCacheSingleAllocationByteLimit() };
65 if size != 0 {
66 Some(size)
67 } else {
68 None
69 }
70}
71
72pub fn set_resource_cache_single_allocation_byte_limit(new_limit: Option<usize>) -> Option<usize> {
73 let size: usize = unsafe {
74 SkGraphics::SetResourceCacheSingleAllocationByteLimit(newLimit:new_limit.unwrap_or_default())
75 };
76 if size != 0 {
77 Some(size)
78 } else {
79 None
80 }
81}
82
83// TODO: dump_memory_statistics() (needs SkTraceMemoryDumpWrapper interop wrapper).
84
85pub fn purge_all_caches() {
86 unsafe { SkGraphics::PurgeAllCaches() }
87}
88
89// TODO: ImageGeneratorFromEncodedDataFactory
90// TODO: SetOpenTypeSVGDecoderFactory & GetOpenTypeSVGDecoderFactory
91