Class DrawContext

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
CairoContext, DrawContext.DrawContext$Impl, GLContext, VulkanContext

@Generated("org.javagi.JavaGI") public abstract class DrawContext extends GObject

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.

  • Constructor Details

    • DrawContext

      public DrawContext(MemorySegment address)
      Create a DrawContext instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • DrawContext

      public DrawContext()
      Create a new DrawContext.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the DrawContext class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected DrawContext asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • beginFrame

      @Deprecated public void beginFrame(org.freedesktop.cairo.Region region)
      Deprecated.
      Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

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

      Calling this function begins a drawing operation using this DrawContext on the surface that this DrawContext 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 endFrame(), 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 getFrameRegion() 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:
      region - minimum region that should be drawn
    • endFrame

      @Deprecated public void endFrame()
      Deprecated.
      Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

      Ends a drawing operation started with gdk_draw_context_begin_frame().

      This makes the drawing available on screen. See beginFrame(Region) 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.

    • getDisplay

      public @Nullable Display getDisplay()
      Retrieves the GdkDisplay the this DrawContext is created for
      Returns:
      the GdkDisplay
    • getFrameRegion

      @Deprecated public @Nullable org.freedesktop.cairo.Region getFrameRegion()
      Deprecated.
      Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

      Retrieves the region that is currently being repainted.

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

      If this DrawContext is not in between calls to beginFrame(Region) and endFrame(), null will be returned.

      Returns:
      a Cairo region
    • getSurface

      public @Nullable Surface getSurface()
      Retrieves the surface that this DrawContext is bound to.
      Returns:
      a GdkSurface
    • isInFrame

      @Deprecated public boolean isInFrame()
      Deprecated.
      Drawing directly to the surface is no longer recommended. Use GskRenderNode and GskRenderer.

      Returns true if this DrawContext is in the process of drawing to its surface.

      This is the case between calls to beginFrame(Region) and endFrame(). In this situation, drawing commands may be effecting the contents of the context's surface.

      Returns:
      true if the context is between beginFrame(Region) and endFrame() calls.