Class MemoryTextureBuilder

All Implemented Interfaces:
Proxy

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

Constructs Texture objects from system memory provided via GLib.Bytes.

The operation is quite simple: Create a texture builder, set all the necessary properties - keep in mind that the properties Gdk.MemoryTextureBuilder:bytes, Gdk.MemoryTextureBuilder:stride, Gdk.MemoryTextureBuilder:width, and Gdk.MemoryTextureBuilder:height are mandatory - and then call build() to create the new texture.

GdkMemoryTextureBuilder can be used for quick one-shot construction of textures as well as kept around and reused to construct multiple textures.

Since:
4.16
  • Constructor Details

    • MemoryTextureBuilder

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

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

    • getType

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

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

      protected MemoryTextureBuilder 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
    • build

      public Texture build()

      Builds a new GdkTexture with the values set up in the builder.

      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.

      Returns:
      a newly built GdkTexture
      Since:
      4.16
    • getBytes

      public byte @Nullable [] getBytes()
      Gets the bytes previously set via gdk_memory_texture_builder_set_bytes() or null if none was set.
      Returns:
      The bytes
      Since:
      4.16
    • getColorState

      public ColorState getColorState()
      Gets the colorstate previously set via gdk_memory_texture_builder_set_color_state().
      Returns:
      The colorstate
      Since:
      4.16
    • getFormat

      public MemoryFormat getFormat()
      Gets the format previously set via gdk_memory_texture_builder_set_format().
      Returns:
      The format
      Since:
      4.16
    • getHeight

      public int getHeight()
      Gets the height previously set via gdk_memory_texture_builder_set_height() or 0 if the height wasn't set.
      Returns:
      The height
      Since:
      4.16
    • getOffset

      public long getOffset(int plane)
      Gets the offset previously set via gdk_memory_texture_builder_set_offset().
      Parameters:
      plane - a plane
      Returns:
      The offset associated to a plane
      Since:
      4.20
    • getStride

      public long getStride()
      Gets the stride previously set via gdk_memory_texture_builder_set_stride().
      Returns:
      the stride
      Since:
      4.16
    • getStrideForPlane

      public long getStrideForPlane(int plane)
      Gets the stride previously set via gdk_memory_texture_builder_set_stride_for_plane().
      Parameters:
      plane - a plane
      Returns:
      The stride associated to a plane
      Since:
      4.20
    • getUpdateRegion

      public @Nullable org.freedesktop.cairo.Region getUpdateRegion()
      Gets the region previously set via gdk_memory_texture_builder_set_update_region() or null if none was set.
      Returns:
      The update region
      Since:
      4.16
    • getUpdateTexture

      public @Nullable Texture getUpdateTexture()
      Gets the texture previously set via gdk_memory_texture_builder_set_update_texture() or null if none was set.
      Returns:
      The update texture
      Since:
      4.16
    • getWidth

      public int getWidth()
      Gets the width previously set via gdk_memory_texture_builder_set_width() or 0 if the width wasn't set.
      Returns:
      The width
      Since:
      4.16
    • setBytes

      public void setBytes(byte @Nullable [] bytes)

      Sets the data to be shown but the texture.

      The bytes must be set before calling build().

      Parameters:
      bytes - The bytes the texture shows or null to unset
      Since:
      4.16
    • setColorState

      public void setColorState(ColorState colorState)

      Sets the colorstate describing the data.

      By default, the sRGB colorstate is used. If you don't know what colorstates are, this is probably the right thing.

      Parameters:
      colorState - The colorstate describing the data
      Since:
      4.16
    • setFormat

      public void setFormat(MemoryFormat format)

      Sets the format of the bytes.

      The default is GDK_MEMORY_R8G8B8A8_PREMULTIPLIED.

      Parameters:
      format - The texture's format
      Since:
      4.16
    • setHeight

      public void setHeight(int height)

      Sets the height of the texture.

      The height must be set before calling build() and conform to size requirements of the provided format.

      Parameters:
      height - The texture's height or 0 to unset
      Since:
      4.16
    • setOffset

      public void setOffset(int plane, long offset)
      Sets the offset of the texture for plane.
      Parameters:
      plane - a plane
      offset - the texture's offset for plane
      Since:
      4.20
    • setStride

      public void setStride(long stride)

      Sets the rowstride of the bytes used.

      The rowstride must be set before calling build().

      Parameters:
      stride - the stride or 0 to unset
      Since:
      4.16
    • setStrideForPlane

      public void setStrideForPlane(int plane, long stride)
      Sets the stride of the texture for plane.
      Parameters:
      plane - a plane
      stride - the texture's stride for plane
      Since:
      4.20
    • setUpdateRegion

      public void setUpdateRegion(@Nullable org.freedesktop.cairo.Region region)

      Sets the region to be updated by this texture.

      Together with Gdk.MemoryTextureBuilder: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
      Since:
      4.16
    • setUpdateTexture

      public void setUpdateTexture(@Nullable Texture texture)

      Sets the texture to be updated by this texture.

      See setUpdateRegion(Region) for an explanation.

      Parameters:
      texture - the texture to update
      Since:
      4.16
    • setWidth

      public void setWidth(int width)

      Sets the width of the texture.

      The width must be set before calling build() and conform to size requirements of the provided format.

      Parameters:
      width - The texture's width or 0 to unset
      Since:
      4.16
    • builder

      public static MemoryTextureBuilder.Builder<? extends MemoryTextureBuilder.Builder> builder()
      A MemoryTextureBuilder.Builder object constructs a MemoryTextureBuilder with the specified properties. Use the various set...() methods to set properties, and finish construction with MemoryTextureBuilder.Builder.build().
      Returns:
      the builder object