Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picture caching support, part 1 (of 2). #3332

Merged
merged 10 commits into from Nov 23, 2018

Add is_image_dirty to check if an image was updated.

  • Loading branch information
gw3583 committed Nov 22, 2018
commit e52ba83660bca9c61b47f4c7e16ecdef37adc8a1
@@ -66,6 +66,8 @@ pub struct GlyphFetchResult {
// we don't need to go through and update
// various CPU-side structures.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct CacheItem {
pub texture_id: TextureSource,
pub uv_rect_handle: GpuCacheHandle,
@@ -408,7 +410,7 @@ pub struct ResourceCache {
state: State,
current_frame_id: FrameId,

texture_cache: TextureCache,
pub texture_cache: TextureCache,

// TODO(gw): We should expire (parts of) this cache semi-regularly!
cached_glyph_dimensions: GlyphDimensionsCache,
@@ -881,6 +883,32 @@ impl ResourceCache {
}
}

/// Check if an image has changed since it was last requested.
pub fn is_image_dirty(
&self,
image_key: ImageKey,
) -> bool {
match self.cached_images.try_get(&image_key) {
Some(ImageResult::UntiledAuto(ref info)) => {
info.dirty_rect.is_some()
}
Some(ImageResult::Multi(ref entries)) => {
for (_, entry) in &entries.resources {
if entry.dirty_rect.is_some() {
return true;
}
}
false
}
Some(ImageResult::Err(..)) => {
false
}
None => {
true
}
}
}

pub fn request_image(
&mut self,
request: ImageRequest,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.