Flutter Engine
flutter::PointerDataPacketConverter Class Reference

#include <pointer_data_packet_converter.h>

Public Member Functions

 PointerDataPacketConverter ()
 
 ~PointerDataPacketConverter ()
 
std::unique_ptr< PointerDataPacketConvert (std::unique_ptr< PointerDataPacket > packet)
 Converts pointer data packet into a form that framework understands. The raw pointer data packet from embedding does not have sufficient information and may contain illegal pointer transitions. This method will fill out that information and attempt to correct pointer transitions. More...
 

Detailed Description

Converter to convert the raw pointer data packet from the platforms.

Framework requires certain information to process pointer data. e.g. pointer identifier and the delta of pointer moment. The converter keeps track each pointer state and fill in those information appropriately.

The converter is also resposible for providing a clean pointer data stream. It will attempt to correct the stream if the it contains illegal pointer transitions.

Example 1 Missing Add:

Down(position x) -> Up(position x)

###After Conversion###

Synthesized_Add(position x) -> Down(position x) -> Up(position x)

Example 2 Missing another move:

Add(position x) -> Down(position x) -> Move(position y) ->
Up(position z)

###After Conversion###

Add(position x) -> Down(position x) -> Move(position y) ->
Synthesized_Move(position z) -> Up(position z)

Platform view is the only client that uses this class to convert all the incoming pointer packet and is responsible for the life cycle of its instance.

Definition at line 63 of file pointer_data_packet_converter.h.

Constructor & Destructor Documentation

◆ PointerDataPacketConverter()

flutter::PointerDataPacketConverter::PointerDataPacketConverter ( )

Definition at line 13 of file pointer_data_packet_converter.cc.

References ~PointerDataPacketConverter().

13 : pointer_(0) {}

◆ ~PointerDataPacketConverter()

flutter::PointerDataPacketConverter::~PointerDataPacketConverter ( )
default

Member Function Documentation

◆ Convert()

std::unique_ptr< PointerDataPacket > flutter::PointerDataPacketConverter::Convert ( std::unique_ptr< PointerDataPacket packet)

Converts pointer data packet into a form that framework understands. The raw pointer data packet from embedding does not have sufficient information and may contain illegal pointer transitions. This method will fill out that information and attempt to correct pointer transitions.

Parameters
[in]packetThe raw pointer packet sent from embedding.
Returns
A full converted packet with all the required information filled. It may contain synthetic pointer data as the result of converter's attempt to correct illegal pointer transitions.

Definition at line 17 of file pointer_data_packet_converter.cc.

References flutter::PointerData::change, flutter::PointerData::device, FML_DCHECK, flutter::PointerState::isDown, flutter::PointerData::kAdd, flutter::kBytesPerField, flutter::PointerData::kCancel, flutter::PointerData::kDown, flutter::PointerData::kHover, flutter::PointerData::kMove, flutter::PointerData::kNone, flutter::kPointerDataFieldCount, flutter::PointerData::kRemove, flutter::PointerData::kScroll, flutter::PointerData::kUp, flutter::PointerData::physical_delta_x, flutter::PointerData::physical_delta_y, flutter::PointerState::physical_x, flutter::PointerData::physical_x, flutter::PointerState::physical_y, flutter::PointerData::physical_y, flutter::PointerState::pointer_identifier, flutter::PointerData::pointer_identifier, flutter::PointerData::signal_kind, and flutter::PointerData::synthesized.

Referenced by flutter::PlatformView::DispatchPointerDataPacket(), and flutter::testing::TEST().

18  {
19  size_t kBytesPerPointerData = kPointerDataFieldCount * kBytesPerField;
20  auto buffer = packet->data();
21  size_t buffer_length = buffer.size();
22 
23  std::vector<PointerData> converted_pointers;
24  // Converts each pointer data in the buffer and stores it in the
25  // converted_pointers.
26  for (size_t i = 0; i < buffer_length / kBytesPerPointerData; i++) {
27  PointerData pointer_data;
28  memcpy(&pointer_data, &buffer[i * kBytesPerPointerData],
29  sizeof(PointerData));
30  ConvertPointerData(pointer_data, converted_pointers);
31  }
32 
33  // Writes converted_pointers into converted_packet.
34  auto converted_packet =
35  std::make_unique<flutter::PointerDataPacket>(converted_pointers.size());
36  size_t count = 0;
37  for (auto& converted_pointer : converted_pointers) {
38  converted_packet->SetPointerData(count++, converted_pointer);
39  }
40 
41  return converted_packet;
42 }
static constexpr int kBytesPerField
Definition: pointer_data.h:14
static constexpr int kPointerDataFieldCount
Definition: pointer_data.h:13

The documentation for this class was generated from the following files: