Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
flutter::PointerDataPacketConverter Class Reference

#include <pointer_data_packet_converter.h>

Classes

class  Delegate
 

Public Member Functions

 PointerDataPacketConverter (const Delegate &delegate)
 Create a PointerDataPacketConverter. More...
 
 ~PointerDataPacketConverter ()
 
std::unique_ptr< PointerDataPacketConvert (const 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 76 of file pointer_data_packet_converter.h.

Constructor & Destructor Documentation

◆ PointerDataPacketConverter()

flutter::PointerDataPacketConverter::PointerDataPacketConverter ( const Delegate delegate)
explicit

Create a PointerDataPacketConverter.

Parameters
[in]delegateA delegate to fulfill the query to the app state. The delegate must exist throughout the lifetime of this class. Typically RuntimeController.

Definition at line 14 of file pointer_data_packet_converter.cc.

15 : delegate_(delegate) {}

◆ ~PointerDataPacketConverter()

flutter::PointerDataPacketConverter::~PointerDataPacketConverter ( )
default

Member Function Documentation

◆ Convert()

std::unique_ptr< PointerDataPacket > flutter::PointerDataPacketConverter::Convert ( const 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.

Pointer data with invalid view IDs will be ignored.

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 19 of file pointer_data_packet_converter.cc.

20 {
21 std::vector<PointerData> converted_pointers;
22 // Converts each pointer data in the buffer and stores it in the
23 // converted_pointers.
24 for (size_t i = 0; i < packet.GetLength(); i++) {
25 PointerData pointer_data = packet.GetPointerData(i);
26 ConvertPointerData(pointer_data, converted_pointers);
27 }
28
29 // Writes converted_pointers into converted_packet.
30 auto converted_packet =
31 std::make_unique<flutter::PointerDataPacket>(converted_pointers.size());
32 size_t count = 0;
33 for (auto& converted_pointer : converted_pointers) {
34 converted_packet->SetPointerData(count++, converted_pointer);
35 }
36
37 return converted_packet;
38}
int count
Definition: FontMgrTest.cpp:50

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