renderer: Allow Bind implementations to expose supported formats

This commit is contained in:
Victor Brekenfeld 2021-04-08 17:21:33 +02:00
parent b7aa4c416b
commit 52d581371c
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,4 @@
use std::collections::HashSet;
use std::ffi::CStr; use std::ffi::CStr;
use std::ptr; use std::ptr;
use std::sync::Arc; use std::sync::Arc;
@ -5,7 +6,7 @@ use std::sync::Arc;
use cgmath::{prelude::*, Matrix3, Vector2}; use cgmath::{prelude::*, Matrix3, Vector2};
mod shaders; mod shaders;
use crate::backend::allocator::dmabuf::{Dmabuf, WeakDmabuf}; use crate::backend::allocator::{dmabuf::{Dmabuf, WeakDmabuf}, Format};
use crate::backend::egl::{EGLContext, EGLSurface, ffi::egl::types::EGLImage}; use crate::backend::egl::{EGLContext, EGLSurface, ffi::egl::types::EGLImage};
use super::{Renderer, Frame, Bind, Unbind, Transform, Texture}; use super::{Renderer, Frame, Bind, Unbind, Transform, Texture};
@ -346,6 +347,10 @@ impl Bind<Dmabuf> for Gles2Renderer {
self.current_buffer = Some(buffer); self.current_buffer = Some(buffer);
Ok(()) Ok(())
} }
fn supported_formats(&self) -> Option<HashSet<Format>> {
Some(self.internal.egl.display.dmabuf_render_formats.clone())
}
} }
impl Unbind for Gles2Renderer { impl Unbind for Gles2Renderer {

View File

@ -1,3 +1,4 @@
use std::collections::HashSet;
use std::error::Error; use std::error::Error;
use cgmath::{prelude::*, Matrix3, Vector2}; use cgmath::{prelude::*, Matrix3, Vector2};
@ -111,6 +112,9 @@ impl From<wayland_server::protocol::wl_output::Transform> for Transform {
pub trait Bind<Target>: Unbind { pub trait Bind<Target>: Unbind {
fn bind(&mut self, target: Target) -> Result<(), <Self as Renderer>::Error>; fn bind(&mut self, target: Target) -> Result<(), <Self as Renderer>::Error>;
fn supported_formats(&self) -> Option<HashSet<crate::backend::allocator::Format>> {
None
}
} }
pub trait Unbind: Renderer { pub trait Unbind: Renderer {