1 | use skia_bindings::SkGraphics; |
2 | |
3 | pub fn init() { |
4 | unsafe { SkGraphics::Init() }; |
5 | } |
6 | |
7 | pub fn font_cache_limit() -> usize { |
8 | unsafe { SkGraphics::GetFontCacheLimit() } |
9 | } |
10 | |
11 | pub fn set_font_cache_limit(bytes: usize) -> usize { |
12 | unsafe { SkGraphics::SetFontCacheLimit(bytes) } |
13 | } |
14 | |
15 | pub fn font_cache_used() -> usize { |
16 | unsafe { SkGraphics::GetFontCacheUsed() } |
17 | } |
18 | |
19 | pub fn font_cache_count_used() -> i32 { |
20 | unsafe { SkGraphics::GetFontCacheCountUsed() } |
21 | } |
22 | |
23 | pub fn font_cache_count_limit() -> i32 { |
24 | unsafe { SkGraphics::GetFontCacheCountLimit() } |
25 | } |
26 | |
27 | pub fn set_font_cache_count_limit(count: i32) -> i32 { |
28 | unsafe { SkGraphics::SetFontCacheCountLimit(count) } |
29 | } |
30 | |
31 | pub fn typeface_cache_count_limit() -> i32 { |
32 | unsafe { SkGraphics::GetTypefaceCacheCountLimit() } |
33 | } |
34 | |
35 | pub fn set_typeface_cache_count_limit(count: i32) -> i32 { |
36 | unsafe { SkGraphics::SetTypefaceCacheCountLimit(count) } |
37 | } |
38 | |
39 | pub fn purge_font_cache() { |
40 | unsafe { SkGraphics::PurgeFontCache() } |
41 | } |
42 | |
43 | pub fn purge_pinned_font_cache() { |
44 | unsafe { SkGraphics::PurgePinnedFontCache() } |
45 | } |
46 | |
47 | pub fn resource_cache_total_bytes_used() -> usize { |
48 | unsafe { SkGraphics::GetResourceCacheTotalBytesUsed() } |
49 | } |
50 | |
51 | pub fn resource_cache_total_bytes_limit() -> usize { |
52 | unsafe { SkGraphics::GetResourceCacheTotalByteLimit() } |
53 | } |
54 | |
55 | pub fn set_resource_cache_total_bytes_limit(new_limit: usize) -> usize { |
56 | unsafe { SkGraphics::SetResourceCacheTotalByteLimit(newLimit:new_limit) } |
57 | } |
58 | |
59 | pub fn purge_resource_cache() { |
60 | unsafe { SkGraphics::PurgeResourceCache() } |
61 | } |
62 | |
63 | pub 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 | |
72 | pub 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 | |
85 | pub fn purge_all_caches() { |
86 | unsafe { SkGraphics::PurgeAllCaches() } |
87 | } |
88 | |
89 | // TODO: ImageGeneratorFromEncodedDataFactory |
90 | // TODO: SetOpenTypeSVGDecoderFactory & GetOpenTypeSVGDecoderFactory |
91 | |