Flutter Engine
The Flutter Engine
engine_modifier.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_WINDOWS_TESTING_ENGINE_MODIFIER_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_ENGINE_MODIFIER_H_
7
8#include "flutter/shell/platform/windows/flutter_windows_engine.h"
9
10#include <chrono>
11
12#include "flutter/fml/macros.h"
13
14namespace flutter {
15
16// A test utility class providing the ability to access and alter various
17// private fields in an Engine instance.
18//
19// This simply provides a way to access the normally-private embedder proc
20// table, so the lifetime of any changes made to the proc table is that of the
21// engine object, not this helper.
23 public:
25
26 // Returns the engine's embedder API proc table, allowing for modification.
27 //
28 // Modifications are to the engine, and will last for the lifetime of the
29 // engine unless overwritten again.
30 FlutterEngineProcTable& embedder_api() { return engine_->embedder_api_; }
31
32 // Override the EGL manager used by the engine.
33 //
34 // Modifications are to the engine, and will last for the lifetime of the
35 // engine unless overwritten again.
36 void SetEGLManager(std::unique_ptr<egl::Manager> egl_manager) {
37 engine_->egl_manager_ = std::move(egl_manager);
38 }
39
40 // Override the engine's implicit view. This is the "default" view
41 // that Flutter apps render to.
43 engine_->views_[kImplicitViewId] = view;
44 }
45
46 /// Reset the start_time field that is used to align vsync events.
47 void SetStartTime(uint64_t start_time_nanos) {
48 engine_->start_time_ = std::chrono::nanoseconds(start_time_nanos);
49 }
50
51 /// Override the frame interval to the provided nanosecond interval.
52 ///
53 /// This will prevent the windows engine from delegating to dwm to
54 /// discover the true frame interval, which can vary across machines.
55 void SetFrameInterval(uint64_t frame_interval_nanos) {
56 engine_->frame_interval_override_ =
57 std::optional<std::chrono::nanoseconds>(frame_interval_nanos);
58 }
59
60 // Explicitly releases the egl::Manager being used by the
61 // FlutterWindowsEngine instance. This should be used if SetEGLManager is
62 // used to explicitly set to a non-null value (but not a valid object) to test
63 // a successful ANGLE initialization.
64 //
65 // Modifications are to the engine, and will last for the lifetime of the
66 // engine unless overwritten again.
67 void ReleaseEGLManager() { engine_->egl_manager_.release(); }
68
69 // Run the FlutterWindowsEngine's handler that runs right before an engine
70 // restart. This resets the keyboard's state if it exists.
71 void Restart() { engine_->OnPreEngineRestart(); }
72
73 // Initialize they keyboard and text input subsystems or reset them them if
74 // they are already initialized.
75 void InitializeKeyboard() { engine_->InitializeKeyboard(); }
76
77 void SetLifecycleManager(std::unique_ptr<WindowsLifecycleManager>&& handler) {
78 engine_->lifecycle_manager_ = std::move(handler);
79 }
80
81 void SetPlatformViewPlugin(std::unique_ptr<PlatformViewPlugin>&& manager) {
82 engine_->platform_view_plugin_ = std::move(manager);
83 }
84
85 private:
86 FlutterWindowsEngine* engine_;
87
88 FML_DISALLOW_COPY_AND_ASSIGN(EngineModifier);
89};
90
91} // namespace flutter
92
93#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_ENGINE_MODIFIER_H_
void SetLifecycleManager(std::unique_ptr< WindowsLifecycleManager > &&handler)
void SetFrameInterval(uint64_t frame_interval_nanos)
EngineModifier(FlutterWindowsEngine *engine)
void SetEGLManager(std::unique_ptr< egl::Manager > egl_manager)
void SetStartTime(uint64_t start_time_nanos)
Reset the start_time field that is used to align vsync events.
FlutterEngineProcTable & embedder_api()
void SetPlatformViewPlugin(std::unique_ptr< PlatformViewPlugin > &&manager)
void SetImplicitView(FlutterWindowsView *view)
FlutterEngine engine
Definition: main.cc:68
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 manager
Definition: switches.h:218
constexpr FlutterViewId kImplicitViewId
Function-pointer-based versions of the APIs above.
Definition: embedder.h:3319