From 52d581371ca1737cf65dd669533b7392a93655a6 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Thu, 8 Apr 2021 17:21:33 +0200 Subject: [PATCH] renderer: Allow Bind implementations to expose supported formats --- src/backend/renderer/gles2/mod.rs | 7 ++++++- src/backend/renderer/mod.rs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/renderer/gles2/mod.rs b/src/backend/renderer/gles2/mod.rs index e4b2534..4aa284a 100644 --- a/src/backend/renderer/gles2/mod.rs +++ b/src/backend/renderer/gles2/mod.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use std::ffi::CStr; use std::ptr; use std::sync::Arc; @@ -5,7 +6,7 @@ use std::sync::Arc; use cgmath::{prelude::*, Matrix3, Vector2}; 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 super::{Renderer, Frame, Bind, Unbind, Transform, Texture}; @@ -346,6 +347,10 @@ impl Bind for Gles2Renderer { self.current_buffer = Some(buffer); Ok(()) } + + fn supported_formats(&self) -> Option> { + Some(self.internal.egl.display.dmabuf_render_formats.clone()) + } } impl Unbind for Gles2Renderer { diff --git a/src/backend/renderer/mod.rs b/src/backend/renderer/mod.rs index 12ef623..37339b6 100644 --- a/src/backend/renderer/mod.rs +++ b/src/backend/renderer/mod.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use std::error::Error; use cgmath::{prelude::*, Matrix3, Vector2}; @@ -111,6 +112,9 @@ impl From for Transform { pub trait Bind: Unbind { fn bind(&mut self, target: Target) -> Result<(), ::Error>; + fn supported_formats(&self) -> Option> { + None + } } pub trait Unbind: Renderer {