pub struct GlesRenderer { /* private fields */ }renderer_gl only.Expand description
A renderer utilizing OpenGL ES
Implementations§
Source§impl GlesRenderer
impl GlesRenderer
Sourcepub unsafe fn supported_capabilities(
context: &EGLContext,
) -> Result<Vec<Capability>, GlesError>
pub unsafe fn supported_capabilities( context: &EGLContext, ) -> Result<Vec<Capability>, GlesError>
Get the supported Capabilities of the renderer
§Safety
This operation will cause undefined behavior if the given EGLContext is active in another thread.
Sourcepub unsafe fn new(context: EGLContext) -> Result<GlesRenderer, GlesError>
pub unsafe fn new(context: EGLContext) -> Result<GlesRenderer, GlesError>
Creates a new OpenGL ES renderer from a given EGLContext
with all supported capabilities.
§Safety
This operation will cause undefined behavior if the given EGLContext is active in another thread.
See: with_capabilities for more information
Sourcepub unsafe fn with_capabilities(
context: EGLContext,
capabilities: impl IntoIterator<Item = Capability>,
) -> Result<GlesRenderer, GlesError>
pub unsafe fn with_capabilities( context: EGLContext, capabilities: impl IntoIterator<Item = Capability>, ) -> Result<GlesRenderer, GlesError>
Creates a new OpenGL ES renderer from a given EGLContext
with the specified Capabilities. If a requested Capability is not supported an
error will be returned.
§Safety
This operation will cause undefined behavior if the given EGLContext is active in another thread.
§Implementation details
- Texture handles created by the resulting renderer are valid for every rendered created with an
EGLContextshared with the given one (seeEGLContext::new_shared) and can be used on any of these renderers. - This renderer has no default framebuffer, use
Bind::bindbefore rendering. - Shm buffers can be released after a successful import, without the texture handle becoming invalid.
- Texture filtering starts with Linear-downscaling and Linear-upscaling.
- If OpenGL ES 3.0 is not available and the underlying
EGLContextis shared, memory textures will insertglFinish-calls into the pipeline. Consider not sharing contexts, if OpenGL ES 3 isn’t available.
Sourcepub fn capabilities(&self) -> &[Capability]
pub fn capabilities(&self) -> &[Capability]
Returns the supported Capabilities of this renderer.
Sourcepub fn is_software(&self) -> bool
pub fn is_software(&self) -> bool
Returns whether the underlying EGLContext is known to be a software renderer.
Source§impl GlesRenderer
impl GlesRenderer
Sourcepub fn egl_context(&self) -> &EGLContext
pub fn egl_context(&self) -> &EGLContext
Get access to the underlying EGLContext.
Note: Modifying the context state, might result in rendering issues. The context state is considered an implementation detail and no guarantee is made about what can or cannot be changed. To make sure a certain modification does not interfere with the renderer’s behaviour, check the source.
Sourcepub fn with_context<F, R>(&mut self, func: F) -> Result<R, GlesError>
pub fn with_context<F, R>(&mut self, func: F) -> Result<R, GlesError>
Run custom code in the GL context owned by this renderer.
The OpenGL state of the renderer is considered an implementation detail and no guarantee is made about what can or cannot be changed, as such you should reset everything you change back to its previous value or check the source code of the version of Smithay you are using to ensure your changes don’t interfere with the renderer’s behavior. Doing otherwise can lead to rendering errors while using other functions of this renderer.
Sourcepub fn with_profiled_context<F, R>(
&mut self,
location: SpanLocation,
func: F,
) -> Result<R, GlesError>
pub fn with_profiled_context<F, R>( &mut self, location: SpanLocation, func: F, ) -> Result<R, GlesError>
Run custom code in the GL context with GPU profiling.
Sets up a GPU profiling span, calls with_context(), then finishes
the span, calls glFlush() and synchronizes the CPU/GPU timestamp.
Sourcepub fn compile_custom_pixel_shader(
&mut self,
src: impl AsRef<str>,
additional_uniforms: &[UniformName<'_>],
) -> Result<GlesPixelProgram, GlesError>
pub fn compile_custom_pixel_shader( &mut self, src: impl AsRef<str>, additional_uniforms: &[UniformName<'_>], ) -> Result<GlesPixelProgram, GlesError>
Compile a custom pixel shader for rendering with GlesFrame::render_pixel_shader_to.
Pixel shaders can be used for completely shader-driven drawing into a given region.
They need to handle the following #define variants:
DEBUG_FLAGSsee below
They receive the following variables:
- varying v_coords
vec2- contains the position from the vertex shader - uniform size
vec2- size of the viewport in pixels - uniform alpha
float- for the alpha value passed by the renderer - uniform tint
float- for the tint passed by the renderer (either 0.0 or 1.0) - only ifDEBUG_FLAGSwas defined
Additional uniform values can be defined by passing UniformNames to the additional_uniforms argument
and can then be set in functions utilizing GlesPixelProgram (like GlesFrame::render_pixel_shader_to).
The shader must not contain a #version directive. It will be interpreted as version 100.
§Panics
Panics if any of the names of the passed additional uniforms contains a \0/NUL-byte.
Sourcepub fn compile_custom_texture_shader(
&mut self,
shader: impl AsRef<str>,
additional_uniforms: &[UniformName<'_>],
) -> Result<GlesTexProgram, GlesError>
pub fn compile_custom_texture_shader( &mut self, shader: impl AsRef<str>, additional_uniforms: &[UniformName<'_>], ) -> Result<GlesTexProgram, GlesError>
Compile a custom texture shader for rendering with GlesFrame::render_texture or GlesFrame::render_texture_from_to.
They need to handle the following #define variants:
EXTERNALuses samplerExternalOES instead of sampler2D, requires the GL_OES_EGL_image_external extensionNO_ALPHAneeds to ignore the alpha channel of the texture and replace it with 1.0DEBUG_FLAGSsee below
They receive the following variables:
- varying v_coords
vec2- contains the position from the vertex shader - uniform tex
sample2d- texture sampler - uniform alpha
float- for the alpha value passed by the renderer - uniform tint
float- for the tint passed by the renderer (either 0.0 or 1.0) - only ifDEBUG_FLAGSwas defined
Additional uniform values can be defined by passing UniformNames to the additional_uniforms argument
and can then be set in functions utilizing GlesTexProgram (like GlesFrame::render_texture or GlesFrame::render_texture_from_to).
The shader must contain a line only containing //_DEFINES. It will be replaced by the renderer with corresponding #define directives.
§Panics
Panics if any of the names of the passed additional uniforms contains a \0/NUL-byte.
Trait Implementations§
Source§impl AsMut<GlesRenderer> for GlesFrameGuard<'_, '_, '_>
impl AsMut<GlesRenderer> for GlesFrameGuard<'_, '_, '_>
Source§fn as_mut(&mut self) -> &mut GlesRenderer
fn as_mut(&mut self) -> &mut GlesRenderer
Source§impl AsRef<GlesRenderer> for GlesFrameGuard<'_, '_, '_>
impl AsRef<GlesRenderer> for GlesFrameGuard<'_, '_, '_>
Source§fn as_ref(&self) -> &GlesRenderer
fn as_ref(&self) -> &GlesRenderer
Source§impl Bind<Dmabuf> for GlesRenderer
impl Bind<Dmabuf> for GlesRenderer
Source§impl Bind<EGLSurface> for GlesRenderer
impl Bind<EGLSurface> for GlesRenderer
Source§fn bind<'a>(
&mut self,
surface: &'a mut EGLSurface,
) -> Result<GlesTarget<'a>, GlesError>
fn bind<'a>( &mut self, surface: &'a mut EGLSurface, ) -> Result<GlesTarget<'a>, GlesError>
Source§fn supported_formats(&self) -> Option<FormatSet>
fn supported_formats(&self) -> Option<FormatSet>
Source§impl Bind<GlesRenderbuffer> for GlesRenderer
impl Bind<GlesRenderbuffer> for GlesRenderer
Source§fn bind<'a>(
&mut self,
renderbuffer: &'a mut GlesRenderbuffer,
) -> Result<GlesTarget<'a>, GlesError>
fn bind<'a>( &mut self, renderbuffer: &'a mut GlesRenderbuffer, ) -> Result<GlesTarget<'a>, GlesError>
Source§fn supported_formats(&self) -> Option<FormatSet>
fn supported_formats(&self) -> Option<FormatSet>
Source§impl Bind<GlesTexture> for GlesRenderer
impl Bind<GlesTexture> for GlesRenderer
Source§fn bind<'a>(
&mut self,
texture: &'a mut GlesTexture,
) -> Result<GlesTarget<'a>, GlesError>
fn bind<'a>( &mut self, texture: &'a mut GlesTexture, ) -> Result<GlesTarget<'a>, GlesError>
Source§fn supported_formats(&self) -> Option<FormatSet>
fn supported_formats(&self) -> Option<FormatSet>
Source§impl Blit for GlesRenderer
impl Blit for GlesRenderer
Source§fn blit(
&mut self,
src_target: &GlesTarget<'_>,
dst_target: &mut GlesTarget<'_>,
src: Rectangle<i32, Physical>,
dst: Rectangle<i32, Physical>,
filter: TextureFilter,
) -> Result<SyncPoint, GlesError>
fn blit( &mut self, src_target: &GlesTarget<'_>, dst_target: &mut GlesTarget<'_>, src: Rectangle<i32, Physical>, dst: Rectangle<i32, Physical>, filter: TextureFilter, ) -> Result<SyncPoint, GlesError>
src from one provided target to dst in the other provided target,
applying filter if necessary. Read moreSource§impl Borrow<GlesRenderer> for GlowRenderer
Available on crate feature renderer_glow only.
impl Borrow<GlesRenderer> for GlowRenderer
renderer_glow only.Source§fn borrow(&self) -> &GlesRenderer
fn borrow(&self) -> &GlesRenderer
Source§impl BorrowMut<GlesRenderer> for GlowRenderer
Available on crate feature renderer_glow only.
impl BorrowMut<GlesRenderer> for GlowRenderer
renderer_glow only.Source§fn borrow_mut(&mut self) -> &mut GlesRenderer
fn borrow_mut(&mut self) -> &mut GlesRenderer
Source§impl Debug for GlesRenderer
impl Debug for GlesRenderer
Source§impl Drop for GlesRenderer
impl Drop for GlesRenderer
Source§impl ExportMem for GlesRenderer
impl ExportMem for GlesRenderer
Source§type TextureMapping = GlesMapping
type TextureMapping = GlesMapping
Source§fn copy_framebuffer(
&mut self,
target: &GlesTarget<'_>,
region: Rectangle<i32, BufferCoord>,
fourcc: Fourcc,
) -> Result<Self::TextureMapping, Self::Error>
fn copy_framebuffer( &mut self, target: &GlesTarget<'_>, region: Rectangle<i32, BufferCoord>, fourcc: Fourcc, ) -> Result<Self::TextureMapping, Self::Error>
Source§fn can_read_texture(
&mut self,
texture: &Self::TextureId,
) -> Result<bool, GlesError>
fn can_read_texture( &mut self, texture: &Self::TextureId, ) -> Result<bool, GlesError>
Source§fn copy_texture(
&mut self,
texture: &Self::TextureId,
region: Rectangle<i32, BufferCoord>,
fourcc: Fourcc,
) -> Result<Self::TextureMapping, Self::Error>
fn copy_texture( &mut self, texture: &Self::TextureId, region: Rectangle<i32, BufferCoord>, fourcc: Fourcc, ) -> Result<Self::TextureMapping, Self::Error>
Source§fn map_texture<'a>(
&mut self,
texture_mapping: &'a Self::TextureMapping,
) -> Result<&'a [u8], Self::Error>
fn map_texture<'a>( &mut self, texture_mapping: &'a Self::TextureMapping, ) -> Result<&'a [u8], Self::Error>
Source§impl<'a, 'frame, 'buffer> FrameContext<'a, 'frame, 'buffer, GlesRenderer> for GlesFrame<'frame, 'buffer>where
'frame: 'a,
impl<'a, 'frame, 'buffer> FrameContext<'a, 'frame, 'buffer, GlesRenderer> for GlesFrame<'frame, 'buffer>where
'frame: 'a,
Source§impl From<GlesRenderer> for GlowRenderer
Available on crate feature renderer_glow only.
impl From<GlesRenderer> for GlowRenderer
renderer_glow only.Source§fn from(renderer: GlesRenderer) -> GlowRenderer
fn from(renderer: GlesRenderer) -> GlowRenderer
Source§impl ImportDma for GlesRenderer
impl ImportDma for GlesRenderer
Source§fn import_dmabuf(
&mut self,
buffer: &Dmabuf,
_damage: Option<&[Rectangle<i32, BufferCoord>]>,
) -> Result<GlesTexture, GlesError>
fn import_dmabuf( &mut self, buffer: &Dmabuf, _damage: Option<&[Rectangle<i32, BufferCoord>]>, ) -> Result<GlesTexture, GlesError>
Source§fn dmabuf_formats(&self) -> FormatSet
fn dmabuf_formats(&self) -> FormatSet
Source§impl ImportDmaWl for GlesRenderer
Available on crate feature wayland_frontend only.
impl ImportDmaWl for GlesRenderer
wayland_frontend only.Source§fn import_dma_buffer(
&mut self,
buffer: &WlBuffer,
_surface: Option<&SurfaceData>,
damage: &[Rectangle<i32, BufferCoord>],
) -> Result<Self::TextureId, Self::Error>
fn import_dma_buffer( &mut self, buffer: &WlBuffer, _surface: Option<&SurfaceData>, damage: &[Rectangle<i32, BufferCoord>], ) -> Result<Self::TextureId, Self::Error>
buffer_type). Read moreSource§impl ImportEgl for GlesRenderer
Available on crate features wayland_frontend and backend_egl and use_system_lib only.
impl ImportEgl for GlesRenderer
wayland_frontend and backend_egl and use_system_lib only.Source§fn bind_wl_display(&mut self, display: &DisplayHandle) -> Result<(), Error>
fn bind_wl_display(&mut self, display: &DisplayHandle) -> Result<(), Error>
Source§fn unbind_wl_display(&mut self)
fn unbind_wl_display(&mut self)
Source§fn egl_reader(&self) -> Option<&EGLBufferReader>
fn egl_reader(&self) -> Option<&EGLBufferReader>
EGLBufferReader. Read moreSource§fn import_egl_buffer(
&mut self,
buffer: &WlBuffer,
_surface: Option<&SurfaceData>,
_damage: &[Rectangle<i32, BufferCoord>],
) -> Result<GlesTexture, GlesError>
fn import_egl_buffer( &mut self, buffer: &WlBuffer, _surface: Option<&SurfaceData>, _damage: &[Rectangle<i32, BufferCoord>], ) -> Result<GlesTexture, GlesError>
buffer_type). Read moreSource§impl ImportMem for GlesRenderer
impl ImportMem for GlesRenderer
Source§fn import_memory(
&mut self,
data: &[u8],
format: Fourcc,
size: Size<i32, BufferCoord>,
flipped: bool,
) -> Result<GlesTexture, GlesError>
fn import_memory( &mut self, data: &[u8], format: Fourcc, size: Size<i32, BufferCoord>, flipped: bool, ) -> Result<GlesTexture, GlesError>
Source§impl ImportMemWl for GlesRenderer
Available on crate feature wayland_frontend only.
impl ImportMemWl for GlesRenderer
wayland_frontend only.Source§fn import_shm_buffer(
&mut self,
buffer: &WlBuffer,
surface: Option<&SurfaceData>,
damage: &[Rectangle<i32, BufferCoord>],
) -> Result<GlesTexture, GlesError>
fn import_shm_buffer( &mut self, buffer: &WlBuffer, surface: Option<&SurfaceData>, damage: &[Rectangle<i32, BufferCoord>], ) -> Result<GlesTexture, GlesError>
buffer_type). Read moreSource§impl Offscreen<GlesRenderbuffer> for GlesRenderer
impl Offscreen<GlesRenderbuffer> for GlesRenderer
Source§fn create_buffer(
&mut self,
format: Fourcc,
size: Size<i32, BufferCoord>,
) -> Result<GlesRenderbuffer, GlesError>
fn create_buffer( &mut self, format: Fourcc, size: Size<i32, BufferCoord>, ) -> Result<GlesRenderbuffer, GlesError>
Source§impl Offscreen<GlesTexture> for GlesRenderer
impl Offscreen<GlesTexture> for GlesRenderer
Source§fn create_buffer(
&mut self,
format: Fourcc,
size: Size<i32, BufferCoord>,
) -> Result<GlesTexture, GlesError>
fn create_buffer( &mut self, format: Fourcc, size: Size<i32, BufferCoord>, ) -> Result<GlesTexture, GlesError>
Source§impl RenderElement<GlesRenderer> for PixelShaderElement
impl RenderElement<GlesRenderer> for PixelShaderElement
Source§fn draw(
&self,
frame: &mut GlesFrame<'_, '_>,
src: Rectangle<f64, Buffer>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
_opaque_regions: &[Rectangle<i32, Physical>],
_cache: Option<&UserDataMap>,
) -> Result<(), GlesError>
fn draw( &self, frame: &mut GlesFrame<'_, '_>, src: Rectangle<f64, Buffer>, dst: Rectangle<i32, Physical>, damage: &[Rectangle<i32, Physical>], _opaque_regions: &[Rectangle<i32, Physical>], _cache: Option<&UserDataMap>, ) -> Result<(), GlesError>
Source§fn underlying_storage(
&self,
_renderer: &mut GlesRenderer,
) -> Option<UnderlyingStorage<'_>>
fn underlying_storage( &self, _renderer: &mut GlesRenderer, ) -> Option<UnderlyingStorage<'_>>
Source§fn capture_framebuffer(
&self,
frame: &mut R::Frame<'_, '_>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
cache: &UserDataMap,
) -> Result<(), R::Error>
fn capture_framebuffer( &self, frame: &mut R::Frame<'_, '_>, src: Rectangle<f64, BufferCoords>, dst: Rectangle<i32, Physical>, cache: &UserDataMap, ) -> Result<(), R::Error>
frame. Read moreSource§impl RenderElement<GlesRenderer> for TextureShaderElement
impl RenderElement<GlesRenderer> for TextureShaderElement
Source§fn draw(
&self,
frame: &mut GlesFrame<'_, '_>,
src: Rectangle<f64, Buffer>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
opaque_regions: &[Rectangle<i32, Physical>],
_cache: Option<&UserDataMap>,
) -> Result<(), GlesError>
fn draw( &self, frame: &mut GlesFrame<'_, '_>, src: Rectangle<f64, Buffer>, dst: Rectangle<i32, Physical>, damage: &[Rectangle<i32, Physical>], opaque_regions: &[Rectangle<i32, Physical>], _cache: Option<&UserDataMap>, ) -> Result<(), GlesError>
Source§fn underlying_storage(&self, renderer: &mut R) -> Option<UnderlyingStorage<'_>>
fn underlying_storage(&self, renderer: &mut R) -> Option<UnderlyingStorage<'_>>
Source§fn capture_framebuffer(
&self,
frame: &mut R::Frame<'_, '_>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
cache: &UserDataMap,
) -> Result<(), R::Error>
fn capture_framebuffer( &self, frame: &mut R::Frame<'_, '_>, src: Rectangle<f64, BufferCoords>, dst: Rectangle<i32, Physical>, cache: &UserDataMap, ) -> Result<(), R::Error>
frame. Read moreSource§impl Renderer for GlesRenderer
impl Renderer for GlesRenderer
Source§fn context_id(&self) -> ContextId<GlesTexture>
fn context_id(&self) -> ContextId<GlesTexture>
Source§fn downscale_filter(&mut self, filter: TextureFilter) -> Result<(), Self::Error>
fn downscale_filter(&mut self, filter: TextureFilter) -> Result<(), Self::Error>
Source§fn upscale_filter(&mut self, filter: TextureFilter) -> Result<(), Self::Error>
fn upscale_filter(&mut self, filter: TextureFilter) -> Result<(), Self::Error>
Source§fn set_debug_flags(&mut self, flags: DebugFlags)
fn set_debug_flags(&mut self, flags: DebugFlags)
DebugFlagsSource§fn debug_flags(&self) -> DebugFlags
fn debug_flags(&self) -> DebugFlags
DebugFlagsSource§fn render<'frame, 'buffer>(
&'frame mut self,
target: &'frame mut GlesTarget<'buffer>,
output_size: Size<i32, Physical>,
transform: Transform,
) -> Result<GlesFrame<'frame, 'buffer>, GlesError>where
'buffer: 'frame,
fn render<'frame, 'buffer>(
&'frame mut self,
target: &'frame mut GlesTarget<'buffer>,
output_size: Size<i32, Physical>,
transform: Transform,
) -> Result<GlesFrame<'frame, 'buffer>, GlesError>where
'buffer: 'frame,
Source§impl RendererSuper for GlesRenderer
impl RendererSuper for GlesRenderer
Source§type TextureId = GlesTexture
type TextureId = GlesTexture
Source§type Framebuffer<'buffer> = GlesTarget<'buffer>
type Framebuffer<'buffer> = GlesTarget<'buffer>
Source§type Frame<'frame, 'buffer> = GlesFrame<'frame, 'buffer>
where
'buffer: 'frame
type Frame<'frame, 'buffer> = GlesFrame<'frame, 'buffer> where 'buffer: 'frame
Renderer::render-callAuto Trait Implementations§
impl Freeze for GlesRenderer
impl !RefUnwindSafe for GlesRenderer
impl !Send for GlesRenderer
impl !Sync for GlesRenderer
impl Unpin for GlesRenderer
impl !UnwindSafe for GlesRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<R> ImportAll for R
impl<R> ImportAll for R
Source§fn import_buffer(
&mut self,
buffer: &WlBuffer,
surface: Option<&SurfaceData>,
damage: &[Rectangle<i32, Buffer>],
) -> Option<Result<<R as RendererSuper>::TextureId, <R as RendererSuper>::Error>>
fn import_buffer( &mut self, buffer: &WlBuffer, surface: Option<&SurfaceData>, damage: &[Rectangle<i32, Buffer>], ) -> Option<Result<<R as RendererSuper>::TextureId, <R as RendererSuper>::Error>>
wayland_frontend only.