| 1 | use std::fmt; |
| 2 | |
| 3 | use skia_bindings::{self as sb, skgpu_MutableTextureState, SkRefCntBase}; |
| 4 | |
| 5 | use super::BackendApi; |
| 6 | use crate::prelude::*; |
| 7 | |
| 8 | pub type MutableTextureState = RCHandle<skgpu_MutableTextureState>; |
| 9 | unsafe_send_sync!(MutableTextureState); |
| 10 | |
| 11 | impl NativeRefCountedBase for skgpu_MutableTextureState { |
| 12 | type Base = SkRefCntBase; |
| 13 | } |
| 14 | |
| 15 | impl Default for MutableTextureState { |
| 16 | fn default() -> Self { |
| 17 | MutableTextureState::from_ptr(unsafe { sb::C_MutableTextureState_Construct() }).unwrap() |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | impl fmt::Debug for MutableTextureState { |
| 22 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 23 | let mut str: DebugStruct<'_, '_> = f.debug_struct(name:"MutableTextureState" ); |
| 24 | #[cfg (feature = "vulkan" )] |
| 25 | { |
| 26 | str.field( |
| 27 | "image_layout" , |
| 28 | &crate::gpu::vk::mutable_texture_states::get_vk_image_layout(self), |
| 29 | ) |
| 30 | .field( |
| 31 | "queue_family_index" , |
| 32 | &crate::gpu::vk::mutable_texture_states::get_vk_queue_family_index(self), |
| 33 | ); |
| 34 | } |
| 35 | str.field(name:"backend" , &self.backend()).finish() |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | impl MutableTextureState { |
| 40 | pub fn copied(&self) -> Self { |
| 41 | MutableTextureState::from_ptr(unsafe { |
| 42 | sb::C_MutableTextureState_CopyConstruct(self.native()) |
| 43 | }) |
| 44 | .unwrap() |
| 45 | } |
| 46 | |
| 47 | #[cfg (feature = "vulkan" )] |
| 48 | #[deprecated ( |
| 49 | since = "0.72.0" , |
| 50 | note = "use gpu::vk::mutable_texture_states::new_vulkan()" |
| 51 | )] |
| 52 | pub fn new_vk(layout: crate::gpu::vk::ImageLayout, queue_family_index: u32) -> Self { |
| 53 | crate::gpu::vk::mutable_texture_states::new_vulkan(layout, queue_family_index) |
| 54 | } |
| 55 | |
| 56 | #[cfg (feature = "vulkan" )] |
| 57 | #[deprecated ( |
| 58 | since = "0.72.0" , |
| 59 | note = "use gpu::vk::mutable_texture_states::get_vk_image_layout()" |
| 60 | )] |
| 61 | pub fn vk_image_layout(&self) -> sb::VkImageLayout { |
| 62 | crate::gpu::vk::mutable_texture_states::get_vk_image_layout(self) |
| 63 | } |
| 64 | |
| 65 | #[cfg (feature = "vulkan" )] |
| 66 | #[deprecated ( |
| 67 | since = "0.72.0" , |
| 68 | note = "use gpu::vk::mutable_texture_states::get_vk_queue_family_index()" |
| 69 | )] |
| 70 | pub fn queue_family_index(&self) -> u32 { |
| 71 | crate::gpu::vk::mutable_texture_states::get_vk_queue_family_index(self) |
| 72 | } |
| 73 | |
| 74 | pub fn backend(&self) -> BackendApi { |
| 75 | unsafe { sb::C_MutableTextureState_backend(self.native()) } |
| 76 | } |
| 77 | } |
| 78 | |