epaint_assert that partial texture update is within texture size
This commit is contained in:
parent
42edb92232
commit
ac9faaf1c1
1 changed files with 12 additions and 13 deletions
|
@ -47,17 +47,21 @@ impl TextureManager {
|
||||||
/// or update a region of it.
|
/// or update a region of it.
|
||||||
pub fn set(&mut self, id: TextureId, delta: ImageDelta) {
|
pub fn set(&mut self, id: TextureId, delta: ImageDelta) {
|
||||||
if let Some(meta) = self.metas.get_mut(&id) {
|
if let Some(meta) = self.metas.get_mut(&id) {
|
||||||
if delta.is_whole() {
|
if let Some(pos) = delta.pos {
|
||||||
|
crate::epaint_assert!(
|
||||||
|
pos[0] + delta.image.width() <= meta.size[0]
|
||||||
|
&& pos[1] + delta.image.height() <= meta.size[1],
|
||||||
|
"Partial texture update is outside the bounds of texture {id:?}",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// whole update
|
||||||
meta.size = delta.image.size();
|
meta.size = delta.image.size();
|
||||||
meta.bytes_per_pixel = delta.image.bytes_per_pixel();
|
meta.bytes_per_pixel = delta.image.bytes_per_pixel();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.delta.set.insert(id, delta);
|
self.delta.set.insert(id, delta);
|
||||||
} else {
|
} else {
|
||||||
crate::epaint_assert!(
|
crate::epaint_assert!(false, "Tried setting texture {id:?} which is not allocated");
|
||||||
false,
|
|
||||||
"Tried setting texture {:?} which is not allocated",
|
|
||||||
id
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,11 +75,7 @@ impl TextureManager {
|
||||||
self.delta.free.push(id);
|
self.delta.free.push(id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
crate::epaint_assert!(
|
crate::epaint_assert!(false, "Tried freeing texture {id:?} which is not allocated");
|
||||||
false,
|
|
||||||
"Tried freeing texture {:?} which is not allocated",
|
|
||||||
id
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +88,7 @@ impl TextureManager {
|
||||||
} else {
|
} else {
|
||||||
crate::epaint_assert!(
|
crate::epaint_assert!(
|
||||||
false,
|
false,
|
||||||
"Tried retaining texture {:?} which is not allocated",
|
"Tried retaining texture {id:?} which is not allocated",
|
||||||
id
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue