Skip to content

Commit 1965c92

Browse files
authored
[revert] Convert Gfx PlatformView to use modern TouchSource API (flutter#33471)
1 parent 05814d9 commit 1965c92

File tree

7 files changed

+36
-31
lines changed

7 files changed

+36
-31
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/flatland_platform_view.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ FlatlandPlatformView::FlatlandPlatformView(
3232
AwaitVsyncCallback await_vsync_callback,
3333
AwaitVsyncForSecondaryCallbackCallback
3434
await_vsync_for_secondary_callback_callback)
35-
: PlatformView(delegate,
35+
: PlatformView(true /* is_flatland */,
36+
delegate,
3637
std::move(task_runners),
3738
std::move(view_ref),
3839
std::move(external_view_embedder),

shell/platform/fuchsia/flutter/gfx_platform_view.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ GfxPlatformView::GfxPlatformView(
3333
AwaitVsyncCallback await_vsync_callback,
3434
AwaitVsyncForSecondaryCallbackCallback
3535
await_vsync_for_secondary_callback_callback)
36-
: PlatformView(delegate,
36+
: PlatformView(false /* is_flatland */,
37+
delegate,
3738
std::move(task_runners),
3839
std::move(view_ref),
3940
std::move(external_view_embedder),

shell/platform/fuchsia/flutter/platform_view.cc

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void SetInterfaceErrorHandler(fidl::Binding<T>& binding, std::string name) {
5151
}
5252

5353
PlatformView::PlatformView(
54+
bool is_flatland,
5455
flutter::PlatformView::Delegate& delegate,
5556
flutter::TaskRunners task_runners,
5657
fuchsia::ui::views::ViewRef view_ref,
@@ -121,31 +122,33 @@ PlatformView::PlatformView(
121122
});
122123

123124
// Begin watching for pointer events.
124-
pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
125-
std::vector<flutter::PointerData> events) {
126-
if (!weak) {
127-
FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
128-
return;
129-
}
125+
if (is_flatland) { // TODO(fxbug.dev/85125): make unconditional
126+
pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
127+
std::vector<flutter::PointerData> events) {
128+
if (!weak) {
129+
FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
130+
return;
131+
}
130132

131-
if (events.empty()) {
132-
return; // No work, bounce out.
133-
}
133+
if (events.size() == 0) {
134+
return; // No work, bounce out.
135+
}
134136

135-
// If pixel ratio hasn't been set, use a default value of 1.
136-
const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
137-
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
138-
for (size_t i = 0; i < events.size(); ++i) {
139-
auto& event = events[i];
140-
// Translate logical to physical coordinates, as per
141-
// flutter::PointerData contract. Done here because pixel ratio comes
142-
// from the graphics API.
143-
event.physical_x = event.physical_x * pixel_ratio;
144-
event.physical_y = event.physical_y * pixel_ratio;
145-
packet->SetPointerData(i, event);
146-
}
147-
weak->DispatchPointerDataPacket(std::move(packet));
148-
});
137+
// If pixel ratio hasn't been set, use a default value of 1.
138+
const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
139+
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
140+
for (size_t i = 0; i < events.size(); ++i) {
141+
auto& event = events[i];
142+
// Translate logical to physical coordinates, as per
143+
// flutter::PointerData contract. Done here because pixel ratio comes
144+
// from the graphics API.
145+
event.physical_x = event.physical_x * pixel_ratio;
146+
event.physical_y = event.physical_y * pixel_ratio;
147+
packet->SetPointerData(i, event);
148+
}
149+
weak->DispatchPointerDataPacket(std::move(packet));
150+
});
151+
}
149152

150153
// Finally! Register the native platform message handlers.
151154
RegisterPlatformMessageHandlers();

shell/platform/fuchsia/flutter/platform_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class PlatformView : public flutter::PlatformView,
6464
private fuchsia::ui::input::InputMethodEditorClient {
6565
public:
6666
PlatformView(
67+
bool is_flatland,
6768
flutter::PlatformView::Delegate& delegate,
6869
flutter::TaskRunners task_runners,
6970
fuchsia::ui::views::ViewRef view_ref,

shell/platform/fuchsia/flutter/platform_view_unittest.cc

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

1388-
TEST_F(PlatformViewTests, TouchSourceLogicalToPhysicalConversion) {
1388+
// TODO(fxbug.dev/85125): Enable when GFX converts to TouchSource.
1389+
TEST_F(PlatformViewTests, DISABLED_TouchSourceLogicalToPhysicalConversion) {
13891390
constexpr std::array<std::array<float, 2>, 2> kRect = {{{0, 0}, {20, 20}}};
13901391
constexpr std::array<float, 9> kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
13911392
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
@@ -429,9 +429,7 @@ void PointerDelegate::WatchLoop(
429429
// Start watching both channels.
430430
touch_source_->Watch(std::move(touch_responses_), /*copy*/ touch_responder_);
431431
touch_responses_.clear();
432-
if (mouse_source_) {
433-
mouse_source_->Watch(/*copy*/ mouse_responder_);
434-
}
432+
mouse_source_->Watch(/*copy*/ mouse_responder_);
435433
}
436434

437435
} // namespace flutter_runner

0 commit comments

Comments
 (0)