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

#include <direct_manipulation.h>

Inheritance diagram for flutter::DirectManipulationEventHandler:
fml::RefCountedThreadSafe< DirectManipulationEventHandler > fml::internal::RefCountedThreadSafeBase

Public Member Functions

 DirectManipulationEventHandler (DirectManipulationOwner *owner)
 
STDMETHODIMP QueryInterface (REFIID iid, void **ppv) override
 
ULONG STDMETHODCALLTYPE AddRef () override
 
ULONG STDMETHODCALLTYPE Release () override
 
HRESULT STDMETHODCALLTYPE OnViewportStatusChanged (IDirectManipulationViewport *viewport, DIRECTMANIPULATION_STATUS current, DIRECTMANIPULATION_STATUS previous) override
 
HRESULT STDMETHODCALLTYPE OnViewportUpdated (IDirectManipulationViewport *viewport) override
 
HRESULT STDMETHODCALLTYPE OnContentUpdated (IDirectManipulationViewport *viewport, IDirectManipulationContent *content) override
 
HRESULT STDMETHODCALLTYPE OnInteraction (IDirectManipulationViewport2 *viewport, DIRECTMANIPULATION_INTERACTION_TYPE interaction) override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< DirectManipulationEventHandler >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 

Friends

class DirectManipulationOwner
 

Additional Inherited Members

- Protected Member Functions inherited from fml::RefCountedThreadSafe< DirectManipulationEventHandler >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 

Detailed Description

Definition at line 67 of file direct_manipulation.h.

Constructor & Destructor Documentation

◆ DirectManipulationEventHandler()

flutter::DirectManipulationEventHandler::DirectManipulationEventHandler ( DirectManipulationOwner owner)
inlineexplicit

Definition at line 76 of file direct_manipulation.h.

77 : owner_(owner) {}

Member Function Documentation

◆ AddRef()

ULONG STDMETHODCALLTYPE flutter::DirectManipulationEventHandler::AddRef ( )
override

Definition at line 165 of file direct_manipulation.cc.

165 {
166 RefCountedThreadSafe::AddRef();
167 return 0;
168}

◆ OnContentUpdated()

HRESULT flutter::DirectManipulationEventHandler::OnContentUpdated ( IDirectManipulationViewport *  viewport,
IDirectManipulationContent *  content 
)
override

Definition at line 133 of file direct_manipulation.cc.

135 {
136 float transform[6];
137 HRESULT hr = content->GetContentTransform(transform, ARRAYSIZE(transform));
138 if (FAILED(hr)) {
139 FML_LOG(ERROR) << "GetContentTransform failed";
140 return S_OK;
141 }
142 if (!during_synthesized_reset_) {
143 GestureData data = ConvertToGestureData(transform);
144 float scale = data.scale / initial_gesture_data_.scale;
145 float pan_x = data.pan_x - initial_gesture_data_.pan_x;
146 float pan_y = data.pan_y - initial_gesture_data_.pan_y;
147 last_pan_delta_x_ = pan_x - last_pan_x_;
148 last_pan_delta_y_ = pan_y - last_pan_y_;
149 last_pan_x_ = pan_x;
150 last_pan_y_ = pan_y;
151 if (owner_->binding_handler_delegate && !during_inertia_) {
153 GetDeviceId(), pan_x, pan_y, scale, 0);
154 }
155 }
156 return S_OK;
157}
WindowBindingHandlerDelegate * binding_handler_delegate
virtual void OnPointerPanZoomUpdate(int32_t device_id, double pan_x, double pan_y, double scale, double rotation)=0
#define FML_LOG(severity)
Definition: logging.h:82
union flutter::testing::@2836::KeyboardChange::@76 content
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
const Scalar scale
#define ERROR(message)
Definition: elf_loader.cc:260
#define FAILED(hr)

◆ OnInteraction()

HRESULT flutter::DirectManipulationEventHandler::OnInteraction ( IDirectManipulationViewport2 *  viewport,
DIRECTMANIPULATION_INTERACTION_TYPE  interaction 
)
override

Definition at line 159 of file direct_manipulation.cc.

161 {
162 return S_OK;
163}

◆ OnViewportStatusChanged()

HRESULT flutter::DirectManipulationEventHandler::OnViewportStatusChanged ( IDirectManipulationViewport *  viewport,
DIRECTMANIPULATION_STATUS  current,
DIRECTMANIPULATION_STATUS  previous 
)
override

Definition at line 64 of file direct_manipulation.cc.

