Checkpoint: render SVGs
This commit is contained in:
parent
a1ee2db6d1
commit
4cf2ba20c2
13 changed files with 187 additions and 175 deletions
|
@ -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<Mutex<MainThread<AppContext>>>);
|
||||
|
||||
impl App {
|
||||
pub fn production() -> Self {
|
||||
Self::new(current_platform())
|
||||
pub fn production(asset_source: Arc<dyn AssetSource>) -> 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<dyn Platform>) -> Self {
|
||||
fn new(platform: Arc<dyn Platform>, asset_source: Arc<dyn AssetSource>) -> 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<dyn PlatformDispatcher>,
|
||||
text_system: Arc<TextSystem>,
|
||||
pending_updates: usize,
|
||||
pub(crate) svg_renderer: SvgRenderer,
|
||||
pub(crate) text_style_stack: Vec<TextStyleRefinement>,
|
||||
pub(crate) state_stacks_by_type: HashMap<TypeId, Vec<Box<dyn Any + Send + Sync>>>,
|
||||
pub(crate) unit_entity: Handle<()>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue