DrawContext#
Superclasses: Object
Subclasses: CairoContext, GLContext, VulkanContext
Base class for objects implementing different rendering methods.
GdkDrawContext is the base object used by contexts implementing different
rendering methods, such as CairoContext or GLContext.
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.
Methods#
- class DrawContext
 - begin_frame(region: Region) None#
 Indicates that you are beginning the process of redrawing
regionon thecontext's surface.Calling this function begins a drawing operation using
contexton the surface thatcontextwas created from. The actual requirements and guarantees for the drawing operation vary for different implementations of drawing, so aCairoContextand aGLContextneed 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
regionpassed 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 useget_frame_regionto query the region that must be drawn.When using GTK, the widget system automatically places calls to
begin_frame()andend_frame()via the use of GskRenderers, so application code does not need to call these functions explicitly.Deprecated since version 4.16:
- Drawing directly to the surface is no longer recommended.
 Use
GskRenderNodeandGskRenderer.
- Parameters:
 region – minimum region that should be drawn
- end_frame() None#
 Ends a drawing operation started with
begin_frame().This makes the drawing available on screen. See
begin_framefor more details about drawing.When using a
GLContext, this function may callglFlush()implicitly before returning; it is not recommended to callglFlush()explicitly before calling this function.Deprecated since version 4.16:
- Drawing directly to the surface is no longer recommended.
 Use
GskRenderNodeandGskRenderer.
- get_frame_region() Region | None#
 Retrieves the region that is currently being repainted.
After a call to
begin_framethis function will return a union of the region passed to that function and the area of the surface that thecontextdetermined needs to be repainted.If
contextis not in between calls tobegin_frameandend_frame,Nonewill be returned.Deprecated since version 4.16:
- Drawing directly to the surface is no longer recommended.
 Use
GskRenderNodeandGskRenderer.
- is_in_frame() bool#
 Returns
Trueifcontextis in the process of drawing to its surface.This is the case between calls to
begin_frameandend_frame. In this situation, drawing commands may be effecting the contents of thecontext's surface.Deprecated since version 4.16:
- Drawing directly to the surface is no longer recommended.
 Use
GskRenderNodeandGskRenderer.