Checkpoint: render SVGs

This commit is contained in:
Antonio Scandurra 2023-10-04 10:51:47 +02:00
parent a1ee2db6d1
commit 4cf2ba20c2
13 changed files with 187 additions and 175 deletions

View file

@ -7,7 +7,7 @@ mod test;
use crate::{
AnyWindowHandle, Bounds, DevicePixels, Font, FontId, FontMetrics, GlyphId, Pixels, Point,
RenderGlyphParams, Result, Scene, ShapedLine, SharedString, Size,
RenderGlyphParams, RenderSvgParams, Result, Scene, ShapedLine, SharedString, Size,
};
use anyhow::anyhow;
use async_task::Runnable;
@ -147,7 +147,7 @@ pub trait PlatformWindow {
fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool;
fn draw(&self, scene: Scene);
fn glyph_atlas(&self) -> Arc<dyn PlatformAtlas>;
fn monochrome_sprite_atlas(&self) -> Arc<dyn PlatformAtlas>;
}
pub trait PlatformDispatcher: Send + Sync {
@ -178,7 +178,7 @@ pub trait PlatformTextSystem: Send + Sync {
#[derive(PartialEq, Eq, Hash, Clone)]
pub enum AtlasKey {
Glyph(RenderGlyphParams),
// Svg(RenderSvgParams),
Svg(RenderSvgParams),
}
impl From<RenderGlyphParams> for AtlasKey {
@ -187,6 +187,12 @@ impl From<RenderGlyphParams> for AtlasKey {
}
}
impl From<RenderSvgParams> for AtlasKey {
fn from(params: RenderSvgParams) -> Self {
Self::Svg(params)
}
}
pub trait PlatformAtlas: Send + Sync {
fn get_or_insert_with(
&self,