1
0
Fork 0
forked from wry/wry

render: store underlying DmaBufs in textures

This commit is contained in:
Julian Orth 2024-02-18 15:23:10 +01:00
parent 1ac4f3dc52
commit 3635ae0104
10 changed files with 38 additions and 35 deletions

View file

@ -259,10 +259,8 @@ impl EglDisplay {
Ok(Rc::new(EglImage {
dpy: self.clone(),
img,
width: buf.width,
height: buf.height,
external_only: format.external_only,
format: buf.format,
dmabuf: buf.clone(),
}))
}
}

View file

@ -1,11 +1,11 @@
use {
crate::{
format::Format,
gfx_apis::gl::egl::{
display::EglDisplay,
sys::{EGLImageKHR, EGL_FALSE},
PROCS,
},
video::dmabuf::DmaBuf,
},
std::rc::Rc,
};
@ -13,10 +13,8 @@ use {
pub struct EglImage {
pub dpy: Rc<EglDisplay>,
pub img: EGLImageKHR,
pub width: i32,
pub height: i32,
pub external_only: bool,
pub format: &'static Format,
pub dmabuf: DmaBuf,
}
impl Drop for EglImage {

View file

@ -60,8 +60,8 @@ impl GlRenderBuffer {
_tex: None,
ctx: self.ctx.clone(),
fbo,
width: self.img.width,
height: self.img.height,
width: self.img.dmabuf.width,
height: self.img.dmabuf.height,
};
if status != GL_FRAMEBUFFER_COMPLETE {
return Err(RenderError::CreateFramebuffer);

View file

@ -56,10 +56,10 @@ impl GlTexture {
ctx: ctx.clone(),
img: Some(img.clone()),
tex,
width: img.width,
height: img.height,
width: img.dmabuf.width,
height: img.dmabuf.height,
external_only: img.external_only,
format: img.format,
format: img.dmabuf.format,
})
}

View file

@ -120,6 +120,6 @@ impl GfxFramebuffer for Framebuffer {
}
fn format(&self) -> &'static Format {
self.gl.rb.img.format
self.gl.rb.img.dmabuf.format
}
}

View file

@ -17,11 +17,11 @@ pub struct Image {
impl Image {
pub fn width(&self) -> i32 {
self.gl.width
self.gl.dmabuf.width
}
pub fn height(&self) -> i32 {
self.gl.height
self.gl.dmabuf.height
}
fn to_texture(self: &Rc<Self>) -> Result<Rc<Texture>, RenderError> {

View file

@ -3,6 +3,7 @@ use {
format::Format,
gfx_api::{GfxError, GfxTexture},
gfx_apis::gl::{gl::texture::GlTexture, renderer::context::GlRenderContext, RenderError},
video::dmabuf::DmaBuf,
},
std::{
any::Any,
@ -58,4 +59,8 @@ impl GfxTexture for Texture {
) -> Result<(), GfxError> {
Err(RenderError::UnsupportedOperation.into())
}
fn dmabuf(&self) -> Option<&DmaBuf> {
self.gl.img.as_ref().map(|i| &i.dmabuf)
}
}