use crate::{IVulkanPlatformGraphicsContext, IVulkanRenderTarget};
use ferroui_base::platform::surfaces::IPlatformRenderSurface;
use ferroui_base::PixelSize;
use std::any::TypeId;
use std::rc::Rc;
use std::sync::Arc;
pub trait IVulkanKhrSurfacePlatformSurface: IPlatformRenderSurface {
fn scaling(&self) -> f64;
fn size(&self) -> PixelSize;
fn create_surface(&self, context: &dyn IVulkanPlatformGraphicsContext) -> u64;
fn dispose(&self);
}
pub fn try_get_vulkan_khr_surface(
surface: &dyn IPlatformRenderSurface,
) -> Option<Rc<dyn IVulkanKhrSurfacePlatformSurface>> {
surface
.try_get_surface_kind(TypeId::of::<dyn IVulkanKhrSurfacePlatformSurface>())?
.downcast_ref::<Rc<dyn IVulkanKhrSurfacePlatformSurface>>()
.cloned()
}
pub trait IVulkanRenderTargetPlatformSurface: IPlatformRenderSurface {
fn create_render_target(&self, context: &Rc<dyn IVulkanPlatformGraphicsContext>) -> Rc<dyn IVulkanRenderTarget>;
}
pub fn try_get_vulkan_render_target_surface(
surface: &dyn IPlatformRenderSurface,
) -> Option<Rc<dyn IVulkanRenderTargetPlatformSurface>> {
surface
.try_get_surface_kind(TypeId::of::<dyn IVulkanRenderTargetPlatformSurface>())?
.downcast_ref::<Rc<dyn IVulkanRenderTargetPlatformSurface>>()
.cloned()
}
pub trait IVulkanKhrSurfacePlatformSurfaceFactory: Send + Sync {
fn can_render_to_surface(
&self,
context: &dyn IVulkanPlatformGraphicsContext,
surface: &Arc<dyn IPlatformRenderSurface>,
) -> bool;
fn create_surface(
&self,
context: &dyn IVulkanPlatformGraphicsContext,
surface: &Arc<dyn IPlatformRenderSurface>,
) -> Rc<dyn IVulkanKhrSurfacePlatformSurface>;
}