GlesRenderer

Struct GlesRenderer 

Source
pub struct GlesRenderer { /* private fields */ }
Available on crate feature renderer_gl only.
Expand description

A renderer utilizing OpenGL ES

Implementations§

Source§

impl GlesRenderer

Source

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.

Source

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

Source

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 EGLContext shared with the given one (see EGLContext::new_shared) and can be used on any of these renderers.
  • This renderer has no default framebuffer, use Bind::bind before 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 EGLContext is shared, memory textures will insert glFinish-calls into the pipeline. Consider not sharing contexts, if OpenGL ES 3 isn’t available.
Source

pub fn capabilities(&self) -> &[Capability]

Returns the supported Capabilities of this renderer.

Source

pub fn is_software(&self) -> bool

Returns whether the underlying EGLContext is known to be a software renderer.

Source§

impl GlesRenderer

Source

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.

Source

pub fn with_context<F, R>(&mut self, func: F) -> Result<R, GlesError>
where F: FnOnce(&Gles2) -> R,

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.

Source

pub fn with_profiled_context<F, R>( &mut self, location: SpanLocation, func: F, ) -> Result<R, GlesError>
where F: FnOnce(&Gles2) -> R,

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.

Source

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_FLAGS see 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 if DEBUG_FLAGS was 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.

Source

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:

  • EXTERNAL uses samplerExternalOES instead of sampler2D, requires the GL_OES_EGL_image_external extension
  • NO_ALPHA needs to ignore the alpha channel of the texture and replace it with 1.0
  • DEBUG_FLAGS see 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 if DEBUG_FLAGS was 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<'_, '_, '_>

Source§

fn as_mut(&mut self) -> &mut GlesRenderer

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<GlesRenderer> for GlesFrameGuard<'_, '_, '_>

Source§

fn as_ref(&self) -> &GlesRenderer

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Bind<Dmabuf> for GlesRenderer

Source§

fn bind<'a>( &mut self, dmabuf: &'a mut Dmabuf, ) -> Result<GlesTarget<'a>, GlesError>

Initialize a framebuffer with a given rendering target. Read more
Source§

fn supported_formats(&self) -> Option<FormatSet>

Supported pixel formats for given targets, if applicable.
Source§

impl Bind<EGLSurface> for GlesRenderer

Source§

fn bind<'a>( &mut self, surface: &'a mut EGLSurface, ) -> Result<GlesTarget<'a>, GlesError>

Initialize a framebuffer with a given rendering target. Read more
Source§

fn supported_formats(&self) -> Option<FormatSet>

Supported pixel formats for given targets, if applicable.
Source§

impl Bind<GlesRenderbuffer> for GlesRenderer

Source§

fn bind<'a>( &mut self, renderbuffer: &'a mut GlesRenderbuffer, ) -> Result<GlesTarget<'a>, GlesError>

Initialize a framebuffer with a given rendering target. Read more
Source§

fn supported_formats(&self) -> Option<FormatSet>

Supported pixel formats for given targets, if applicable.
Source§

impl Bind<GlesTexture> for GlesRenderer

Source§

fn bind<'a>( &mut self, texture: &'a mut GlesTexture, ) -> Result<GlesTarget<'a>, GlesError>

Initialize a framebuffer with a given rendering target. Read more
Source§

fn supported_formats(&self) -> Option<FormatSet>

Supported pixel formats for given targets, if applicable.
Source§

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>

Copies the contents of src from one provided target to dst in the other provided target, applying filter if necessary. Read more
Source§

impl Borrow<GlesRenderer> for GlowRenderer

Available on crate feature renderer_glow only.
Source§

fn borrow(&self) -> &GlesRenderer

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<GlesRenderer> for GlowRenderer

Available on crate feature renderer_glow only.
Source§

fn borrow_mut(&mut self) -> &mut GlesRenderer

Mutably borrows from an owned value. Read more
Source§

impl Debug for GlesRenderer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for GlesRenderer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ExportMem for GlesRenderer

Source§

type TextureMapping = GlesMapping

