diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
index 40c56be4a8..054befa0a6 100644
--- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
+++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java
@@ -244,12 +244,11 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
@Override
public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) {
- float density = context.getResources().getDisplayMetrics().density;
PointerProperties[] pointerProperties =
parsePointerPropertiesList(touch.rawPointerPropertiesList)
.toArray(new PointerProperties[touch.pointerCount]);
PointerCoords[] pointerCoords =
- parsePointerCoordsList(touch.rawPointerCoords, density)
+ parsePointerCoordsList(touch.rawPointerCoords, getDisplayDensity())
.toArray(new PointerCoords[touch.pointerCount]);
if (!vdControllers.containsKey(touch.viewId)) {
@@ -569,9 +568,12 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
}
}
+ private float getDisplayDensity() {
+ return context.getResources().getDisplayMetrics().density;
+ }
+
private int toPhysicalPixels(double logicalPixels) {
- float density = context.getResources().getDisplayMetrics().density;
- return (int) Math.round(logicalPixels * density);
+ return (int) Math.round(logicalPixels * getDisplayDensity());
}
private void flushAllViews() {
@@ -621,8 +623,18 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
PlatformView platformView = factory.create(context, viewId, createParams);
View view = platformView.getView();
- platformViews.put(viewId, view);
+ // Reverse scale the view based on the screen density.
+ //
+ // Flow pixels are based on the physical resolution. For example, 1000 pixels in flow equals
+ // 500 points in Android if the display density is 2.0.
+ float density = getDisplayDensity();
+ view.setPivotX(0);
+ view.setPivotY(0);
+ view.setScaleX(1 / density);
+ view.setScaleY(1 / density);
+
+ platformViews.put(viewId, view);
((FlutterView) flutterView).addView(view);
}
diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java
index ec037ee680..960c9c78ac 100644
--- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java
+++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java
@@ -111,7 +111,7 @@ class VirtualDisplayController {
DisplayManager displayManager =
(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
virtualDisplay =
- displayManager.createVirtualDisplay("flutter-vd", width, height, densityDpi, surface, 0);
+ displayManager.createVirtualDisplay("flutter-vd", width, height, 1, surface, 0);
final View embeddedView = getView();
// There's a bug in Android version older than O where view tree observer onDrawListeners don't
diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java
index 23a3943e45..c3e50feba9 100644
--- a/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java
+++ b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java
@@ -41,8 +41,7 @@ public class EngineLaunchE2ETest {
// TODO: Fix race condition between sending this over the channel and starting the entrypoint.
// https://github.com/flutter/flutter/issues/55999
UiThreadStatement.runOnUiThread(
- () ->
- engine.get().getLocalizationChannel().sendLocales(Arrays.asList(Locale.US), Locale.US));
+ () -> engine.get().getLocalizationChannel().sendLocales(Arrays.asList(Locale.US)));
// The default Dart main entrypoint sends back a platform message on the "waiting_for_status"
// channel. That will be our launch success assertion condition.
diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml b/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml
index a7416851cc..a580f17b7a 100644
--- a/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml
+++ b/engine/src/flutter/testing/scenario_app/android/app/src/main/AndroidManifest.xml
@@ -1,9 +1,8 @@
-
-
-
@@ -28,11 +25,19 @@
+
+
+
+
+
+
+
-
-
-
\ No newline at end of file
+
diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/BlankActivity.java b/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/BlankActivity.java
deleted file mode 100644
index 4504e97b1e..0000000000
--- a/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/BlankActivity.java
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package dev.flutter.scenarios;
-
-import android.os.Bundle;
-import androidx.appcompat.app.AppCompatActivity;
-
-public class BlankActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-}
diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/ScenarioApplication.java b/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/ScenarioApplication.java
deleted file mode 100644
index 812e09aa81..0000000000
--- a/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/ScenarioApplication.java
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package dev.flutter.scenarios;
-
-import android.os.StrictMode;
-import io.flutter.app.FlutterApplication;
-
-public class ScenarioApplication extends FlutterApplication {
- @Override
- public void onCreate() {
- StrictMode.setThreadPolicy(
- new StrictMode.ThreadPolicy.Builder()
- .detectDiskReads()
- .detectDiskWrites()
- .penaltyDeath()
- .build());
- super.onCreate();
- }
-}
diff --git a/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/StrictModeFlutterActivity.java b/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/StrictModeFlutterActivity.java
new file mode 100644
index 0000000000..3df39d74b0
--- /dev/null
+++ b/engine/src/flutter/testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/StrictModeFlutterActivity.java
@@ -0,0 +1,24 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package dev.flutter.scenarios;
+
+import android.os.Bundle;
+import android.os.StrictMode;
+import io.flutter.embedding.android.FlutterActivity;
+
+// TODO: Trigger this activity.
+// https://github.com/flutter/flutter/issues/60635
+public class StrictModeFlutterActivity extends FlutterActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ StrictMode.setThreadPolicy(
+ new StrictMode.ThreadPolicy.Builder()
+ .detectDiskReads()
+ .detectDiskWrites()
+ .penaltyDeath()
+ .build());
+ super.onCreate(savedInstanceState);
+ }
+}
diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/UnobstructedPlatformViewTests.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/UnobstructedPlatformViewTests.m
index 02e7eee35f..375220361a 100644
--- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/UnobstructedPlatformViewTests.m
+++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/UnobstructedPlatformViewTests.m
@@ -192,28 +192,28 @@
app.launchArguments = @[ @"--platform-view-multiple-background-foreground" ];
[app launch];
- XCUIElement* platform_view1 = app.textViews[@"platform_view[8]"];
+ XCUIElement* platform_view1 = app.textViews[@"platform_view[0]"];
XCTAssertTrue(platform_view1.exists);
XCTAssertEqual(platform_view1.frame.origin.x, 25);
XCTAssertEqual(platform_view1.frame.origin.y, 325);
XCTAssertEqual(platform_view1.frame.size.width, 250);
XCTAssertEqual(platform_view1.frame.size.height, 250);
- XCUIElement* platform_view2 = app.textViews[@"platform_view[9]"];
+ XCUIElement* platform_view2 = app.textViews[@"platform_view[1]"];
XCTAssertTrue(platform_view2.exists);
XCTAssertEqual(platform_view2.frame.origin.x, 25);
XCTAssertEqual(platform_view2.frame.origin.y, 25);
XCTAssertEqual(platform_view2.frame.size.width, 250);
XCTAssertEqual(platform_view2.frame.size.height, 250);
- XCUIElement* overlay1 = app.otherElements[@"platform_view[8].overlay[0]"];
+ XCUIElement* overlay1 = app.otherElements[@"platform_view[0].overlay[0]"];
XCTAssertTrue(overlay1.exists);
XCTAssertEqual(overlay1.frame.origin.x, 25);
XCTAssertEqual(overlay1.frame.origin.y, 325);
XCTAssertEqual(overlay1.frame.size.width, 225);
XCTAssertEqual(overlay1.frame.size.height, 175);
- XCUIElement* overlay2 = app.otherElements[@"platform_view[9].overlay[0]"];
+ XCUIElement* overlay2 = app.otherElements[@"platform_view[1].overlay[0]"];
XCTAssertTrue(overlay2.exists);
XCTAssertEqual(overlay2.frame.origin.x, 25);
XCTAssertEqual(overlay2.frame.origin.y, 25);
diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone 8_simulator.png b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone 8_simulator.png
index 6c4a2098b8..2c5f5b8acc 100644
Binary files a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone 8_simulator.png and b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone 8_simulator.png differ
diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png
index 5281191b08..16aeafa24a 100644
Binary files a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png and b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png differ
diff --git a/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart b/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart
index 293569c895..e2d0d6a0e3 100644
--- a/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart
+++ b/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart
@@ -33,19 +33,22 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- PlatformViewScenario(Window window, String text, {int id = 0})
+ PlatformViewScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier.
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
- finishBuilderByAddingPlatformViewAndPicture(builder, 0);
+ finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
@@ -54,12 +57,15 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- PlatformViewNoOverlayIntersectionScenario(Window window, String text, {int id = 0})
+ PlatformViewNoOverlayIntersectionScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier.
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
@@ -68,7 +74,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
finishBuilderByAddingPlatformViewAndPicture(
builder,
- 0,
+ id,
overlayOffset: const Offset(150, 350),
);
}
@@ -79,12 +85,15 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- PlatformViewPartialIntersectionScenario(Window window, String text, {int id = 0})
+ PlatformViewPartialIntersectionScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier .
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
@@ -93,7 +102,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
finishBuilderByAddingPlatformViewAndPicture(
builder,
- 0,
+ id,
overlayOffset: const Offset(150, 250),
);
}
@@ -104,19 +113,22 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario with _BasePla
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- PlatformViewTwoIntersectingOverlaysScenario(Window window, String text, {int id = 0})
+ PlatformViewTwoIntersectingOverlaysScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier.
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
- _addPlatformViewtoScene(builder, 0, 500, 500);
+ _addPlatformViewtoScene(builder, id, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawCircle(
@@ -142,19 +154,22 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario wit
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- PlatformViewOneOverlayTwoIntersectingOverlaysScenario(Window window, String text, {int id = 0})
+ PlatformViewOneOverlayTwoIntersectingOverlaysScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier.
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
- _addPlatformViewtoScene(builder, 0, 500, 500);
+ _addPlatformViewtoScene(builder, id, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawCircle(
@@ -185,12 +200,19 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- MultiPlatformViewWithoutOverlaysScenario(Window window, String text, {int id = 0})
+ MultiPlatformViewWithoutOverlaysScenario(Window window, String text, { this.firstId, this.secondId })
: assert(window != null),
super(window) {
- createPlatformView(window, text, id);
+ createPlatformView(window, text, firstId);
+ createPlatformView(window, text, secondId);
}
+ /// The platform view identifier to use for the first platform view.
+ final int firstId;
+
+ /// The platform view identifier to use for the second platform view.
+ final int secondId;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
@@ -198,10 +220,10 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
builder.pushOffset(0, 0);
builder.pushOffset(0, 600);
- _addPlatformViewtoScene(builder, 0, 500, 500);
+ _addPlatformViewtoScene(builder, firstId, 500, 500);
builder.pop();
- _addPlatformViewtoScene(builder, 1, 500, 500);
+ _addPlatformViewtoScene(builder, secondId, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
@@ -224,19 +246,22 @@ class PlatformViewMaxOverlaysScenario extends Scenario with _BasePlatformViewSce
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
- PlatformViewMaxOverlaysScenario(Window window, String text, {int id = 0})
+ PlatformViewMaxOverlaysScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier.
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
- _addPlatformViewtoScene(builder, 0, 500, 500);
+ _addPlatformViewtoScene(builder, id, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawCircle(
@@ -394,25 +419,28 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
/// Platform view with clip rect.
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
/// Constructs a platform view with clip rect scenario.
- PlatformViewClipRectScenario(Window window, String text, {int id = 0})
+ PlatformViewClipRectScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
+ /// The platform view identifier.
+ final int id;
+
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
builder.pushClipRect(const Rect.fromLTRB(100, 100, 400, 400));
- finishBuilderByAddingPlatformViewAndPicture(builder, 1);
+ finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with clip rrect.
class PlatformViewClipRRectScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rrect scenario.
- PlatformViewClipRRectScenario(Window window, String text, {int id = 0})
+ PlatformViewClipRRectScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
@@ -431,14 +459,14 @@ class PlatformViewClipRRectScenario extends PlatformViewScenario {
bottomLeft: const Radius.circular(50),
),
);
- finishBuilderByAddingPlatformViewAndPicture(builder, 2);
+ finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with clip path.
class PlatformViewClipPathScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rrect scenario.
- PlatformViewClipPathScenario(Window window, String text, {int id = 0})
+ PlatformViewClipPathScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
@@ -455,14 +483,14 @@ class PlatformViewClipPathScenario extends PlatformViewScenario {
..close();
builder.pushClipPath(path);
- finishBuilderByAddingPlatformViewAndPicture(builder, 3);
+ finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with transform.
class PlatformViewTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with transform scenario.
- PlatformViewTransformScenario(Window window, String text, {int id = 0})
+ PlatformViewTransformScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
@@ -477,14 +505,14 @@ class PlatformViewTransformScenario extends PlatformViewScenario {
builder.pushTransform(matrix4.storage);
- finishBuilderByAddingPlatformViewAndPicture(builder, 4);
+ finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with opacity.
class PlatformViewOpacityScenario extends PlatformViewScenario {
/// Constructs a platform view with transform scenario.
- PlatformViewOpacityScenario(Window window, String text, {int id = 0})
+ PlatformViewOpacityScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
@@ -494,7 +522,7 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
builder.pushOffset(0, 0);
builder.pushOpacity(150);
- finishBuilderByAddingPlatformViewAndPicture(builder, 5);
+ finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
@@ -524,7 +552,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
- finishBuilderByAddingPlatformViewAndPicture(builder, 11);
+ finishBuilderByAddingPlatformViewAndPicture(builder, _viewId);
}
@override
@@ -562,17 +590,23 @@ class PlatformViewForTouchIOSScenario extends Scenario
mixin _BasePlatformViewScenarioMixin on Scenario {
int _textureId;
+ bool get usesAndroidHybridComposition {
+ return (scenarioParams['use_android_view'] as bool) == true;
+ }
+
/// Construct the platform view related scenario
///
/// It prepare a TextPlatformView so it can be added to the SceneBuilder in `onBeginFrame`.
/// Call this method in the constructor of the platform view related scenarios
/// to perform necessary set up.
void createPlatformView(Window window, String text, int id, {String viewType = 'scenarios/textPlatformView'}) {
+ const int _valueTrue = 1;
const int _valueInt32 = 3;
const int _valueFloat64 = 6;
const int _valueString = 7;
const int _valueUint8List = 8;
const int _valueMap = 13;
+
final Uint8List message = Uint8List.fromList([
_valueString,
'create'.length, // this won't work if we use multi-byte characters.
@@ -580,8 +614,10 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
_valueMap,
if (Platform.isIOS)
3, // 3 entries in map for iOS.
- if (Platform.isAndroid)
- 6, // 6 entries in map for Android.
+ if (Platform.isAndroid && !usesAndroidHybridComposition)
+ 6, // 6 entries in map for virtual displays on Android.
+ if (Platform.isAndroid && usesAndroidHybridComposition)
+ 5, // 5 entries in map for Android views.
_valueString,
'id'.length,
...utf8.encode('id'),
@@ -593,7 +629,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
_valueString,
viewType.length,
...utf8.encode(viewType),
- if (Platform.isAndroid) ...[
+ if (Platform.isAndroid && !usesAndroidHybridComposition) ...[
_valueString,
'width'.length,
...utf8.encode('width'),
@@ -610,6 +646,17 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
_valueInt32,
..._to32(0), // LTR
],
+ if (Platform.isAndroid && usesAndroidHybridComposition) ...[
+ _valueString,
+ 'hybrid'.length,
+ ...utf8.encode('hybrid'),
+ _valueTrue,
+ _valueString,
+ 'direction'.length,
+ ...utf8.encode('direction'),
+ _valueInt32,
+ ..._to32(0), // LTR
+ ],
_valueString,
'params'.length,
...utf8.encode('params'),
@@ -622,7 +669,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
'flutter/platform_views',
message.buffer.asByteData(),
(ByteData response) {
- if (response != null && Platform.isAndroid) {
+ if (response != null && Platform.isAndroid && !usesAndroidHybridComposition) {
// Envelope.
_textureId = response.getUint8(0);
}
@@ -641,9 +688,12 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
if (Platform.isIOS) {
sceneBuilder.addPlatformView(viewId, offset: overlayOffset, width: width, height: height);
} else if (Platform.isAndroid) {
- if (scenarioParams['use_android_view'] as bool) {
- // Hybrid composition.
- sceneBuilder.addPlatformView(viewId, offset: overlayOffset, width: width, height: height);
+ if (usesAndroidHybridComposition) {
+ // Hybrid composition does not support `offset`.
+ // https://github.com/flutter/flutter/issues/60630
+ sceneBuilder.pushOffset(overlayOffset.dx, overlayOffset.dy);
+ sceneBuilder.addPlatformView(viewId, width: width, height: height);
+ sceneBuilder.pop();
} else if (_textureId != null) {
sceneBuilder.addTexture(_textureId, offset: overlayOffset, width: width, height: height);
}
diff --git a/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart b/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart
index 861c71a354..6f4bf28d28 100644
--- a/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart
+++ b/engine/src/flutter/testing/scenario_app/lib/src/scenarios.dart
@@ -13,52 +13,59 @@ import 'scenario.dart';
import 'send_text_focus_semantics.dart';
import 'touches_scenario.dart';
-Map _scenarios = {
- 'animated_color_square': AnimatedColorSquareScenario(window),
- 'locale_initialization': LocaleInitialization(window),
- 'platform_view': PlatformViewScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_no_overlay_intersection': PlatformViewNoOverlayIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_partial_intersection': PlatformViewPartialIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_two_intersecting_overlays': PlatformViewTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_one_overlay_two_intersecting_overlays': PlatformViewOneOverlayTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_multiple_without_overlays': MultiPlatformViewWithoutOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_max_overlays': PlatformViewMaxOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
- 'platform_view_cliprect': PlatformViewClipRectScenario(window, 'PlatformViewClipRect', id: 1),
- 'platform_view_cliprrect': PlatformViewClipRRectScenario(window, 'PlatformViewClipRRect', id: 2),
- 'platform_view_clippath': PlatformViewClipPathScenario(window, 'PlatformViewClipPath', id: 3),
- 'platform_view_transform': PlatformViewTransformScenario(window, 'PlatformViewTransform', id: 4),
- 'platform_view_opacity': PlatformViewOpacityScenario(window, 'PlatformViewOpacity', id: 5),
- 'platform_view_multiple': MultiPlatformViewScenario(window, firstId: 6, secondId: 7),
- 'platform_view_multiple_background_foreground': MultiPlatformViewBackgroundForegroundScenario(window, firstId: 8, secondId: 9),
- 'poppable_screen': PoppableScreenScenario(window),
- 'platform_view_rotate': PlatformViewScenario(window, 'Rotate Platform View', id: 10),
- 'platform_view_gesture_reject_eager': PlatformViewForTouchIOSScenario(window, 'platform view touch', id: 11, accept: false),
- 'platform_view_gesture_accept': PlatformViewForTouchIOSScenario(window, 'platform view touch', id: 11, accept: true),
- 'platform_view_gesture_reject_after_touches_ended': PlatformViewForTouchIOSScenario(window, 'platform view touch', id: 11, accept: false, rejectUntilTouchesEnded: true),
- 'tap_status_bar': TouchesScenario(window),
- 'text_semantics_focus': SendTextFocusScemantics(window),
+typedef ScenarioFactory = Scenario Function();
+
+int _viewId = 0;
+
+Map _scenarios = {
+ 'animated_color_square': () => AnimatedColorSquareScenario(window),
+ 'locale_initialization': () => LocaleInitialization(window),
+ 'platform_view': () => PlatformViewScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
+ 'platform_view_no_overlay_intersection': () => PlatformViewNoOverlayIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
+ 'platform_view_partial_intersection': () => PlatformViewPartialIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
+ 'platform_view_two_intersecting_overlays': () => PlatformViewTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
+ 'platform_view_one_overlay_two_intersecting_overlays': () => PlatformViewOneOverlayTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
+ 'platform_view_multiple_without_overlays': () => MultiPlatformViewWithoutOverlaysScenario(window, 'Hello from Scenarios (Platform View)', firstId: _viewId++, secondId: _viewId++),
+ 'platform_view_max_overlays': () => PlatformViewMaxOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
+ 'platform_view_cliprect': () => PlatformViewClipRectScenario(window, 'PlatformViewClipRect', id: _viewId++),
+ 'platform_view_cliprrect': () => PlatformViewClipRRectScenario(window, 'PlatformViewClipRRect', id: _viewId++),
+ 'platform_view_clippath': () => PlatformViewClipPathScenario(window, 'PlatformViewClipPath', id: _viewId++),
+ 'platform_view_transform': () => PlatformViewTransformScenario(window, 'PlatformViewTransform', id: _viewId++),
+ 'platform_view_opacity': () => PlatformViewOpacityScenario(window, 'PlatformViewOpacity', id: _viewId++),
+ 'platform_view_multiple': () => MultiPlatformViewScenario(window, firstId: 6, secondId: _viewId++),
+ 'platform_view_multiple_background_foreground': () => MultiPlatformViewBackgroundForegroundScenario(window, firstId: _viewId++, secondId: _viewId++),
+ 'poppable_screen': () => PoppableScreenScenario(window),
+ 'platform_view_rotate': () => PlatformViewScenario(window, 'Rotate Platform View', id: _viewId++),
+ 'platform_view_gesture_reject_eager': () => PlatformViewForTouchIOSScenario(window, 'platform view touch', id: _viewId++, accept: false),
+ 'platform_view_gesture_accept': () => PlatformViewForTouchIOSScenario(window, 'platform view touch', id: _viewId++, accept: true),
+ 'platform_view_gesture_reject_after_touches_ended': () => PlatformViewForTouchIOSScenario(window, 'platform view touch', id: _viewId++, accept: false, rejectUntilTouchesEnded: true),
+ 'tap_status_bar': () => TouchesScenario(window),
+ 'text_semantics_focus': () => SendTextFocusScemantics(window),
};
-Map _currentScenario = {
+Map _currentScenarioParams = {
'name': 'animated_color_square',
};
+Scenario _currentScenarioInstance = _scenarios[_currentScenarioParams['name']]();
+
/// Loads an scenario.
/// The map must contain a `name` entry, which equals to the name of the scenario.
void loadScenario(Map scenario) {
final String scenarioName = scenario['name'] as String;
assert(_scenarios[scenarioName] != null);
- _currentScenario = scenario;
+ _currentScenarioParams = scenario;
+ _currentScenarioInstance = _scenarios[scenario['name']]();
window.scheduleFrame();
print('Loading scenario $scenarioName');
}
/// Gets the loaded [Scenario].
Scenario get currentScenario {
- return _currentScenario != null ? _scenarios[_currentScenario['name']] : null;
+ return _currentScenarioInstance;
}
/// Gets the parameters passed to the app over the channel.
Map get scenarioParams {
- return Map.from(_currentScenario);
+ return Map.from(_currentScenarioParams);
}