Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bf58727

Browse files
zandersoitsjustkevin
authored andcommitted
Revert "Support opacity layers for platform-views using hybrid-composition" (#31002)
* Revert "Support opacity layers for platform-views using hybrid-composition (#30264)" This reverts commit 730b469. * Empty
1 parent 83cfdcc commit bf58727

File tree

6 files changed

+1
-124
lines changed

6 files changed

+1
-124
lines changed

shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import android.content.Context;
77
import android.graphics.Canvas;
88
import android.graphics.Matrix;
9-
import android.graphics.Paint;
109
import android.graphics.Path;
1110
import android.view.MotionEvent;
1211
import android.view.View;
@@ -29,7 +28,6 @@ public class FlutterMutatorView extends FrameLayout {
2928
private int top;
3029
private int prevLeft;
3130
private int prevTop;
32-
private Paint paint;
3331

3432
private final AndroidTouchProcessor androidTouchProcessor;
3533

@@ -44,7 +42,6 @@ public FlutterMutatorView(
4442
super(context, null);
4543
this.screenDensity = screenDensity;
4644
this.androidTouchProcessor = androidTouchProcessor;
47-
this.paint = new Paint();
4845
}
4946

5047
/** Initialize the FlutterMutatorView. */
@@ -145,11 +142,6 @@ public void draw(Canvas canvas) {
145142
pathCopy.offset(-left, -top);
146143
canvas.clipPath(pathCopy);
147144
}
148-
149-
// Apply the final opacity value on the parent canvas.
150-
paint.setAlpha((int) (mutatorsStack.getFinalOpacity() * 255));
151-
this.setLayerType(LAYER_TYPE_HARDWARE, paint);
152-
153145
super.draw(canvas);
154146
canvas.restore();
155147
}

shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorsStack.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class FlutterMutator {
4747
@Nullable private Rect rect;
4848
@Nullable private Path path;
4949
@Nullable private float[] radiis;
50-
@Nullable private float opacity;
5150

5251
private FlutterMutatorType type;
5352

@@ -94,16 +93,6 @@ public FlutterMutator(Matrix matrix) {
9493
this.matrix = matrix;
9594
}
9695

97-
/**
98-
* Initialize an opacity mutator.
99-
*
100-
* @param opacity the opacity to apply.
101-
*/
102-
public FlutterMutator(float opacity) {
103-
this.type = FlutterMutatorType.OPACITY;
104-
this.opacity = opacity;
105-
}
106-
10796
/**
10897
* Get the mutator type.
10998
*
@@ -139,29 +128,18 @@ public Path getPath() {
139128
public Matrix getMatrix() {
140129
return matrix;
141130
}
142-
143-
/**
144-
* Get the opacity of the mutator if {@link #getType()} returns FlutterMutatorType.OPACITY.
145-
*
146-
* @return the opacity if the type is FlutterMutatorType.OPACITY; otherwise null.
147-
*/
148-
public float getOpacity() {
149-
return opacity;
150-
}
151131
}
152132

153133
private @NonNull List<FlutterMutator> mutators;
154134

155135
private List<Path> finalClippingPaths;
156136
private Matrix finalMatrix;
157-
private float finalOpacity;
158137

159138
/** Initialize the mutator stack. */
160139
public FlutterMutatorsStack() {
161140
this.mutators = new ArrayList<FlutterMutator>();
162141
finalMatrix = new Matrix();
163142
finalClippingPaths = new ArrayList<Path>();
164-
finalOpacity = 1.f;
165143
}
166144

167145
/**
@@ -209,17 +187,6 @@ public void pushClipRRect(int left, int top, int right, int bottom, float[] radi
209187
finalClippingPaths.add(path);
210188
}
211189

212-
/**
213-
* Push an opacity {@link FlutterMutatorsStack.FlutterMutator} to the stack.
214-
*
215-
* @param opacity the opacity value.
216-
*/
217-
public void pushOpacity(float opacity) {
218-
FlutterMutator mutator = new FlutterMutator(opacity);
219-
mutators.add(mutator);
220-
finalOpacity *= opacity;
221-
}
222-
223190
/**
224191
* Get a list of all the raw mutators. The 0 index of the returned list is the top of the stack.
225192
*/
@@ -247,9 +214,4 @@ public List<Path> getFinalClippingPaths() {
247214
public Matrix getFinalMatrix() {
248215
return finalMatrix;
249216
}
250-
251-
/** Returns the final opacity value. Apply this value to the canvas of the view. */
252-
public float getFinalOpacity() {
253-
return finalOpacity;
254-
}
255217
}

shell/platform/android/platform_view_android_jni_impl.cc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ static jmethodID g_mutators_stack_init_method = nullptr;
121121
static jmethodID g_mutators_stack_push_transform_method = nullptr;
122122
static jmethodID g_mutators_stack_push_cliprect_method = nullptr;
123123
static jmethodID g_mutators_stack_push_cliprrect_method = nullptr;
124-
static jmethodID g_mutators_stack_push_opacity_method = nullptr;
125124

126125
// Called By Java
127126
static jlong AttachJNI(JNIEnv* env, jclass clazz, jobject flutterJNI) {
@@ -1020,14 +1019,6 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
10201019
return false;
10211020
}
10221021

1023-
g_mutators_stack_push_opacity_method =
1024-
env->GetMethodID(g_mutators_stack_class->obj(), "pushOpacity", "(F)V");
1025-
if (g_mutators_stack_push_opacity_method == nullptr) {
1026-
FML_LOG(ERROR)
1027-
<< "Could not locate FlutterMutatorsStack.pushOpacity method";
1028-
return false;
1029-
}
1030-
10311022
g_on_display_platform_view_method =
10321023
env->GetMethodID(g_flutter_jni_class->obj(), "onDisplayPlatformView",
10331024
"(IIIIIIILio/flutter/embedding/engine/mutatorsstack/"
@@ -1462,15 +1453,10 @@ void PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView(
14621453
(int)rect.bottom(), radiisArray.obj());
14631454
break;
14641455
}
1465-
case opacity: {
1466-
float opacity = (*iter)->GetAlphaFloat();
1467-
env->CallVoidMethod(mutatorsStack, g_mutators_stack_push_opacity_method,
1468-
opacity);
1469-
break;
1470-
}
14711456
// TODO(cyanglaz): Implement other mutators.
14721457
// https://github.com/flutter/flutter/issues/58426
14731458
case clip_path:
1459+
case opacity:
14741460
break;
14751461
}
14761462
++iter;

