Class Renderer
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
BroadwayRenderer
,CairoRenderer
,GLRenderer
,NglRenderer
,Renderer.RendererImpl
,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 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
-
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
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 Renderer
asParent()
Returns this instance as if it were its parent type.static Renderer
forSurface
(Surface surface) Creates an appropriateGskRenderer
instance for the given surface.Retrieves the surface that the renderer is associated with.static Type
getType()
Get the GType of the Renderer classboolean
Checks whether the renderer is realized or not.boolean
Creates the resources needed by the renderer.boolean
realizeForDisplay
(Display display) Creates the resources needed by the renderer.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 given region gets redrawn.renderTexture
(RenderNode root, @Nullable Rect viewport) Renders a scene graph, described by a tree ofGskRenderNode
instances, to a texture.void
Releases 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, 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
-
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 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 given surface.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
- a surface- Returns:
- the realized renderer
-
getSurface
Retrieves the surface that the renderer is associated with.If the renderer has not been realized yet,
NULL
will 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 ofGskRenderNode
instances 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
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 renderer will acquire a reference on the
GskRenderNode
tree while the rendering is in progress.- Parameters:
root
- the render node to renderregion
- thecairo_region_t
that must be redrawn orNULL
for the whole surface
-
renderTexture
Renders a scene graph, described by a tree ofGskRenderNode
instances, to a texture.The 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
- the render node to renderviewport
- the section to draw orNULL
to useroot
's bounds- Returns:
- a texture with the rendered contents of
root
-
unrealize
public void unrealize()Releases all the resources created byrealize(org.gnome.gdk.Surface)
.
-