Skip to content

Commit

Permalink
fix: client rect on use element (#2513)
Browse files Browse the repository at this point in the history
# 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 |    ✅      |
  • Loading branch information
jakex7 authored Oct 28, 2024
1 parent 8e865a9 commit 36ca5c4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion android/src/main/java/com/horcrux/svg/UseView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 36ca5c4

Please sign in to comment.