#[cfg(wgpu_core)]
use core::ops::Deref;
use crate::*;
#[derive(Debug, Clone)]
pub struct TextureView {
pub(crate) inner: dispatch::DispatchTextureView,
pub(crate) texture: Texture,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(TextureView: Send, Sync);
crate::cmp::impl_eq_ord_hash_proxy!(TextureView => .inner);
impl TextureView {
pub fn texture(&self) -> &Texture {
&self.texture
}
#[cfg(wgpu_core)]
pub unsafe fn as_hal<A: wgc::hal_api::HalApi>(
&self,
) -> Option<impl Deref<Target = A::TextureView>> {
let view = self.inner.as_core_opt()?;
unsafe { view.context.texture_view_as_hal::<A>(view) }
}
#[cfg(custom)]
pub fn as_custom<T: custom::TextureViewInterface>(&self) -> Option<&T> {
self.inner.as_custom()
}
}
pub type TextureViewDescriptor<'a> = wgt::TextureViewDescriptor<Label<'a>>;
static_assertions::assert_impl_all!(TextureViewDescriptor<'_>: Send, Sync);