clutter/auto/
texture_node.rs

1use crate::{Color, PaintNode, PipelineNode, ScalingFilter};
2use glib::{
3    object::{Cast, IsA},
4    translate::*,
5};
6use std::fmt;
7
8glib_wrapper! {
9    pub struct TextureNode(Object<ffi::ClutterTextureNode, ffi::ClutterTextureNodeClass, TextureNodeClass>) @extends PipelineNode, PaintNode;
10
11    match fn {
12        get_type => || ffi::clutter_texture_node_get_type(),
13    }
14}
15
16impl TextureNode {
17    /// Creates a new `PaintNode` that will paint the passed `texture`.
18    ///
19    /// This function will take a reference on `texture`, so it is safe to
20    /// call `cogl_object_unref` on `texture` when it returns.
21    ///
22    /// The `color` must not be pre-multiplied with its `Color.alpha`
23    /// channel value; if `color` is `None`, a fully opaque white color will
24    /// be used for blending.
25    /// ## `texture`
26    /// a `cogl::Texture`
27    /// ## `color`
28    /// a `Color` used for blending, or `None`
29    /// ## `min_filter`
30    /// the minification filter for the texture
31    /// ## `mag_filter`
32    /// the magnification filter for the texture
33    ///
34    /// # Returns
35    ///
36    /// the newly created `PaintNode`.
37    ///  Use `PaintNodeExt::unref` when done
38    pub fn new<P: IsA<cogl::Texture>>(
39        texture: &P,
40        color: Option<&Color>,
41        min_filter: ScalingFilter,
42        mag_filter: ScalingFilter,
43    ) -> TextureNode {
44        unsafe {
45            PaintNode::from_glib_full(ffi::clutter_texture_node_new(
46                texture.as_ref().to_glib_none().0,
47                color.to_glib_none().0,
48                min_filter.to_glib(),
49                mag_filter.to_glib(),
50            ))
51            .unsafe_cast()
52        }
53    }
54}
55
56impl fmt::Display for TextureNode {
57    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
58        write!(f, "TextureNode")
59    }
60}