mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
fix: filter subregion depend on primitive units not filter units (#2490)
# Summary This fix addresses a minor bug/typo that was recently introduced, where the filter subregion was incorrectly relying on filterUnits instead of primitiveUnits.
This commit is contained in:
@@ -36,18 +36,18 @@ public class FilterRegion {
|
||||
|
||||
public Rect getCropRect(VirtualView view, FilterProperties.Units units, RectF bounds) {
|
||||
double x, y, width, height;
|
||||
if (units == FilterProperties.Units.USER_SPACE_ON_USE) {
|
||||
if (units == FilterProperties.Units.OBJECT_BOUNDING_BOX) {
|
||||
x = bounds.left + view.relativeOnFraction(this.mX, bounds.width());
|
||||
y = bounds.top + view.relativeOnFraction(this.mY, bounds.height());
|
||||
width = view.relativeOnFraction(this.mW, bounds.width());
|
||||
height = view.relativeOnFraction(this.mH, bounds.height());
|
||||
} else { // FilterProperties.Units.USER_SPACE_ON_USE
|
||||
float canvasWidth = view.getSvgView().getCanvasWidth();
|
||||
float canvasHeight = view.getSvgView().getCanvasHeight();
|
||||
x = getRelativeOrDefault(view, mX, canvasWidth, bounds.left);
|
||||
y = getRelativeOrDefault(view, mY, canvasHeight, bounds.top);
|
||||
width = getRelativeOrDefault(view, mW, canvasWidth, bounds.width());
|
||||
height = getRelativeOrDefault(view, mH, canvasHeight, bounds.height());
|
||||
} else { // FilterProperties.Units.OBJECT_BOUNDING_BOX
|
||||
x = bounds.left + view.relativeOnFraction(this.mX, bounds.width());
|
||||
y = bounds.top + view.relativeOnFraction(this.mY, bounds.height());
|
||||
width = view.relativeOnFraction(this.mW, bounds.width());
|
||||
height = view.relativeOnFraction(this.mH, bounds.height());
|
||||
}
|
||||
return new Rect((int) x, (int) y, (int) (x + width), (int) (y + height));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class FilterView extends DefinitionView {
|
||||
currentFilter.mFilterSubregion.getCropRect(
|
||||
currentFilter,
|
||||
this.mPrimitiveUnits,
|
||||
this.mFilterUnits == FilterProperties.Units.USER_SPACE_ON_USE
|
||||
this.mPrimitiveUnits == FilterProperties.Units.USER_SPACE_ON_USE
|
||||
? new RectF(filterRegionRect)
|
||||
: renderableBounds);
|
||||
canvas.drawBitmap(currentFilter.applyFilter(mResultsMap, res), cropRect, cropRect, null);
|
||||
|
||||
Reference in New Issue
Block a user