From 407711fecfc5f10fd5c04b248c994403e06698a9 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 7 Sep 2021 20:10:35 -0400 Subject: graphics: path: Fix bounding box state sharing issue. Create a new bounding box each time the compiled path is reset to avoid all paths sharing, and clobbering, the same rect object. --- chickadee/graphics/path.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chickadee/graphics/path.scm b/chickadee/graphics/path.scm index 5cef98b..8f21394 100644 --- a/chickadee/graphics/path.scm +++ b/chickadee/graphics/path.scm @@ -480,7 +480,7 @@ ;; Step 2: Use compiled points to fill vertex buffers with triangles ;; for filling or stroking. (define-record-type - (%make-compiled-path point-capacity point-count path-capacity path-count bounding-box) + (%make-compiled-path point-capacity point-count path-capacity path-count) compiled-path? (point-count compiled-path-point-count set-compiled-path-point-count!) (point-capacity compiled-path-point-capacity set-compiled-path-point-capacity!) @@ -489,7 +489,7 @@ (points compiled-path-points set-compiled-path-points!) (offsets compiled-path-offsets set-compiled-path-offsets!) (counts compiled-path-counts set-compiled-path-counts!) - (bounding-box compiled-path-bounding-box)) + (bounding-box compiled-path-bounding-box set-compiled-path-bounding-box!)) (define (resize-compiled-path-offsets-and-counts! compiled-path capacity) (let ((new-offsets (make-u32vector capacity)) @@ -512,14 +512,15 @@ (set-compiled-path-point-capacity! compiled-path capacity))) (define (make-compiled-path) - (let ((compiled-path (%make-compiled-path 0 0 0 0 (make-rect 0.0 0.0 0.0 0.0)))) + (let ((compiled-path (%make-compiled-path 0 0 0 0))) (resize-compiled-path-offsets-and-counts! compiled-path 64) (resize-compiled-path-points! compiled-path 256) compiled-path)) (define (clear-compiled-path compiled-path) (set-compiled-path-count! compiled-path 0) - (set-compiled-path-point-count! compiled-path 0)) + (set-compiled-path-point-count! compiled-path 0) + (set-compiled-path-bounding-box! compiled-path (make-rect 0.0 0.0 0.0 0.0))) (define %origin (vec2 0.0 0.0)) -- cgit v1.2.3