render: don't require framebuffer to perform shm screencopies
This commit is contained in:
parent
69d63b7e83
commit
9de63bddf3
12 changed files with 65 additions and 76 deletions
|
|
@ -6,7 +6,7 @@ use {
|
|||
ResetStatus,
|
||||
},
|
||||
gfx_apis::gl::{
|
||||
egl::{context::EglContext, display::EglDisplay},
|
||||
egl::{context::EglContext, display::EglDisplay, image::EglImage},
|
||||
ext::GL_OES_EGL_IMAGE_EXTERNAL,
|
||||
gl::{
|
||||
program::GlProgram, render_buffer::GlRenderBuffer, sys::GLint, texture::GlTexture,
|
||||
|
|
@ -190,6 +190,20 @@ impl GlRenderContext {
|
|||
format,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn image_to_fb(
|
||||
self: &Rc<Self>,
|
||||
img: &Rc<EglImage>,
|
||||
) -> Result<Rc<Framebuffer>, RenderError> {
|
||||
self.ctx.with_current(|| unsafe {
|
||||
let rb = GlRenderBuffer::from_image(img, &self.ctx)?;
|
||||
let fb = rb.create_framebuffer()?;
|
||||
Ok(Rc::new(Framebuffer {
|
||||
ctx: self.clone(),
|
||||
gl: fb,
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl GfxContext for GlRenderContext {
|
||||
|
|
|
|||
|
|
@ -106,15 +106,16 @@ impl GfxFramebuffer for Framebuffer {
|
|||
}
|
||||
|
||||
fn copy_to_shm(
|
||||
&self,
|
||||
self: Rc<Self>,
|
||||
x: i32,
|
||||
y: i32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
format: &Format,
|
||||
_stride: i32,
|
||||
format: &'static Format,
|
||||
shm: &[Cell<u8>],
|
||||
) -> Result<(), GfxError> {
|
||||
self.copy_to_shm(x, y, width, height, format, shm);
|
||||
(*self).copy_to_shm(x, y, width, height, format, shm);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ use {
|
|||
crate::{
|
||||
gfx_api::{GfxError, GfxFramebuffer, GfxImage, GfxTexture},
|
||||
gfx_apis::gl::{
|
||||
egl::image::EglImage,
|
||||
gl::{render_buffer::GlRenderBuffer, texture::GlTexture},
|
||||
Framebuffer, GlRenderContext, RenderError, Texture,
|
||||
egl::image::EglImage, gl::texture::GlTexture, Framebuffer, GlRenderContext,
|
||||
RenderError, Texture,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -34,14 +33,7 @@ impl Image {
|
|||
}
|
||||
|
||||
fn to_framebuffer(&self) -> Result<Rc<Framebuffer>, RenderError> {
|
||||
self.ctx.ctx.with_current(|| unsafe {
|
||||
let rb = GlRenderBuffer::from_image(&self.gl, &self.ctx.ctx)?;
|
||||
let fb = rb.create_framebuffer()?;
|
||||
Ok(Rc::new(Framebuffer {
|
||||
ctx: self.ctx.clone(),
|
||||
gl: fb,
|
||||
}))
|
||||
})
|
||||
self.ctx.image_to_fb(&self.gl)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ use {
|
|||
crate::{
|
||||
format::Format,
|
||||
gfx_api::{GfxError, GfxTexture, TextureReservations},
|
||||
gfx_apis::gl::{gl::texture::GlTexture, renderer::context::GlRenderContext, RenderError},
|
||||
gfx_apis::gl::{
|
||||
gl::texture::GlTexture,
|
||||
renderer::{context::GlRenderContext, framebuffer::Framebuffer},
|
||||
RenderError,
|
||||
},
|
||||
video::dmabuf::DmaBuf,
|
||||
},
|
||||
std::{
|
||||
|
|
@ -34,6 +38,13 @@ impl Texture {
|
|||
pub fn height(&self) -> i32 {
|
||||
self.gl.height
|
||||
}
|
||||
|
||||
pub fn to_framebuffer(&self) -> Result<Rc<Framebuffer>, RenderError> {
|
||||
match &self.gl.img {
|
||||
Some(img) => self.ctx.image_to_fb(img),
|
||||
_ => Err(RenderError::ShmTextureToFb),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GfxTexture for Texture {
|
||||
|
|
@ -51,15 +62,17 @@ impl GfxTexture for Texture {
|
|||
|
||||
fn read_pixels(
|
||||
self: Rc<Self>,
|
||||
_x: i32,
|
||||
_y: i32,
|
||||
_width: i32,
|
||||
_height: i32,
|
||||
x: i32,
|
||||
y: i32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
_stride: i32,
|
||||
_format: &Format,
|
||||
_shm: &[Cell<u8>],
|
||||
format: &Format,
|
||||
shm: &[Cell<u8>],
|
||||
) -> Result<(), GfxError> {
|
||||
Err(RenderError::UnsupportedOperation.into())
|
||||
self.to_framebuffer()?
|
||||
.copy_to_shm(x, y, width, height, format, shm);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn dmabuf(&self) -> Option<&DmaBuf> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue