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

Commit 3651c9f

Browse files
itsjustkevinzandersoarbreng
authored
Revert flutter engine (#31143)
* 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 * Revert "[fuchsia] Switch from core-jit to core snapshots. (#30744)" (#31065) This reverts commit a193f08. Co-authored-by: Zachary Anderson <zanderso@users.noreply.github.com> Co-authored-by: David Worsham <dworsham@google.com>
1 parent 83cfdcc commit 3651c9f

File tree

16 files changed

+96
-161
lines changed

16 files changed

+96
-161
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.

shell/platform/fuchsia/dart_runner/BUILD.gn

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,21 @@ template("jit_runner_package") {
223223
rebase_path("$target_gen_dir/kernel/vm_data${product_suffix}.bin")
224224
dest = "vm_snapshot_data.bin"
225225
},
226+
{
227+
path = rebase_path(
228+
"$target_gen_dir/kernel/vm_instructions${product_suffix}.bin")
229+
dest = "vm_snapshot_instructions.bin"
230+
},
226231
{
227232
path = rebase_path(
228233
"$target_gen_dir/kernel/isolate_data${product_suffix}.bin")
229234
dest = "isolate_core_snapshot_data.bin"
230235
},
236+
{
237+
path = rebase_path(
238+
"$target_gen_dir/kernel/isolate_instructions${product_suffix}.bin")
239+
dest = "isolate_core_snapshot_instructions.bin"
240+
},
231241
]
232242

233243
if (!invoker.product) {

shell/platform/fuchsia/dart_runner/dart_component_controller.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,14 @@ bool DartComponentController::SetupFromKernel() {
206206
isolate_snapshot_data_)) {
207207
return false;
208208
}
209+
if (!dart_utils::MappedResource::LoadFromNamespace(
210+
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
211+
isolate_snapshot_instructions_, true /* executable */)) {
212+
return false;
213+
}
209214

210-
// The core snapshot does not separate instructions from data.
211215
if (!CreateIsolate(isolate_snapshot_data_.address(),
212-
nullptr /* isolate_snapshot_instructions */)) {
216+
isolate_snapshot_instructions_.address())) {
213217
return false;
214218
}
215219

@@ -273,16 +277,16 @@ bool DartComponentController::SetupFromAppSnapshot() {
273277
return false;
274278
}
275279
} else {
276-
// TODO(fxb/91200): This code path was broken for over a year and is
277-
// probably not used.
278280
if (!dart_utils::MappedResource::LoadFromNamespace(
279281
namespace_, data_path_ + "/isolate_snapshot_data.bin",
280282
isolate_snapshot_data_)) {
281283
return false;
282284
}
283-
isolate_data = isolate_snapshot_data_.address();
284-
// We don't separate instructions from data in 'core' snapshots.
285-
isolate_instructions = nullptr;
285+
if (!dart_utils::MappedResource::LoadFromNamespace(
286+
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
287+
isolate_snapshot_instructions_, true /* executable */)) {
288+
return false;
289+
}
286290
}
287291
return CreateIsolate(isolate_data, isolate_instructions);
288292
#endif // defined(AOT_RUNTIME)

shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ bool DartComponentControllerV2::CreateAndBindNamespace() {
214214

215215
bool DartComponentControllerV2::SetUpFromKernel() {
216216
dart_utils::MappedResource manifest;
217-
218217
if (!dart_utils::MappedResource::LoadFromNamespace(
219218
namespace_, data_path_ + "/app.dilplist", manifest)) {
220219
return false;
@@ -225,10 +224,14 @@ bool DartComponentControllerV2::SetUpFromKernel() {
225224
isolate_snapshot_data_)) {
226225
return false;
227226
}
227+
if (!dart_utils::MappedResource::LoadFromNamespace(
228+
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
229+
isolate_snapshot_instructions_, true /* executable */)) {
230+
return false;
231+
}
228232

229-
// The core snapshot does not separate instructions from data.
230233
if (!CreateIsolate(isolate_snapshot_data_.address(),
231-
nullptr /* isolate_snapshot_instructions */)) {
234+
isolate_snapshot_instructions_.address())) {
232235
return false;
233236
}
234237

@@ -293,16 +296,16 @@ bool DartComponentControllerV2::SetUpFromAppSnapshot() {
293296
return false;
294297
}
295298
} else {
296-
// TODO(fxb/91200): This code path was broken for over a year and is
297-
// probably not used.
298299
if (!dart_utils::MappedResource::LoadFromNamespace(
299300
namespace_, data_path_ + "/isolate_snapshot_data.bin",
300301
isolate_snapshot_data_)) {
301302
return false;
302303
}
303-
isolate_data = isolate_snapshot_data_.address();
304-
// We don't separate instructions from data in 'core' snapshots.
305-
isolate_instructions = nullptr;
304+
if (!dart_utils::MappedResource::LoadFromNamespace(
305+
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
306+
isolate_snapshot_instructions_, true /* executable */)) {
307+
return false;
308+
}
306309
}
307310
return CreateIsolate(isolate_data, isolate_instructions);
308311
#endif // defined(AOT_RUNTIME)

shell/platform/fuchsia/dart_runner/dart_runner.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ DartRunner::DartRunner(sys::ComponentContext* context) : context_(context) {
200200
nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
201201
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
202202
}
203+
if (!dart_utils::MappedResource::LoadFromNamespace(
204+
nullptr, "/pkg/data/vm_snapshot_instructions.bin",
205+
vm_snapshot_instructions_, true /* executable */)) {
206+
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
207+
}
203208
params.vm_snapshot_data = vm_snapshot_data_.address();
209+
params.vm_snapshot_instructions = vm_snapshot_instructions_.address();
204210
#endif
205211
params.create_group = IsolateGroupCreateCallback;
206212
params.shutdown_isolate = IsolateShutdownCallback;

0 commit comments

Comments
 (0)