1mod governor;
4mod lru;
5mod options;
6mod policy;
7mod registry;
8mod stats;
9
10#[cfg(feature = "persistent-cache")]
11mod persistent;
12
13pub use governor::{MemoryGovernor, MemoryReservation, MemoryTaskReservation};
14#[doc(hidden)]
15pub use lru::LruCache;
16pub use options::{MemoryBudget, MemoryDomainBudgets, MemoryEventPolicy, MemoryOptions};
17pub use policy::{
18 CacheDomain, CacheKey, CachePriority, CacheScope, ImageCachePolicy, MemoryAction, MemoryEvent,
19 ResourceClass, RetentionClass, TrimReason,
20};
21pub use registry::{
22 CacheAdapter, CacheRegistration, DomainInstanceId, DomainRegistration, TrimRequest, TrimResult,
23};
24#[doc(hidden)]
25pub use stats::CacheTelemetry;
26pub use stats::{CacheUsage, DomainSnapshot, MemorySnapshot, TrimSnapshot};
27
28#[cfg(feature = "persistent-cache")]
29pub use persistent::{
30 CacheStoreError, FileCacheStore, PersistentCacheKey, PersistentCacheStats,
31 PersistentCacheStore, PersistentEntry,
32};
33
34#[path = "memory_test.rs"]
35#[cfg(test)]
36mod tests;
37
38#[cfg(any(test, feature = "test-support"))]
39#[doc(hidden)]
40pub const fn test_memory_options() -> MemoryOptions {
41 const MIB: usize = 1024 * 1024;
42 MemoryOptions::new(
43 "lgui-tests",
44 MemoryBudget::new(
45 64 * MIB,
46 96 * MIB,
47 64 * MIB,
48 64 * MIB as u64,
49 8 * MIB,
50 16 * MIB,
51 4,
52 ),
53 MemoryDomainBudgets {
54 encoded_image_bytes: 16 * MIB,
55 decoded_image_bytes: 16 * MIB,
56 svg_bytes: 4 * MIB,
57 blur_bytes: 4 * MIB,
58 text_bytes: 8 * MIB,
59 static_layer_bytes: 8 * MIB,
60 scroll_raster_bytes: 4 * MIB,
61 gdi_bytes: 16 * MIB,
62 d2d_bytes: 16 * MIB,
63 skia_bytes: 16 * MIB,
64 component_output_bytes: 4 * MIB,
65 host_scene_bytes: 4 * MIB,
66 diagnostics_bytes: 2 * MIB,
67 },
68 MemoryEventPolicy::ignore_all(),
69 ImageCachePolicy::Session,
70 true,
71 )
72}
73
74#[cfg(all(feature = "persistent-cache", any(test, feature = "test-support")))]
75#[doc(hidden)]
76pub fn test_memory_governor_with_store(
77 options: MemoryOptions,
78 store: std::sync::Arc<dyn PersistentCacheStore>,
79) -> MemoryGovernor {
80 MemoryGovernor::with_store(options, Some(store))
81}