webrender_traits::rendering_context

Trait RenderingContext

Source
pub trait RenderingContext {
    // Required methods
    fn read_to_image(
        &self,
        source_rectangle: DeviceIntRect,
    ) -> Option<RgbaImage>;
    fn size(&self) -> PhysicalSize<u32>;
    fn resize(&self, size: PhysicalSize<u32>);
    fn present(&self);
    fn make_current(&self) -> Result<(), Error>;
    fn gleam_gl_api(&self) -> Rc<dyn Gl>;
    fn glow_gl_api(&self) -> Arc<Context>;

    // Provided methods
    fn prepare_for_rendering(&self) { ... }
    fn size2d(&self) -> Size2D<u32, DevicePixel> { ... }
    fn create_texture(
        &self,
        _surface: Surface,
    ) -> Option<(SurfaceTexture, u32, UntypedSize2D<i32>)> { ... }
    fn destroy_texture(
        &self,
        _surface_texture: SurfaceTexture,
    ) -> Option<Surface> { ... }
    fn connection(&self) -> Option<Connection> { ... }
}
Expand description

The RenderingContext trait defines a set of methods for managing an OpenGL or GLES rendering context. Implementors of this trait are responsible for handling the creation, management, and destruction of the rendering context and its associated resources.

Required Methods§

Source

fn read_to_image(&self, source_rectangle: DeviceIntRect) -> Option<RgbaImage>

Read the contents of this [Renderingcontext] into an in-memory image. If the image cannot be read (for instance, if no rendering has taken place yet), then None is returned.

In a double-buffered RenderingContext this is expected to read from the back buffer. That means that once Servo renders to the context, this should return those results, even before RenderingContext::present is called.

Source

fn size(&self) -> PhysicalSize<u32>

Get the current size of this RenderingContext.

Source

fn resize(&self, size: PhysicalSize<u32>)

Resizes the rendering surface to the given size.

Source

fn present(&self)

Presents the rendered frame to the screen. In a double-buffered context, this would swap buffers.

Source

fn make_current(&self) -> Result<(), Error>

Makes the context the current OpenGL context for this thread. After calling this function, it is valid to use OpenGL rendering commands.

Source

fn gleam_gl_api(&self) -> Rc<dyn Gl>

Returns the gleam version of the OpenGL or GLES API.

Source

fn glow_gl_api(&self) -> Arc<Context>

Returns the OpenGL or GLES API.

Provided Methods§

Source

fn prepare_for_rendering(&self)

Prepare this RenderingContext to be rendered upon by Servo. For instance, by binding a framebuffer to the current OpenGL context.

Source

fn size2d(&self) -> Size2D<u32, DevicePixel>

Get the current size of this RenderingContext as Size2D.

Source

fn create_texture( &self, _surface: Surface, ) -> Option<(SurfaceTexture, u32, UntypedSize2D<i32>)>

Creates a texture from a given surface and returns the surface texture, the OpenGL texture object, and the size of the surface. Default to None.

Source

fn destroy_texture(&self, _surface_texture: SurfaceTexture) -> Option<Surface>

Destroys the texture and returns the surface. Default to None.

Source

fn connection(&self) -> Option<Connection>

The connection to the display server for WebGL. Default to None.

Implementors§