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

Commit 2610a1b

Browse files
authored
Revert "[fuchsia] Convert Gfx PlatformView to use modern TouchSource API (#35018)"
This reverts commit 25e8021.
1 parent 98c0699 commit 2610a1b

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

shell/platform/fuchsia/flutter/engine.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ void Engine::Initialize(
166166
} else {
167167
gfx_protocols.set_view_focuser(focuser.NewRequest());
168168
gfx_protocols.set_view_ref_focused(view_ref_focused.NewRequest());
169-
gfx_protocols.set_touch_source(touch_source.NewRequest());
170-
// GFX used only on products without a mouse.
169+
// TODO(fxbug.dev/85125): Enable TouchSource for GFX.
170+
// gfx_protocols.set_touch_source(touch_source.NewRequest());
171171
}
172172
scenic->CreateSessionT(std::move(gfx_protocols), [] {});
173173

shell/platform/fuchsia/flutter/platform_view.cc

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,33 @@ PlatformView::PlatformView(
109109
});
110110

111111
// Begin watching for pointer events.
112-
pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
113-
std::vector<flutter::PointerData> events) {
114-
if (!weak) {
115-
FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
116-
return;
117-
}
112+
if (is_flatland) { // TODO(fxbug.dev/85125): make unconditional
113+
pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
114+
std::vector<flutter::PointerData> events) {
115+
if (!weak) {
116+
FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
117+
return;
118+
}
118119

119-
if (events.empty()) {
120-
return; // No work, bounce out.
121-
}
120+
if (events.size() == 0) {
121+
return; // No work, bounce out.
122+
}
122123

123-
// If pixel ratio hasn't been set, use a default value of 1.
124-
const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
125-
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
126-
for (size_t i = 0; i < events.size(); ++i) {
127-
auto& event = events[i];
128-
// Translate logical to physical coordinates, as per
129-
// flutter::PointerData contract. Done here because pixel ratio comes
130-
// from the graphics API.
131-
event.physical_x = event.physical_x * pixel_ratio;
132-
event.physical_y = event.physical_y * pixel_ratio;
133-
packet->SetPointerData(i, event);
134-
}
135-
weak->DispatchPointerDataPacket(std::move(packet));
136-
});
124+
// If pixel ratio hasn't been set, use a default value of 1.
125+
const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
126+
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
127+
for (size_t i = 0; i < events.size(); ++i) {
128+
auto& event = events[i];
129+
// Translate logical to physical coordinates, as per
130+
// flutter::PointerData contract. Done here because pixel ratio comes
131+
// from the graphics API.
132+
event.physical_x = event.physical_x * pixel_ratio;
133+
event.physical_y = event.physical_y * pixel_ratio;
134+
packet->SetPointerData(i, event);
135+
}
136+
weak->DispatchPointerDataPacket(std::move(packet));
137+
});
138+
}
137139

138140
// Configure the pointer injector delegate.
139141
pointer_injector_delegate_ = std::make_unique<PointerInjectorDelegate>(

shell/platform/fuchsia/flutter/platform_view_unittest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,8 @@ TEST_F(PlatformViewTests, OnShaderWarmup) {
13961396
EXPECT_EQ(expected_result_string, response->result_string);
13971397
}
13981398

1399-
TEST_F(PlatformViewTests, TouchSourceLogicalToPhysicalConversion) {
1399+
// TODO(fxbug.dev/85125): Enable when GFX converts to TouchSource.
1400+
TEST_F(PlatformViewTests, DISABLED_TouchSourceLogicalToPhysicalConversion) {
14001401
constexpr std::array<std::array<float, 2>, 2> kRect = {{{0, 0}, {20, 20}}};
14011402
constexpr std::array<float, 9> kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
14021403
constexpr fuchsia::ui::pointer::TouchInteractionId kIxnOne = {

shell/platform/fuchsia/flutter/pointer_delegate.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,7 @@ void PointerDelegate::WatchLoop(
447447
// Start watching both channels.
448448
touch_source_->Watch(std::move(touch_responses_), /*copy*/ touch_responder_);
449449
touch_responses_.clear();
450-
if (mouse_source_) {
451-
mouse_source_->Watch(/*copy*/ mouse_responder_);
452-
}
450+
mouse_source_->Watch(/*copy*/ mouse_responder_);
453451
}
454452

455453
} // namespace flutter_runner

0 commit comments

Comments
 (0)