// 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::{ColorState, MemoryFormat, Texture, ffi};
use glib::translate::*;

glib::wrapper! {
    #[doc(alias = "GdkMemoryTextureBuilder")]
    pub struct MemoryTextureBuilder(Object<ffi::GdkMemoryTextureBuilder, ffi::GdkMemoryTextureBuilderClass>);

    match fn {
        type_ => || ffi::gdk_memory_texture_builder_get_type(),
    }
}

impl MemoryTextureBuilder {
    #[doc(alias = "gdk_memory_texture_builder_new")]
    pub fn new() -> MemoryTextureBuilder {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gdk_memory_texture_builder_new()) }
    }

    #[doc(alias = "gdk_memory_texture_builder_build")]
    pub fn build(&self) -> Texture {
        unsafe { from_glib_full(ffi::gdk_memory_texture_builder_build(self.to_glib_none().0)) }
    }

    #[doc(alias = "gdk_memory_texture_builder_get_bytes")]
    #[doc(alias = "get_bytes")]
    pub fn bytes(&self) -> Option<glib::Bytes> {
        unsafe {
            from_glib_none(ffi::gdk_memory_texture_builder_get_bytes(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_memory_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_memory_texture_builder_get_color_state(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_memory_texture_builder_get_format")]
    #[doc(alias = "get_format")]
    pub fn format(&self) -> MemoryFormat {
        unsafe {
            from_glib(ffi::gdk_memory_texture_builder_get_format(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_memory_texture_builder_get_height")]
    #[doc(alias = "get_height")]
    pub fn height(&self) -> i32 {
        unsafe { ffi::gdk_memory_texture_builder_get_height(self.to_glib_none().0) }
    }

    #[cfg(feature = "v4_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
    #[doc(alias = "gdk_memory_texture_builder_get_offset")]
    #[doc(alias = "get_offset")]
    pub fn offset(&self, plane: u32) -> usize {
        unsafe { ffi::gdk_memory_texture_builder_get_offset(self.to_glib_none().0, plane) }
    }

    #[doc(alias = "gdk_memory_texture_builder_get_stride")]
    #[doc(alias = "get_stride")]
    pub fn stride(&self) -> usize {
        unsafe { ffi::gdk_memory_texture_builder_get_stride(self.to_glib_none().0) }
    }

    #[cfg(feature = "v4_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
    #[doc(alias = "gdk_memory_texture_builder_get_stride_for_plane")]
    #[doc(alias = "get_stride_for_plane")]
    pub fn stride_for_plane(&self, plane: u32) -> usize {
        unsafe {
            ffi::gdk_memory_texture_builder_get_stride_for_plane(self.to_glib_none().0, plane)
        }
    }

    #[doc(alias = "gdk_memory_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_memory_texture_builder_get_update_region(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_memory_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_memory_texture_builder_get_update_texture(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_memory_texture_builder_get_width")]
    #[doc(alias = "get_width")]
    pub fn width(&self) -> i32 {
        unsafe { ffi::gdk_memory_texture_builder_get_width(self.to_glib_none().0) }
    }
}

#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
impl Default for MemoryTextureBuilder {
    fn default() -> Self {
        Self::new()
    }
}

unsafe impl Send for MemoryTextureBuilder {}
unsafe impl Sync for MemoryTextureBuilder {}
