@@ -58,23 +58,35 @@ static std::string GetICUDataPath() {
58
58
return icu_path;
59
59
}
60
60
61
- FlutterApplication::FlutterApplication () {
61
+ FlutterApplication::FlutterApplication (
62
+ const std::vector<std::string>& command_line_args,
63
+ RenderDelegate& render_delegate)
64
+ : render_delegate_(render_delegate) {
62
65
FlutterRendererConfig config = {};
63
- config.type = kSoftware ;
64
- config.software .struct_size = sizeof (FlutterSoftwareRendererConfig);
65
- config.software .surface_present_callback =
66
- &FlutterApplication::PresentSurface;
66
+ config.type = kOpenGL ;
67
+ config.open_gl .struct_size = sizeof (config.open_gl );
68
+ config.open_gl .make_current = [](void * userdata) -> bool {
69
+ return reinterpret_cast <FlutterApplication*>(userdata)
70
+ ->render_delegate_ .OnApplicationContextMakeCurrent ();
71
+ };
72
+ config.open_gl .clear_current = [](void * userdata) -> bool {
73
+ return reinterpret_cast <FlutterApplication*>(userdata)
74
+ ->render_delegate_ .OnApplicationContextClearCurrent ();
75
+ };
76
+ config.open_gl .present = [](void * userdata) -> bool {
77
+ return reinterpret_cast <FlutterApplication*>(userdata)
78
+ ->render_delegate_ .OnApplicationPresent ();
79
+ };
80
+ config.open_gl .fbo_callback = [](void * userdata) -> uint32_t {
81
+ return reinterpret_cast <FlutterApplication*>(userdata)
82
+ ->render_delegate_ .OnApplicationGetOnscreenFBO ();
83
+ };
67
84
68
85
// TODO: Pipe this in through command line args.
69
86
#define MY_PROJECT \
70
87
" /usr/local/google/home/chinmaygarde/VersionControlled/flutter/examples/" \
71
88
" flutter_gallery/build/flutter_assets"
72
89
73
- std::vector<const char *> engine_command_line_args = {
74
- " --disable-observatory" , //
75
- " --dart-non-checked-mode" , //
76
- };
77
-
78
90
auto icu_data_path = GetICUDataPath ();
79
91
80
92
if (icu_data_path == " " ) {
@@ -84,19 +96,25 @@ FlutterApplication::FlutterApplication() {
84
96
return ;
85
97
}
86
98
99
+ std::vector<const char *> command_line_args_c;
100
+
101
+ for (const auto & arg : command_line_args) {
102
+ command_line_args_c.push_back (arg.c_str ());
103
+ }
104
+
87
105
FlutterProjectArgs args = {
88
106
.struct_size = sizeof (FlutterProjectArgs),
89
- .assets_path = MY_PROJECT " /build/flutter_assets " ,
107
+ .assets_path = MY_PROJECT,
90
108
.main_path = " " ,
91
109
.packages_path = " " ,
92
110
.icu_data_path = icu_data_path.c_str (),
93
- .command_line_argc = static_cast <int >(engine_command_line_args .size ()),
94
- .command_line_argv = engine_command_line_args .data (),
111
+ .command_line_argc = static_cast <int >(command_line_args_c .size ()),
112
+ .command_line_argv = command_line_args_c .data (),
95
113
};
96
114
97
115
FlutterEngine engine = nullptr ;
98
- auto result = FlutterEngineRun (FLUTTER_ENGINE_VERSION, &config, // renderer
99
- &args, this , &engine_);
116
+ auto result = FlutterEngineRun (FLUTTER_ENGINE_VERSION, &config, &args,
117
+ this /* userdata */ , &engine_);
100
118
101
119
if (result != kSuccess ) {
102
120
FLWAY_ERROR << " Could not run the Flutter engine" << std::endl;
@@ -135,31 +153,6 @@ void FlutterApplication::ProcessEvents() {
135
153
__FlutterEngineFlushPendingTasksNow ();
136
154
}
137
155
138
- bool FlutterApplication::PresentSurface (void * user_data,
139
- const void * allocation,
140
- size_t row_bytes,
141
- size_t height) {
142
- return reinterpret_cast <FlutterApplication*>(user_data)->PresentSurface (
143
- allocation, row_bytes, height);
144
- }
145
-
146
- void FlutterApplication::SetOnPresentCallback (PresentCallback callback) {
147
- std::lock_guard<std::mutex> lock (mutex_);
148
- present_callback_ = callback;
149
- }
150
-
151
- bool FlutterApplication::PresentSurface (const void * allocation,
152
- size_t row_bytes,
153
- size_t height) {
154
- std::lock_guard<std::mutex> lock (mutex_);
155
- if (!present_callback_) {
156
- FLWAY_ERROR << " Present callback was not set." << std::endl;
157
- return false ;
158
- }
159
- present_callback_ (allocation, row_bytes, height);
160
- return true ;
161
- }
162
-
163
156
bool FlutterApplication::SendPointerEvent (int button, int x, int y) {
164
157
if (!valid_) {
165
158
FLWAY_ERROR << " Pointer events on an invalid application." << std::endl;
0 commit comments