Texture type representing a downloaded pixel buffer.
Source§

fn copy_framebuffer( &mut self, target: &GlesTarget<'_>, region: Rectangle<i32, BufferCoord>, fourcc: Fourcc, ) -> Result<Self::TextureMapping, Self::Error>

Copies the contents of the provided target. Read more
Source§

fn can_read_texture( &mut self, texture: &Self::TextureId, ) -> Result<bool, GlesError>

Returns whether the renderer should be able to read-back from the given texture. Read more
Source§

fn copy_texture( &mut self, texture: &Self::TextureId, region: Rectangle<i32, BufferCoord>, fourcc: Fourcc, ) -> Result<Self::TextureMapping, Self::Error>

Copies the contents of the passed texture. Note: This function may change or invalidate the current bind. Read more
Source§

fn map_texture<'a>( &mut self, texture_mapping: &'a Self::TextureMapping, ) -> Result<&'a [u8], Self::Error>

Returns a read-only pointer to a previously created texture mapping. Read more
Source§

impl<'a, 'frame, 'buffer> FrameContext<'a, 'frame, 'buffer, GlesRenderer> for GlesFrame<'frame, 'buffer>
where 'frame: 'a,

Source§

type Guard = GlesFrameGuard<'a, 'frame, 'buffer>

Type returned by FrameContext::renderer which derefs into the underlying Renderer.
Source§

