Flutter Engine
 
Loading...
Searching...
No Matches
windows_test_config_builder.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
6
7#include <combaseapi.h>
8
9#include <string>
10#include <string_view>
11#include <vector>
12
13#include "flutter/fml/logging.h"
17
18namespace flutter {
19namespace testing {
20
23
25
26void WindowsConfigBuilder::SetDartEntrypoint(std::string_view entrypoint) {
27 if (entrypoint.empty()) {
28 return;
29 }
30 dart_entrypoint_ = entrypoint;
31}
32
37
39 if (arg.empty()) {
40 return;
41 }
42
43 dart_entrypoint_arguments_.emplace_back(std::move(arg));
44}
45
47 FlutterDesktopGpuPreference gpu_preference) {
48 gpu_preference_ = gpu_preference;
49}
50
52 const {
53 FlutterDesktopEngineProperties engine_properties = {};
54 engine_properties.assets_path = context_.GetAssetsPath().c_str();
55 engine_properties.icu_data_path = context_.GetIcuDataPath().c_str();
56
57 // Set Dart entrypoint.
58 engine_properties.dart_entrypoint = dart_entrypoint_.c_str();
59
60 // Set Dart entrypoint argc, argv.
61 std::vector<const char*> dart_args;
62 dart_args.reserve(dart_entrypoint_arguments_.size());
63 for (const auto& arg : dart_entrypoint_arguments_) {
64 dart_args.push_back(arg.c_str());
65 }
66 if (!dart_args.empty()) {
67 engine_properties.dart_entrypoint_argv = dart_args.data();
68 engine_properties.dart_entrypoint_argc = dart_args.size();
69 } else {
70 // Clear this out in case this is not the first engine launch from the
71 // embedder config builder.
72 engine_properties.dart_entrypoint_argv = nullptr;
73 engine_properties.dart_entrypoint_argc = 0;
74 }
75
76 engine_properties.gpu_preference = gpu_preference_;
77 engine_properties.ui_thread_policy = ui_thread_policy_;
78
79 return engine_properties;
80}
81
86
88 InitializeCOM();
89
91 if (!engine) {
92 return {};
93 }
94
95 // Register native functions.
96 FlutterWindowsEngine* windows_engine =
97 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
98 windows_engine->SetRootIsolateCreateCallback(
99 context_.GetRootIsolateCallback());
100
101 if (!FlutterDesktopEngineRun(engine.get(), /* entry_point */ nullptr)) {
102 return {};
103 }
104
105 return engine;
106}
107
109 InitializeCOM();
110
112 if (!engine) {
113 return {};
114 }
115
116 // Register native functions.
117 FlutterWindowsEngine* windows_engine =
118 reinterpret_cast<FlutterWindowsEngine*>(engine.get());
119 windows_engine->SetRootIsolateCreateCallback(
120 context_.GetRootIsolateCallback());
121
122 int width = 600;
123 int height = 400;
124
125 // Create a view controller that owns the engine.
126 ViewControllerPtr controller{
128 if (!controller) {
129 return {};
130 }
131
132 return controller;
133}
134
135void WindowsConfigBuilder::InitializeCOM() const {
136 FML_CHECK(SUCCEEDED(::CoInitializeEx(nullptr, COINIT_MULTITHREADED)));
137}
138
139} // namespace testing
140} // namespace flutter
void SetRootIsolateCreateCallback(const fml::closure &callback)
FlutterDesktopEngineProperties GetEngineProperties() const
void SetDartEntrypoint(std::string_view entrypoint)
void SetUIThreadPolicy(FlutterDesktopUIThreadPolicy policy)
void SetGpuPreference(FlutterDesktopGpuPreference gpu_preference)
const std::wstring & GetIcuDataPath() const
const std::wstring & GetAssetsPath() const
FlutterEngine engine
Definition main.cc:84
FlutterDesktopUIThreadPolicy
FlutterDesktopGpuPreference
#define FML_CHECK(condition)
Definition logging.h:104
std::unique_ptr< FlutterDesktopEngine, EngineDeleter > EnginePtr
std::unique_ptr< FlutterDesktopViewController, ViewControllerDeleter > ViewControllerPtr
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 policy
int32_t height
int32_t width
FlutterDesktopUIThreadPolicy ui_thread_policy
FlutterDesktopGpuPreference gpu_preference
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)
#define SUCCEEDED(hr)