[revert] Convert Gfx PlatformView to use modern TouchSource API (flutter/engine#33471)
This commit is contained in:
@@ -166,8 +166,8 @@ void Engine::Initialize(
|
|||||||
} else {
|
} else {
|
||||||
gfx_protocols.set_view_focuser(focuser.NewRequest());
|
gfx_protocols.set_view_focuser(focuser.NewRequest());
|
||||||
gfx_protocols.set_view_ref_focused(view_ref_focused.NewRequest());
|
gfx_protocols.set_view_ref_focused(view_ref_focused.NewRequest());
|
||||||
gfx_protocols.set_touch_source(touch_source.NewRequest());
|
// TODO(fxbug.dev/85125): Enable TouchSource for GFX.
|
||||||
// GFX used only on products without a mouse.
|
// gfx_protocols.set_touch_source(touch_source.NewRequest());
|
||||||
}
|
}
|
||||||
scenic->CreateSessionT(std::move(gfx_protocols), [] {});
|
scenic->CreateSessionT(std::move(gfx_protocols), [] {});
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ FlatlandPlatformView::FlatlandPlatformView(
|
|||||||
AwaitVsyncCallback await_vsync_callback,
|
AwaitVsyncCallback await_vsync_callback,
|
||||||
AwaitVsyncForSecondaryCallbackCallback
|
AwaitVsyncForSecondaryCallbackCallback
|
||||||
await_vsync_for_secondary_callback_callback)
|
await_vsync_for_secondary_callback_callback)
|
||||||
: PlatformView(delegate,
|
: PlatformView(true /* is_flatland */,
|
||||||
|
delegate,
|
||||||
std::move(task_runners),
|
std::move(task_runners),
|
||||||
std::move(view_ref),
|
std::move(view_ref),
|
||||||
std::move(external_view_embedder),
|
std::move(external_view_embedder),
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ GfxPlatformView::GfxPlatformView(
|
|||||||
AwaitVsyncCallback await_vsync_callback,
|
AwaitVsyncCallback await_vsync_callback,
|
||||||
AwaitVsyncForSecondaryCallbackCallback
|
AwaitVsyncForSecondaryCallbackCallback
|
||||||
await_vsync_for_secondary_callback_callback)
|
await_vsync_for_secondary_callback_callback)
|
||||||
: PlatformView(delegate,
|
: PlatformView(false /* is_flatland */,
|
||||||
|
delegate,
|
||||||
std::move(task_runners),
|
std::move(task_runners),
|
||||||
std::move(view_ref),
|
std::move(view_ref),
|
||||||
std::move(external_view_embedder),
|
std::move(external_view_embedder),
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ void SetInterfaceErrorHandler(fidl::Binding<T>& binding, std::string name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlatformView::PlatformView(
|
PlatformView::PlatformView(
|
||||||
|
bool is_flatland,
|
||||||
flutter::PlatformView::Delegate& delegate,
|
flutter::PlatformView::Delegate& delegate,
|
||||||
flutter::TaskRunners task_runners,
|
flutter::TaskRunners task_runners,
|
||||||
fuchsia::ui::views::ViewRef view_ref,
|
fuchsia::ui::views::ViewRef view_ref,
|
||||||
@@ -121,31 +122,33 @@ PlatformView::PlatformView(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Begin watching for pointer events.
|
// Begin watching for pointer events.
|
||||||
pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
|
if (is_flatland) { // TODO(fxbug.dev/85125): make unconditional
|
||||||
std::vector<flutter::PointerData> events) {
|
pointer_delegate_->WatchLoop([weak = weak_factory_.GetWeakPtr()](
|
||||||
if (!weak) {
|
std::vector<flutter::PointerData> events) {
|
||||||
FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
|
if (!weak) {
|
||||||
return;
|
FML_LOG(WARNING) << "PlatformView use-after-free attempted. Ignoring.";
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (events.empty()) {
|
if (events.size() == 0) {
|
||||||
return; // No work, bounce out.
|
return; // No work, bounce out.
|
||||||
}
|
}
|
||||||
|
|
||||||
// If pixel ratio hasn't been set, use a default value of 1.
|
// If pixel ratio hasn't been set, use a default value of 1.
|
||||||
const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
|
const float pixel_ratio = weak->view_pixel_ratio_.value_or(1.f);
|
||||||
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
|
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
|
||||||
for (size_t i = 0; i < events.size(); ++i) {
|
for (size_t i = 0; i < events.size(); ++i) {
|
||||||
auto& event = events[i];
|
auto& event = events[i];
|
||||||
// Translate logical to physical coordinates, as per
|
// Translate logical to physical coordinates, as per
|
||||||
// flutter::PointerData contract. Done here because pixel ratio comes
|
// flutter::PointerData contract. Done here because pixel ratio comes
|
||||||
// from the graphics API.
|
// from the graphics API.
|
||||||
event.physical_x = event.physical_x * pixel_ratio;
|
event.physical_x = event.physical_x * pixel_ratio;
|
||||||
event.physical_y = event.physical_y * pixel_ratio;
|
event.physical_y = event.physical_y * pixel_ratio;
|
||||||
packet->SetPointerData(i, event);
|
packet->SetPointerData(i, event);
|
||||||
}
|
}
|
||||||
weak->DispatchPointerDataPacket(std::move(packet));
|
weak->DispatchPointerDataPacket(std::move(packet));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Finally! Register the native platform message handlers.
|
// Finally! Register the native platform message handlers.
|
||||||
RegisterPlatformMessageHandlers();
|
RegisterPlatformMessageHandlers();
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class PlatformView : public flutter::PlatformView,
|
|||||||
private fuchsia::ui::input::InputMethodEditorClient {
|
private fuchsia::ui::input::InputMethodEditorClient {
|
||||||
public:
|
public:
|
||||||
PlatformView(
|
PlatformView(
|
||||||
|
bool is_flatland,
|
||||||
flutter::PlatformView::Delegate& delegate,
|
flutter::PlatformView::Delegate& delegate,
|
||||||
flutter::TaskRunners task_runners,
|
flutter::TaskRunners task_runners,
|
||||||
fuchsia::ui::views::ViewRef view_ref,
|
fuchsia::ui::views::ViewRef view_ref,
|
||||||
|
|||||||
@@ -1385,7 +1385,8 @@ TEST_F(PlatformViewTests, OnShaderWarmup) {
|
|||||||
EXPECT_EQ(expected_result_string, response->result_string);
|
EXPECT_EQ(expected_result_string, response->result_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlatformViewTests, TouchSourceLogicalToPhysicalConversion) {
|
// TODO(fxbug.dev/85125): Enable when GFX converts to TouchSource.
|
||||||
|
TEST_F(PlatformViewTests, DISABLED_TouchSourceLogicalToPhysicalConversion) {
|
||||||
constexpr std::array<std::array<float, 2>, 2> kRect = {{{0, 0}, {20, 20}}};
|
constexpr std::array<std::array<float, 2>, 2> kRect = {{{0, 0}, {20, 20}}};
|
||||||
constexpr std::array<float, 9> kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
constexpr std::array<float, 9> kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
||||||
constexpr fuchsia::ui::pointer::TouchInteractionId kIxnOne = {
|
constexpr fuchsia::ui::pointer::TouchInteractionId kIxnOne = {
|
||||||
|
|||||||
@@ -429,9 +429,7 @@ void PointerDelegate::WatchLoop(
|
|||||||
// Start watching both channels.
|
// Start watching both channels.
|
||||||
touch_source_->Watch(std::move(touch_responses_), /*copy*/ touch_responder_);
|
touch_source_->Watch(std::move(touch_responses_), /*copy*/ touch_responder_);
|
||||||
touch_responses_.clear();
|
touch_responses_.clear();
|
||||||
if (mouse_source_) {
|
mouse_source_->Watch(/*copy*/ mouse_responder_);
|
||||||
mouse_source_->Watch(/*copy*/ mouse_responder_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace flutter_runner
|
} // namespace flutter_runner
|
||||||
|
|||||||
Reference in New Issue
Block a user