14#define RETURN_IF_FAILED(operation) \
15 if (FAILED(operation)) { \
16 FML_LOG(ERROR) << #operation << " failed"; \
18 updateManager_ = nullptr; \
19 viewport_ = nullptr; \
23#define WARN_IF_FAILED(operation) \
24 if (FAILED(operation)) { \
25 FML_LOG(ERROR) << #operation << " failed"; \
30int32_t DirectManipulationEventHandler::GetDeviceId() {
31 return (int32_t)
reinterpret_cast<int64_t
>(
this);
36 if ((iid == IID_IUnknown) ||
37 (iid == IID_IDirectManipulationViewportEventHandler)) {
38 *ppv =
static_cast<IDirectManipulationViewportEventHandler*
>(
this);
41 }
else if (iid == IID_IDirectManipulationInteractionEventHandler) {
42 *ppv =
static_cast<IDirectManipulationInteractionEventHandler*
>(
this);
49DirectManipulationEventHandler::GestureData
50DirectManipulationEventHandler::ConvertToGestureData(
float transform[6]) {
55 const int mantissa_bits_chop = 2;
56 const float factor = (1 << mantissa_bits_chop) + 1;
66 IDirectManipulationViewport* viewport,
67 DIRECTMANIPULATION_STATUS current,
68 DIRECTMANIPULATION_STATUS previous) {
69 if (during_synthesized_reset_) {
70 during_synthesized_reset_ = current != DIRECTMANIPULATION_READY;
73 during_inertia_ = current == DIRECTMANIPULATION_INERTIA;
74 if (current == DIRECTMANIPULATION_RUNNING) {
75 IDirectManipulationContent*
content;
76 HRESULT hr = viewport->GetPrimaryContent(IID_PPV_ARGS(&
content));
81 initial_gesture_data_ = ConvertToGestureData(
transform);
83 FML_LOG(ERROR) <<
"GetContentTransform failed";
86 FML_LOG(ERROR) <<
"GetPrimaryContent failed";
91 }
else if (previous == DIRECTMANIPULATION_RUNNING) {
93 last_pan_delta_x_ = 0.0;
94 last_pan_delta_y_ = 0.0;
98 }
else if (previous == DIRECTMANIPULATION_INERTIA) {
100 (std::max)(std::abs(last_pan_delta_x_), std::abs(last_pan_delta_y_)) >
108 during_synthesized_reset_ =
true;
111 last_pan_delta_x_ = 0.0;
112 last_pan_delta_y_ = 0.0;
114 HRESULT hr = viewport->GetViewportRect(&rect);
116 FML_LOG(ERROR) <<
"Failed to get the current viewport rect";
119 hr = viewport->ZoomToRect(rect.left, rect.top, rect.right, rect.bottom,
122 FML_LOG(ERROR) <<
"Failed to reset the gesture using ZoomToRect";
130 IDirectManipulationViewport* viewport) {
135 IDirectManipulationViewport* viewport,
136 IDirectManipulationContent*
content) {
140 FML_LOG(ERROR) <<
"GetContentTransform failed";
143 if (!during_synthesized_reset_) {
145 float scale =
data.scale / initial_gesture_data_.scale;
146 float pan_x =
data.pan_x - initial_gesture_data_.pan_x;
147 float pan_y =
data.pan_y - initial_gesture_data_.pan_y;
148 last_pan_delta_x_ = pan_x - last_pan_x_;
149 last_pan_delta_y_ = pan_y - last_pan_y_;
154 GetDeviceId(), pan_x, pan_y, scale, 0);
161 IDirectManipulationViewport2* viewport,
162 DIRECTMANIPULATION_INTERACTION_TYPE interaction) {
167 RefCountedThreadSafe::AddRef();
172 RefCountedThreadSafe::Release();
181 CLSCTX_INPROC_SERVER,
182 IID_IDirectManipulationManager, &manager_));
184 IID_IDirectManipulationUpdateManager, &updateManager_));
186 IID_IDirectManipulationViewport,
188 DIRECTMANIPULATION_CONFIGURATION configuration =
189 DIRECTMANIPULATION_CONFIGURATION_INTERACTION |
190 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_X |
191 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_Y |
192 DIRECTMANIPULATION_CONFIGURATION_SCALING |
193 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA;
196 DIRECTMANIPULATION_VIEWPORT_OPTIONS_MANUALUPDATE));
197 handler_ = fml::MakeRefCounted<DirectManipulationEventHandler>(
this);
218 handler_->owner_ =
nullptr;
224 WARN_IF_FAILED(viewport_->RemoveEventHandler(viewportHandlerCookie_));
228 if (window_ && manager_) {
234 updateManager_ =
nullptr;
241 viewport_->SetContact(contactId);
251 if (updateManager_) {
252 HRESULT hr = updateManager_->Update(
nullptr);
254 FML_LOG(ERROR) <<
"updateManager_->Update failed";
258 size_t size = FormatMessageW(
259 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
260 FORMAT_MESSAGE_IGNORE_INSERTS,
261 NULL,
error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
262 reinterpret_cast<LPWSTR
>(&
message), 0, NULL);
ULONG STDMETHODCALLTYPE Release() override
HRESULT STDMETHODCALLTYPE OnViewportUpdated(IDirectManipulationViewport *viewport) override
STDMETHODIMP QueryInterface(REFIID iid, void **ppv) override
HRESULT STDMETHODCALLTYPE OnInteraction(IDirectManipulationViewport2 *viewport, DIRECTMANIPULATION_INTERACTION_TYPE interaction) override
ULONG STDMETHODCALLTYPE AddRef() override
HRESULT STDMETHODCALLTYPE OnViewportStatusChanged(IDirectManipulationViewport *viewport, DIRECTMANIPULATION_STATUS current, DIRECTMANIPULATION_STATUS previous) override
HRESULT STDMETHODCALLTYPE OnContentUpdated(IDirectManipulationViewport *viewport, IDirectManipulationContent *content) override
virtual void SetContact(UINT contactId)
void SetBindingHandlerDelegate(WindowBindingHandlerDelegate *binding_handler_delegate)
WindowBindingHandlerDelegate * binding_handler_delegate
int Init(unsigned int width, unsigned int height)
void ResizeViewport(unsigned int width, unsigned int height)
DirectManipulationOwner(FlutterWindow *window)
virtual HWND GetWindowHandle() override
virtual void OnPointerPanZoomStart(int32_t device_id)=0
virtual void OnPointerPanZoomEnd(int32_t device_id)=0
virtual void OnScrollInertiaCancel(int32_t device_id)=0
virtual void OnPointerPanZoomUpdate(int32_t device_id, double pan_x, double pan_y, double scale, double rotation)=0
#define WARN_IF_FAILED(operation)
#define RETURN_IF_FAILED(operation)
G_BEGIN_DECLS GBytes * message
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
union flutter::testing::@2824::KeyboardChange::@78 content
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::string WCharBufferToString(const wchar_t *wstr)
Convert a null terminated wchar_t buffer to a std::string using Windows utilities.
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)