From eb56238f46d6010463d1b4e7b7216b1078d8ab18 Mon Sep 17 00:00:00 2001 From: pekingme <8545955+pekingme@users.noreply.github.com> Date: Wed, 10 Jul 2024 19:42:50 +0000 Subject: [PATCH] [Shape] Moved unnecessary object from the drawable state. PiperOrigin-RevId: 651118525 --- .../android/material/shape/MaterialShapeDrawable.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/java/com/google/android/material/shape/MaterialShapeDrawable.java b/lib/java/com/google/android/material/shape/MaterialShapeDrawable.java index 4c86a0ab892..0d2325c61bf 100644 --- a/lib/java/com/google/android/material/shape/MaterialShapeDrawable.java +++ b/lib/java/com/google/android/material/shape/MaterialShapeDrawable.java @@ -166,6 +166,7 @@ public CornerSize apply(@NonNull CornerSize cornerSize) { private final Paint fillPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final Paint strokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + @NonNull private ShapeAppearanceModel strokeShapeAppearanceModel; private final ShadowRenderer shadowRenderer = new ShadowRenderer(); @NonNull private final PathListener pathShadowListener; @@ -1228,7 +1229,7 @@ protected void drawStrokeShape(@NonNull Canvas canvas) { canvas, strokePaint, pathInsetByStroke, - drawableState.strokeShapeAppearanceModel, + strokeShapeAppearanceModel, springAnimatedStrokeCornerSizes, getBoundsInsetByStroke()); } @@ -1332,7 +1333,7 @@ private void calculateStrokePath() { updateStrokeShapeAppearanceModels(); RectF boundsInsetByStroke = getBoundsInsetByStroke(); pathProvider.calculatePath( - drawableState.strokeShapeAppearanceModel, + strokeShapeAppearanceModel, springAnimatedStrokeCornerSizes, drawableState.interpolation, boundsInsetByStroke, @@ -1343,7 +1344,7 @@ private void calculateStrokePath() { private void updateStrokeShapeAppearanceModels() { // Adjust corner radius in order to draw the stroke so that the corners of the background are // drawn on top of the edges. - drawableState.strokeShapeAppearanceModel = + strokeShapeAppearanceModel = getShapeAppearanceModel().withTransformedCornerSizes(strokeInsetCornerSizeUnaryOperator); // Adjust spring animated corner sizes, when springs are controlling the corner sizes, in order // to draw the stroke so that the corners of the background are drawn on top of the edges. @@ -1653,7 +1654,6 @@ protected static class MaterialShapeDrawableState extends ConstantState { @NonNull ShapeAppearanceModel shapeAppearanceModel; @Nullable StateListShapeAppearanceModel stateListShapeAppearanceModel; - @NonNull ShapeAppearanceModel strokeShapeAppearanceModel; @Nullable ElevationOverlayProvider elevationOverlayProvider; @Nullable ColorFilter colorFilter; @@ -1691,7 +1691,6 @@ public MaterialShapeDrawableState( public MaterialShapeDrawableState(@NonNull MaterialShapeDrawableState orig) { shapeAppearanceModel = orig.shapeAppearanceModel; stateListShapeAppearanceModel = orig.stateListShapeAppearanceModel; - strokeShapeAppearanceModel = orig.strokeShapeAppearanceModel; elevationOverlayProvider = orig.elevationOverlayProvider; strokeWidth = orig.strokeWidth; colorFilter = orig.colorFilter;