forked from firka/flutter
[fuchsia] Update Flatland Clipping API (flutter/engine#31311)
This commit is contained in:
@@ -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<fuchsia::math::Rect> 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.
|
||||
|
||||
@@ -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<fuchsia::math::Rect> bounds) override;
|
||||
|
||||
// TODO(fxbug.dev/89111): Re-enable once SDK rolls.
|
||||
// // |fuchsia::ui::composition::Flatland|
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<fuchsia::math::Rect> clip_bounds;
|
||||
fuchsia::ui::composition::Orientation orientation{kDefaultOrientation};
|
||||
|
||||
std::vector<std::shared_ptr<FakeTransform>> children;
|
||||
|
||||
@@ -215,7 +215,7 @@ Matcher<FakeGraph> 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<std::shared_ptr<FakeTransform>> 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<FakeImage>(FieldsAre(
|
||||
@@ -252,8 +252,8 @@ Matcher<std::shared_ptr<FakeTransform>> 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<FakeViewport>(FieldsAre(
|
||||
|
||||
Reference in New Issue
Block a user