| Flutter Windows Embedder |

flutter_windows.cc
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 #include "flutter/shell/platform/windows/public/flutter_windows.h"
6
7 #include <io.h>
8
9 #include <algorithm>
10 #include <chrono>
11 #include <cstdlib>
12 #include <filesystem>
13 #include <memory>
14 #include <vector>
15
16 #include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h"
17 #include "flutter/shell/platform/common/incoming_message_dispatcher.h"
18 #include "flutter/shell/platform/common/path_utils.h"
19 #include "flutter/shell/platform/embedder/embedder.h"
20 #include "flutter/shell/platform/windows/dpi_utils.h"
21 #include "flutter/shell/platform/windows/flutter_project_bundle.h"
22 #include "flutter/shell/platform/windows/flutter_window.h"
23 #include "flutter/shell/platform/windows/flutter_windows_engine.h"
24 #include "flutter/shell/platform/windows/flutter_windows_view.h"
25 #include "flutter/shell/platform/windows/flutter_windows_view_controller.h"
26 #include "flutter/shell/platform/windows/window_binding_handler.h"
27 #include "flutter/shell/platform/windows/window_state.h"
28
29 static_assert(FLUTTER_ENGINE_VERSION == 1, "");
30
31 // Returns the engine corresponding to the given opaque API handle.
32 static flutter::FlutterWindowsEngine* EngineFromHandle(
33 FlutterDesktopEngineRef ref) {
34 return reinterpret_cast<flutter::FlutterWindowsEngine*>(ref);
35 }
36
37 // Returns the opaque API handle for the given engine instance.
38 static FlutterDesktopEngineRef HandleForEngine(
39 flutter::FlutterWindowsEngine* engine) {
40 return reinterpret_cast<FlutterDesktopEngineRef>(engine);
41 }
42
43 static flutter::FlutterWindowsViewController* ViewControllerFromHandle(
44 FlutterDesktopViewControllerRef ref) {
45 return reinterpret_cast<flutter::FlutterWindowsViewController*>(ref);
46 }
47
48 static FlutterDesktopViewControllerRef HandleForViewController(
49 flutter::FlutterWindowsViewController* view_controller) {
50 return reinterpret_cast<FlutterDesktopViewControllerRef>(view_controller);
51 }
52
53 // Returns the view corresponding to the given opaque API handle.
54 static flutter::FlutterWindowsView* ViewFromHandle(FlutterDesktopViewRef ref) {
55 return reinterpret_cast<flutter::FlutterWindowsView*>(ref);
56 }
57
58 // Returns the opaque API handle for the given view instance.
59 static FlutterDesktopViewRef HandleForView(flutter::FlutterWindowsView* view) {
60 return reinterpret_cast<FlutterDesktopViewRef>(view);
61 }
62
63 // Returns the texture registrar corresponding to the given opaque API handle.
64 static flutter::FlutterWindowsTextureRegistrar* TextureRegistrarFromHandle(
65 FlutterDesktopTextureRegistrarRef ref) {
66 return reinterpret_cast<flutter::FlutterWindowsTextureRegistrar*>(ref);
67 }
68
69 // Returns the opaque API handle for the given texture registrar instance.
70 static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar(
71 flutter::FlutterWindowsTextureRegistrar* registrar) {
72 return reinterpret_cast<FlutterDesktopTextureRegistrarRef>(registrar);
73 }
74
75 // Creates a view controller that might own the engine.
76 //
77 // If `owns_engine` is true, then the returned `FlutterDesktopViewControllerRef`
78 // owns `engine_ref` and will deallocate `engine_ref` upon its own destruction.
79 static FlutterDesktopViewControllerRef CreateViewController(
80 FlutterDesktopEngineRef engine_ref,
81 int width,
82 int height,
83 bool owns_engine) {
84 flutter::FlutterWindowsEngine* engine_ptr = EngineFromHandle(engine_ref);
85 std::unique_ptr<flutter::WindowBindingHandler> window_wrapper =
86 std::make_unique<flutter::FlutterWindow>(
87 width, height, engine_ptr->windows_proc_table());
88
89 std::unique_ptr<flutter::FlutterWindowsEngine> engine;
90 if (owns_engine) {
91 engine = std::unique_ptr<flutter::FlutterWindowsEngine>(engine_ptr);
92 }
93
94 std::unique_ptr<flutter::FlutterWindowsView> view =
95 engine_ptr->CreateView(std::move(window_wrapper));
96 if (!view) {
97 return nullptr;
98 }
99
100 auto controller = std::make_unique<flutter::FlutterWindowsViewController>(
101 std::move(engine), std::move(view));
102
103 // Launch the engine if it is not running already.
104 if (!controller->engine()->running()) {
105 if (!controller->engine()->Run()) {
106 return nullptr;
107 }
108 }
109
110 // Must happen after engine is running.
111 controller->view()->SendInitialBounds();
112
113 // The Windows embedder listens to accessibility updates using the
114 // view's HWND. The embedder's accessibility features may be stale if
115 // the app was in headless mode.
116 controller->engine()->UpdateAccessibilityFeatures();
117
118 return HandleForViewController(controller.release());
119 }
120
121 FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(
122 int width,
123 int height,
124 FlutterDesktopEngineRef engine) {
125 return CreateViewController(engine, width, height, /*owns_engine=*/true);
126 }
127
128 FlutterDesktopViewControllerRef FlutterDesktopEngineCreateViewController(
129 FlutterDesktopEngineRef engine,
130 const FlutterDesktopViewControllerProperties* properties) {
131 return CreateViewController(engine, properties->width, properties->height,
132 /*owns_engine=*/false);
133 }
134
135 void FlutterDesktopViewControllerDestroy(FlutterDesktopViewControllerRef ref) {
136 auto controller = ViewControllerFromHandle(ref);
137 controller->Destroy();
138 delete controller;
139 }
140
141 FlutterDesktopViewId FlutterDesktopViewControllerGetViewId(
142 FlutterDesktopViewControllerRef ref) {
143 auto controller = ViewControllerFromHandle(ref);
144 return static_cast<FlutterDesktopViewId>(controller->view()->view_id());
145 }
146
147 FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(
148 FlutterDesktopViewControllerRef ref) {
149 auto controller = ViewControllerFromHandle(ref);
150 return HandleForEngine(controller->engine());
151 }
152
153 FlutterDesktopViewRef FlutterDesktopViewControllerGetView(
154 FlutterDesktopViewControllerRef ref) {
155 auto controller = ViewControllerFromHandle(ref);
156 return HandleForView(controller->view());
157 }
158
159 void FlutterDesktopViewControllerForceRedraw(
160 FlutterDesktopViewControllerRef ref) {
161 auto controller = ViewControllerFromHandle(ref);
162 controller->view()->ForceRedraw();
163 }
164
165 bool FlutterDesktopViewControllerHandleTopLevelWindowProc(
166 FlutterDesktopViewControllerRef ref,
167 HWND hwnd,
168 UINT message,
169 WPARAM wparam,
170 LPARAM lparam,
171 LRESULT* result) {
172 auto controller = ViewControllerFromHandle(ref);
173 std::optional<LRESULT> delegate_result =
174 controller->engine()
175 ->window_proc_delegate_manager()
176 ->OnTopLevelWindowProc(hwnd, message, wparam, lparam);
177 if (delegate_result) {
178 *result = *delegate_result;
179 }
180 return delegate_result.has_value();
181 }
182
183 FlutterDesktopEngineRef FlutterDesktopEngineCreate(
184 const FlutterDesktopEngineProperties* engine_properties) {
185 flutter::FlutterProjectBundle project(*engine_properties);
186 auto engine = std::make_unique<flutter::FlutterWindowsEngine>(project);
187 return HandleForEngine(engine.release());
188 }
189
190 bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref) {
191 flutter::FlutterWindowsEngine* engine = EngineFromHandle(engine_ref);
192 bool result = true;
193 if (engine->running()) {
194 result = engine->Stop();
195 }
196 delete engine;
197 return result;
198 }
199
200 FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineForId(
201 int64_t engine_id) {
202 return HandleForEngine(
203 flutter::FlutterWindowsEngine::GetEngineForId(engine_id));
204 }
205
206 bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine,
207 const char* entry_point) {
208 std::string_view entry_point_view{""};
209 if (entry_point != nullptr) {
210 entry_point_view = entry_point;
211 }
212
213 return EngineFromHandle(engine)->Run(entry_point_view);
214 }
215
216 uint64_t FlutterDesktopEngineProcessMessages(FlutterDesktopEngineRef engine) {
217 return std::chrono::nanoseconds::max().count();
218 }
219
220 void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine) {
221 EngineFromHandle(engine)->ReloadSystemFonts();
222 }
223
224 FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(
225 FlutterDesktopEngineRef engine,
226 const char* plugin_name) {
227 // Currently, one registrar acts as the registrar for all plugins, so the
228 // name is ignored. It is part of the API to reduce churn in the future when
229 // aligning more closely with the Flutter registrar system.
230
231 return EngineFromHandle(engine)->GetRegistrar();
232 }
233
234 FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger(
235 FlutterDesktopEngineRef engine) {
236 return EngineFromHandle(engine)->messenger();
237 }
238
239 FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar(
240 FlutterDesktopEngineRef engine) {
241 return HandleForTextureRegistrar(
242 EngineFromHandle(engine)->texture_registrar());
243 }
244
245 void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine,
246 VoidCallback callback,
247 void* user_data) {
248 EngineFromHandle(engine)->SetNextFrameCallback(
249 [callback, user_data]() { callback(user_data); });
250 }
251
252 HWND FlutterDesktopViewGetHWND(FlutterDesktopViewRef view) {
253 return ViewFromHandle(view)->GetWindowHandle();
254 }
255
256 IDXGIAdapter* FlutterDesktopViewGetGraphicsAdapter(FlutterDesktopViewRef view) {
257 auto egl_manager = ViewFromHandle(view)->GetEngine()->egl_manager();
258 if (egl_manager) {
259 Microsoft::WRL::ComPtr<ID3D11Device> d3d_device;
260 Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device;
261 if (egl_manager->GetDevice(d3d_device.GetAddressOf()) &&
262 SUCCEEDED(d3d_device.As(&dxgi_device))) {
263 IDXGIAdapter* adapter;
264 if (SUCCEEDED(dxgi_device->GetAdapter(&adapter))) {
265 return adapter;
266 }
267 }
268 }
269 return nullptr;
270 }
271
272 bool FlutterDesktopEngineProcessExternalWindowMessage(
273 FlutterDesktopEngineRef engine,
274 HWND hwnd,
275 UINT message,
276 WPARAM wparam,
277 LPARAM lparam,
278 LRESULT* result) {
279 std::optional<LRESULT> lresult =
280 EngineFromHandle(engine)->ProcessExternalWindowMessage(hwnd, message,
281 wparam, lparam);
282 if (result && lresult.has_value()) {
283 *result = lresult.value();
284 }
285 return lresult.has_value();
286 }
287
288 void FlutterDesktopEngineRegisterPlatformViewType(
289 FlutterDesktopEngineRef engine,
290 const char* view_type_name,
291 FlutterPlatformViewTypeEntry view_type) {
292 // TODO(schectman): forward to platform view manager.
293 // https://github.com/flutter/flutter/issues/143375
294 }
295
296 FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(
297 FlutterDesktopPluginRegistrarRef registrar) {
298 return HandleForView(registrar->engine->view(flutter::kImplicitViewId));
299 }
300
301 FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetViewById(
302 FlutterDesktopPluginRegistrarRef registrar,
303 FlutterDesktopViewId view_id) {
304 return HandleForView(registrar->engine->view(view_id));
305 }
306
307 void FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate(
308 FlutterDesktopPluginRegistrarRef registrar,
309 FlutterDesktopWindowProcCallback delegate,
310 void* user_data) {
311 registrar->engine->window_proc_delegate_manager()
312 ->RegisterTopLevelWindowProcDelegate(delegate, user_data);
313 }
314
315 void FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate(
316 FlutterDesktopPluginRegistrarRef registrar,
317 FlutterDesktopWindowProcCallback delegate) {
318 registrar->engine->window_proc_delegate_manager()
319 ->UnregisterTopLevelWindowProcDelegate(delegate);
320 }
321
322 UINT FlutterDesktopGetDpiForHWND(HWND hwnd) {
323 return flutter::GetDpiForHWND(hwnd);
324 }
325
326 UINT FlutterDesktopGetDpiForMonitor(HMONITOR monitor) {
327 return flutter::GetDpiForMonitor(monitor);
328 }
329
330 void FlutterDesktopResyncOutputStreams() {
331 FILE* unused;
332 if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
333 _dup2(_fileno(stdout), 1);
334 }
335 if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
336 _dup2(_fileno(stdout), 2);
337 }
338 std::ios::sync_with_stdio();
339 }
340
341 // Implementations of common/ API methods.
342
343 FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
344 FlutterDesktopPluginRegistrarRef registrar) {
345 return registrar->engine->messenger();
346 }
347
348 void FlutterDesktopPluginRegistrarSetDestructionHandler(
349 FlutterDesktopPluginRegistrarRef registrar,
350 FlutterDesktopOnPluginRegistrarDestroyed callback) {
351 registrar->engine->AddPluginRegistrarDestructionCallback(callback, registrar);
352 }
353
354 bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger,
355 const char* channel,
356 const uint8_t* message,
357 const size_t message_size,
358 const FlutterDesktopBinaryReply reply,
359 void* user_data) {
360 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
361 << "Messenger must reference a running engine to send a message";
362
363 return flutter::FlutterDesktopMessenger::FromRef(messenger)
364 ->GetEngine()
365 ->SendPlatformMessage(channel, message, message_size, reply, user_data);
366 }
367
368 bool FlutterDesktopMessengerSend(FlutterDesktopMessengerRef messenger,
369 const char* channel,
370 const uint8_t* message,
371 const size_t message_size) {
372 return FlutterDesktopMessengerSendWithReply(messenger, channel, message,
373 message_size, nullptr, nullptr);
374 }
375
376 void FlutterDesktopMessengerSendResponse(
377 FlutterDesktopMessengerRef messenger,
378 const FlutterDesktopMessageResponseHandle* handle,
379 const uint8_t* data,
380 size_t data_length) {
381 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
382 << "Messenger must reference a running engine to send a response";
383
384 flutter::FlutterDesktopMessenger::FromRef(messenger)
385 ->GetEngine()
386 ->SendPlatformMessageResponse(handle, data, data_length);
387 }
388
389 void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger,
390 const char* channel,
391 FlutterDesktopMessageCallback callback,
392 void* user_data) {
393 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
394 << "Messenger must reference a running engine to set a callback";
395
396 flutter::FlutterDesktopMessenger::FromRef(messenger)
397 ->GetEngine()
398 ->message_dispatcher()
399 ->SetMessageCallback(channel, callback, user_data);
400 }
401
402 FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef(
403 FlutterDesktopMessengerRef messenger) {
404 return flutter::FlutterDesktopMessenger::FromRef(messenger)
405 ->AddRef()
406 ->ToRef();
407 }
408
409 void FlutterDesktopMessengerRelease(FlutterDesktopMessengerRef messenger) {
410 flutter::FlutterDesktopMessenger::FromRef(messenger)->Release();
411 }
412
413 bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger) {
414 return flutter::FlutterDesktopMessenger::FromRef(messenger)->GetEngine() !=
415 nullptr;
416 }
417
418 FlutterDesktopMessengerRef FlutterDesktopMessengerLock(
419 FlutterDesktopMessengerRef messenger) {
420 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().lock();
421 return messenger;
422 }
423
424 void FlutterDesktopMessengerUnlock(FlutterDesktopMessengerRef messenger) {
425 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().unlock();
426 }
427
428 FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar(
429 FlutterDesktopPluginRegistrarRef registrar) {
430 return HandleForTextureRegistrar(registrar->engine->texture_registrar());
431 }
432
433 int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture(
434 FlutterDesktopTextureRegistrarRef texture_registrar,
435 const FlutterDesktopTextureInfo* texture_info) {
436 return TextureRegistrarFromHandle(texture_registrar)
437 ->RegisterTexture(texture_info);
438 }
439
440 void FlutterDesktopTextureRegistrarUnregisterExternalTexture(
441 FlutterDesktopTextureRegistrarRef texture_registrar,
442 int64_t texture_id,
443 void (*callback)(void* user_data),
444 void* user_data) {
445 auto registrar = TextureRegistrarFromHandle(texture_registrar);
446 if (callback) {
447 registrar->UnregisterTexture(
448 texture_id, [callback, user_data]() { callback(user_data); });
449 return;
450 }
451 registrar->UnregisterTexture(texture_id);
452 }
453
454 bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(
455 FlutterDesktopTextureRegistrarRef texture_registrar,
456 int64_t texture_id) {
457 return TextureRegistrarFromHandle(texture_registrar)
458 ->MarkTextureFrameAvailable(texture_id);
459 }
flutter::FlutterDesktopMessenger::GetEngine
flutter::FlutterWindowsEngine * GetEngine() const
Getter for the engine field.
Definition: flutter_desktop_messenger.h:38
flutter::FlutterDesktopMessenger::ToRef
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:28
flutter::FlutterDesktopMessenger::FromRef
static FlutterDesktopMessenger * FromRef(FlutterDesktopMessengerRef ref)
Convert from FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:33
flutter::FlutterDesktopMessenger::GetMutex
std::mutex & GetMutex()
Definition: flutter_desktop_messenger.h:70
flutter::FlutterDesktopMessenger::AddRef
FlutterDesktopMessenger * AddRef()
Definition: flutter_desktop_messenger.h:50
flutter::FlutterDesktopMessenger::Release
void Release()
Definition: flutter_desktop_messenger.h:59
flutter::FlutterProjectBundle
Definition: flutter_project_bundle.h:32
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:90
flutter::FlutterWindowsEngine::texture_registrar
FlutterWindowsTextureRegistrar * texture_registrar()
Definition: flutter_windows_engine.h:165
flutter::FlutterWindowsEngine::windows_proc_table
std::shared_ptr< WindowsProcTable > windows_proc_table()
Definition: flutter_windows_engine.h:307
flutter::FlutterWindowsEngine::messenger
FlutterDesktopMessengerRef messenger()
Definition: flutter_windows_engine.h:155
flutter::FlutterWindowsEngine::Run
bool Run()
Definition: flutter_windows_engine.cc:245
flutter::FlutterWindowsEngine::window_proc_delegate_manager
WindowProcDelegateManager * window_proc_delegate_manager()
Definition: flutter_windows_engine.h:173
flutter::FlutterWindowsEngine::view
FlutterWindowsView * view(FlutterViewId view_id) const
Definition: flutter_windows_engine.cc:674
flutter::FlutterWindowsEngine::SendPlatformMessage
bool SendPlatformMessage(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
Definition: flutter_windows_engine.cc:724
flutter::FlutterWindowsEngine::ProcessExternalWindowMessage
std::optional< LRESULT > ProcessExternalWindowMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Definition: flutter_windows_engine.cc:1030
flutter::FlutterWindowsEngine::AddPluginRegistrarDestructionCallback
void AddPluginRegistrarDestructionCallback(FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows_engine.cc:690
flutter::FlutterWindowsEngine::SendPlatformMessageResponse
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Definition: flutter_windows_engine.cc:758
flutter::FlutterWindowsEngine::GetEngineForId
static FlutterWindowsEngine * GetEngineForId(int64_t engine_id)
Definition: flutter_windows_engine.cc:236
flutter::FlutterWindowsEngine::running
virtual bool running() const
Definition: flutter_windows_engine.h:123
flutter::FlutterWindowsEngine::CreateView
std::unique_ptr< FlutterWindowsView > CreateView(std::unique_ptr< WindowBindingHandler > window)
Definition: flutter_windows_engine.cc:512
flutter::FlutterWindowsEngine::message_dispatcher
IncomingMessageDispatcher * message_dispatcher()
Definition: flutter_windows_engine.h:157
flutter::FlutterWindowsEngine::SetNextFrameCallback
void SetNextFrameCallback(fml::closure callback)
Definition: flutter_windows_engine.cc:787
flutter::FlutterWindowsEngine::Stop
virtual bool Stop()
Definition: flutter_windows_engine.cc:499
flutter::FlutterWindowsEngine::GetRegistrar
FlutterDesktopPluginRegistrarRef GetRegistrar()
Definition: flutter_windows_engine.cc:686
flutter::FlutterWindowsEngine::ReloadSystemFonts
void ReloadSystemFonts()
Definition: flutter_windows_engine.cc:779
flutter::FlutterWindowsEngine::egl_manager
egl::Manager * egl_manager() const
Definition: flutter_windows_engine.h:171
flutter::FlutterWindowsTextureRegistrar
Definition: flutter_windows_texture_registrar.h:24
flutter::FlutterWindowsTextureRegistrar::RegisterTexture
int64_t RegisterTexture(const FlutterDesktopTextureInfo *texture_info)
Definition: flutter_windows_texture_registrar.cc:26
flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable
bool MarkTextureFrameAvailable(int64_t texture_id)
Definition: flutter_windows_texture_registrar.cc:103
flutter::FlutterWindowsViewController
Controls a view that displays Flutter content.
Definition: flutter_windows_view_controller.h:17
flutter::FlutterWindowsView
Definition: flutter_windows_view.h:34
flutter::FlutterWindowsView::GetEngine
FlutterWindowsEngine * GetEngine() const
Definition: flutter_windows_view.cc:782
flutter::FlutterWindowsView::GetWindowHandle
virtual HWND GetWindowHandle() const
Definition: flutter_windows_view.cc:778
flutter::IncomingMessageDispatcher::SetMessageCallback
void SetMessageCallback(const std::string &channel, FlutterDesktopMessageCallback callback, void *user_data)
Definition: incoming_message_dispatcher.cc:43
flutter::WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate
void UnregisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback)
Definition: window_proc_delegate_manager.cc:27
flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate
void RegisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback, void *user_data)
Definition: window_proc_delegate_manager.cc:16
texture_id
uint32_t texture_id
Definition: compositor_opengl.cc:20
dpi_utils.h
FLUTTER_EXPORT
#define FLUTTER_EXPORT
Definition: flutter_export.h:23
FlutterDesktopBinaryReply
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)
Definition: flutter_messenger.h:26
FlutterDesktopMessengerRef
struct FlutterDesktopMessenger * FlutterDesktopMessengerRef
Definition: flutter_messenger.h:19
FlutterDesktopMessageCallback
void(* FlutterDesktopMessageCallback)(FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)
Definition: flutter_messenger.h:49
FlutterDesktopMessageResponseHandle
struct _FlutterPlatformMessageResponseHandle FlutterDesktopMessageResponseHandle
Definition: flutter_messenger.h:22
FlutterDesktopOnPluginRegistrarDestroyed
void(* FlutterDesktopOnPluginRegistrarDestroyed)(FlutterDesktopPluginRegistrarRef)
Definition: flutter_plugin_registrar.h:23
flutter_project_bundle.h
FlutterDesktopTextureRegistrarRef
struct FlutterDesktopTextureRegistrar * FlutterDesktopTextureRegistrarRef
Definition: flutter_texture_registrar.h:19
flutter_window.h
TextureRegistrarFromHandle
static flutter::FlutterWindowsTextureRegistrar * TextureRegistrarFromHandle(FlutterDesktopTextureRegistrarRef ref)
Definition: flutter_windows.cc:64
FlutterDesktopMessengerSetCallback
void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
Definition: flutter_windows.cc:389
FlutterDesktopGetDpiForHWND
UINT FlutterDesktopGetDpiForHWND(HWND hwnd)
Definition: flutter_windows.cc:322
FlutterDesktopViewControllerForceRedraw
void FlutterDesktopViewControllerForceRedraw(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:159
HandleForTextureRegistrar
static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar(flutter::FlutterWindowsTextureRegistrar *registrar)
Definition: flutter_windows.cc:70
FlutterDesktopEngineCreate
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
Definition: flutter_windows.cc:183
FlutterDesktopEngineReloadSystemFonts
void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:220
FlutterDesktopEngineProcessExternalWindowMessage
bool FlutterDesktopEngineProcessExternalWindowMessage(FlutterDesktopEngineRef engine, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
Definition: flutter_windows.cc:272
ViewFromHandle
static flutter::FlutterWindowsView * ViewFromHandle(FlutterDesktopViewRef ref)
Definition: flutter_windows.cc:54
FlutterDesktopResyncOutputStreams
void FlutterDesktopResyncOutputStreams()
Definition: flutter_windows.cc:330
FlutterDesktopEngineRegisterPlatformViewType
void FlutterDesktopEngineRegisterPlatformViewType(FlutterDesktopEngineRef engine, const char *view_type_name, FlutterPlatformViewTypeEntry view_type)
Definition: flutter_windows.cc:288
HandleForView
static FlutterDesktopViewRef HandleForView(flutter::FlutterWindowsView *view)
Definition: flutter_windows.cc:59
CreateViewController
static FlutterDesktopViewControllerRef CreateViewController(FlutterDesktopEngineRef engine_ref, int width, int height, bool owns_engine)
Definition: flutter_windows.cc:79
FlutterDesktopEngineForId
FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopEngineForId(int64_t engine_id)
Definition: flutter_windows.cc:200
FlutterDesktopMessengerSendResponse
void FlutterDesktopMessengerSendResponse(FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Definition: flutter_windows.cc:376
FlutterDesktopPluginRegistrarGetViewById
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetViewById(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopViewId view_id)
Definition: flutter_windows.cc:301
HandleForEngine
static FlutterDesktopEngineRef HandleForEngine(flutter::FlutterWindowsEngine *engine)
Definition: flutter_windows.cc:38
FlutterDesktopMessengerSendWithReply
bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
Definition: flutter_windows.cc:354
FlutterDesktopPluginRegistrarSetDestructionHandler
void FlutterDesktopPluginRegistrarSetDestructionHandler(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopOnPluginRegistrarDestroyed callback)
Definition: flutter_windows.cc:348
FlutterDesktopEngineGetPluginRegistrar
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
Definition: flutter_windows.cc:224
EngineFromHandle
static flutter::FlutterWindowsEngine * EngineFromHandle(FlutterDesktopEngineRef ref)
Definition: flutter_windows.cc:32
FlutterDesktopTextureRegistrarRegisterExternalTexture
int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, const FlutterDesktopTextureInfo *texture_info)
Definition: flutter_windows.cc:433
HandleForViewController
static FlutterDesktopViewControllerRef HandleForViewController(flutter::FlutterWindowsViewController *view_controller)
Definition: flutter_windows.cc:48
FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable
bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id)
Definition: flutter_windows.cc:454
FlutterDesktopViewControllerCreate
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:121
FlutterDesktopMessengerLock
FlutterDesktopMessengerRef FlutterDesktopMessengerLock(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:418
FlutterDesktopTextureRegistrarUnregisterExternalTexture
void FlutterDesktopTextureRegistrarUnregisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id, void(*callback)(void *user_data), void *user_data)
Definition: flutter_windows.cc:440
FlutterDesktopEngineDestroy
bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref)
Definition: flutter_windows.cc:190
FlutterDesktopGetDpiForMonitor
UINT FlutterDesktopGetDpiForMonitor(HMONITOR monitor)
Definition: flutter_windows.cc:326
FlutterDesktopMessengerIsAvailable
bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:413
FlutterDesktopMessengerSend
bool FlutterDesktopMessengerSend(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
Definition: flutter_windows.cc:368
FlutterDesktopEngineGetTextureRegistrar
FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:239
FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate
void FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopWindowProcCallback delegate)
Definition: flutter_windows.cc:315
FlutterDesktopViewGetGraphicsAdapter
IDXGIAdapter * FlutterDesktopViewGetGraphicsAdapter(FlutterDesktopViewRef view)
Definition: flutter_windows.cc:256
FlutterDesktopViewControllerHandleTopLevelWindowProc
bool FlutterDesktopViewControllerHandleTopLevelWindowProc(FlutterDesktopViewControllerRef ref, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
Definition: flutter_windows.cc:165
FlutterDesktopEngineProcessMessages
uint64_t FlutterDesktopEngineProcessMessages(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:216
FlutterDesktopMessengerUnlock
void FlutterDesktopMessengerUnlock(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:424
FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate
void FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopWindowProcCallback delegate, void *user_data)
Definition: flutter_windows.cc:307
FlutterDesktopEngineGetMessenger
FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:234
FlutterDesktopViewControllerGetViewId
FlutterDesktopViewId FlutterDesktopViewControllerGetViewId(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:141
FlutterDesktopViewControllerGetEngine
FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:147
FlutterDesktopRegistrarGetTextureRegistrar
FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar(FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows.cc:428
FlutterDesktopPluginRegistrarGetMessenger
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows.cc:343
FlutterDesktopEngineSetNextFrameCallback
void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)
Definition: flutter_windows.cc:245
FlutterDesktopViewGetHWND
HWND FlutterDesktopViewGetHWND(FlutterDesktopViewRef view)
Definition: flutter_windows.cc:252
FlutterDesktopMessengerRelease
void FlutterDesktopMessengerRelease(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:409
FlutterDesktopViewControllerGetView
FlutterDesktopViewRef FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:153
FlutterDesktopPluginRegistrarGetView
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows.cc:296
FlutterDesktopMessengerAddRef
FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:402
FlutterDesktopEngineCreateViewController
FlutterDesktopViewControllerRef FlutterDesktopEngineCreateViewController(FlutterDesktopEngineRef engine, const FlutterDesktopViewControllerProperties *properties)
Definition: flutter_windows.cc:128
FlutterDesktopViewControllerDestroy
void FlutterDesktopViewControllerDestroy(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:135
ViewControllerFromHandle
static flutter::FlutterWindowsViewController * ViewControllerFromHandle(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:43
FlutterDesktopEngineRun
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)
Definition: flutter_windows.cc:206
flutter_windows.h
FlutterDesktopViewControllerRef
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
Definition: flutter_windows.h:25
FlutterDesktopWindowProcCallback
bool(* FlutterDesktopWindowProcCallback)(HWND, UINT, WPARAM, LPARAM, void *, LRESULT *result)
Definition: flutter_windows.h:271
FlutterDesktopEngineRef
struct FlutterDesktopEngine * FlutterDesktopEngineRef
Definition: flutter_windows.h:33
FlutterDesktopViewId
int64_t FlutterDesktopViewId
Definition: flutter_windows.h:36
FlutterDesktopViewRef
struct FlutterDesktopView * FlutterDesktopViewRef
Definition: flutter_windows.h:29
VoidCallback
void(* VoidCallback)(void *)
Definition: flutter_windows.h:21
flutter_windows_engine.h
flutter_windows_view.h
flutter_windows_view_controller.h
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:53
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
incoming_message_dispatcher.h
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter::GetDpiForHWND
UINT GetDpiForHWND(HWND hwnd)
Definition: dpi_utils.cc:130
flutter::GetDpiForMonitor
UINT GetDpiForMonitor(HMONITOR monitor)
Definition: dpi_utils.cc:134
flutter::kImplicitViewId
constexpr FlutterViewId kImplicitViewId
Definition: flutter_windows_engine.h:55
path_utils.h
plugin_registrar.h
FlutterDesktopEngineProperties
Definition: flutter_windows.h:60
FlutterDesktopPluginRegistrar
Definition: window_state.h:23
FlutterDesktopPluginRegistrar::engine
flutter::FlutterWindowsEngine * engine
Definition: window_state.h:25
FlutterDesktopTextureInfo
Definition: flutter_texture_registrar.h:151
FlutterDesktopViewControllerProperties
Definition: flutter_windows_internal.h:18
FlutterDesktopViewControllerProperties::width
int width
Definition: flutter_windows_internal.h:20
FlutterDesktopViewControllerProperties::height
int height
Definition: flutter_windows_internal.h:23
FlutterPlatformViewTypeEntry
Definition: flutter_windows_internal.h:57
window_binding_handler.h
window_state.h