Flutter Engine
The Flutter Engine
embedder_config_builder.h
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#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
7
8#include "flutter/fml/macros.h"
9#include "flutter/fml/unique_object.h"
10#include "flutter/shell/platform/embedder/embedder.h"
11#include "flutter/shell/platform/embedder/tests/embedder_test.h"
12#include "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"
13
14namespace flutter {
15namespace testing {
16
18 static FlutterEngine InvalidValue() { return nullptr; }
19
20 static bool IsValid(const FlutterEngine& value) { return value != nullptr; }
21
22 static void Free(FlutterEngine& engine) {
25 }
26};
27
29
31 public:
33 kSnapshotsInitialize,
34 kAOTDataInitialize,
35 kMultiAOTInitialize,
36 kNoInitialize,
37 };
38
39 explicit EmbedderConfigBuilder(
40 EmbedderTestContext& context,
41 InitializationPreference preference =
43
45
47
49
50 void SetSoftwareRendererConfig(SkISize surface_size = SkISize::Make(1, 1));
51
52 void SetOpenGLRendererConfig(SkISize surface_size);
53
54 void SetMetalRendererConfig(SkISize surface_size);
55
57 SkISize surface_size,
58 std::optional<FlutterVulkanInstanceProcAddressCallback>
59 instance_proc_address_callback = {});
60
61 // Used to explicitly set an `open_gl.fbo_callback`. Using this method will
62 // cause your test to fail since the ctor for this class sets
63 // `open_gl.fbo_callback_with_frame_info`. This method exists as a utility to
64 // explicitly test this behavior.
66
67 // Used to explicitly set an `open_gl.present`. Using this method will cause
68 // your test to fail since the ctor for this class sets
69 // `open_gl.present_with_info`. This method exists as a utility to explicitly
70 // test this behavior.
72
73 void SetAssetsPath();
74
75 void SetSnapshots();
76
77 void SetAOTDataElf();
78
80
82
83 // Used to set a custom log message handler.
85
87
88 // Used to set a custom log tag.
89 void SetLogTag(std::string tag);
90
92
93 void SetExecutableName(std::string executable_name);
94
95 void SetDartEntrypoint(std::string entrypoint);
96
97 void AddCommandLineArgument(std::string arg);
98
99 void AddDartEntrypointArgument(std::string arg);
100
102
104
106 const std::function<void(const FlutterPlatformMessage*)>& callback);
107
108 void SetCompositor(bool avoid_backing_store_cache = false,
109 bool use_present_layers_callback = false);
110
112
114
117 FlutterSoftwarePixelFormat software_pixfmt =
119
121
123
124 // Sets up the callback for vsync, the callbacks needs to be specified on the
125 // text context vis `SetVsyncCallback`.
126 void SetupVsyncCallback();
127
128 private:
129 EmbedderTestContext& context_;
130 FlutterProjectArgs project_args_ = {};
131 FlutterRendererConfig renderer_config_ = {};
132 FlutterSoftwareRendererConfig software_renderer_config_ = {};
133#ifdef SHELL_ENABLE_GL
134 FlutterOpenGLRendererConfig opengl_renderer_config_ = {};
135#endif
136#ifdef SHELL_ENABLE_VULKAN
137 void InitializeVulkanRendererConfig();
138 FlutterVulkanRendererConfig vulkan_renderer_config_ = {};
139#endif
140#ifdef SHELL_ENABLE_METAL
141 void InitializeMetalRendererConfig();
142 FlutterMetalRendererConfig metal_renderer_config_ = {};
143#endif
144 std::string dart_entrypoint_;
145 FlutterCustomTaskRunners custom_task_runners_ = {};
146 FlutterCompositor compositor_ = {};
147 std::vector<std::string> command_line_arguments_;
148 std::vector<std::string> dart_entrypoint_arguments_;
149 std::string log_tag_;
150
151 UniqueEngine SetupEngine(bool run) const;
152
153 FML_DISALLOW_COPY_AND_ASSIGN(EmbedderConfigBuilder);
154};
155
156} // namespace testing
157} // namespace flutter
158
159#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONFIG_BUILDER_H_
GLenum type
void SetSoftwareRendererConfig(SkISize surface_size=SkISize::Make(1, 1))
void SetPlatformTaskRunner(const FlutterTaskRunnerDescription *runner)
void SetRendererConfig(EmbedderTestContextType type, SkISize surface_size)
void SetExecutableName(std::string executable_name)
void SetRenderTargetType(EmbedderTestBackingStoreProducer::RenderTargetType type, FlutterSoftwarePixelFormat software_pixfmt=kFlutterSoftwarePixelFormatNative32)
void SetRenderTaskRunner(const FlutterTaskRunnerDescription *runner)
void SetVulkanRendererConfig(SkISize surface_size, std::optional< FlutterVulkanInstanceProcAddressCallback > instance_proc_address_callback={})
EmbedderConfigBuilder(EmbedderTestContext &context, InitializationPreference preference=InitializationPreference::kSnapshotsInitialize)
void SetCompositor(bool avoid_backing_store_cache=false, bool use_present_layers_callback=false)
void SetPlatformMessageCallback(const std::function< void(const FlutterPlatformMessage *)> &callback)
FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine) engine)
Shuts down a Flutter engine instance. The engine handle is no longer valid for any calls in the embed...
Definition: embedder.cc:2309
FlutterSoftwarePixelFormat
Definition: embedder.h:335
@ kFlutterSoftwarePixelFormatNative32
Definition: embedder.h:363
@ kSuccess
Definition: embedder.h:73
FlutterEngine engine
Definition: main.cc:68
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value
GAsyncResult * result
#define FML_CHECK(condition)
Definition: logging.h:85
Dart_NativeFunction function
Definition: fuchsia.cc:51
fml::UniqueObject< FlutterEngine, UniqueEngineTraits > UniqueEngine
Definition: run.py:1
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static bool IsValid(const FlutterEngine &value)
static void Free(FlutterEngine &engine)