Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[fuchsia][scenic] Add input shield flag support in Flatland. #36880

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions shell/platform/fuchsia/flutter/flatland_external_view_embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ FlatlandExternalViewEmbedder::FlatlandExternalViewEmbedder(
root_transform_id_ = flatland_->NextTransformId();
flatland_->flatland()->CreateTransform(root_transform_id_);
flatland_->flatland()->SetRootTransform(root_transform_id_);

if (intercept_all_input) {
input_interceptor_transform_ = flatland_->NextTransformId();
flatland_->flatland()->CreateTransform(*input_interceptor_transform_);

flatland_->flatland()->AddChild(root_transform_id_,
*input_interceptor_transform_);
child_transforms_.emplace_back(*input_interceptor_transform_);

// Attach full-screen hit testing shield. Note that since the hit-region
// may be transformed (translated, rotated), we do not want to set
// width/height to FLT_MAX. This will cause a numeric overflow.
flatland_->flatland()->SetHitRegions(
*input_interceptor_transform_,
{{{0, 0, kMaxHitRegionSize, kMaxHitRegionSize},
fuchsia::ui::composition::HitTestInteraction::
SEMANTICALLY_INVISIBLE}});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gfx is adding the child here, so lets just follow that? We should also add it to child_transforms_.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

FlatlandExternalViewEmbedder::~FlatlandExternalViewEmbedder() = default;
Expand Down Expand Up @@ -336,6 +354,18 @@ void FlatlandExternalViewEmbedder::SubmitFrame(
// Reset for the next pass:
flatland_layer_index++;
}

// TODO(fxbug.dev/104956): Setting per-layer overlay hit region for Flatland
// external view embedder should match with what is being done in GFX
// external view embedder.
// Set up the input interceptor at the top of the
// scene, if applicable. It will capture all input, and any unwanted input
// will be reinjected into embedded views.
if (input_interceptor_transform_.has_value()) {
flatland_->flatland()->AddChild(root_transform_id_,
*input_interceptor_transform_);
child_transforms_.emplace_back(*input_interceptor_transform_);
}
}

// Present the session to Scenic, along with surface acquire/release fences.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ class FlatlandExternalViewEmbedder final
SkISize frame_size_ = SkISize::Make(0, 0);
float frame_dpr_ = 1.f;

// TransformId for the input interceptor node when input shield is turned on,
// std::nullptr otherwise.
std::optional<fuchsia::ui::composition::TransformId>
input_interceptor_transform_;

FML_DISALLOW_COPY_AND_ASSIGN(FlatlandExternalViewEmbedder);
};

Expand Down