mirror of
https://github.com/penpot/penpot.git
synced 2025-02-15 11:38:24 -05:00
WIP: improve flush
This commit is contained in:
parent
1f8fe2dc4c
commit
0f0b23e38b
3 changed files with 18 additions and 10 deletions
|
@ -125,6 +125,11 @@ pub unsafe extern "C" fn draw_rect(
|
|||
let color = Color::from_rgb(r, g, b);
|
||||
|
||||
render_rect(&mut state.surface, rect, color);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn flush(state: *mut State) {
|
||||
let state = unsafe { state.as_mut() }.expect("got an invalid state pointer");
|
||||
state
|
||||
.gpu_state
|
||||
.context
|
||||
|
|
|
@ -22,17 +22,19 @@
|
|||
translate (gobj/get ^js internal-module "_translate")
|
||||
reset-canvas (gobj/get ^js internal-module "_reset_canvas")
|
||||
scale (gobj/get ^js internal-module "_scale")
|
||||
flush (gobj/get ^js internal-module "_flush")
|
||||
supported-shapes (filter (fn [shape] (not= (:type shape) :frame)) (vals objects))]
|
||||
|
||||
(js/requestAnimationFrame (fn [])
|
||||
(reset-canvas gpu-state)
|
||||
(scale gpu-state zoom zoom)
|
||||
(translate gpu-state (- (:x vbox)) (- (:y vbox)))
|
||||
(doseq [shape supported-shapes]
|
||||
(let [sr (:selrect shape)
|
||||
[r g b] (cc/hex->rgb (-> shape :fills first :fill-color))]
|
||||
;; (js/console.log (clj->js shape))
|
||||
(draw-rect gpu-state (:x1 sr) (:y1 sr) (:x2 sr) (:y2 sr) r g b))))))
|
||||
(js/requestAnimationFrame (fn []
|
||||
(reset-canvas gpu-state)
|
||||
(scale gpu-state zoom zoom)
|
||||
(translate gpu-state (- (:x vbox)) (- (:y vbox)))
|
||||
(doseq [shape supported-shapes]
|
||||
(let [sr (:selrect shape)
|
||||
[r g b] (cc/hex->rgb (-> shape :fills first :fill-color))]
|
||||
;; (js/console.log (clj->js shape))
|
||||
(draw-rect gpu-state (:x1 sr) (:y1 sr) (:x2 sr) (:y2 sr) r g b)))
|
||||
(flush gpu-state)))))
|
||||
|
||||
(defn set-canvas
|
||||
[canvas vbox zoom objects]
|
||||
|
|
|
@ -28,7 +28,7 @@ var readyPromise = new Promise((resolve, reject) => {
|
|||
readyPromiseResolve = resolve;
|
||||
readyPromiseReject = reject;
|
||||
});
|
||||
["_draw_rect","_init","_main","_reset_canvas","_resize_surface","_scale","_translate","getExceptionMessage","incrementExceptionRefcount","decrementExceptionRefcount","_memory","___indirect_function_table","onRuntimeInitialized"].forEach((prop) => {
|
||||
["_draw_rect","_flush","_init","_main","_reset_canvas","_resize_surface","_scale","_translate","getExceptionMessage","incrementExceptionRefcount","decrementExceptionRefcount","_memory","___indirect_function_table","onRuntimeInitialized"].forEach((prop) => {
|
||||
if (!Object.getOwnPropertyDescriptor(readyPromise, prop)) {
|
||||
Object.defineProperty(readyPromise, prop, {
|
||||
get: () => abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
|
||||
|
@ -8564,6 +8564,7 @@ var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
|
|||
var _init = Module['_init'] = createExportWrapper('init', 2);
|
||||
var _resize_surface = Module['_resize_surface'] = createExportWrapper('resize_surface', 3);
|
||||
var _draw_rect = Module['_draw_rect'] = createExportWrapper('draw_rect', 8);
|
||||
var _flush = Module['_flush'] = createExportWrapper('flush', 1);
|
||||
var _translate = Module['_translate'] = createExportWrapper('translate', 3);
|
||||
var _scale = Module['_scale'] = createExportWrapper('scale', 3);
|
||||
var _reset_canvas = Module['_reset_canvas'] = createExportWrapper('reset_canvas', 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue