Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -29,7 +28,6 @@ public class FlutterMutatorView extends FrameLayout {
private int top;
private int prevLeft;
private int prevTop;
private Paint paint;

private final AndroidTouchProcessor androidTouchProcessor;

Expand All @@ -44,7 +42,6 @@ public FlutterMutatorView(
super(context, null);
this.screenDensity = screenDensity;
this.androidTouchProcessor = androidTouchProcessor;
this.paint = new Paint();
}

/** Initialize the FlutterMutatorView. */
Expand Down Expand Up @@ -145,11 +142,6 @@ public void draw(Canvas canvas) {
pathCopy.offset(-left, -top);
canvas.clipPath(pathCopy);
}

// Apply the final opacity value on the parent canvas.
paint.setAlpha((int) (mutatorsStack.getFinalOpacity() * 255));
this.setLayerType(LAYER_TYPE_HARDWARE, paint);

super.draw(canvas);
canvas.restore();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class FlutterMutator {
@Nullable private Rect rect;
@Nullable private Path path;
@Nullable private float[] radiis;
@Nullable private float opacity;

private FlutterMutatorType type;

Expand Down Expand Up @@ -94,16 +93,6 @@ public FlutterMutator(Matrix matrix) {
this.matrix = matrix;
}

/**
* Initialize an opacity mutator.
*
* @param opacity the opacity to apply.
*/
public FlutterMutator(float opacity) {
this.type = FlutterMutatorType.OPACITY;
this.opacity = opacity;
}

/**
* Get the mutator type.
*
Expand Down Expand Up @@ -139,29 +128,18 @@ public Path getPath() {
public Matrix getMatrix() {
return matrix;
}

/**
* Get the opacity of the mutator if {@link #getType()} returns FlutterMutatorType.OPACITY.
*
* @return the opacity if the type is FlutterMutatorType.OPACITY; otherwise null.
*/
public float getOpacity() {
return opacity;
}
}

private @NonNull List<FlutterMutator> mutators;

private List<Path> finalClippingPaths;
private Matrix finalMatrix;
private float finalOpacity;

/** Initialize the mutator stack. */
public FlutterMutatorsStack() {
this.mutators = new ArrayList<FlutterMutator>();
finalMatrix = new Matrix();
finalClippingPaths = new ArrayList<Path>();
finalOpacity = 1.f;
}

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

/**
* Push an opacity {@link FlutterMutatorsStack.FlutterMutator} to the stack.
*
* @param opacity the opacity value.
*/
public void pushOpacity(float opacity) {
FlutterMutator mutator = new FlutterMutator(opacity);
mutators.add(mutator);
finalOpacity *= opacity;
}

/**
* Get a list of all the raw mutators. The 0 index of the returned list is the top of the stack.
*/
Expand Down Expand Up @@ -247,9 +214,4 @@ public List<Path> getFinalClippingPaths() {
public Matrix getFinalMatrix() {
return finalMatrix;
}

/** Returns the final opacity value. Apply this value to the canvas of the view. */
public float getFinalOpacity() {
return finalOpacity;
}
}
16 changes: 1 addition & 15 deletions shell/platform/android/platform_view_android_jni_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ static jmethodID g_mutators_stack_init_method = nullptr;
static jmethodID g_mutators_stack_push_transform_method = nullptr;
static jmethodID g_mutators_stack_push_cliprect_method = nullptr;
static jmethodID g_mutators_stack_push_cliprrect_method = nullptr;
static jmethodID g_mutators_stack_push_opacity_method = nullptr;

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

g_mutators_stack_push_opacity_method =
env->GetMethodID(g_mutators_stack_class->obj(), "pushOpacity", "(F)V");
if (g_mutators_stack_push_opacity_method == nullptr) {
FML_LOG(ERROR)
<< "Could not locate FlutterMutatorsStack.pushOpacity method";
return false;
}

g_on_display_platform_view_method =
env->GetMethodID(g_flutter_jni_class->obj(), "onDisplayPlatformView",
"(IIIIIIILio/flutter/embedding/engine/mutatorsstack/"
Expand Down Expand Up @@ -1462,15 +1453,10 @@ void PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView(
(int)rect.bottom(), radiisArray.obj());
break;
}
case opacity: {
float opacity = (*iter)->GetAlphaFloat();
env->CallVoidMethod(mutatorsStack, g_mutators_stack_push_opacity_method,
opacity);
break;
}
// TODO(cyanglaz): Implement other mutators.
// https://github.com/flutter/flutter/issues/58426
case clip_path:
case opacity:
break;
}
++iter;
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/android/test/io/flutter/FlutterTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.flutter.embedding.engine.loader.ApplicationInfoLoaderTest;
import io.flutter.embedding.engine.loader.FlutterLoaderTest;
import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorViewTest;
import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorsStackTest;
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistryTest;
import io.flutter.embedding.engine.renderer.FlutterRendererTest;
import io.flutter.embedding.engine.systemchannels.DeferredComponentChannelTest;
Expand Down Expand Up @@ -74,7 +73,6 @@
FlutterJNITest.class,
FlutterLaunchTests.class,
FlutterLoaderTest.class,
FlutterMutatorsStackTest.class,
FlutterMutatorViewTest.class,
FlutterShellArgsTest.class,
FlutterRendererTest.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.flutter.embedding.engine.mutatorsstack;

