metal: preserve render buffer contents in more situations
This commit is contained in:
parent
dce572865b
commit
410e4676ce
2 changed files with 53 additions and 29 deletions
|
|
@ -41,7 +41,7 @@ use {
|
|||
asyncevent::AsyncEvent, binary_search_map::BinarySearchMap, bitflags::BitflagsExt,
|
||||
cell_ext::CellExt, clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
|
||||
geometric_decay::GeometricDecay, numcell::NumCell, on_change::OnChange,
|
||||
opaque_cell::OpaqueCell, ordered_float::F64, oserror::OsError,
|
||||
opaque_cell::OpaqueCell, ordered_float::F64, oserror::OsError, rc_eq::rc_eq,
|
||||
},
|
||||
video::{
|
||||
INVALID_MODIFIER, Modifier,
|
||||
|
|
@ -66,6 +66,7 @@ use {
|
|||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::hash_map::Entry,
|
||||
error::Error,
|
||||
ffi::CString,
|
||||
fmt::{Debug, Formatter},
|
||||
mem,
|
||||
|
|
@ -3021,4 +3022,43 @@ impl RenderBuffer {
|
|||
self.damage_queue.clear_all();
|
||||
self.damage_queue.damage(&[rect]);
|
||||
}
|
||||
|
||||
pub fn clear(&self, cd: &Rc<ColorDescription>) -> Result<Option<SyncFile>, Box<dyn Error>> {
|
||||
self.dev_fb
|
||||
.clear(AcquireSync::Unnecessary, ReleaseSync::Explicit, cd)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn copy_to_new(
|
||||
&self,
|
||||
new: &Self,
|
||||
cd: &Rc<ColorDescription>,
|
||||
) -> Result<Option<SyncFile>, Box<dyn Error>> {
|
||||
let old = self;
|
||||
let copy_texture = |new: &Rc<dyn GfxFramebuffer>, old: &Rc<dyn GfxTexture>| {
|
||||
new.copy_texture(
|
||||
AcquireSync::Unnecessary,
|
||||
ReleaseSync::Explicit,
|
||||
cd,
|
||||
old,
|
||||
cd,
|
||||
None,
|
||||
AcquireSync::Unnecessary,
|
||||
ReleaseSync::Explicit,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
.map_err(Into::into)
|
||||
};
|
||||
if rc_eq(&old.dev_ctx, &new.dev_ctx) {
|
||||
return copy_texture(&new.dev_fb, old.dev_tex.as_ref().unwrap_or(&old.render_tex));
|
||||
}
|
||||
let tex = new
|
||||
.dev_ctx
|
||||
.gfx
|
||||
.clone()
|
||||
.dmabuf_img(old.dev_bo.dmabuf())?
|
||||
.to_texture()?;
|
||||
copy_texture(&new.dev_fb, &tex)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue