diff --git a/src/backend/drm/render.rs b/src/backend/drm/render.rs index 710ece4..0c8d4ec 100644 --- a/src/backend/drm/render.rs +++ b/src/backend/drm/render.rs @@ -223,17 +223,17 @@ where D: AsRawFd + 'static, A: Allocator, B: Buffer + TryInto, - R: Bind + Renderer, + R: Bind + Renderer, T: Texture, E1: std::error::Error + 'static, E2: std::error::Error + 'static, E3: std::error::Error + 'static, { type Error = Error; - type Texture = T; + type TextureId = T; #[cfg(feature = "image")] - fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result { + fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result { self.renderer.import_bitmap(image).map_err(Error::RenderError) } @@ -243,16 +243,16 @@ where } #[cfg(feature = "wayland_frontend")] - fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result { + fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result { self.renderer.import_shm(buffer).map_err(Error::RenderError) } #[cfg(feature = "wayland_frontend")] - fn import_egl(&mut self, buffer: &EGLBuffer) -> Result { + fn import_egl(&mut self, buffer: &EGLBuffer) -> Result { self.renderer.import_egl(buffer).map_err(Error::RenderError) } - fn destroy_texture(&mut self, texture: Self::Texture) -> Result<(), Self::Error> { + fn destroy_texture(&mut self, texture: Self::TextureId) -> Result<(), Self::Error> { self.renderer.destroy_texture(texture).map_err(Error::RenderError) } @@ -271,7 +271,7 @@ where self.renderer.clear(color).map_err(Error::RenderError) } - fn render_texture(&mut self, texture: &Self::Texture, matrix: Matrix3, alpha: f32) -> Result<(), Self::Error> { + fn render_texture(&mut self, texture: &Self::TextureId, matrix: Matrix3, alpha: f32) -> Result<(), Self::Error> { self.renderer.render_texture(texture, matrix, alpha).map_err(Error::RenderError) } diff --git a/src/backend/renderer/gles2/mod.rs b/src/backend/renderer/gles2/mod.rs index fa06a5b..3a8bb64 100644 --- a/src/backend/renderer/gles2/mod.rs +++ b/src/backend/renderer/gles2/mod.rs @@ -426,7 +426,7 @@ static TEX_COORDS: [ffi::types::GLfloat; 8] = [ impl Renderer for Gles2Renderer { type Error = Gles2Error; - type Texture = Gles2Texture; + type TextureId = Gles2Texture; #[cfg(feature = "wayland_frontend")] fn shm_formats(&self) -> &[wl_shm::Format] { @@ -439,7 +439,7 @@ impl Renderer for Gles2Renderer { } #[cfg(feature = "image")] - fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result { + fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result { self.make_current()?; let mut tex = 0; @@ -467,7 +467,7 @@ impl Renderer for Gles2Renderer { #[cfg(feature = "wayland_frontend")] - fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result { + fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result { use crate::wayland::shm::with_buffer_contents; with_buffer_contents(&buffer, |slice, data| { @@ -522,7 +522,7 @@ impl Renderer for Gles2Renderer { } #[cfg(feature = "wayland_frontend")] - fn import_egl(&mut self, buffer: &EGLBuffer) -> Result { + fn import_egl(&mut self, buffer: &EGLBuffer) -> Result { if !self.extensions.iter().any(|ext| ext == "GL_OES_EGL_image") { return Err(Gles2Error::GLExtensionNotSupported(&["GL_OES_EGL_image"])); } @@ -559,7 +559,7 @@ impl Renderer for Gles2Renderer { Ok(texture) } - fn destroy_texture(&mut self, mut texture: Self::Texture) -> Result<(), Self::Error> { + fn destroy_texture(&mut self, mut texture: Self::TextureId) -> Result<(), Self::Error> { self.make_current()?; unsafe { @@ -612,7 +612,7 @@ impl Renderer for Gles2Renderer { Ok(()) } - fn render_texture(&mut self, tex: &Self::Texture, mut matrix: Matrix3, alpha: f32) -> Result<(), Self::Error> { + fn render_texture(&mut self, tex: &Self::TextureId, mut matrix: Matrix3, alpha: f32) -> Result<(), Self::Error> { self.make_current()?; if self.current_projection.is_none() { return Err(Gles2Error::UnconstraintRenderingOperation); diff --git a/src/backend/renderer/mod.rs b/src/backend/renderer/mod.rs index 8c37c23..0894668 100644 --- a/src/backend/renderer/mod.rs +++ b/src/backend/renderer/mod.rs @@ -134,27 +134,27 @@ pub trait Texture { pub trait Renderer { type Error: Error; - type Texture: Texture; + type TextureId: Texture; #[cfg(feature = "image")] - fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result; + fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result; #[cfg(feature = "wayland_frontend")] fn shm_formats(&self) -> &[wl_shm::Format] { // Mandatory &[wl_shm::Format::Argb8888, wl_shm::Format::Xrgb8888] } #[cfg(feature = "wayland_frontend")] - fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result; + fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result; #[cfg(feature = "wayland_frontend")] - fn import_egl(&mut self, buffer: &EGLBuffer) -> Result; - fn destroy_texture(&mut self, texture: Self::Texture) -> Result<(), Self::Error>; + fn import_egl(&mut self, buffer: &EGLBuffer) -> Result; + fn destroy_texture(&mut self, texture: Self::TextureId) -> Result<(), Self::Error>; fn begin(&mut self, width: u32, height: u32, transform: Transform) -> Result<(), ::Error>; fn finish(&mut self) -> Result<(), SwapBuffersError>; fn clear(&mut self, color: [f32; 4]) -> Result<(), Self::Error>; - fn render_texture(&mut self, texture: &Self::Texture, matrix: Matrix3, alpha: f32) -> Result<(), Self::Error>; - fn render_texture_at(&mut self, texture: &Self::Texture, pos: (i32, i32), transform: Transform, alpha: f32) -> Result<(), Self::Error> { + fn render_texture(&mut self, texture: &Self::TextureId, matrix: Matrix3, alpha: f32) -> Result<(), Self::Error>; + fn render_texture_at(&mut self, texture: &Self::TextureId, pos: (i32, i32), transform: Transform, alpha: f32) -> Result<(), Self::Error> { let mut mat = Matrix3::::identity(); // position and scale diff --git a/src/backend/winit.rs b/src/backend/winit.rs index f065fa1..13ec276 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -258,10 +258,10 @@ impl WinitGraphicsBackend { impl Renderer for WinitGraphicsBackend { type Error = Gles2Error; - type Texture = Gles2Texture; + type TextureId = Gles2Texture; #[cfg(feature = "image")] - fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result { + fn import_bitmap>(&mut self, image: &image::ImageBuffer, C>) -> Result { self.renderer.import_bitmap(image) } @@ -271,16 +271,16 @@ impl Renderer for WinitGraphicsBackend { } #[cfg(feature = "wayland_frontend")] - fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result { + fn import_shm(&mut self, buffer: &wl_buffer::WlBuffer) -> Result { self.renderer.import_shm(buffer) } #[cfg(feature = "wayland_frontend")] - fn import_egl(&mut self, buffer: &EGLBuffer) -> Result { + fn import_egl(&mut self, buffer: &EGLBuffer) -> Result { self.renderer.import_egl(buffer) } - fn destroy_texture(&mut self, texture: Self::Texture) -> Result<(), Self::Error> { + fn destroy_texture(&mut self, texture: Self::TextureId) -> Result<(), Self::Error> { self.renderer.destroy_texture(texture) } @@ -293,7 +293,7 @@ impl Renderer for WinitGraphicsBackend { self.renderer.clear(color) } - fn render_texture(&mut self, texture: &Self::Texture, matrix: Matrix3, alpha: f32) -> Result<(), Self::Error> { + fn render_texture(&mut self, texture: &Self::TextureId, matrix: Matrix3, alpha: f32) -> Result<(), Self::Error> { self.renderer.render_texture(texture, matrix, alpha) }