import static android.view.View.LAYER_TYPE_HARDWARE;
import static android.view.View.OnFocusChangeListener;
import static junit.framework.TestCase.*;
import static org.mockito.Mockito.*;

import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -253,20 +250,4 @@ public ViewTreeObserver getViewTreeObserver() {
view.unsetOnDescendantFocusChangeListener();
verify(viewTreeObserver, times(1)).removeOnGlobalFocusChangeListener(activeFocusListener);
}

@Test
public void draw_opacityApplied() {
final FlutterMutatorView view = new FlutterMutatorView(RuntimeEnvironment.systemContext);
final FlutterMutatorView spy = spy(view);

final FlutterMutatorsStack mutatorsStack = new FlutterMutatorsStack();
mutatorsStack.pushOpacity(.3f);

spy.readyToDisplay(mutatorsStack, /*left=*/ 1, /*top=*/ 2, /*width=*/ 0, /*height=*/ 0);
spy.draw(new Canvas());
verify(spy)
.setLayerType(
intThat((Integer layerType) -> layerType == LAYER_TYPE_HARDWARE),
argThat((Paint paint) -> paint.getAlpha() == (int) (.3f * 255)));
}
}

This file was deleted.

10 changes: 10 additions & 0 deletions shell/platform/fuchsia/dart_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,21 @@ template("jit_runner_package") {
rebase_path("$target_gen_dir/kernel/vm_data${product_suffix}.bin")
dest = "vm_snapshot_data.bin"
},
{
path = rebase_path(
"$target_gen_dir/kernel/vm_instructions${product_suffix}.bin")
dest = "vm_snapshot_instructions.bin"
},
{
path = rebase_path(
"$target_gen_dir/kernel/isolate_data${product_suffix}.bin")
dest = "isolate_core_snapshot_data.bin"
},
{
path = rebase_path(
"$target_gen_dir/kernel/isolate_instructions${product_suffix}.bin")
dest = "isolate_core_snapshot_instructions.bin"
},
]

if (!invoker.product) {
Expand Down
18 changes: 11 additions & 7 deletions shell/platform/fuchsia/dart_runner/dart_component_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ bool DartComponentController::SetupFromKernel() {
isolate_snapshot_data_)) {
return false;
}
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}

// The core snapshot does not separate instructions from data.
if (!CreateIsolate(isolate_snapshot_data_.address(),
nullptr /* isolate_snapshot_instructions */)) {
isolate_snapshot_instructions_.address())) {
return false;
}

Expand Down Expand Up @@ -273,16 +277,16 @@ bool DartComponentController::SetupFromAppSnapshot() {
return false;
}
} else {
// TODO(fxb/91200): This code path was broken for over a year and is
// probably not used.
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}
isolate_data = isolate_snapshot_data_.address();
// We don't separate instructions from data in 'core' snapshots.
isolate_instructions = nullptr;
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}
}
return CreateIsolate(isolate_data, isolate_instructions);
#endif // defined(AOT_RUNTIME)
Expand Down
19 changes: 11 additions & 8 deletions shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ bool DartComponentControllerV2::CreateAndBindNamespace() {

bool DartComponentControllerV2::SetUpFromKernel() {
dart_utils::MappedResource manifest;

if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/app.dilplist", manifest)) {
return false;
Expand All @@ -225,10 +224,14 @@ bool DartComponentControllerV2::SetUpFromKernel() {
isolate_snapshot_data_)) {
return false;
}
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}

// The core snapshot does not separate instructions from data.
if (!CreateIsolate(isolate_snapshot_data_.address(),
nullptr /* isolate_snapshot_instructions */)) {
isolate_snapshot_instructions_.address())) {
return false;
}

Expand Down Expand Up @@ -293,16 +296,16 @@ bool DartComponentControllerV2::SetUpFromAppSnapshot() {
return false;
}
} else {
// TODO(fxb/91200): This code path was broken for over a year and is
// probably not used.
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}
isolate_data = isolate_snapshot_data_.address();
// We don't separate instructions from data in 'core' snapshots.
isolate_instructions = nullptr;
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}
}
return CreateIsolate(isolate_data, isolate_instructions);
#endif // defined(AOT_RUNTIME)
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/fuchsia/dart_runner/dart_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ DartRunner::DartRunner(sys::ComponentContext* context) : context_(context) {
nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
}
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "/pkg/data/vm_snapshot_instructions.bin",
vm_snapshot_instructions_, true /* executable */)) {
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
}
params.vm_snapshot_data = vm_snapshot_data_.address();
params.vm_snapshot_instructions = vm_snapshot_instructions_.address();
#endif
params.create_group = IsolateGroupCreateCallback;
params.shutdown_isolate = IsolateShutdownCallback;
Expand Down
Loading