TextureProtocol

public protocol TextureProtocol : ObjectProtocol, PaintableProtocol

The TextureProtocol protocol exposes the methods and properties of an underlying GdkTexture instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Texture. Alternatively, use TextureRef as a lighweight, unowned reference if you already have an instance you just want to use.

GdkTexture is the basic element used to refer to pixel data.

It is primarily meant for pixel data that will not change over multiple frames, and will be used for a long time.

There are various ways to create GdkTexture objects from a GdkPixbuf, or a Cairo surface, or other pixel data.

The ownership of the pixel data is transferred to the GdkTexture instance; you can only make a copy of it, via [methodGdk.Texture.download].

GdkTexture is an immutable object: That means you cannot change anything about it other than increasing the reference count via g_object_ref().

  • ptr

    Untyped pointer to the underlying GdkTexture instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • texture_ptr Default implementation

    Typed pointer to the underlying GdkTexture instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkTexture instance.

    Declaration

    Swift

    var texture_ptr: UnsafeMutablePointer<GdkTexture>! { get }
  • Required Initialiser for types conforming to TextureProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Texture Class

  • Bind a TexturePropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: TexturePropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Texture property

    Declaration

    Swift

    @inlinable
    func get(property: TexturePropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Texture property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: TexturePropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Texture Class: TextureProtocol extension (methods and fields)

  • download(data:stride:) Extension method

    Downloads the texture into local memory.

    This may be an expensive operation, as the actual texture data may reside on a GPU or on a remote display server.

    The data format of the downloaded data is equivalent to CAIRO_FORMAT_ARGB32, so every downloaded pixel requires 4 bytes of memory.

    Downloading a texture into a Cairo image surface:

    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                          gdk_texture_get_width (texture),
                                          gdk_texture_get_height (texture));
    gdk_texture_download (texture,
                          cairo_image_surface_get_data (surface),
                          cairo_image_surface_get_stride (surface));
    cairo_surface_mark_dirty (surface);
    

    Declaration

    Swift

    @inlinable
    func download(data: UnsafeMutablePointer<guchar>!, stride: Int)
  • getHeight() Extension method

    Returns the height of the texture, in pixels.

    Declaration

    Swift

    @inlinable
    func getHeight() -> Int
  • getWidth() Extension method

    Returns the width of texture, in pixels.

    Declaration

    Swift

    @inlinable
    func getWidth() -> Int
  • saveToPng(filename:) Extension method

    Store the given texture to the filename as a PNG file.

    This is a utility function intended for debugging and testing. If you want more control over formats, proper error handling or want to store to a GFile or other location, you might want to look into using the gdk-pixbuf library.

    Declaration

    Swift

    @inlinable
    func saveToPng(filename: UnsafePointer<CChar>!) -> Bool
  • pixbufGetFromTexture() Extension method

    Creates a new pixbuf from texture.

    This should generally not be used in newly written code as later stages will almost certainly convert the pixbuf back into a texture to draw it on screen.

    Declaration

    Swift

    @inlinable
    func pixbufGetFromTexture() -> PixbufRef!
  • height Extension method

    The height of the texture, in pixels.

    Declaration

    Swift

    @inlinable
    var height: Int { get }
  • width Extension method

    The width of the texture, in pixels.

    Declaration

    Swift

    @inlinable
    var width: Int { get }