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
use super::BackendApi;
use crate::prelude::*;
use skia_bindings::{self as sb, skgpu_MutableTextureState};
use std::fmt;

pub type MutableTextureState = Handle<skgpu_MutableTextureState>;
unsafe_send_sync!(MutableTextureState);

impl NativeDrop for skgpu_MutableTextureState {
    fn drop(&mut self) {
        unsafe { sb::C_MutableTextureState_destruct(self) }
    }
}

impl NativeClone for skgpu_MutableTextureState {
    fn clone(&self) -> Self {
        construct(|s| unsafe { sb::C_MutableTextureState_CopyConstruct(s, self) })
    }
}

impl Default for MutableTextureState {
    fn default() -> Self {
        Self::construct(|s| unsafe { sb::C_MutableTextureState_Construct(s) })
    }
}

impl fmt::Debug for MutableTextureState {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mut str = f.debug_struct("MutableTextureState");
        #[cfg(feature = "vulkan")]
        {
            str.field("image_layout", &self.vk_image_layout())
                .field("queue_family_index", &self.queue_family_index());
        }
        str.field("backend", &self.backend()).finish()
    }
}

impl MutableTextureState {
    #[cfg(feature = "vulkan")]
    pub fn new_vk(layout: crate::gpu::vk::ImageLayout, queue_family_index: u32) -> Self {
        Self::construct(|ptr| unsafe {
            sb::C_MutableTextureState_ConstructVK(ptr, layout, queue_family_index)
        })
    }
    #[cfg(feature = "vulkan")]
    pub fn vk_image_layout(&self) -> sb::VkImageLayout {
        unsafe { sb::C_MutableTextureState_getVkImageLayout(self.native()) }
    }

    #[cfg(feature = "vulkan")]
    pub fn queue_family_index(&self) -> u32 {
        unsafe { sb::C_MutableTextureState_getQueueFamilyIndex(self.native()) }
    }

    pub fn backend(&self) -> BackendApi {
        unsafe { sb::C_MutableTextureState_backend(self.native()) }
    }
}