Keep text atlases alive during temporary empty uploads
This commit is contained in:
parent
b276a603a1
commit
7e2d0dc931
1 changed files with 44 additions and 32 deletions
|
|
@ -61,6 +61,10 @@ impl Cache {
|
|||
}
|
||||
|
||||
pub fn update(&mut self, text: Vec<Text>) {
|
||||
if self.text.is_empty() && text.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
self.text = Rc::from(text);
|
||||
self.version += 1;
|
||||
}
|
||||
|
|
@ -139,11 +143,11 @@ impl Storage {
|
|||
hash_map::Entry::Occupied(entry) => {
|
||||
let upload = entry.into_mut();
|
||||
|
||||
if !cache.text.is_empty()
|
||||
&& (upload.version != cache.version
|
||||
if upload.version != cache.version
|
||||
|| upload.group_version != group.version
|
||||
|| upload.transformation != new_transformation)
|
||||
|| upload.transformation != new_transformation
|
||||
{
|
||||
if !cache.text.is_empty() {
|
||||
let _ = prepare(
|
||||
device,
|
||||
queue,
|
||||
|
|
@ -156,6 +160,7 @@ impl Storage {
|
|||
new_transformation,
|
||||
target_size,
|
||||
);
|
||||
}
|
||||
|
||||
// Only trim if glyphs have changed
|
||||
group.should_trim =
|
||||
|
|
@ -179,6 +184,7 @@ impl Storage {
|
|||
|
||||
let mut buffer_cache = BufferCache::new();
|
||||
|
||||
if !cache.text.is_empty() {
|
||||
let _ = prepare(
|
||||
device,
|
||||
queue,
|
||||
|
|
@ -191,6 +197,7 @@ impl Storage {
|
|||
new_transformation,
|
||||
target_size,
|
||||
);
|
||||
}
|
||||
|
||||
let _ = entry.insert(Upload {
|
||||
renderer,
|
||||
|
|
@ -202,6 +209,8 @@ impl Storage {
|
|||
_atlas: Rc::downgrade(&group.handle),
|
||||
});
|
||||
|
||||
group.should_trim = cache.group.is_singleton();
|
||||
|
||||
log::debug!(
|
||||
"New text upload: {} (total: {})",
|
||||
cache.id.0,
|
||||
|
|
@ -224,10 +233,8 @@ impl Storage {
|
|||
return false;
|
||||
}
|
||||
|
||||
if id.is_singleton() || group.should_trim {
|
||||
log::debug!(
|
||||
"Trimming text atlas: {id:?} (uploads: {active_uploads})"
|
||||
);
|
||||
if group.should_trim {
|
||||
log::trace!("Trimming text atlas: {id:?}");
|
||||
|
||||
group.atlas.trim();
|
||||
group.should_trim = false;
|
||||
|
|
@ -236,6 +243,11 @@ impl Storage {
|
|||
// when the atlas may be shared by multiple
|
||||
// uploads.
|
||||
if !id.is_singleton() {
|
||||
log::debug!(
|
||||
"Invalidating text atlas: {id:?} \
|
||||
(uploads: {active_uploads})"
|
||||
);
|
||||
|
||||
group.version += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue