From e893b8feb25ab5f0cb50079f3020e037d9b17ef6 Mon Sep 17 00:00:00 2001 From: cfontas Date: Tue, 8 Feb 2022 14:30:07 -0800 Subject: [PATCH] [fuchsia] Update Flatland Clipping API (flutter/engine#31311) --- .../flutter/tests/fakes/scenic/fake_flatland.cc | 15 ++++++++++----- .../flutter/tests/fakes/scenic/fake_flatland.h | 4 ++-- .../tests/fakes/scenic/fake_flatland_types.cc | 6 +++--- .../tests/fakes/scenic/fake_flatland_types.h | 6 +----- .../flatland_external_view_embedder_unittests.cc | 8 ++++---- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.cc index b6733254d9..2359fcfabb 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.cc @@ -234,27 +234,32 @@ void FakeFlatland::SetOrientation( transform->orientation = orientation; } -void FakeFlatland::SetClipBounds( +void FakeFlatland::SetClipBoundary( fuchsia::ui::composition::TransformId transform_id, - fuchsia::math::Rect clip_bounds) { + std::unique_ptr bounds) { if (transform_id.value == 0) { // TODO(fxb/85619): Raise a FlatlandError here FML_CHECK(false) - << "FakeFlatland::SetClipBounds: TransformId 0 is invalid."; + << "FakeFlatland::SetClipBoundary: TransformId 0 is invalid."; return; } auto found_transform = pending_graph_.transform_map.find(transform_id.value); if (found_transform == pending_graph_.transform_map.end()) { // TODO(fxb/85619): Raise a FlatlandError here - FML_CHECK(false) << "FakeFlatland::SetClipBounds: TransformId " + FML_CHECK(false) << "FakeFlatland::SetClipBoundary: TransformId " << transform_id.value << " does not exist."; return; } auto& transform = found_transform->second; FML_CHECK(transform); - transform->clip_bounds = clip_bounds; + if (bounds == nullptr) { + transform->clip_bounds = std::nullopt; + return; + } + + transform->clip_bounds = *bounds.get(); } // TODO(fxbug.dev/89111): Re-enable once SDK rolls. diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.h b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.h index 507f7eb2f0..5690939ac3 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland.h @@ -227,8 +227,8 @@ class FakeFlatland fuchsia::ui::composition::Orientation orientation) override; // |fuchsia::ui::composition::Flatland| - void SetClipBounds(fuchsia::ui::composition::TransformId transform_id, - fuchsia::math::Rect clip_bounds) override; + void SetClipBoundary(fuchsia::ui::composition::TransformId transform_id, + std::unique_ptr bounds) override; // TODO(fxbug.dev/89111): Re-enable once SDK rolls. // // |fuchsia::ui::composition::Flatland| diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.cc index f509feb6f5..9d72400d98 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.cc @@ -132,9 +132,9 @@ bool FakeImage::operator==(const FakeImage& other) const { bool FakeTransform::operator==(const FakeTransform& other) const { return id == other.id && translation == other.translation && - clip_bounds == other.clip_bounds && orientation == other.orientation && - children == other.children && content == other.content && - num_hit_regions == other.num_hit_regions; + *clip_bounds == *other.clip_bounds && + orientation == other.orientation && children == other.children && + content == other.content && num_hit_regions == other.num_hit_regions; } bool FakeGraph::operator==(const FakeGraph& other) const { diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.h b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.h index 86b563f35f..3572f9cd12 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/fakes/scenic/fake_flatland_types.h @@ -165,17 +165,13 @@ struct FakeTransform { bool operator==(const FakeTransform& other) const; constexpr static fuchsia::math::Vec kDefaultTranslation{.x = 0, .y = 0}; - constexpr static fuchsia::math::Rect kDefaultClipBounds{.x = 0, - .y = 0, - .width = 0, - .height = 0}; constexpr static fuchsia::ui::composition::Orientation kDefaultOrientation{ fuchsia::ui::composition::Orientation::CCW_0_DEGREES}; fuchsia::ui::composition::TransformId id{kInvalidTransformId}; fuchsia::math::Vec translation{kDefaultTranslation}; - fuchsia::math::Rect clip_bounds{kDefaultClipBounds}; + std::optional clip_bounds; fuchsia::ui::composition::Orientation orientation{kDefaultOrientation}; std::vector> children; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_external_view_embedder_unittests.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_external_view_embedder_unittests.cc index aa824c9ed5..4531107c76 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_external_view_embedder_unittests.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/tests/flatland_external_view_embedder_unittests.cc @@ -215,7 +215,7 @@ Matcher IsFlutterGraph( /*content_map*/ _, /*transform_map*/ _, Pointee(FieldsAre( /*id*/ _, FakeTransform::kDefaultTranslation, - FakeTransform::kDefaultClipBounds, FakeTransform::kDefaultOrientation, + /*clip_bounds*/ _, FakeTransform::kDefaultOrientation, /*children*/ ElementsAreArray(layer_matchers), /*content*/ Eq(nullptr), /*num_hit_regions*/ _)), Eq(FakeView{ @@ -236,7 +236,7 @@ Matcher> IsImageLayer( size_t num_hit_regions) { return Pointee(FieldsAre( /*id*/ _, FakeTransform::kDefaultTranslation, - FakeTransform::kDefaultClipBounds, FakeTransform::kDefaultOrientation, + /*clip_bounds*/ _, FakeTransform::kDefaultOrientation, /*children*/ IsEmpty(), /*content*/ Pointee(VariantWith(FieldsAre( @@ -252,8 +252,8 @@ Matcher> IsViewportLayer( const fuchsia::math::SizeU& view_logical_size, const fuchsia::math::Vec& view_transform) { return Pointee( - FieldsAre(_ /* id */, view_transform, FakeTransform::kDefaultClipBounds, - FakeTransform::kDefaultOrientation, + FieldsAre(/* id */ _, view_transform, + /*clip_bounds*/ _, FakeTransform::kDefaultOrientation, /*children*/ IsEmpty(), /*content*/ Pointee(VariantWith(FieldsAre(