Class Renderer
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
BroadwayRenderer
,CairoRenderer
,GLRenderer
,NglRenderer
,Renderer.RendererImpl
,VulkanRenderer
GskRenderer
is a class that renders a scene graph defined via a
tree of RenderNode
instances.
Typically you will use a GskRenderer
instance to repeatedly call
render(org.gnome.gsk.RenderNode, org.freedesktop.cairo.Region)
to update the contents of its associated
Surface
.
It is necessary to realize a GskRenderer
instance using
realize(org.gnome.gdk.Surface)
before calling render(org.gnome.gsk.RenderNode, org.freedesktop.cairo.Region)
,
in order to create the appropriate windowing system resources needed
to render the scene.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Renderer.Builder<B extends Renderer.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
static class
The RendererImpl type represents a native instance of the abstract Renderer class.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionRenderer
(MemorySegment address) Create a Renderer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Renderer
asParent()
Returns this instance as if it were its parent type.static Renderer.Builder
<? extends Renderer.Builder> builder()
ARenderer.Builder
object constructs aRenderer
with the specified properties.static Renderer
forSurface
(Surface surface) Creates an appropriateGskRenderer
instance for the givensurface
.Retrieves theGdkSurface
set using gsk_enderer_realize().static Type
getType()
Get the GType of the Renderer classboolean
Checks whether the this Renderer is realized or not.boolean
Creates the resources needed by the this Renderer to render the scene graph.boolean
realizeForDisplay
(Display display) Creates the resources needed by the this Renderer to render the scene graph.void
render
(RenderNode root, @Nullable org.freedesktop.cairo.Region region) Renders the scene graph, described by a tree ofGskRenderNode
instances to the renderer's surface, ensuring that the givenregion
gets redrawn.renderTexture
(RenderNode root, @Nullable Rect viewport) Renders the scene graph, described by a tree ofGskRenderNode
instances, to aGdkTexture
.void
Releases all the resources created by gsk_renderer_realize().Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Renderer
Create a Renderer proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
forSurface
Creates an appropriateGskRenderer
instance for the givensurface
.If the
GSK_RENDERER
environment variable is set, GSK will try that renderer first, before trying the backend-specific default. The ultimate fallback is the cairo renderer.The renderer will be realized before it is returned.
- Parameters:
surface
- aGdkSurface
- Returns:
- a
GskRenderer
-
getSurface
Retrieves theGdkSurface
set using gsk_enderer_realize().If the renderer has not been realized yet,
null
will be returned.- Returns:
- a
GdkSurface
-
isRealized
public boolean isRealized()Checks whether the this Renderer is realized or not.- Returns:
true
if theGskRenderer
was realized, andfalse
otherwise
-
realize
Creates the resources needed by the this Renderer to render the scene graph.Since GTK 4.6, the surface may be
NULL
, which allows using renderers without having to create a surface. Since GTK 4.14, it is recommended to userealizeForDisplay(org.gnome.gdk.Display)
instead.Note that it is mandatory to call
unrealize()
before destroying the renderer.- Parameters:
surface
- theGdkSurface
renderer will be used on- Returns:
- Whether the renderer was successfully realized
- Throws:
GErrorException
- seeGError
-
realizeForDisplay
Creates the resources needed by the this Renderer to render the scene graph.Note that it is mandatory to call
unrealize()
before destroying the renderer.- Parameters:
display
- theGdkDisplay
renderer will be used on- Returns:
- Whether the renderer was successfully realized
- Throws:
GErrorException
- seeGError
-
render
Renders the scene graph, described by a tree ofGskRenderNode
instances to the renderer's surface, ensuring that the givenregion
gets redrawn.If the renderer has no associated surface, this function does nothing.
Renderers must ensure that changes of the contents given by the
root
node as well as the area given byregion
are redrawn. They are however free to not redraw any pixel outside ofregion
if they can guarantee that it didn't change.The this Renderer will acquire a reference on the
GskRenderNode
tree while the rendering is in progress.- Parameters:
root
- aGskRenderNode
region
- thecairo_region_t
that must be redrawn ornull
for the whole window
-
renderTexture
Renders the scene graph, described by a tree ofGskRenderNode
instances, to aGdkTexture
.The this Renderer will acquire a reference on the
GskRenderNode
tree while the rendering is in progress.If you want to apply any transformations to
root
, you should put it into a transform node and pass that node instead.- Parameters:
root
- aGskRenderNode
viewport
- the section to draw ornull
to useroot
's bounds- Returns:
- a
GdkTexture
with the rendered contents ofroot
.
-
unrealize
public void unrealize()Releases all the resources created by gsk_renderer_realize(). -
builder
ARenderer.Builder
object constructs aRenderer
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withRenderer.Builder.build()
.
-