From 562e87e3f48edcc866a98f85bc5d5a7b5397d14a Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Wed, 19 May 2021 20:44:03 -0700 Subject: [PATCH] Fix hybrid composition case and enable test (flutter/engine#26272) --- .../external_view_embedder.cc | 27 +++++++++---------- .../scenariosui/PlatformTextureUiTests.java | 6 +++++ .../scenariosui/PlatformViewUiTests.java | 6 +++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/external_view_embedder/external_view_embedder.cc b/engine/src/flutter/shell/platform/android/external_view_embedder/external_view_embedder.cc index dde2890bae2..070e54fd705 100644 --- a/engine/src/flutter/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/engine/src/flutter/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/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java index 770d1e87ce9..2723ed7b793 100644 --- a/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java +++ b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformTextureUiTests.java @@ -96,4 +96,10 @@ public class PlatformTextureUiTests { 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/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java index 54fcdf4d5c5..63b86677958 100644 --- a/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java +++ b/engine/src/flutter/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenariosui/PlatformViewUiTests.java @@ -96,4 +96,10 @@ public class PlatformViewUiTests { 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)); + } }