67 {
68 if (during_synthesized_reset_) {
69 during_synthesized_reset_ = current != DIRECTMANIPULATION_READY;
70 return S_OK;
71 }
72 during_inertia_ = current == DIRECTMANIPULATION_INERTIA;
73 if (current == DIRECTMANIPULATION_RUNNING) {
74 IDirectManipulationContent* content;
75 HRESULT hr = viewport->GetPrimaryContent(IID_PPV_ARGS(&content));
76 if (SUCCEEDED(hr)) {
77 float transform[6];
78 hr = content->GetContentTransform(transform, ARRAYSIZE(transform));
79 if (SUCCEEDED(hr)) {
80 initial_gesture_data_ = ConvertToGestureData(transform);
81 } else {
82 FML_LOG(ERROR) << "GetContentTransform failed";
83 }
84 } else {
85 FML_LOG(ERROR) << "GetPrimaryContent failed";
86 }
87 if (owner_->binding_handler_delegate) {
88 owner_->binding_handler_delegate->OnPointerPanZoomStart(GetDeviceId());
89 }
90 } else if (previous == DIRECTMANIPULATION_RUNNING) {
91 // Reset deltas to ensure only inertia values will be compared later.
92 last_pan_delta_x_ = 0.0;
93 last_pan_delta_y_ = 0.0;
94 if (owner_->binding_handler_delegate) {
95 owner_->binding_handler_delegate->OnPointerPanZoomEnd(GetDeviceId());
96 }
97 } else if (previous == DIRECTMANIPULATION_INERTIA) {
98 if (owner_->binding_handler_delegate &&
99 (std::max)(std::abs(last_pan_delta_x_), std::abs(last_pan_delta_y_)) >
100 0.01) {
101 owner_->binding_handler_delegate->OnScrollInertiaCancel(GetDeviceId());
102 }
103 // Need to reset the content transform to its original position
104 // so that we are ready for the next gesture.
105 // Use during_synthesized_reset_ flag to prevent sending reset also to the
106 // framework.
107 during_synthesized_reset_ = true;
108 last_pan_x_ = 0.0;
109 last_pan_y_ = 0.0;
110 last_pan_delta_x_ = 0.0;
111 last_pan_delta_y_ = 0.0;
112 RECT rect;
113 HRESULT hr = viewport->GetViewportRect(&rect);
114 if (FAILED(hr)) {
115 FML_LOG(ERROR) << "Failed to get the current viewport rect";
116 return E_FAIL;
117 }
118 hr = viewport->ZoomToRect(rect.left, rect.top, rect.right, rect.bottom,
119 false);
120 if (FAILED(hr)) {
121 FML_LOG(ERROR) << "Failed to reset the gesture using ZoomToRect";
122 return E_FAIL;
123 }
124 }
125 return S_OK;
126}
virtual void OnPointerPanZoomStart(int32_t device_id)=0
virtual void OnPointerPanZoomEnd(int32_t device_id)=0
virtual void OnScrollInertiaCancel(int32_t device_id)=0
static float max(float r, float g, float b)
Definition: hsl.cpp:49
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707
#define SUCCEEDED(hr)

◆ OnViewportUpdated()

HRESULT flutter::DirectManipulationEventHandler::OnViewportUpdated ( IDirectManipulationViewport *  viewport)
override

Definition at line 128 of file direct_manipulation.cc.

129 {
130 return S_OK;
131}

◆ QueryInterface()

STDMETHODIMP flutter::DirectManipulationEventHandler::QueryInterface ( REFIID  iid,
void **  ppv 
)
override

Definition at line 33 of file direct_manipulation.cc.

34 {
35 if ((iid == IID_IUnknown) ||
36 (iid == IID_IDirectManipulationViewportEventHandler)) {
37 *ppv = static_cast<IDirectManipulationViewportEventHandler*>(this);
38 AddRef();
39 return S_OK;
40 } else if (iid == IID_IDirectManipulationInteractionEventHandler) {
41 *ppv = static_cast<IDirectManipulationInteractionEventHandler*>(this);
42 AddRef();
43 return S_OK;
44 }
45 return E_NOINTERFACE;
46}
ULONG STDMETHODCALLTYPE AddRef() override

◆ Release()

ULONG STDMETHODCALLTYPE flutter::DirectManipulationEventHandler::Release ( )
override

Definition at line 170 of file direct_manipulation.cc.

170 {
171 RefCountedThreadSafe::Release();
172 return 0;
173}

Friends And Related Function Documentation

◆ DirectManipulationOwner

friend class DirectManipulationOwner
friend

Definition at line 71 of file direct_manipulation.h.


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