1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{GLContext, MemoryFormat, Texture};
use glib::translate::*;
use std::fmt;
glib::wrapper! {
/// [`GLTextureBuilder`][crate::GLTextureBuilder] is a buider used to construct [`Texture`][crate::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 [`context`][struct@crate::GLTextureBuilder#context],
/// [`id`][struct@crate::GLTextureBuilder#id], [`width`][struct@crate::GLTextureBuilder#width], and
/// [`height`][struct@crate::GLTextureBuilder#height] are mandatory - and then call
/// [`build()`][Self::build()] to create the new texture.
///
/// [`GLTextureBuilder`][crate::GLTextureBuilder] can be used for quick one-shot construction of
/// textures as well as kept around and reused to construct multiple textures.
///
/// ## Properties
///
///
/// #### `context`
/// The context owning the texture.
///
/// Readable | Writeable
///
///
/// #### `format`
/// The format when downloading the texture.
///
/// Readable | Writeable
///
///
/// #### `has-mipmap`
/// If the texture has a mipmap.
///
/// Readable | Writeable
///
///
/// #### `height`
/// The height of the texture.
///
/// Readable | Writeable
///
///
/// #### `id`
/// The texture ID to use.
///
/// Readable | Writeable
///
///
/// #### `sync`
/// An optional `GLSync` object.
///
/// If this is set, GTK will wait on it before using the texture.
///
/// Readable | Writeable
///
///
/// #### `update-region`
/// The update region for [`update-texture`][struct@crate::GLTextureBuilder#update-texture].
///
/// Readable | Writeable
///
///
/// #### `update-texture`
/// The texture [`update-region`][struct@crate::GLTextureBuilder#update-region] is an update for.
///
/// Readable | Writeable
///
///
/// #### `width`
/// The width of the texture.
///
/// Readable | Writeable
#[doc(alias = "GdkGLTextureBuilder")]
pub struct GLTextureBuilder(Object<ffi::GdkGLTextureBuilder, ffi::GdkGLTextureBuilderClass>);
match fn {
type_ => || ffi::gdk_gl_texture_builder_get_type(),
}
}
impl GLTextureBuilder {
/// Creates a new texture builder.
///
/// # Returns
///
/// the new `GdkTextureBuilder`
#[doc(alias = "gdk_gl_texture_builder_new")]
pub fn new() -> GLTextureBuilder {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_gl_texture_builder_new()) }
}
/// Gets the context previously set via gdk_gl_texture_builder_set_context() or
/// [`None`] if none was set.
///
/// # Returns
///
/// The context
#[doc(alias = "gdk_gl_texture_builder_get_context")]
#[doc(alias = "get_context")]
pub fn context(&self) -> Option<GLContext> {
unsafe {
from_glib_none(ffi::gdk_gl_texture_builder_get_context(
self.to_glib_none().0,
))
}
}
/// Gets the format previously set via gdk_gl_texture_builder_set_format().
///
/// # Returns
///
/// The format
#[doc(alias = "gdk_gl_texture_builder_get_format")]
#[doc(alias = "get_format")]
pub fn format(&self) -> MemoryFormat {
unsafe {
from_glib(ffi::gdk_gl_texture_builder_get_format(
self.to_glib_none().0,
))
}
}
/// Gets whether the texture has a mipmap.
///
/// # Returns
///
/// Whether the texture has a mipmap
#[doc(alias = "gdk_gl_texture_builder_get_has_mipmap")]
#[doc(alias = "get_has_mipmap")]
pub fn has_mipmap(&self) -> bool {
unsafe {
from_glib(ffi::gdk_gl_texture_builder_get_has_mipmap(
self.to_glib_none().0,
))
}
}
/// Gets the height previously set via gdk_gl_texture_builder_set_height() or
/// 0 if the height wasn't set.
///
/// # Returns
///
/// The height
#[doc(alias = "gdk_gl_texture_builder_get_height")]
#[doc(alias = "get_height")]
pub fn height(&self) -> i32 {
unsafe { ffi::gdk_gl_texture_builder_get_height(self.to_glib_none().0) }
}
/// Gets the texture id previously set via gdk_gl_texture_builder_set_id() or
/// 0 if the id wasn't set.
///
/// # Returns
///
/// The id
#[doc(alias = "gdk_gl_texture_builder_get_id")]
#[doc(alias = "get_id")]
pub fn id(&self) -> u32 {
unsafe { ffi::gdk_gl_texture_builder_get_id(self.to_glib_none().0) }
}
/// Gets the region previously set via gdk_gl_texture_builder_set_update_region() or
/// [`None`] if none was set.
///
/// # Returns
///
/// The region
#[doc(alias = "gdk_gl_texture_builder_get_update_region")]
#[doc(alias = "get_update_region")]
pub fn update_region(&self) -> Option<cairo::Region> {
unsafe {
from_glib_none(ffi::gdk_gl_texture_builder_get_update_region(
self.to_glib_none().0,
))
}
}
/// Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() or
/// [`None`] if none was set.
///
/// # Returns
///
/// The texture
#[doc(alias = "gdk_gl_texture_builder_get_update_texture")]
#[doc(alias = "get_update_texture")]
pub fn update_texture(&self) -> Option<Texture> {
unsafe {
from_glib_none(ffi::gdk_gl_texture_builder_get_update_texture(
self.to_glib_none().0,
))
}
}
/// Gets the width previously set via gdk_gl_texture_builder_set_width() or
/// 0 if the width wasn't set.
///
/// # Returns
///
/// The width
#[doc(alias = "gdk_gl_texture_builder_get_width")]
#[doc(alias = "get_width")]
pub fn width(&self) -> i32 {
unsafe { ffi::gdk_gl_texture_builder_get_width(self.to_glib_none().0) }
}
}
#[cfg(feature = "v4_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
impl Default for GLTextureBuilder {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for GLTextureBuilder {}
unsafe impl Sync for GLTextureBuilder {}
impl fmt::Display for GLTextureBuilder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("GLTextureBuilder")
}
}