gdk4/auto/gl_texture_builder.rs
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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
// 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
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
use crate::ColorState;
use crate::{ffi, GLContext, MemoryFormat, Texture};
use glib::translate::*;
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
};
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
use std::boxed::Box as Box_;
glib::wrapper! {
/// [`GLTextureBuilder`][crate::GLTextureBuilder] is a builder 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
///
///
/// #### `color-state`
/// The color state of the texture.
///
/// Readable | Writeable
///
///
/// #### `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 color state previously set via gdk_gl_texture_builder_set_color_state().
///
/// # Returns
///
/// the color state
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
#[doc(alias = "gdk_gl_texture_builder_get_color_state")]
#[doc(alias = "get_color_state")]
#[doc(alias = "color-state")]
pub fn color_state(&self) -> ColorState {
unsafe {
from_glib_none(ffi::gdk_gl_texture_builder_get_color_state(
self.to_glib_none().0,
))
}
}
/// 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")]
#[doc(alias = "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")]
#[doc(alias = "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")]
#[doc(alias = "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) }
}
/// 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.
/// ## `color_state`
/// a [`ColorState`][crate::ColorState]
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
#[doc(alias = "gdk_gl_texture_builder_set_color_state")]
#[doc(alias = "color-state")]
pub fn set_color_state(&self, color_state: &ColorState) {
unsafe {
ffi::gdk_gl_texture_builder_set_color_state(
self.to_glib_none().0,
color_state.to_glib_none().0,
);
}
}
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
#[doc(alias = "color-state")]
pub fn connect_color_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_color_state_trampoline<
F: Fn(&GLTextureBuilder) + Send + Sync + 'static,
>(
this: *mut ffi::GdkGLTextureBuilder,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::color-state\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_color_state_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
#[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 {}