Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
lib
ui
window
pointer_data_packet_converter.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_LIB_UI_WINDOW_POINTER_DATA_PACKET_CONVERTER_H_
6
#define FLUTTER_LIB_UI_WINDOW_POINTER_DATA_PACKET_CONVERTER_H_
7
8
#include <cstring>
9
#include <map>
10
#include <memory>
11
#include <vector>
12
13
#include "flutter/fml/macros.h"
14
#include "flutter/lib/ui/window/pointer_data_packet.h"
15
16
namespace
flutter
{
17
18
//------------------------------------------------------------------------------
19
/// The current information about a pointer.
20
///
21
/// This struct is used by PointerDataPacketConverter to fill in necessary
22
/// information for the raw pointer packet sent from embedding. This struct also
23
/// stores the button state of the last pointer down, up, move, or hover event.
24
/// When an embedder issues a pointer up or down event where the pointer's
25
/// position has changed since the last move or hover event,
26
/// PointerDataPacketConverter generates a synthetic move or hover to notify the
27
/// framework. In these cases, these events must be issued with the button state
28
/// prior to the pointer up or down.
29
///
30
struct
PointerState
{
31
int64_t
pointer_identifier
;
32
bool
is_down
;
33
bool
is_pan_zoom_active
;
34
double
physical_x
;
35
double
physical_y
;
36
double
pan_x
;
37
double
pan_y
;
38
double
scale
;
39
double
rotation
;
40
int64_t
buttons
;
41
};
42
43
//------------------------------------------------------------------------------
44
/// Converter to convert the raw pointer data packet from the platforms.
45
///
46
/// Framework requires certain information to process pointer data. e.g. pointer
47
/// identifier and the delta of pointer moment. The converter keeps track each
48
/// pointer state and fill in those information appropriately.
49
///
50
/// The converter is also resposible for providing a clean pointer data stream.
51
/// It will attempt to correct the stream if the it contains illegal pointer
52
/// transitions.
53
///
54
/// Example 1 Missing Add:
55
///
56
/// Down(position x) -> Up(position x)
57
///
58
/// ###After Conversion###
59
///
60
/// Synthesized_Add(position x) -> Down(position x) -> Up(position x)
61
///
62
/// Example 2 Missing another move:
63
///
64
/// Add(position x) -> Down(position x) -> Move(position y) ->
65
/// Up(position z)
66
///
67
/// ###After Conversion###
68
///
69
/// Add(position x) -> Down(position x) -> Move(position y) ->
70
/// Synthesized_Move(position z) -> Up(position z)
71
///
72
/// Platform view is the only client that uses this class to convert all the
73
/// incoming pointer packet and is responsible for the life cycle of its
74
/// instance.
75
///
76
class
PointerDataPacketConverter
{
77
public
:
78
PointerDataPacketConverter
();
79
~PointerDataPacketConverter
();
80
81
//----------------------------------------------------------------------------
82
/// @brief Converts pointer data packet into a form that framework
83
/// understands. The raw pointer data packet from embedding does
84
/// not have sufficient information and may contain illegal
85
/// pointer transitions. This method will fill out that
86
/// information and attempt to correct pointer transitions.
87
///
88
/// @param[in] packet The raw pointer packet sent from
89
/// embedding.
90
///
91
/// @return A full converted packet with all the required information
92
/// filled.
93
/// It may contain synthetic pointer data as the result of
94
/// converter's attempt to correct illegal pointer transitions.
95
///
96
std::unique_ptr<PointerDataPacket>
Convert
(
97
std::unique_ptr<PointerDataPacket> packet);
98
99
private
:
100
std::map<int64_t, PointerState> states_;
101
102
int64_t pointer_ = 0;
103
104
void
ConvertPointerData(
PointerData
pointer_data,
105
std::vector<PointerData>& converted_pointers);
106
107
PointerState
EnsurePointerState(
PointerData
pointer_data);
108
109
void
UpdateDeltaAndState(
PointerData
& pointer_data,
PointerState
&
state
);
110
111
void
UpdatePointerIdentifier(
PointerData
& pointer_data,
112
PointerState
&
state
,
113
bool
start_new_pointer);
114
115
bool
LocationNeedsUpdate(
const
PointerData
pointer_data,
116
const
PointerState
state
);
117
118
FML_DISALLOW_COPY_AND_ASSIGN
(
PointerDataPacketConverter
);
119
};
120
121
}
// namespace flutter
122
123
#endif
// FLUTTER_LIB_UI_WINDOW_POINTER_DATA_PACKET_CONVERTER_H_
flutter::PointerDataPacketConverter
Definition
pointer_data_packet_converter.h:76
flutter::PointerDataPacketConverter::~PointerDataPacketConverter
~PointerDataPacketConverter()
flutter::PointerDataPacketConverter::Convert
std::unique_ptr< PointerDataPacket > Convert(std::unique_ptr< PointerDataPacket > packet)
Converts pointer data packet into a form that framework understands. The raw pointer data packet from...
Definition
pointer_data_packet_converter.cc:18
flutter::PointerDataPacketConverter::PointerDataPacketConverter
PointerDataPacketConverter()
Definition
pointer_data_packet_converter.cc:14
state
AtkStateType state
Definition
fl_accessible_node.cc:10
FML_DISALLOW_COPY_AND_ASSIGN
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition
macros.h:27
flutter
Definition
asset_manager.cc:10
flutter::PointerData
Definition
pointer_data.h:38
flutter::PointerState
Definition
pointer_data_packet_converter.h:30
flutter::PointerState::physical_y
double physical_y
Definition
pointer_data_packet_converter.h:35
flutter::PointerState::rotation
double rotation
Definition
pointer_data_packet_converter.h:39
flutter::PointerState::buttons
int64_t buttons
Definition
pointer_data_packet_converter.h:40
flutter::PointerState::pan_y
double pan_y
Definition
pointer_data_packet_converter.h:37
flutter::PointerState::is_pan_zoom_active
bool is_pan_zoom_active
Definition
pointer_data_packet_converter.h:33
flutter::PointerState::is_down
bool is_down
Definition
pointer_data_packet_converter.h:32
flutter::PointerState::physical_x
double physical_x
Definition
pointer_data_packet_converter.h:34
flutter::PointerState::scale
double scale
Definition
pointer_data_packet_converter.h:38
flutter::PointerState::pan_x
double pan_x
Definition
pointer_data_packet_converter.h:36
flutter::PointerState::pointer_identifier
int64_t pointer_identifier
Definition
pointer_data_packet_converter.h:31
Generated on Fri Apr 26 2024 06:14:17 for Flutter Engine by
1.9.8