@@ -40,13 +40,16 @@ static DeviceProfile GetDeviceProfile() {
40
40
41
41
FlutterTizenEngine::FlutterTizenEngine (bool headed)
42
42
: device_profile(GetDeviceProfile()) {
43
+ embedder_api_.struct_size = sizeof (FlutterEngineProcTable);
44
+ FlutterEngineGetProcAddresses (&embedder_api_);
45
+
43
46
// Run flutter task on Tizen main loop.
44
47
// Tizen engine has four threads (GPU thread, UI thread, IO thread, platform
45
48
// thread). UI threads need to send flutter task to platform thread.
46
49
event_loop_ = std::make_unique<TizenPlatformEventLoop>(
47
50
std::this_thread::get_id (), // main thread
48
51
[this ](const auto * task) {
49
- if (FlutterEngineRunTask (this ->flutter_engine , task) != kSuccess ) {
52
+ if (embedder_api_. RunTask (this ->flutter_engine , task) != kSuccess ) {
50
53
FT_LOGE (" Could not post an engine task." );
51
54
}
52
55
});
@@ -75,7 +78,7 @@ void FlutterTizenEngine::InitializeRenderer() {
75
78
render_loop_ = std::make_unique<TizenRenderEventLoop>(
76
79
std::this_thread::get_id (), // main thread
77
80
[this ](const auto * task) {
78
- if (FlutterEngineRunTask (this ->flutter_engine , task) != kSuccess ) {
81
+ if (embedder_api_. RunTask (this ->flutter_engine , task) != kSuccess ) {
79
82
FT_LOGE (" Could not post an engine task." );
80
83
}
81
84
},
@@ -87,9 +90,13 @@ void FlutterTizenEngine::InitializeRenderer() {
87
90
#endif
88
91
}
89
92
93
+ void FlutterTizenEngine::NotifyLowMemoryWarning () {
94
+ embedder_api_.NotifyLowMemoryWarning (flutter_engine);
95
+ }
96
+
90
97
// Attempts to load AOT data from the given path, which must be absolute and
91
98
// non-empty. Logs and returns nullptr on failure.
92
- UniqueAotDataPtr LoadAotData (std::string aot_data_path) {
99
+ UniqueAotDataPtr FlutterTizenEngine:: LoadAotData (std::string aot_data_path) {
93
100
if (aot_data_path.empty ()) {
94
101
FT_LOGE (
95
102
" Attempted to load AOT data, but no aot_library_path was provided." );
@@ -104,7 +111,7 @@ UniqueAotDataPtr LoadAotData(std::string aot_data_path) {
104
111
source.type = kFlutterEngineAOTDataSourceTypeElfPath ;
105
112
source.elf_path = aot_data_path.c_str ();
106
113
FlutterEngineAOTData data = nullptr ;
107
- auto result = FlutterEngineCreateAOTData (&source, &data);
114
+ auto result = embedder_api_. CreateAOTData (&source, &data);
108
115
if (result != kSuccess ) {
109
116
FT_LOGE (" Failed to load AOT data from: %s" , aot_data_path.c_str ());
110
117
return nullptr ;
@@ -180,7 +187,7 @@ bool FlutterTizenEngine::RunEngine(
180
187
}
181
188
#endif
182
189
183
- if (FlutterEngineRunsAOTCompiledDartCode ()) {
190
+ if (embedder_api_. RunsAOTCompiledDartCode ()) {
184
191
aot_data_ = LoadAotData (engine_properties.aot_library_path );
185
192
if (!aot_data_) {
186
193
FT_LOGE (" Unable to start engine without AOT data." );
@@ -191,8 +198,8 @@ bool FlutterTizenEngine::RunEngine(
191
198
192
199
FlutterRendererConfig renderer_config = GetRendererConfig ();
193
200
194
- auto result = FlutterEngineRun (FLUTTER_ENGINE_VERSION, &renderer_config,
195
- &args, this , &flutter_engine);
201
+ auto result = embedder_api_. Run (FLUTTER_ENGINE_VERSION, &renderer_config,
202
+ &args, this , &flutter_engine);
196
203
if (result == kSuccess && flutter_engine != nullptr ) {
197
204
FT_LOGD (" FlutterEngineRun Success!" );
198
205
} else {
@@ -207,9 +214,9 @@ bool FlutterTizenEngine::RunEngine(
207
214
internal_plugin_registrar_->messenger (), renderer.get ());
208
215
settings_channel = std::make_unique<SettingsChannel>(
209
216
internal_plugin_registrar_->messenger ());
210
- localization_channel = std::make_unique<LocalizationChannel>(flutter_engine );
217
+ localization_channel = std::make_unique<LocalizationChannel>(this );
211
218
localization_channel->SendLocales ();
212
- lifecycle_channel = std::make_unique<LifecycleChannel>(flutter_engine );
219
+ lifecycle_channel = std::make_unique<LifecycleChannel>(this );
213
220
214
221
if (IsHeaded ()) {
215
222
auto texture_registrar = std::make_unique<FlutterTextureRegistrar>();
@@ -241,7 +248,7 @@ bool FlutterTizenEngine::StopEngine() {
241
248
if (plugin_registrar_destruction_callback_) {
242
249
plugin_registrar_destruction_callback_ (plugin_registrar_.get ());
243
250
}
244
- FlutterEngineResult result = FlutterEngineShutdown (flutter_engine);
251
+ FlutterEngineResult result = embedder_api_. Shutdown (flutter_engine);
245
252
flutter_engine = nullptr ;
246
253
return (result == kSuccess );
247
254
}
@@ -257,6 +264,52 @@ void FlutterTizenEngine::SetPluginRegistrarDestructionCallback(
257
264
plugin_registrar_destruction_callback_ = callback;
258
265
}
259
266
267
+ bool FlutterTizenEngine::SendPlatformMessage (
268
+ const char * channel,
269
+ const uint8_t * message,
270
+ const size_t message_size,
271
+ const FlutterDesktopBinaryReply reply,
272
+ void * user_data) {
273
+ FlutterPlatformMessageResponseHandle* response_handle = nullptr ;
274
+ if (reply != nullptr && user_data != nullptr ) {
275
+ FlutterEngineResult result =
276
+ embedder_api_.PlatformMessageCreateResponseHandle (
277
+ flutter_engine, reply, user_data, &response_handle);
278
+ if (result != kSuccess ) {
279
+ std::cout << " Failed to create response handle\n " ;
280
+ return false ;
281
+ }
282
+ }
283
+
284
+ FlutterPlatformMessage platform_message = {
285
+ sizeof (FlutterPlatformMessage),
286
+ channel,
287
+ message,
288
+ message_size,
289
+ response_handle,
290
+ };
291
+
292
+ FlutterEngineResult message_result =
293
+ embedder_api_.SendPlatformMessage (flutter_engine, &platform_message);
294
+ if (response_handle != nullptr ) {
295
+ embedder_api_.PlatformMessageReleaseResponseHandle (flutter_engine,
296
+ response_handle);
297
+ }
298
+ return message_result == kSuccess ;
299
+ }
300
+
301
+ void FlutterTizenEngine::SendPlatformMessageResponse (
302
+ const FlutterDesktopMessageResponseHandle* handle,
303
+ const uint8_t * data,
304
+ size_t data_length) {
305
+ embedder_api_.SendPlatformMessageResponse (flutter_engine, handle, data,
306
+ data_length);
307
+ }
308
+
309
+ void FlutterTizenEngine::SendPointerEvent (const FlutterPointerEvent& event) {
310
+ embedder_api_.SendPointerEvent (flutter_engine, &event, 1 );
311
+ }
312
+
260
313
void FlutterTizenEngine::SendWindowMetrics (int32_t width,
261
314
int32_t height,
262
315
double pixel_ratio) {
@@ -285,7 +338,7 @@ void FlutterTizenEngine::SendWindowMetrics(int32_t width,
285
338
} else {
286
339
event.pixel_ratio = pixel_ratio;
287
340
}
288
- FlutterEngineSendWindowMetricsEvent (flutter_engine, &event);
341
+ embedder_api_. SendWindowMetricsEvent (flutter_engine, &event);
289
342
}
290
343
291
344
// This must be called at least once in order to initialize the value of
@@ -331,6 +384,18 @@ void FlutterTizenEngine::OnOrientationChange(int32_t degree) {
331
384
SetWindowOrientation (degree);
332
385
}
333
386
387
+ void FlutterTizenEngine::OnVsync (intptr_t baton,
388
+ uint64_t frame_start_time_nanos,
389
+ uint64_t frame_target_time_nanos) {
390
+ embedder_api_.OnVsync (flutter_engine, baton, frame_start_time_nanos,
391
+ frame_target_time_nanos);
392
+ }
393
+
394
+ void FlutterTizenEngine::UpdateLocales (const FlutterLocale** locales,
395
+ size_t locales_count) {
396
+ embedder_api_.UpdateLocales (flutter_engine, locales, locales_count);
397
+ }
398
+
334
399
// The Flutter Engine calls out to this function when new platform messages are
335
400
// available.
336
401
void FlutterTizenEngine::OnFlutterPlatformMessage (
0 commit comments