WIP: Start on rendering scenes via presenter

This commit is contained in:
Nathan Sobo 2021-03-18 21:33:16 -06:00
parent e809d6119a
commit 605bdd62dd
12 changed files with 495 additions and 388 deletions

View file

@ -7,22 +7,22 @@ use crate::{
AssetCache, Scene,
};
use pathfinder_geometry::vector::{vec2f, Vector2F};
use std::{any::Any, collections::HashMap, rc::Rc};
use std::{any::Any, collections::HashMap, sync::Arc};
pub struct Presenter {
window_id: usize,
rendered_views: HashMap<usize, Box<dyn Element>>,
parents: HashMap<usize, usize>,
font_cache: Rc<FontCache>,
font_cache: Arc<FontCache>,
text_layout_cache: TextLayoutCache,
asset_cache: Rc<AssetCache>,
asset_cache: Arc<AssetCache>,
}
impl Presenter {
pub fn new(
window_id: usize,
font_cache: Rc<FontCache>,
asset_cache: Rc<AssetCache>,
font_cache: Arc<FontCache>,
asset_cache: Arc<AssetCache>,
app: &MutableAppContext,
) -> Self {
Self {
@ -35,7 +35,7 @@ impl Presenter {
}
}
fn invalidate(&mut self, invalidation: WindowInvalidation, app: &AppContext) {
pub fn invalidate(&mut self, invalidation: WindowInvalidation, app: &AppContext) {
for view_id in invalidation.updated {
self.rendered_views
.insert(view_id, app.render_view(self.window_id, view_id).unwrap());
@ -52,9 +52,9 @@ impl Presenter {
scale_factor: f32,
app: &mut MutableAppContext,
) -> Scene {
self.layout(window_size, app.ctx());
self.layout(window_size, app.downgrade());
self.after_layout(app);
let scene = self.paint(window_size, scale_factor, app.ctx());
let scene = self.paint(window_size, scale_factor, app.downgrade());
self.text_layout_cache.finish_frame();
scene
}