1
0
Fork 0
forked from wry/wry

Merge pull request #79 from mahkoh/jorth/spb

fix: store single-pixel colors outside of buffer storage
This commit is contained in:
mahkoh 2024-02-06 15:04:53 +01:00 committed by GitHub
commit 672ee88d76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 12 deletions

View file

@ -27,7 +27,6 @@ use {
pub enum WlBufferStorage {
Shm { mem: ClientMemOffset, stride: i32 },
Dmabuf(Rc<dyn GfxImage>),
Color(Color),
}
pub struct WlBuffer {
@ -39,6 +38,7 @@ pub struct WlBuffer {
dmabuf: Option<DmaBuf>,
render_ctx_version: Cell<u32>,
pub storage: RefCell<Option<WlBufferStorage>>,
pub color: Option<Color>,
pub texture: CloneCell<Option<Rc<dyn GfxTexture>>>,
pub famebuffer: CloneCell<Option<Rc<dyn GfxFramebuffer>>>,
width: i32,
@ -75,6 +75,7 @@ impl WlBuffer {
render_ctx_version: Cell::new(client.state.render_ctx_version.get()),
storage: RefCell::new(Some(WlBufferStorage::Dmabuf(img.clone()))),
tracker: Default::default(),
color: None,
}
}
@ -113,6 +114,7 @@ impl WlBuffer {
texture: CloneCell::new(None),
tracker: Default::default(),
famebuffer: Default::default(),
color: None,
})
}
@ -132,14 +134,13 @@ impl WlBuffer {
format: ARGB8888,
dmabuf: None,
render_ctx_version: Cell::new(client.state.render_ctx_version.get()),
storage: RefCell::new(Some(WlBufferStorage::Color(
Color::from_u32_rgba_premultiplied(r, g, b, a),
))),
storage: RefCell::new(None),
width: 1,
height: 1,
texture: CloneCell::new(None),
tracker: Default::default(),
famebuffer: Default::default(),
color: Some(Color::from_u32_rgba_premultiplied(r, g, b, a)),
}
}
@ -197,9 +198,6 @@ impl WlBuffer {
self.texture.set(Some(img.clone().to_texture()?));
}
}
WlBufferStorage::Color(_) => {
// nothing
}
}
Ok(())
}
@ -219,9 +217,6 @@ impl WlBuffer {
self.famebuffer.set(Some(img.clone().to_framebuffer()?));
}
}
WlBufferStorage::Color(_) => {
// nothing
}
}
Ok(())
}

View file

@ -3,7 +3,7 @@ use {
format::ARGB8888,
gfx_api::{BufferPoints, GfxApiOpt},
ifs::{
wl_buffer::{WlBuffer, WlBufferStorage},
wl_buffer::WlBuffer,
wl_callback::WlCallback,
wl_surface::{
xdg_surface::XdgSurface, zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, WlSurface,
@ -93,6 +93,7 @@ impl Renderer<'_> {
x + pos.x1() - opos.x1(),
y + pos.y1() - opos.y1(),
);
self.base.ops.push(GfxApiOpt::Sync);
}
};
}
@ -400,7 +401,7 @@ impl Renderer<'_> {
max_width,
max_height,
);
} else if let Some(WlBufferStorage::Color(color)) = &*buffer.storage.borrow() {
} else if let Some(color) = &buffer.color {
if let Some(rect) =
Rect::new_sized(x, y, tsize.0.min(max_width), tsize.1.min(max_height))
{