diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.cc b/shell/platform/android/external_view_embedder/external_view_embedder.cc index dde2890bae2e8..070e54fd70551 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder.cc @@ -125,22 +125,19 @@ void AndroidExternalViewEmbedder::SubmitFrame( joined_rect.join(rect); } } - - if (joined_rect.isEmpty()) { - continue; + if (!joined_rect.isEmpty()) { + // Subpixels in the platform may not align with the canvas subpixels. + // + // To workaround it, round the floating point bounds and make the rect + // slightly larger. + // + // For example, {0.3, 0.5, 3.1, 4.7} becomes {0, 0, 4, 5}. + joined_rect.set(joined_rect.roundOut()); + overlay_layers.insert({view_id, joined_rect}); + // Clip the background canvas, so it doesn't contain any of the pixels + // drawn on the overlay layer. + background_canvas->clipRect(joined_rect, SkClipOp::kDifference); } - - // Subpixels in the platform may not align with the canvas subpixels. - // - // To workaround it, round the floating point bounds and make the rect - // slightly larger. - // - // For example, {0.3, 0.5, 3.1, 4.7} becomes {0, 0, 4, 5}. - joined_rect.set(joined_rect.roundOut()); - overlay_layers.insert({view_id, joined_rect}); - // Clip the background canvas, so it doesn't contain any of the pixels - // drawn on the overlay layer. - background_canvas->clipRect(joined_rect, SkClipOp::kDifference); background_canvas->drawPicture(pictures.at(view_id)); } // Submit the background canvas frame before switching the GL context to diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java index 770d1e87ce9ac..2723ed7b793f6 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java @@ -96,4 +96,10 @@ public void testPlatformViewTwoIntersectingOverlays() throws Exception { intent.putExtra("scenario", "platform_view_two_intersecting_overlays"); ScreenshotUtil.capture(activityRule.launchActivity(intent)); } + + @Test + public void testPlatformViewWithoutOverlayIntersection() throws Exception { + intent.putExtra("scenario", "platform_view_no_overlay_intersection"); + ScreenshotUtil.capture(activityRule.launchActivity(intent)); + } } diff --git a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java index 54fcdf4d5c51a..63b866779588b 100644 --- a/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java +++ b/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java @@ -96,4 +96,10 @@ public void testPlatformViewTwoIntersectingOverlays() throws Exception { intent.putExtra("scenario", "platform_view_two_intersecting_overlays"); ScreenshotUtil.capture(activityRule.launchActivity(intent)); } + + @Test + public void testPlatformViewWithoutOverlayIntersection() throws Exception { + intent.putExtra("scenario", "platform_view_no_overlay_intersection"); + ScreenshotUtil.capture(activityRule.launchActivity(intent)); + } } diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformView.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformView.png index e156516b90071..e306303d2df03 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformView.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformView.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewClippath.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewClippath.png index cbeeffe9c4019..8b3ce0b747cbf 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewClippath.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewClippath.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprect.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprect.png index 5fa8ce6514c38..8711e785359f9 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprect.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprect.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprrect.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprrect.png index 1d9e4d6096421..bd84e34a7d81b 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprrect.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewCliprrect.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultiple.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultiple.png index d8114305c9bc4..2efaa30868b5a 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultiple.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultiple.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleBackgroundForeground.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleBackgroundForeground.png index b0efa3c418caf..0383f6a2cdc70 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleBackgroundForeground.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleBackgroundForeground.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleWithoutOverlays.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleWithoutOverlays.png index 31bcd62f6aeb8..8a7fa8caf5829 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleWithoutOverlays.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewMultipleWithoutOverlays.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewOpacity.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewOpacity.png index ce9baa21868fd..8d37c9dff3a9e 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewOpacity.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewOpacity.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewRotate.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewRotate.png index 5b2b8f8d8d807..3639a3b20be56 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewRotate.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewRotate.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTransform.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTransform.png index 5c2a0f394445c..5f5f2b5131365 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTransform.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTransform.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTwoIntersectingOverlays.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTwoIntersectingOverlays.png index a339678ed2d1d..f127ffcaa22cf 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTwoIntersectingOverlays.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewTwoIntersectingOverlays.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewWithoutOverlayIntersection.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewWithoutOverlayIntersection.png new file mode 100644 index 0000000000000..7970d1375e0a9 Binary files /dev/null and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformTextureUiTests__testPlatformViewWithoutOverlayIntersection.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformViewUiTests__testPlatformViewWithoutOverlayIntersection.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformViewUiTests__testPlatformViewWithoutOverlayIntersection.png new file mode 100644 index 0000000000000..f0e71fb9ed8c7 Binary files /dev/null and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.PlatformViewUiTests__testPlatformViewWithoutOverlayIntersection.png differ diff --git a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.SpawnEngineTests__testSpawnedEngine.png b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.SpawnEngineTests__testSpawnedEngine.png index 8771e1487403f..381f4e75d311e 100644 Binary files a/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.SpawnEngineTests__testSpawnedEngine.png and b/testing/scenario_app/android/reports/screenshots/dev.flutter.scenariosui.SpawnEngineTests__testSpawnedEngine.png differ