@@ -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,10 @@ 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 );
220
+
213
221
if (IsHeaded ()) {
214
222
texture_registrar_ = std::make_unique<FlutterTizenTextureRegistrar>(this );
215
223
key_event_channel = std::make_unique<KeyEventChannel>(
@@ -237,7 +245,7 @@ bool FlutterTizenEngine::StopEngine() {
237
245
if (plugin_registrar_destruction_callback_) {
238
246
plugin_registrar_destruction_callback_ (plugin_registrar_.get ());
239
247
}
240
- FlutterEngineResult result = FlutterEngineShutdown (flutter_engine);
248
+ FlutterEngineResult result = embedder_api_. Shutdown (flutter_engine);
241
249
flutter_engine = nullptr ;
242
250
return (result == kSuccess );
243
251
}
@@ -257,6 +265,52 @@ void FlutterTizenEngine::SetPluginRegistrarDestructionCallback(
257
265
plugin_registrar_destruction_callback_ = callback;
258
266
}
259
267
268
+ bool FlutterTizenEngine::SendPlatformMessage (
269
+ const char * channel,
270
+ const uint8_t * message,
271
+ const size_t message_size,
272
+ const FlutterDesktopBinaryReply reply,
273
+ void * user_data) {
274
+ FlutterPlatformMessageResponseHandle* response_handle = nullptr ;
275
+ if (reply != nullptr && user_data != nullptr ) {
276
+ FlutterEngineResult result =
277
+ embedder_api_.PlatformMessageCreateResponseHandle (
278
+ flutter_engine, reply, user_data, &response_handle);
279
+ if (result != kSuccess ) {
280
+ std::cout << " Failed to create response handle\n " ;
281
+ return false ;
282
+ }
283
+ }
284
+
285
+ FlutterPlatformMessage platform_message = {
286
+ sizeof (FlutterPlatformMessage),
287
+ channel,
288
+ message,
289
+ message_size,
290
+ response_handle,
291
+ };
292
+
293
+ FlutterEngineResult message_result =
294
+ embedder_api_.SendPlatformMessage (flutter_engine, &platform_message);
295
+ if (response_handle != nullptr ) {
296
+ embedder_api_.PlatformMessageReleaseResponseHandle (flutter_engine,
297
+ response_handle);
298
+ }
299
+ return message_result == kSuccess ;
300
+ }
301
+
302
+ void FlutterTizenEngine::SendPlatformMessageResponse (
303
+ const FlutterDesktopMessageResponseHandle* handle,
304
+ const uint8_t * data,
305
+ size_t data_length) {
306
+ embedder_api_.SendPlatformMessageResponse (flutter_engine, handle, data,
307
+ data_length);
308
+ }
309
+
310
+ void FlutterTizenEngine::SendPointerEvent (const FlutterPointerEvent& event) {
311
+ embedder_api_.SendPointerEvent (flutter_engine, &event, 1 );
312
+ }
313
+
260
314
void FlutterTizenEngine::SendWindowMetrics (int32_t width,
261
315
int32_t height,
262
316
double pixel_ratio) {
@@ -285,7 +339,7 @@ void FlutterTizenEngine::SendWindowMetrics(int32_t width,
285
339
} else {
286
340
event.pixel_ratio = pixel_ratio;
287
341
}
288
- FlutterEngineSendWindowMetricsEvent (flutter_engine, &event);
342
+ embedder_api_. SendWindowMetricsEvent (flutter_engine, &event);
289
343
}
290
344
291
345
// This must be called at least once in order to initialize the value of
@@ -331,6 +385,33 @@ void FlutterTizenEngine::OnOrientationChange(int32_t degree) {
331
385
SetWindowOrientation (degree);
332
386
}
333
387
388
+ void FlutterTizenEngine::OnVsync (intptr_t baton,
389
+ uint64_t frame_start_time_nanos,
390
+ uint64_t frame_target_time_nanos) {
391
+ embedder_api_.OnVsync (flutter_engine, baton, frame_start_time_nanos,
392
+ frame_target_time_nanos);
393
+ }
394
+
395
+ void FlutterTizenEngine::UpdateLocales (const FlutterLocale** locales,
396
+ size_t locales_count) {
397
+ embedder_api_.UpdateLocales (flutter_engine, locales, locales_count);
398
+ }
399
+
400
+ bool FlutterTizenEngine::RegisterExternalTexture (int64_t texture_id) {
401
+ return (embedder_api_.RegisterExternalTexture (flutter_engine, texture_id) ==
402
+ kSuccess );
403
+ }
404
+
405
+ bool FlutterTizenEngine::UnregisterExternalTexture (int64_t texture_id) {
406
+ return (embedder_api_.UnregisterExternalTexture (flutter_engine, texture_id) ==
407
+ kSuccess );
408
+ }
409
+
410
+ bool FlutterTizenEngine::MarkExternalTextureFrameAvailable (int64_t texture_id) {
411
+ return (embedder_api_.MarkExternalTextureFrameAvailable (
412
+ flutter_engine, texture_id) == kSuccess );
413
+ }
414
+
334
415
// The Flutter Engine calls out to this function when new platform messages are
335
416
// available.
336
417
void FlutterTizenEngine::OnFlutterPlatformMessage (
0 commit comments