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

Discard the dirty rect of evicted texture cache entries #2774

Merged
merged 2 commits into from May 24, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Invalidate the dirty rect when a texture is evicted

  • Loading branch information
kvark committed May 24, 2018
commit cc26f52aadce1818a41bfdbdbc9c87f0498bcbb0
@@ -174,7 +174,7 @@ where
K: Clone + Hash + Eq + Debug,
U: Default,
{
pub fn new() -> ResourceClassCache<K, V, U> {
pub fn new() -> Self {
ResourceClassCache {
resources: FastHashMap::default(),
user_data: Default::default(),
@@ -510,16 +510,14 @@ impl ResourceCache {
tiling,
);
}
let dirty_rect = Some(descriptor.full_rect());

let resource = ImageResource {
descriptor,
data,
epoch: Epoch(0),
tiling,
dirty_rect: Some(DeviceUintRect::new(
DeviceUintPoint::zero(),
descriptor.size,
)),
dirty_rect,
};

self.resources.image_templates.insert(image_key, resource);
@@ -636,9 +634,14 @@ impl ResourceCache {
let needs_upload = self.texture_cache
.request(&entry.as_ref().unwrap().texture_cache_handle, gpu_cache);

if !needs_upload && !needs_update {
return;
}
let dirty_rect = if needs_upload {
// the texture cache entry has been evicted, treat it as all dirty
Some(template.descriptor.full_rect())
} else if needs_update {
template.dirty_rect
} else {
return
};

// We can start a worker thread rasterizing right now, if:
// - The image is a blob.
@@ -658,7 +661,7 @@ impl ResourceCache {
tile_offset.y as f32 * tile_size as f32,
);

if let Some(dirty) = template.dirty_rect {
if let Some(dirty) = dirty_rect {
if intersect_for_tile(dirty, actual_size, tile_size, tile_offset).is_none() {
// don't bother requesting unchanged tiles
return
@@ -678,7 +681,7 @@ impl ResourceCache {
offset,
format: template.descriptor.format,
},
template.dirty_rect,
dirty_rect,
);
}
}
@@ -6,7 +6,8 @@ extern crate serde_bytes;

use font::{FontInstanceKey, FontKey, FontTemplate};
use std::sync::Arc;
use {DevicePoint, DeviceUintRect, DeviceUintSize, IdNamespace, TileOffset, TileSize};
use {DevicePoint, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
use {IdNamespace, TileOffset, TileSize};
use euclid::size2;

#[repr(C)]
@@ -106,6 +107,13 @@ impl ImageDescriptor {
pub fn compute_total_size(&self) -> u32 {
self.compute_stride() * self.size.height
}

pub fn full_rect(&self) -> DeviceUintRect {
DeviceUintRect::new(
DeviceUintPoint::zero(),
self.size,
)
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.