mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 23:31:38 +02:00
🐛 Fix asynchronous content dependant rendering (#6142)
* 🐛 Fix custom fonts rendering * 🐛 Fix asynchronous content dependant rendering * 🎉 Renaming clear_cache to clear_drawing_cache
This commit is contained in:
parent
9653e72e47
commit
065b50f5a2
4 changed files with 24 additions and 10 deletions
|
@ -777,8 +777,8 @@
|
||||||
(h/call internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)))
|
(h/call internal-module "_set_view" zoom (- (:x vbox)) (- (:y vbox)))
|
||||||
(render nil))
|
(render nil))
|
||||||
|
|
||||||
(defn clear-cache []
|
(defn clear-drawing-cache []
|
||||||
(h/call internal-module "_clear_cache"))
|
(h/call internal-module "_clear_drawing_cache"))
|
||||||
|
|
||||||
(defn- store-all-fonts
|
(defn- store-all-fonts
|
||||||
[fonts]
|
[fonts]
|
||||||
|
@ -803,7 +803,9 @@
|
||||||
(->> (rx/from pending)
|
(->> (rx/from pending)
|
||||||
(rx/mapcat identity)
|
(rx/mapcat identity)
|
||||||
(rx/reduce conj [])
|
(rx/reduce conj [])
|
||||||
(rx/subs! request-render))))
|
(rx/subs! (fn [_]
|
||||||
|
(clear-drawing-cache)
|
||||||
|
(request-render "set-fonts"))))))
|
||||||
|
|
||||||
(defn set-objects
|
(defn set-objects
|
||||||
[objects]
|
[objects]
|
||||||
|
@ -886,13 +888,15 @@
|
||||||
(let [pending' (concat (set-shape-fills fills) (set-shape-strokes strokes))]
|
(let [pending' (concat (set-shape-fills fills) (set-shape-strokes strokes))]
|
||||||
(recur (inc index) (into pending pending'))))
|
(recur (inc index) (into pending pending'))))
|
||||||
pending))]
|
pending))]
|
||||||
(clear-cache)
|
(clear-drawing-cache)
|
||||||
(request-render "set-objects")
|
(request-render "set-objects")
|
||||||
(when-let [pending (seq pending)]
|
(when-let [pending (seq pending)]
|
||||||
(->> (rx/from pending)
|
(->> (rx/from pending)
|
||||||
(rx/mapcat identity)
|
(rx/mapcat identity)
|
||||||
(rx/reduce conj [])
|
(rx/reduce conj [])
|
||||||
(rx/subs! request-render)))))
|
(rx/subs! (fn [_]
|
||||||
|
(clear-drawing-cache)
|
||||||
|
(request-render "set-objects")))))))
|
||||||
|
|
||||||
(defn uuid->u8
|
(defn uuid->u8
|
||||||
[id]
|
[id]
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
;; when something synced with wasm
|
;; when something synced with wasm
|
||||||
;; is modified, we need to request
|
;; is modified, we need to request
|
||||||
;; a new render.
|
;; a new render.
|
||||||
(api/clear-cache)
|
(api/clear-drawing-cache)
|
||||||
(api/request-render "set-wasm-attrs")))
|
(api/request-render "set-wasm-attrs")))
|
||||||
|
|
||||||
(defn- impl-assoc
|
(defn- impl-assoc
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub extern "C" fn clean_up() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn clear_cache() {
|
pub extern "C" fn clear_drawing_cache() {
|
||||||
with_state!(state, {
|
with_state!(state, {
|
||||||
state.rebuild_tiles();
|
state.rebuild_tiles();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use skia_safe::{self as skia, textlayout, Font};
|
use skia_safe::{self as skia, textlayout, Font, FontMgr};
|
||||||
|
|
||||||
use crate::shapes::FontFamily;
|
use crate::shapes::FontFamily;
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ impl FontStore {
|
||||||
font_provider.register_typeface(emoji_font, DEFAULT_EMOJI_FONT);
|
font_provider.register_typeface(emoji_font, DEFAULT_EMOJI_FONT);
|
||||||
|
|
||||||
let mut font_collection = skia::textlayout::FontCollection::new();
|
let mut font_collection = skia::textlayout::FontCollection::new();
|
||||||
font_collection.set_default_font_manager(Some(font_provider.clone().into()), None);
|
font_collection.set_default_font_manager(FontMgr::default(), None);
|
||||||
font_collection.set_dynamic_font_manager(Some(font_provider.clone().into()));
|
font_collection.set_dynamic_font_manager(FontMgr::from(font_provider.clone()));
|
||||||
|
|
||||||
let debug_typeface = font_provider
|
let debug_typeface = font_provider
|
||||||
.match_family_style("robotomono-regular", skia::FontStyle::default())
|
.match_family_style("robotomono-regular", skia::FontStyle::default())
|
||||||
|
@ -72,6 +72,8 @@ impl FontStore {
|
||||||
self.font_provider
|
self.font_provider
|
||||||
.register_typeface(typeface, alias.as_str());
|
.register_typeface(typeface, alias.as_str());
|
||||||
|
|
||||||
|
self.refresh_font_collection();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,4 +81,12 @@ impl FontStore {
|
||||||
let serialized = format!("{}", family);
|
let serialized = format!("{}", family);
|
||||||
self.font_provider.family_names().any(|x| x == serialized)
|
self.font_provider.family_names().any(|x| x == serialized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn refresh_font_collection(&mut self) {
|
||||||
|
self.font_collection = skia::textlayout::FontCollection::new();
|
||||||
|
self.font_collection
|
||||||
|
.set_default_font_manager(FontMgr::default(), None);
|
||||||
|
self.font_collection
|
||||||
|
.set_dynamic_font_manager(FontMgr::from(self.font_provider.clone()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue