gdk4::prelude

Trait DrawContextExt

Source
pub trait DrawContextExt: IsA<DrawContext> + '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)

👎Deprecated: Since 4.16

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.

§Deprecated since 4.16

Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

§region

minimum region that should be drawn

Source

fn end_frame(&self)

👎Deprecated: Since 4.16

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.

§Deprecated since 4.16

Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

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

👎Deprecated: Since 4.16

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.

§Deprecated since 4.16

Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

§Returns

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§