mirror of
https://github.com/penpot/penpot.git
synced 2025-07-31 23:58:32 +02:00
Merge pull request #6491 from penpot/alotor-perf-pixel-precision
✨ Pixel precision for new renderer
This commit is contained in:
commit
58b1cf6b0c
8 changed files with 76 additions and 22 deletions
|
@ -529,17 +529,15 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(wasm.api/clean-modifiers)
|
||||
|
||||
(let [prev-wasm-props (:prev-wasm-props state)
|
||||
wasm-props (:wasm-props state)
|
||||
objects (dsh/lookup-page-objects state)]
|
||||
|
||||
objects (dsh/lookup-page-objects state)
|
||||
pixel-precision false]
|
||||
(set-wasm-props! objects prev-wasm-props wasm-props)
|
||||
|
||||
(let [structure-entries (parse-structure-modifiers modif-tree)]
|
||||
(wasm.api/set-structure-modifiers structure-entries)
|
||||
(let [geometry-entries (parse-geometry-modifiers modif-tree)
|
||||
selrect (wasm.api/propagate-apply geometry-entries)]
|
||||
selrect (wasm.api/propagate-apply geometry-entries pixel-precision)]
|
||||
(rx/of (set-temporary-selrect selrect))))))))
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
|
@ -549,15 +547,18 @@
|
|||
:as params}]
|
||||
(ptk/reify ::apply-wasm-modifiesr
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(watch [_ state _]
|
||||
(let [geometry-entries
|
||||
(parse-geometry-modifiers modif-tree)
|
||||
|
||||
snap-pixel?
|
||||
(and (not ignore-snap-pixel) (contains? (:workspace-layout state) :snap-pixel-grid))
|
||||
|
||||
transforms
|
||||
(into
|
||||
{}
|
||||
(map (fn [{:keys [id transform]}] [id transform]))
|
||||
(wasm.api/propagate-modifiers geometry-entries))
|
||||
(wasm.api/propagate-modifiers geometry-entries snap-pixel?))
|
||||
|
||||
ids
|
||||
(into (set (keys modif-tree)) (keys transforms))
|
||||
|
|
|
@ -262,10 +262,10 @@
|
|||
|
||||
[x y width height]
|
||||
(if (features/active-feature? @st/state "render-wasm/v1")
|
||||
(let [{:keys [width height]} (wasm.api/text-dimensions shape-id)
|
||||
(let [{:keys [max-width height]} (wasm.api/text-dimensions shape-id)
|
||||
{:keys [x y]} (:selrect shape)]
|
||||
|
||||
[x y width height])
|
||||
[x y max-width height])
|
||||
|
||||
(let [bounds (gst/shape->rect shape)
|
||||
x (mth/min (dm/get-prop bounds :x)
|
||||
|
|
|
@ -654,9 +654,10 @@
|
|||
(let [offset (h/call wasm/internal-module "_get_text_dimensions")
|
||||
heapf32 (mem/get-heap-f32)
|
||||
width (aget heapf32 (mem/ptr8->ptr32 offset))
|
||||
height (aget heapf32 (mem/ptr8->ptr32 (+ offset 4)))]
|
||||
height (aget heapf32 (mem/ptr8->ptr32 (+ offset 4)))
|
||||
max-width (aget heapf32 (mem/ptr8->ptr32 (+ offset 8)))]
|
||||
(h/call wasm/internal-module "_free_bytes")
|
||||
{:width width :height height})))
|
||||
{:width width :height height :max-width max-width})))
|
||||
|
||||
(defn set-view-box
|
||||
[zoom vbox]
|
||||
|
@ -803,7 +804,7 @@
|
|||
(h/call wasm/internal-module "_set_structure_modifiers"))))
|
||||
|
||||
(defn propagate-modifiers
|
||||
[entries]
|
||||
[entries pixel-precision]
|
||||
(when (d/not-empty? entries)
|
||||
(let [offset (mem/alloc-bytes-32 (modifier-get-entries-size entries))
|
||||
heapf32 (mem/get-heap-f32)
|
||||
|
@ -817,7 +818,7 @@
|
|||
(sr/heapf32-set-matrix transform heapf32 (+ current-offset (mem/ptr8->ptr32 MODIFIER-ENTRY-TRANSFORM-OFFSET)))
|
||||
(recur (rest entries) (+ current-offset (mem/ptr8->ptr32 MODIFIER-ENTRY-SIZE))))))
|
||||
|
||||
(let [result-offset (h/call wasm/internal-module "_propagate_modifiers")
|
||||
(let [result-offset (h/call wasm/internal-module "_propagate_modifiers" pixel-precision)
|
||||
heapf32 (mem/get-heap-f32)
|
||||
heapu32 (mem/get-heap-u32)
|
||||
len (aget heapu32 (mem/ptr8->ptr32 result-offset))
|
||||
|
@ -829,7 +830,7 @@
|
|||
result))))
|
||||
|
||||
(defn propagate-apply
|
||||
[entries]
|
||||
[entries pixel-precision]
|
||||
(when (d/not-empty? entries)
|
||||
(let [offset (mem/alloc-bytes-32 (modifier-get-entries-size entries))
|
||||
heapf32 (mem/get-heap-f32)
|
||||
|
@ -843,7 +844,7 @@
|
|||
(sr/heapf32-set-matrix transform heapf32 (+ current-offset (mem/ptr8->ptr32 MODIFIER-ENTRY-TRANSFORM-OFFSET)))
|
||||
(recur (rest entries) (+ current-offset (mem/ptr8->ptr32 MODIFIER-ENTRY-SIZE))))))
|
||||
|
||||
(let [offset (h/call wasm/internal-module "_propagate_apply")
|
||||
(let [offset (h/call wasm/internal-module "_propagate_apply" pixel-precision)
|
||||
heapf32 (mem/get-heap-f32)
|
||||
width (aget heapf32 (mem/ptr8->ptr32 (+ offset 0)))
|
||||
height (aget heapf32 (mem/ptr8->ptr32 (+ offset 4)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue