GdkDrawContext

GdkDrawContext — Base class for draw contexts

Types and Values

Object Hierarchy

    GObject
    ╰── GdkDrawContext
        ├── GdkGLContext
        ╰── GdkVulkanContext

Includes

#include <gdk/gdk.h>

Description

GdkDrawContext is the base object used by contexts implementing different rendering methods, such as GdkGLContext or GdkVulkanContext. It provides shared functionality between those contexts.

You will always interact with one of those subclasses.

A GdkDrawContext is always associated with a single toplevel surface.

Functions

gdk_draw_context_get_display ()

GdkDisplay *
gdk_draw_context_get_display (GdkDrawContext *context);

Retrieves the GdkDisplay the context is created for

Parameters

context

a GdkDrawContext

 

Returns

a GdkDisplay or NULL.

[nullable][transfer none]


gdk_draw_context_get_surface ()

GdkSurface *
gdk_draw_context_get_surface (GdkDrawContext *context);

Retrieves the GdkSurface used by the context .

Parameters

context

a GdkDrawContext

 

Returns

a GdkSurface or NULL.

[nullable][transfer none]


gdk_draw_context_begin_frame ()

void
gdk_draw_context_begin_frame (GdkDrawContext *context,
                              const cairo_region_t *region);

Indicates that you are beginning the process of redrawing region on the context 's surface.

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

A call to this function is a requirement for drawing and must be followed by a call to gdk_draw_context_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 gdk_draw_context_get_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.

Parameters

context

the context used to draw the frame

 

region

minimum region that should be drawn

 

gdk_draw_context_end_frame ()

void
gdk_draw_context_end_frame (GdkDrawContext *context);

Ends a drawing operation started with gdk_draw_context_begin_frame() and makes the drawing available on screen. See that function for more details about drawing.

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

Parameters

context

a GdkDrawContext

 

gdk_draw_context_is_in_frame ()

gboolean
gdk_draw_context_is_in_frame (GdkDrawContext *context);

Returns TRUE if context is in the process of drawing to its surface after a call to gdk_draw_context_begin_frame() and not yet having called gdk_draw_context_end_frame(). In this situation, drawing commands may be effecting the contents of a context 's surface.

Parameters

context

a GdkDrawContext

 

Returns

TRUE if the context is between gdk_draw_context_begin_frame() and gdk_draw_context_end_frame() calls.


gdk_draw_context_get_frame_region ()

const cairo_region_t *
gdk_draw_context_get_frame_region (GdkDrawContext *context);

Retrieves the region that is currently in the process of being repainted.

After a call to gdk_draw_context_begin_frame() this function will return a union of the region passed to that function and the area of the surface that the context determined needs to be repainted.

If context is not in between calls to gdk_draw_context_begin_frame() and gdk_draw_context_end_frame(), NULL will be returned.

Parameters

context

a GdkDrawContext

 

Returns

a Cairo region or NULL if not drawing a frame.

[transfer none][nullable]

Types and Values

GdkDrawContext

typedef struct _GdkDrawContext GdkDrawContext;

The GdkDrawContext struct contains only private fields and should not be accessed directly.