1
0
Fork 0
forked from wry/wry

gfx: add ShmGfxTexture

This commit is contained in:
Julian Orth 2024-09-07 20:22:30 +02:00
parent ed4ef3c8e7
commit c968024905
10 changed files with 51 additions and 22 deletions

View file

@ -4,7 +4,8 @@ use {
format::{Format, ARGB8888, XRGB8888},
gfx_api::{
CopyTexture, FillRect, FramebufferRect, GfxApiOpt, GfxContext, GfxError, GfxFormat,
GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier, ResetStatus, SyncFile,
GfxFramebuffer, GfxImage, GfxTexture, GfxWriteModifier, ResetStatus, ShmGfxTexture,
SyncFile,
},
rect::Rect,
theme::Color,
@ -108,14 +109,14 @@ impl GfxContext for TestGfxCtx {
fn shmem_texture(
self: Rc<Self>,
_old: Option<Rc<dyn GfxTexture>>,
_old: Option<Rc<dyn ShmGfxTexture>>,
data: &[Cell<u8>],
format: &'static Format,
width: i32,
height: i32,
stride: i32,
_damage: Option<&[Rect]>,
) -> Result<Rc<dyn GfxTexture>, GfxError> {
) -> Result<Rc<dyn ShmGfxTexture>, GfxError> {
assert!(stride >= width * 4);
let size = (stride * height) as usize;
assert!(data.len() >= size);
@ -301,6 +302,12 @@ impl GfxTexture for TestGfxImage {
}
}
impl ShmGfxTexture for TestGfxImage {
fn into_texture(self: Rc<Self>) -> Rc<dyn GfxTexture> {
self
}
}
impl GfxImage for TestGfxImage {
fn to_framebuffer(self: Rc<Self>) -> Result<Rc<dyn GfxFramebuffer>, GfxError> {
Ok(Rc::new(TestGfxFb {