use crate::context::ContextID;
use crate::platform::generic::egl::ffi::EGLImageKHR;
use euclid::default::Size2D;
use glow::Texture;
use std::fmt::{self, Debug, Formatter};
use std::marker::PhantomData;
use std::thread;
pub use crate::platform::generic::egl::context::ContextDescriptor;
#[cfg(android_platform)]
mod android_surface;
#[cfg(android_platform)]
pub use android_surface::*;
#[cfg(ohos_platform)]
mod ohos_surface;
#[cfg(ohos_platform)]
pub use ohos_surface::*;
pub struct Surface {
pub(crate) context_id: ContextID,
pub(crate) size: Size2D<i32>,
pub(crate) objects: SurfaceObjects,
pub(crate) destroyed: bool,
}
pub struct SurfaceTexture {
pub(crate) surface: Surface,
pub(crate) local_egl_image: EGLImageKHR,
pub(crate) texture_object: Option<Texture>,
pub(crate) phantom: PhantomData<*const ()>,
}
unsafe impl Send for Surface {}
impl Debug for Surface {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
write!(formatter, "Surface({:x})", self.id().0)
}
}
impl Drop for Surface {
fn drop(&mut self) {
if !self.destroyed && !thread::panicking() {
panic!("Should have destroyed the surface first with `destroy_surface()`!")
}
}
}
impl Debug for SurfaceTexture {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
write!(f, "SurfaceTexture({:?})", self.surface)
}
}