Class Renderer
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
BroadwayRenderer,CairoRenderer,GLRenderer,NglRenderer,Renderer.Renderer$Impl,VulkanRenderer
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
Nested ClassesModifier and TypeClassDescriptionstatic classRenderer.Builder<B extends Renderer.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe Renderer$Impl type represents a native instance of the abstract Renderer class.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionRenderer()Creates a new Renderer.Renderer(MemorySegment address) Create a Renderer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected RendererasParent()Returns this instance as if it were its parent type.static RendererforSurface(Surface surface) Creates an appropriateGskRendererinstance for the given surface.@Nullable SurfaceRetrieves the surface that the renderer is associated with.static @Nullable TypegetType()Get the GType of the Renderer classbooleanChecks whether the renderer is realized or not.booleanCreates the resources needed by the renderer.booleanrealizeForDisplay(Display display) Creates the resources needed by the renderer.voidrender(RenderNode root, @Nullable org.freedesktop.cairo.Region region) Renders the scene graph, described by a tree ofGskRenderNodeinstances to the renderer's surface, ensuring that the given region gets redrawn.renderTexture(RenderNode root, @Nullable Rect viewport) Renders a scene graph, described by a tree ofGskRenderNodeinstances, to a texture.voidReleases all the resources created byrealize(org.gnome.gdk.Surface).Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
Renderer
public Renderer()Creates a new Renderer.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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 appropriateGskRendererinstance for the given surface.If the
GSK_RENDERERenvironment 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- a surface- Returns:
- the realized renderer
-
getSurface
Retrieves the surface that the renderer is associated with.If the renderer has not been realized yet,
NULLwill be returned.- Returns:
- the surface
-
isRealized
public boolean isRealized()Checks whether the renderer is realized or not.- Returns:
- true if the renderer was realized, false otherwise
-
realize
Creates the resources needed by the renderer.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)for this case.Note that it is mandatory to call
unrealize()before destroying the renderer.- Parameters:
surface- the surface that renderer will be used on- Returns:
- whether the renderer was successfully realized
- Throws:
GErrorException- seeGError
-
realizeForDisplay
Creates the resources needed by the renderer.Note that it is mandatory to call
unrealize()before destroying the renderer.- Parameters:
display- the display that the renderer will be used on- Returns:
- whether the renderer was successfully realized
- Throws:
GErrorException- seeGError- Since:
- 4.14
-
render
Renders the scene graph, described by a tree ofGskRenderNodeinstances to the renderer's surface, ensuring that the given region gets redrawn.If the renderer has no associated surface, this function does nothing.
Renderers must ensure that changes of the contents given by the
rootnode as well as the area given byregionare redrawn. They are however free to not redraw any pixel outside ofregionif they can guarantee that it didn't change.The renderer will acquire a reference on the
GskRenderNodetree while the rendering is in progress.- Parameters:
root- the render node to renderregion- thecairo_region_tthat must be redrawn orNULLfor the whole surface
-
renderTexture
Renders a scene graph, described by a tree ofGskRenderNodeinstances, to a texture.The renderer will acquire a reference on the
GskRenderNodetree 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- the render node to renderviewport- the section to draw orNULLto useroot'sbounds- Returns:
- a texture with the rendered contents of
root
-
unrealize
public void unrealize()Releases all the resources created byrealize(org.gnome.gdk.Surface).
-