shell/platform/android/test/io/flutter/FlutterTestSuite.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import io.flutter.embedding.engine.loader.ApplicationInfoLoaderTest;
2525
import io.flutter.embedding.engine.loader.FlutterLoaderTest;
2626
import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorViewTest;
27-
import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorsStackTest;
2827
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistryTest;
2928
import io.flutter.embedding.engine.renderer.FlutterRendererTest;
3029
import io.flutter.embedding.engine.systemchannels.DeferredComponentChannelTest;
@@ -74,7 +73,6 @@
7473
FlutterJNITest.class,
7574
FlutterLaunchTests.class,
7675
FlutterLoaderTest.class,
77-
FlutterMutatorsStackTest.class,
7876
FlutterMutatorViewTest.class,
7977
FlutterShellArgsTest.class,
8078
FlutterRendererTest.class,

shell/platform/android/test/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorViewTest.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package io.flutter.embedding.engine.mutatorsstack;
22

3-
import static android.view.View.LAYER_TYPE_HARDWARE;
43
import static android.view.View.OnFocusChangeListener;
54
import static junit.framework.TestCase.*;
65
import static org.mockito.Mockito.*;
76

8-
import android.graphics.Canvas;
97
import android.graphics.Matrix;
10-
import android.graphics.Paint;
118
import android.view.MotionEvent;
129
import android.view.View;
1310
import android.view.ViewGroup;
@@ -253,20 +250,4 @@ public ViewTreeObserver getViewTreeObserver() {
253250
view.unsetOnDescendantFocusChangeListener();
254251
verify(viewTreeObserver, times(1)).removeOnGlobalFocusChangeListener(activeFocusListener);
255252
}
256-
257-
@Test
258-
public void draw_opacityApplied() {
259-
final FlutterMutatorView view = new FlutterMutatorView(RuntimeEnvironment.systemContext);
260-
final FlutterMutatorView spy = spy(view);
261-
262-
final FlutterMutatorsStack mutatorsStack = new FlutterMutatorsStack();
263-
mutatorsStack.pushOpacity(.3f);
264-
265-
spy.readyToDisplay(mutatorsStack, /*left=*/ 1, /*top=*/ 2, /*width=*/ 0, /*height=*/ 0);
266-
spy.draw(new Canvas());
267-
verify(spy)
268-
.setLayerType(
269-
intThat((Integer layerType) -> layerType == LAYER_TYPE_HARDWARE),
270-
argThat((Paint paint) -> paint.getAlpha() == (int) (.3f * 255)));
271-
}
272253
}

shell/platform/android/test/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)