renderer: add destroy_texture function
This commit is contained in:
parent
30a8693789
commit
ab6dd61592
|
@ -252,6 +252,10 @@ where
|
|||
self.renderer.import_egl(buffer).map_err(Error::RenderError)
|
||||
}
|
||||
|
||||
fn destroy_texture(&mut self, texture: Self::Texture) -> Result<(), Self::Error> {
|
||||
self.renderer.destroy_texture(texture).map_err(Error::RenderError)
|
||||
}
|
||||
|
||||
fn begin(&mut self, width: u32, height: u32, transform: Transform) -> Result<(), Error<E1, E2, E3>> {
|
||||
if self.current_buffer.is_some() {
|
||||
return Ok(());
|
||||
|
|
|
@ -559,6 +559,17 @@ impl Renderer for Gles2Renderer {
|
|||
Ok(texture)
|
||||
}
|
||||
|
||||
fn destroy_texture(&mut self, mut texture: Self::Texture) -> Result<(), Self::Error> {
|
||||
self.make_current()?;
|
||||
|
||||
unsafe {
|
||||
self.gl.DeleteTextures(1, &mut texture.texture);
|
||||
}
|
||||
self.egl.unbind()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
fn begin(&mut self, width: u32, height: u32, transform: Transform) -> Result<(), Gles2Error> {
|
||||
self.make_current()?;
|
||||
|
|
|
@ -147,6 +147,7 @@ pub trait Renderer {
|
|||
fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result<Self::Texture, Self::Error>;
|
||||
#[cfg(feature = "wayland_frontend")]
|
||||
fn import_egl(&mut self, buffer: &EGLBuffer) -> Result<Self::Texture, Self::Error>;
|
||||
fn destroy_texture(&mut self, texture: Self::Texture) -> Result<(), Self::Error>;
|
||||
|
||||
fn begin(&mut self, width: u32, height: u32, transform: Transform) -> Result<(), <Self as Renderer>::Error>;
|
||||
fn finish(&mut self) -> Result<(), SwapBuffersError>;
|
||||
|
|
|
@ -280,6 +280,10 @@ impl Renderer for WinitGraphicsBackend {
|
|||
self.renderer.import_egl(buffer)
|
||||
}
|
||||
|
||||
fn destroy_texture(&mut self, texture: Self::Texture) -> Result<(), Self::Error> {
|
||||
self.renderer.destroy_texture(texture)
|
||||
}
|
||||
|
||||
fn begin(&mut self, width: u32, height: u32, transform: Transform) -> Result<(), <Self as Renderer>::Error> {
|
||||
self.renderer.bind(self.egl.clone())?;
|
||||
self.renderer.begin(width, height, transform)
|
||||
|
|
Loading…
Reference in New Issue