5#include "flutter/fml/logging.h"
9#include "flutter/shell/platform/windows/direct_manipulation.h"
10#include "flutter/shell/platform/windows/flutter_window.h"
11#include "flutter/shell/platform/windows/window_binding_handler_delegate.h"
13#define RETURN_IF_FAILED(operation) \
14 if (FAILED(operation)) { \
15 FML_LOG(ERROR) << #operation << " failed"; \
17 updateManager_ = nullptr; \
18 viewport_ = nullptr; \
22#define WARN_IF_FAILED(operation) \
23 if (FAILED(operation)) { \
24 FML_LOG(ERROR) << #operation << " failed"; \
29int32_t DirectManipulationEventHandler::GetDeviceId() {
30 return (int32_t)
reinterpret_cast<int64_t
>(
this);
35 if ((iid == IID_IUnknown) ||
36 (iid == IID_IDirectManipulationViewportEventHandler)) {
37 *ppv =
static_cast<IDirectManipulationViewportEventHandler*
>(
this);
40 }
else if (iid == IID_IDirectManipulationInteractionEventHandler) {
41 *ppv =
static_cast<IDirectManipulationInteractionEventHandler*
>(
this);
48DirectManipulationEventHandler::GestureData
49DirectManipulationEventHandler::ConvertToGestureData(
float transform[6]) {
54 const int mantissa_bits_chop = 2;
55 const float factor = (1 << mantissa_bits_chop) + 1;
65 IDirectManipulationViewport* viewport,
66 DIRECTMANIPULATION_STATUS current,
67 DIRECTMANIPULATION_STATUS previous) {
68 if (during_synthesized_reset_) {
69 during_synthesized_reset_ = current != DIRECTMANIPULATION_READY;
72 during_inertia_ = current == DIRECTMANIPULATION_INERTIA;
73 if (current == DIRECTMANIPULATION_RUNNING) {
74 IDirectManipulationContent*
content;
75 HRESULT hr = viewport->GetPrimaryContent(IID_PPV_ARGS(&
content));
80 initial_gesture_data_ = ConvertToGestureData(
transform);
90 }
else if (previous == DIRECTMANIPULATION_RUNNING) {
92 last_pan_delta_x_ = 0.0;
93 last_pan_delta_y_ = 0.0;
97 }
else if (previous == DIRECTMANIPULATION_INERTIA) {
107 during_synthesized_reset_ =
true;
110 last_pan_delta_x_ = 0.0;
111 last_pan_delta_y_ = 0.0;
113 HRESULT hr = viewport->GetViewportRect(&
rect);
115 FML_LOG(
ERROR) <<
"Failed to get the current viewport rect";
121 FML_LOG(
ERROR) <<
"Failed to reset the gesture using ZoomToRect";
129 IDirectManipulationViewport* viewport) {
134 IDirectManipulationViewport* viewport,
135 IDirectManipulationContent*
content) {
142 if (!during_synthesized_reset_) {
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_;
153 GetDeviceId(), pan_x, pan_y,
scale, 0);
160 IDirectManipulationViewport2* viewport,
161 DIRECTMANIPULATION_INTERACTION_TYPE interaction) {
166 RefCountedThreadSafe::AddRef();
171 RefCountedThreadSafe::Release();
180 CLSCTX_INPROC_SERVER,
181 IID_IDirectManipulationManager, &manager_));
183 IID_IDirectManipulationUpdateManager, &updateManager_));
185 IID_IDirectManipulationViewport,
187 DIRECTMANIPULATION_CONFIGURATION configuration =
188 DIRECTMANIPULATION_CONFIGURATION_INTERACTION |
189 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_X |
190 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_Y |
191 DIRECTMANIPULATION_CONFIGURATION_SCALING |
192 DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA;
195 DIRECTMANIPULATION_VIEWPORT_OPTIONS_MANUALUPDATE));
196 handler_ = fml::MakeRefCounted<DirectManipulationEventHandler>(
this);
217 handler_->owner_ =
nullptr;
223 WARN_IF_FAILED(viewport_->RemoveEventHandler(viewportHandlerCookie_));
227 if (window_ && manager_) {
233 updateManager_ =
nullptr;
240 viewport_->SetContact(contactId);
250 if (updateManager_) {
251 HRESULT hr = updateManager_->Update(
nullptr);
257 size_t size = FormatMessageW(
258 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
259 FORMAT_MESSAGE_IGNORE_INSERTS,
260 NULL,
error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
261 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)
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
static float max(float r, float g, float b)
union flutter::testing::@2836::KeyboardChange::@76 content
sk_sp< SkBlender > blender SkRect rect
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
it will be possible to load the file into Perfetto s trace viewer 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
SIN Vec< N, float > abs(const Vec< N, float > &x)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)