Skip to content

Commit

Permalink
[fuchsia] Remove spurious ERROR log (flutter#32870)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeheon authored Apr 23, 2022
1 parent 8ab4124 commit 0e8e617
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
3 changes: 2 additions & 1 deletion shell/platform/fuchsia/flutter/flatland_platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ FlatlandPlatformView::FlatlandPlatformView(
AwaitVsyncCallback await_vsync_callback,
AwaitVsyncForSecondaryCallbackCallback
await_vsync_for_secondary_callback_callback)
: PlatformView(delegate,
: PlatformView(true /* is_flatland */,
delegate,
std::move(task_runners),
std::move(view_ref),
std::move(external_view_embedder),
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/fuchsia/flutter/gfx_platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ GfxPlatformView::GfxPlatformView(
AwaitVsyncCallback await_vsync_callback,
AwaitVsyncForSecondaryCallbackCallback
await_vsync_for_secondary_callback_callback)
: PlatformView(delegate,
: PlatformView(false /* is_flatland */,
delegate,
std::move(task_runners),
std::move(view_ref),
std::move(external_view_embedder),
Expand Down
48 changes: 26 additions & 22 deletions shell/platform/fuchsia/flutter/platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void SetInterfaceErrorHandler(fidl::Binding<T>& binding, std::string name) {
}

PlatformView::PlatformView(
bool is_flatland,
flutter::PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
fuchsia::ui::views::ViewRef view_ref,
Expand Down Expand Up @@ -121,30 +122,33 @@ PlatformView::PlatformView(
});

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

if (events.size() == 0) {
return; // No work, bounce out.
}
if (events.size() == 0) {
return; // No work, bounce out.
}

// 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);
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
for (size_t i = 0; i < events.size(); ++i) {
auto& event = events[i];
// Translate logical to physical coordinates, as per flutter::PointerData
// contract. Done here because pixel ratio comes from the graphics API.
event.physical_x = event.physical_x * pixel_ratio;
event.physical_y = event.physical_y * pixel_ratio;
packet->SetPointerData(i, event);
}
weak->DispatchPointerDataPacket(std::move(packet));
});
// 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);
auto packet = std::make_unique<flutter::PointerDataPacket>(events.size());
for (size_t i = 0; i < events.size(); ++i) {
auto& event = events[i];
// Translate logical to physical coordinates, as per
// flutter::PointerData contract. Done here because pixel ratio comes
// from the graphics API.
event.physical_x = event.physical_x * pixel_ratio;
event.physical_y = event.physical_y * pixel_ratio;
packet->SetPointerData(i, event);
}
weak->DispatchPointerDataPacket(std::move(packet));
});
}

// Finally! Register the native platform message handlers.
RegisterPlatformMessageHandlers();
Expand Down
1 change: 1 addition & 0 deletions shell/platform/fuchsia/flutter/platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class PlatformView : public flutter::PlatformView,
private fuchsia::ui::input::InputMethodEditorClient {
public:
PlatformView(
bool is_flatland,
flutter::PlatformView::Delegate& delegate,
flutter::TaskRunners task_runners,
fuchsia::ui::views::ViewRef view_ref,
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/fuchsia/flutter/platform_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,8 @@ TEST_F(PlatformViewTests, OnShaderWarmup) {
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<float, 9> kIdentity = {1, 0, 0, 0, 1, 0, 0, 0, 1};
constexpr fuchsia::ui::pointer::TouchInteractionId kIxnOne = {
Expand Down

0 comments on commit 0e8e617

Please sign in to comment.