Merge pull request #9599 from penpot/superalex-fix-drag-crop-cache-viewport-clamp

🐛 Fix clamp backbuffer crop origin for partially off-screen shapes
This commit is contained in:
Alejandro Alonso 2026-05-13 13:00:03 +02:00 committed by GitHub
commit 4f5d269313
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1721,6 +1721,16 @@ impl RenderState {
&& doc_bounds.top >= viewport.top
&& doc_bounds.right <= viewport.right
&& doc_bounds.bottom <= viewport.bottom;
// When the shape extends beyond the viewport to the left or top,
// `left`/`top` are negative. Skia clamps `makeImageSnapshot` to the
// surface bounds, so the returned image actually starts at pixel 0 —
// not at the negative coordinate. Store the clamped value so that
// `doc_left`/`doc_top` computed during the drag reflects the true
// image origin in the backbuffer.
let capture_src_left = left.max(0);
let capture_src_top = top.max(0);
self.backbuffer_crop_cache.insert(
id,
InteractiveDragCrop {
@ -1729,8 +1739,8 @@ impl RenderState {
fits_viewport_at_capture,
capture_vb_left: vb_left,
capture_vb_top: vb_top,
capture_src_left: src_irect.left,
capture_src_top: src_irect.top,
capture_src_left,
capture_src_top,
image,
},
);