diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-05-28 12:44:44 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-05-28 12:46:43 +0200 |
| commit | 0bfee5b7772338fd39bbf708d3e31ea7bcec859b (patch) | |
| tree | 5f76c7d0529d6c089e8e3383356692dfce09cffb /src/cache.rs | |
| parent | eabf28f08187bd9a10bbadbbaf9617e2bc1949aa (diff) | |
Refactored loading and cache architecture
Diffstat (limited to 'src/cache.rs')
| -rw-r--r-- | src/cache.rs | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/cache.rs b/src/cache.rs index 4cf97ba6..aa9c10a0 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,34 +1,27 @@ -//! Caching for incremental compilation. +//! Caching of compilation artifacts. -use std::collections::HashMap; +use crate::font::FontCache; +use crate::image::ImageCache; +use crate::layout::LayoutCache; +use crate::loading::Loader; -use crate::layout::{Frame, Regions}; - -/// A cache for incremental compilation. -#[derive(Default, Debug, Clone)] +/// Caches compilation artifacts. pub struct Cache { - /// A map that holds the layouted nodes from past compilations. - pub frames: HashMap<u64, FramesEntry>, + /// Caches parsed font faces. + pub font: FontCache, + /// Caches decoded images. + pub image: ImageCache, + /// Caches layouting artifacts. + pub layout: LayoutCache, } impl Cache { /// Create a new, empty cache. - pub fn new() -> Self { - Self::default() - } - - /// Clear the cache. - pub fn clear(&mut self) { - self.frames.clear(); + pub fn new(loader: &dyn Loader) -> Self { + Self { + font: FontCache::new(loader), + image: ImageCache::new(), + layout: LayoutCache::new(), + } } } - -/// Frames from past compilations and checks for their validity in future -/// compilations. -#[derive(Debug, Clone)] -pub struct FramesEntry { - /// The regions in which these frames are valid. - pub regions: Regions, - /// Cached frames for a node. - pub frames: Vec<Frame>, -} |
