From 36ca5c458460c1e7675335a2f16a1a6bb91350a5 Mon Sep 17 00:00:00 2001 From: Jakub Grzywacz Date: Mon, 28 Oct 2024 13:45:52 +0100 Subject: [PATCH] fix: client rect on use element (#2513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Summary Use elements had incorrect `clientRect` based on templates' rect, which was incorrect. With this change, it ensures client rect is based on path transformed by CTM. ## Test Plan Example app -> Filters -> FeComposite ## Compatibility | OS | Implemented | | ------- | :---------: | | Android | ✅ | --- android/src/main/java/com/horcrux/svg/UseView.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/horcrux/svg/UseView.java b/android/src/main/java/com/horcrux/svg/UseView.java index c3227caaa..b0cf2b7cd 100644 --- a/android/src/main/java/com/horcrux/svg/UseView.java +++ b/android/src/main/java/com/horcrux/svg/UseView.java @@ -13,6 +13,7 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; +import android.graphics.RectF; import com.facebook.common.logging.FLog; import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.ReactContext; @@ -86,7 +87,11 @@ void draw(Canvas canvas, Paint paint, float opacity) { template.draw(canvas, paint, opacity * mOpacity); } - this.setClientRect(template.getClientRect()); + // TODO: replace getMatrix with mCTM when it will be fixed + RectF clientRect = new RectF(); + this.getPath(canvas, paint).computeBounds(clientRect, true); + canvas.getMatrix().mapRect(clientRect); + this.setClientRect(clientRect); template.restoreCanvas(canvas, count); if (template instanceof RenderableView) {