Trait gdk4::prelude::DrawContextExt

source ·
pub trait DrawContextExt: IsA<DrawContext> + Sealed + 'static {
    // Provided methods
    fn begin_frame(&self, region: &Region) { ... }
    fn end_frame(&self) { ... }
    fn display(&self) -> Option<Display> { ... }
    fn surface(&self) -> Option<Surface> { ... }
    fn is_in_frame(&self) -> bool { ... }
}
Expand description

Trait containing all DrawContext methods.

§Implementors

CairoContext, DrawContext, GLContext, VulkanContext

Provided Methods§

source

fn begin_frame(&self, region: &Region)

Indicates that you are beginning the process of redrawing @region on the @self’s surface.

Calling this function begins a drawing operation using @self on the surface that @self was created from. The actual requirements and guarantees for the drawing operation vary for different implementations of drawing, so a CairoContext and a GLContext need to be treated differently.

A call to this function is a requirement for drawing and must be followed by a call to end_frame(), which will complete the drawing operation and ensure the contents become visible on screen.

Note that the @region passed to this function is the minimum region that needs to be drawn and depending on implementation, windowing system and hardware in use, it might be necessary to draw a larger region. Drawing implementation must use DrawContextExtManual::frame_region() to query the region that must be drawn.

When using GTK, the widget system automatically places calls to gdk_draw_context_begin_frame() and gdk_draw_context_end_frame() via the use of GskRenderers, so application code does not need to call these functions explicitly.

§region

minimum region that should be drawn

source

fn end_frame(&self)

Ends a drawing operation started with gdk_draw_context_begin_frame().

This makes the drawing available on screen. See begin_frame() for more details about drawing.

When using a GLContext, this function may call glFlush() implicitly before returning; it is not recommended to call glFlush() explicitly before calling this function.

source

fn display(&self) -> Option<Display>

Retrieves the Display the @self is created for

§Returns

the Display

source

fn surface(&self) -> Option<Surface>

Retrieves the surface that @self is bound to.

§Returns

a Surface

source

fn is_in_frame(&self) -> bool

Returns true if @self is in the process of drawing to its surface.

This is the case between calls to begin_frame() and end_frame(). In this situation, drawing commands may be effecting the contents of the @self’s surface.

§Returns

true if the context is between begin_frame() and end_frame() calls.

Object Safety§

This trait is not object safe.

Implementors§