fn renderer(&'a mut self) -> Self::Guard

Receive the underlying Renderer
Source§

impl From<GlesRenderer> for GlowRenderer

Available on crate feature renderer_glow only.
Source§

fn from(renderer: GlesRenderer) -> GlowRenderer

Converts to this type from the input type.
Source§

impl ImportDma for GlesRenderer

Source§

fn import_dmabuf( &mut self, buffer: &Dmabuf, _damage: Option<&[Rectangle<i32, BufferCoord>]>, ) -> Result<GlesTexture, GlesError>

Import a given raw dmabuf into the renderer. Read more
Source§

fn dmabuf_formats(&self) -> FormatSet

Returns supported formats for dmabufs.
Source§

fn has_dmabuf_format(&self, format: Format) -> bool

Test if a specific dmabuf Format is supported
Source§

impl ImportDmaWl for GlesRenderer

Available on crate feature wayland_frontend only.
Source§

fn import_dma_buffer( &mut self, buffer: &WlBuffer, _surface: Option<&SurfaceData>, damage: &[Rectangle<i32, BufferCoord>], ) -> Result<Self::TextureId, Self::Error>

Import a given dmabuf-based buffer into the renderer (see buffer_type). Read more
Source§

impl ImportEgl for GlesRenderer

Available on crate features wayland_frontend and backend_egl and use_system_lib only.
Source§

fn bind_wl_display(&mut self, display: &DisplayHandle) -> Result<(), Error>

Binds the underlying EGL display to the given Wayland display. Read more
Source§

fn unbind_wl_display(&mut self)

Unbinds a previously bound egl display, if existing. Read more
Source§

fn egl_reader(&self) -> Option<&EGLBufferReader>

Returns the underlying EGLBufferReader. Read more
Source§

fn import_egl_buffer( &mut self, buffer: &WlBuffer, _surface: Option<&SurfaceData>, _damage: &[Rectangle<i32, BufferCoord>], ) -> Result<GlesTexture, GlesError>

Import a given wl_drm-based buffer into the renderer (see buffer_type). Read more
Source§

impl ImportMem for GlesRenderer

Source§

fn import_memory( &mut self, data: &[u8], format: Fourcc, size: Size<i32, BufferCoord>, flipped: bool, ) -> Result<GlesTexture, GlesError>

Import a given chunk of memory into the renderer. Read more
Source§

fn update_memory( &mut self, texture: &Self::TextureId, data: &[u8], region: Rectangle<i32, BufferCoord>, ) -> Result<(), Self::Error>

Update a portion of a given chunk of memory into an existing texture. Read more
Source§

fn mem_formats(&self) -> Box<dyn Iterator<Item = Fourcc>>

Returns supported formats for memory imports.
Source§

impl ImportMemWl for GlesRenderer

Available on crate feature wayland_frontend only.
Source§

fn import_shm_buffer( &mut self, buffer: &WlBuffer, surface: Option<&SurfaceData>, damage: &[Rectangle<i32, BufferCoord>], ) -> Result<GlesTexture, GlesError>

Import a given shm-based buffer into the renderer (see buffer_type). Read more
Source§

fn shm_formats(&self) -> Box<dyn Iterator<Item = Format>>

Returns supported formats for shared memory buffers. Read more
Source§

impl Offscreen<GlesRenderbuffer> for GlesRenderer

Source§

fn create_buffer( &mut self, format: Fourcc, size: Size<i32, BufferCoord>, ) -> Result<GlesRenderbuffer, GlesError>

Create a new instance of a framebuffer. Read more
Source§

impl Offscreen<GlesTexture> for GlesRenderer

Source§

fn create_buffer( &mut self, format: Fourcc, size: Size<i32, BufferCoord>, ) -> Result<GlesTexture, GlesError>

Create a new instance of a framebuffer. Read more
Source§

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>

Draw this element Read more
Source§

fn underlying_storage( &self, _renderer: &mut GlesRenderer, ) -> Option<UnderlyingStorage<'_>>

Get the underlying storage of this element, may be used to optimize rendering (eg. drm planes)
Source§

fn capture_framebuffer( &self, frame: &mut R::Frame<'_, '_>, src: Rectangle<f64, BufferCoords>, dst: Rectangle<i32, Physical>, cache: &UserDataMap, ) -> Result<(), R::Error>

Notification, that the underlying framebuffer has changed allowing the element to blit the contents of the frame. Read more
Source§

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>

Draw this element Read more
Source§

fn underlying_storage(&self, renderer: &mut R) -> Option<UnderlyingStorage<'_>>

Get the underlying storage of this element, may be used to optimize rendering (eg. drm planes)
Source§

fn capture_framebuffer( &self, frame: &mut R::Frame<'_, '_>, src: Rectangle<f64, BufferCoords>, dst: Rectangle<i32, Physical>, cache: &UserDataMap, ) -> Result<(), R::Error>

Notification, that the underlying framebuffer has changed allowing the element to blit the contents of the frame. Read more
Source§

impl Renderer for GlesRenderer

Source§

fn context_id(&self) -> ContextId<GlesTexture>

Returns the ContextId of this renderer Read more
Source§

fn downscale_filter(&mut self, filter: TextureFilter) -> Result<(), Self::Error>

Set the filter method to be used when rendering a texture into a smaller area than its size
Source§

fn upscale_filter(&mut self, filter: TextureFilter) -> Result<(), Self::Error>

Set the filter method to be used when rendering a texture into a larger area than its size
Source§

fn set_debug_flags(&mut self, flags: DebugFlags)

Set the enabled DebugFlags
Source§

fn debug_flags(&self) -> DebugFlags

Returns the current enabled DebugFlags
Source§

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,

Initialize a rendering context on the provided framebuffer with given dimensions and transformation. Read more
Source§

fn wait(&mut self, sync: &SyncPoint) -> Result<(), Self::Error>

Wait for a SyncPoint to be signaled
Source§

fn cleanup_texture_cache(&mut self) -> Result<(), Self::Error>

Forcibly clean up the renderer internal texture cache Read more
Source§

impl RendererSuper for GlesRenderer

Source§

type Error = GlesError

Error type returned by the rendering operations of this renderer.
Source§

type TextureId = GlesTexture

Texture Handle type used by this renderer.
Source§

type Framebuffer<'buffer> = GlesTarget<'buffer>

Framebuffer to draw onto
Source§

type Frame<'frame, 'buffer> = GlesFrame<'frame, 'buffer> where 'buffer: 'frame

Type representing a currently in-progress frame during the Renderer::render-call

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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>>

Available on crate feature wayland_frontend only.
Import a given buffer into the renderer. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more