diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 124cc55c3c..da0153d383 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -8,9 +8,9 @@ pub use model_context::*; use refineable::Refineable; use crate::{ - current_platform, run_on_main, spawn_on_main, Context, LayoutId, MainThread, MainThreadOnly, - Platform, PlatformDispatcher, RootView, TextStyle, TextStyleRefinement, TextSystem, Window, - WindowContext, WindowHandle, WindowId, + current_platform, run_on_main, spawn_on_main, AssetSource, Context, LayoutId, MainThread, + MainThreadOnly, Platform, PlatformDispatcher, RootView, SvgRenderer, TextStyle, + TextStyleRefinement, TextSystem, Window, WindowContext, WindowHandle, WindowId, }; use anyhow::{anyhow, Result}; use collections::{HashMap, VecDeque}; @@ -29,16 +29,18 @@ use util::ResultExt; pub struct App(Arc>>); impl App { - pub fn production() -> Self { - Self::new(current_platform()) + pub fn production(asset_source: Arc) -> Self { + Self::new(current_platform(), asset_source) } #[cfg(any(test, feature = "test"))] pub fn test() -> Self { - Self::new(Arc::new(super::TestPlatform::new())) + let platform = Arc::new(super::TestPlatform::new()); + let asset_source = Arc::new(()); + Self::new(platform, asset_source) } - fn new(platform: Arc) -> Self { + fn new(platform: Arc, asset_source: Arc) -> Self { let dispatcher = platform.dispatcher(); let text_system = Arc::new(TextSystem::new(platform.text_system())); let entities = EntityMap::new(); @@ -49,6 +51,7 @@ impl App { platform: MainThreadOnly::new(platform, dispatcher.clone()), dispatcher, text_system, + svg_renderer: SvgRenderer::new(asset_source), pending_updates: 0, text_style_stack: Vec::new(), state_stacks_by_type: HashMap::default(), @@ -83,6 +86,7 @@ pub struct AppContext { dispatcher: Arc, text_system: Arc, pending_updates: usize, + pub(crate) svg_renderer: SvgRenderer, pub(crate) text_style_stack: Vec, pub(crate) state_stacks_by_type: HashMap>>, pub(crate) unit_entity: Handle<()>, diff --git a/crates/gpui3/src/assets.rs b/crates/gpui3/src/assets.rs index 5d737fcd2f..15af277f66 100644 --- a/crates/gpui3/src/assets.rs +++ b/crates/gpui3/src/assets.rs @@ -44,6 +44,10 @@ impl ImageData { &self.data } + pub fn into_bytes(self) -> Vec { + self.data.into_raw() + } + pub fn size(&self) -> Size { let (width, height) = self.data.dimensions(); size(width.into(), height.into()) diff --git a/crates/gpui3/src/elements/svg.rs b/crates/gpui3/src/elements/svg.rs index 70abf63cb4..dbb4ffb155 100644 --- a/crates/gpui3/src/elements/svg.rs +++ b/crates/gpui3/src/elements/svg.rs @@ -1,9 +1,9 @@ -use crate::{Element, Layout, LayoutId, Result, Style, StyleHelpers, Styled}; +use crate::{Element, Layout, LayoutId, Result, SharedString, Style, StyleHelpers, Styled}; use refineable::RefinementCascade; -use std::{borrow::Cow, marker::PhantomData}; +use std::marker::PhantomData; pub struct Svg { - path: Option>, + path: Option, style: RefinementCascade