GlowRenderer

Struct GlowRenderer 

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

A renderer utilizing OpenGL ES 2 and [glow] on top for easier custom rendering.

Implementations§

Source§

impl GlowRenderer

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<GlowRenderer, GlesError>

Creates a new OpenGL ES 2 + Glow 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<GlowRenderer, GlesError>

Creates a new OpenGL ES 2 + Glow 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.
  • Binding a new target, while another one is already bound, will replace the current target.
  • Shm buffers can be released after a successful import, without the texture handle becoming invalid.
  • Texture filtering starts with Linear-downscaling and Linear-upscaling
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(&Arc<Context>) -> 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.

Trait Implementations§

Source§

impl AsMut<GlowRenderer> for GlowFrameGuard<'_, '_, '_>

Source§

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

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

impl AsRef<GlowRenderer> for GlowFrameGuard<'_, '_, '_>

Source§

fn as_ref(&self) -> &GlowRenderer

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

impl<T> Bind<T> for GlowRenderer
where GlesRenderer: Bind<T>,

Source§

fn bind<'a>(&mut self, target: &'a mut T) -> 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 GlowRenderer

Source§

fn blit( &mut self, from: &GlesTarget<'_>, to: &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

Source§

fn borrow(&self) -> &GlesRenderer

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<GlesRenderer> for GlowRenderer

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl Debug for GlowRenderer

Source§

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

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

impl ExportMem for GlowRenderer

Source§

type TextureMapping = GlesMapping

Texture type representing a downloaded pixel buffer.
Source§

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

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

fn copy_texture( &mut self, texture: &Self::TextureId, region: Rectangle<i32, BufferCoord>, format: 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 can_read_texture( &mut self, texture: &Self::TextureId, ) -> Result<bool, Self::Error>

Returns whether the renderer should be able to read-back from the given texture. 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, GlowRenderer> for GlowFrame<'frame, 'buffer>
where 'frame: 'a,

Source§

type Guard = GlowFrameGuard<'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

Source§

fn from(renderer: GlesRenderer) -> GlowRenderer

Converts to this type from the input type.
Source§

impl ImportDma for GlowRenderer

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 GlowRenderer

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 GlowRenderer

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 GlowRenderer

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 GlowRenderer

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<T> Offscreen<T> for GlowRenderer

Source§

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

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

impl RenderElement<GlowRenderer> for PixelShaderElement

Source§

fn draw( &self, frame: &mut GlowFrame<'_, '_>, src: Rectangle<f64, BufferCoord>, 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 GlowRenderer, ) -> 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<GlowRenderer> for TextureShaderElement

Source§

fn draw( &self, frame: &mut GlowFrame<'_, '_>, src: Rectangle<f64, BufferCoord>, 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 GlowRenderer, ) -> 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 GlowRenderer

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<GlowFrame<'frame, 'buffer>, Self::Error>
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 GlowRenderer

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> = GlowFrame<'frame, 'buffer> where Self: 'frame, '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