use super::surfaces::IPlatformRenderSurface;
use super::{
AlphaFormat, IBitmapImpl, IDrawingContextLayerImpl, IGeometryImpl, IOptionalFeatureProvider,
IPlatformGraphicsContext, IPlatformRenderInterfaceRegion, IRenderTarget, IRenderTargetBitmapImpl,
IStreamGeometryBuilder, IWriteableBitmapImpl, PixelFormat,
};
use crate::media::imaging::BitmapInterpolationMode;
use crate::media::{FillRule, GeometryCombineMode};
use crate::{PixelSize, Point, Rect, Vector};
use std::io::Read;
use std::rc::Rc;
use std::sync::Arc;
pub trait IPlatformRenderInterface: 'static {
fn create_ellipse_geometry(&self, rect: Rect) -> Arc<dyn IGeometryImpl>;
fn create_line_geometry(&self, p1: Point, p2: Point) -> Arc<dyn IGeometryImpl>;
fn create_rectangle_geometry(&self, rect: Rect) -> Arc<dyn IGeometryImpl>;
fn create_stream_geometry_builder(&self, source: Option<&dyn IGeometryImpl>) -> Box<dyn IStreamGeometryBuilder>;
fn create_geometry_group(&self, fill_rule: FillRule, children: &[Arc<dyn IGeometryImpl>]) -> Arc<dyn IGeometryImpl>;
fn create_combined_geometry(
&self,
combine_mode: GeometryCombineMode,
g1: Arc<dyn IGeometryImpl>,
g2: Arc<dyn IGeometryImpl>,
) -> Arc<dyn IGeometryImpl>;
fn build_glyph_run_geometry(&self, glyph_run: &crate::media::GlyphRun) -> Arc<dyn IGeometryImpl>;
fn create_glyph_run(
&self,
glyph_typeface: &Rc<crate::media::GlyphTypeface>,
font_rendering_em_size: f64,
glyph_infos: &[crate::media::text_formatting::GlyphInfo],
baseline_origin: Point,
) -> std::sync::Arc<dyn super::IGlyphRunImpl>;
fn create_render_target_bitmap(&self, size: PixelSize, dpi: Vector) -> std::sync::Arc<dyn IRenderTargetBitmapImpl>;
fn create_writeable_bitmap(
&self,
size: PixelSize,
dpi: Vector,
format: PixelFormat,
alpha_format: AlphaFormat,
) -> std::sync::Arc<dyn IWriteableBitmapImpl>;
fn load_bitmap_from_file(&self, file_name: &str) -> std::io::Result<std::sync::Arc<crate::platform::SharedBitmapImpl>>;
fn load_bitmap(&self, stream: &mut dyn Read) -> std::io::Result<std::sync::Arc<crate::platform::SharedBitmapImpl>>;
fn load_writeable_bitmap_to_width(
&self,
stream: &mut dyn Read,
width: i32,
interpolation_mode: BitmapInterpolationMode,
) -> std::io::Result<std::sync::Arc<dyn IWriteableBitmapImpl>>;
fn load_writeable_bitmap_to_height(
&self,
stream: &mut dyn Read,
height: i32,
interpolation_mode: BitmapInterpolationMode,
) -> std::io::Result<std::sync::Arc<dyn IWriteableBitmapImpl>>;
fn load_writeable_bitmap_from_file(&self, file_name: &str) -> std::io::Result<std::sync::Arc<dyn IWriteableBitmapImpl>>;
fn load_writeable_bitmap(&self, stream: &mut dyn Read) -> std::io::Result<std::sync::Arc<dyn IWriteableBitmapImpl>>;
fn load_bitmap_to_width(
&self,
stream: &mut dyn Read,
width: i32,
interpolation_mode: BitmapInterpolationMode,
) -> std::io::Result<std::sync::Arc<crate::platform::SharedBitmapImpl>>;
fn load_bitmap_to_height(
&self,
stream: &mut dyn Read,
height: i32,
interpolation_mode: BitmapInterpolationMode,
) -> std::io::Result<std::sync::Arc<crate::platform::SharedBitmapImpl>>;
fn resize_bitmap(
&self,
bitmap_impl: &dyn IBitmapImpl,
destination_size: PixelSize,
interpolation_mode: BitmapInterpolationMode,
) -> std::sync::Arc<crate::platform::SharedBitmapImpl>;
fn load_bitmap_from_pixels(
&self,
format: PixelFormat,
alpha_format: AlphaFormat,
data: &[u8],
size: PixelSize,
dpi: Vector,
stride: i32,
) -> std::sync::Arc<crate::platform::SharedBitmapImpl>;
fn create_backend_context(
&self,
graphics_api_context: Option<Rc<dyn IPlatformGraphicsContext>>,
) -> Rc<dyn IPlatformRenderInterfaceContext>;
fn supports_individual_round_rects(&self) -> bool;
fn default_alpha_format(&self) -> AlphaFormat;
fn default_pixel_format(&self) -> PixelFormat;
fn is_supported_bitmap_pixel_format(&self, format: PixelFormat) -> bool;
fn supports_regions(&self) -> bool;
fn create_region(&self) -> Rc<dyn IPlatformRenderInterfaceRegion>;
}
pub trait IPlatformRenderInterfaceContext: IOptionalFeatureProvider {
fn create_render_target(&self, surfaces: &[std::sync::Arc<dyn IPlatformRenderSurface>]) -> Rc<dyn IRenderTarget>;
fn create_offscreen_render_target(
&self,
pixel_size: PixelSize,
scaling: Vector,
enable_text_antialiasing: bool,
) -> Rc<dyn IDrawingContextLayerImpl>;
fn is_lost(&self) -> bool;
fn max_offscreen_render_target_pixel_size(&self) -> Option<PixelSize>;
fn public_features(&self) -> std::collections::HashMap<std::any::TypeId, Rc<dyn std::any::Any>> {
std::collections::HashMap::new()
}
fn is_ready_to_create_render_target(&self, _surfaces: &[std::sync::Arc<dyn IPlatformRenderSurface>]) -> bool {
true
}
fn dispose(&self);
}