Class GLTextureBuilder
- All Implemented Interfaces:
Proxy
GdkGLTextureBuilder
is a builder used to construct Texture
objects from
GL textures.
The operation is quite simple: Create a texture builder, set all the necessary
properties - keep in mind that the properties Gdk.GLTextureBuilder:context
,
Gdk.GLTextureBuilder:id
, Gdk.GLTextureBuilder:width
, and
Gdk.GLTextureBuilder:height
are mandatory - and then call
build(java.lang.foreign.MemorySegment)
to create the new texture.
GdkGLTextureBuilder
can be used for quick one-shot construction of
textures as well as kept around and reused to construct multiple textures.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
GLTextureBuilder.Builder<B extends GLTextureBuilder.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a new texture builder.GLTextureBuilder
(MemorySegment address) Create a GLTextureBuilder proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected GLTextureBuilder
asParent()
Returns this instance as if it were its parent type.build
(@Nullable MemorySegment data) Builds a newGdkTexture
with the values set up in the builder.static GLTextureBuilder.Builder
<? extends GLTextureBuilder.Builder> builder()
AGLTextureBuilder.Builder
object constructs aGLTextureBuilder
with the specified properties.Gets the color state previously set via gdk_gl_texture_builder_set_color_state().Gets the context previously set via gdk_gl_texture_builder_set_context() ornull
if none was set.Gets the format previously set via gdk_gl_texture_builder_set_format().boolean
Gets whether the texture has a mipmap.int
Gets the height previously set via gdk_gl_texture_builder_set_height() or 0 if the height wasn't set.int
getId()
Gets the texture id previously set via gdk_gl_texture_builder_set_id() or 0 if the id wasn't set.getSync()
Gets theGLsync
previously set via gdk_gl_texture_builder_set_sync().static Type
getType()
Get the GType of the GLTextureBuilder classorg.freedesktop.cairo.Region
Gets the region previously set via gdk_gl_texture_builder_set_update_region() ornull
if none was set.Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() ornull
if none was set.int
getWidth()
Gets the width previously set via gdk_gl_texture_builder_set_width() or 0 if the width wasn't set.void
setColorState
(ColorState colorState) Sets the color state for the texture.void
setContext
(@Nullable GLContext context) Sets the context to be used for the texture.void
setFormat
(MemoryFormat format) Sets the format of the texture.void
setHasMipmap
(boolean hasMipmap) Sets whether the texture has a mipmap.void
setHeight
(int height) Sets the height of the texture.void
setId
(int id) Sets the texture id of the texture.void
setSync
(@Nullable MemorySegment sync) Sets the GLSync object to use for the texture.void
setUpdateRegion
(@Nullable org.freedesktop.cairo.Region region) Sets the region to be updated by this texture.void
setUpdateTexture
(@Nullable Texture texture) Sets the texture to be updated by this texture.void
setWidth
(int width) Sets the width of the texture.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
-
GLTextureBuilder
Create a GLTextureBuilder proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
GLTextureBuilder
public GLTextureBuilder()Creates a new texture builder.
-
-
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. -
build
Builds a newGdkTexture
with the values set up in the builder.The
destroy
function gets called when the returned texture gets released; either when the texture is finalized or by an explicit call toGLTexture.release()
. It should release all GL resources associated with the texture, such as theGdk.GLTextureBuilder:id
and theGdk.GLTextureBuilder:sync
.Note that it is a programming error to call this function if any mandatory property has not been set.
It is possible to call this function multiple times to create multiple textures, possibly with changing properties in between.
- Parameters:
data
- user data to pass to the destroy function- Returns:
- a newly built
GdkTexture
-
getColorState
Gets the color state previously set via gdk_gl_texture_builder_set_color_state().- Returns:
- the color state
-
getContext
Gets the context previously set via gdk_gl_texture_builder_set_context() ornull
if none was set.- Returns:
- The context
-
getFormat
Gets the format previously set via gdk_gl_texture_builder_set_format().- Returns:
- The format
-
getHasMipmap
public boolean getHasMipmap()Gets whether the texture has a mipmap.- Returns:
- Whether the texture has a mipmap
-
getHeight
public int getHeight()Gets the height previously set via gdk_gl_texture_builder_set_height() or 0 if the height wasn't set.- Returns:
- The height
-
getId
public int getId()Gets the texture id previously set via gdk_gl_texture_builder_set_id() or 0 if the id wasn't set.- Returns:
- The id
-
getSync
Gets theGLsync
previously set via gdk_gl_texture_builder_set_sync().- Returns:
- the
GLSync
-
getUpdateRegion
public org.freedesktop.cairo.Region getUpdateRegion()Gets the region previously set via gdk_gl_texture_builder_set_update_region() ornull
if none was set.- Returns:
- The region
-
getUpdateTexture
Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() ornull
if none was set.- Returns:
- The texture
-
getWidth
public int getWidth()Gets the width previously set via gdk_gl_texture_builder_set_width() or 0 if the width wasn't set.- Returns:
- The width
-
setColorState
Sets the color state for the texture.By default, the sRGB colorstate is used. If you don't know what colorstates are, this is probably the right thing.
- Parameters:
colorState
- aGdkColorState
-
setContext
Sets the context to be used for the texture. This is the context that owns the texture.The context must be set before calling
build(java.lang.foreign.MemorySegment)
.- Parameters:
context
- The context the texture belongs to ornull
to unset
-
setFormat
Sets the format of the texture. The default isGDK_MEMORY_R8G8B8A8_PREMULTIPLIED
.The format is the preferred format the texture data should be downloaded to. The format must be supported by the GL version of
Gdk.GLTextureBuilder:context
.GDK's texture download code assumes that the format corresponds to the storage parameters of the GL texture in an obvious way. For example, a format of
GDK_MEMORY_R16G16B16A16_PREMULTIPLIED
is expected to be stored asGL_RGBA16
texture, andGDK_MEMORY_G8A8
is expected to be stored asGL_RG8
texture.Setting the right format is particularly useful when using high bit depth textures to preserve the bit depth, to set the correct value for unpremultiplied textures and to make sure opaque textures are treated as such.
Non-RGBA textures need to have swizzling parameters set up properly to be usable in GSK's shaders.
- Parameters:
format
- The texture's format
-
setHasMipmap
public void setHasMipmap(boolean hasMipmap) Sets whether the texture has a mipmap. This allows the renderer and other users of the generated texture to use a higher quality downscaling.Typically, the
glGenerateMipmap
function is used to generate a mimap.- Parameters:
hasMipmap
- Whether the texture has a mipmap
-
setHeight
public void setHeight(int height) Sets the height of the texture.The height must be set before calling
build(java.lang.foreign.MemorySegment)
.- Parameters:
height
- The texture's height or 0 to unset
-
setId
public void setId(int id) Sets the texture id of the texture. The texture id must remain unmodified until the texture was finalized. Seebuild(java.lang.foreign.MemorySegment)
for a longer discussion.The id must be set before calling
build(java.lang.foreign.MemorySegment)
.- Parameters:
id
- The texture id to be used for creating the texture
-
setSync
Sets the GLSync object to use for the texture.GTK will wait on this object before using the created
GdkTexture
.The
destroy
function that is passed tobuild(java.lang.foreign.MemorySegment)
is responsible for freeing the sync object when it is no longer needed. The texture builder does not destroy it and it is the callers responsibility to make sure it doesn't leak.- Parameters:
sync
- the GLSync object
-
setUpdateRegion
public void setUpdateRegion(@Nullable @Nullable org.freedesktop.cairo.Region region) Sets the region to be updated by this texture. Together withGdk.GLTextureBuilder:update-texture
this describes an update of a previous texture.When rendering animations of large textures, it is possible that consecutive textures are only updating contents in parts of the texture. It is then possible to describe this update via these two properties, so that GTK can avoid rerendering parts that did not change.
An example would be a screen recording where only the mouse pointer moves.
- Parameters:
region
- the region to update
-
setUpdateTexture
Sets the texture to be updated by this texture. SeesetUpdateRegion(org.freedesktop.cairo.Region)
for an explanation.- Parameters:
texture
- the texture to update
-
setWidth
public void setWidth(int width) Sets the width of the texture.The width must be set before calling
build(java.lang.foreign.MemorySegment)
.- Parameters:
width
- The texture's width or 0 to unset
-
builder
AGLTextureBuilder.Builder
object constructs aGLTextureBuilder
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withGLTextureBuilder.Builder.build()
.
-