@@ -49,7 +49,7 @@ FlutterTizenEngine::FlutterTizenEngine(bool headed)
49
49
event_loop_ = std::make_unique<TizenPlatformEventLoop>(
50
50
std::this_thread::get_id (), // main thread
51
51
[this ](const auto * task) {
52
- if (embedder_api_.RunTask (this ->flutter_engine , task) != kSuccess ) {
52
+ if (embedder_api_.RunTask (this ->engine_ , task) != kSuccess ) {
53
53
FT_LOGE (" Could not post an engine task." );
54
54
}
55
55
});
@@ -78,7 +78,7 @@ void FlutterTizenEngine::InitializeRenderer() {
78
78
render_loop_ = std::make_unique<TizenRenderEventLoop>(
79
79
std::this_thread::get_id (), // main thread
80
80
[this ](const auto * task) {
81
- if (embedder_api_.RunTask (this ->flutter_engine , task) != kSuccess ) {
81
+ if (embedder_api_.RunTask (this ->engine_ , task) != kSuccess ) {
82
82
FT_LOGE (" Could not post an engine task." );
83
83
}
84
84
},
@@ -91,7 +91,7 @@ void FlutterTizenEngine::InitializeRenderer() {
91
91
}
92
92
93
93
void FlutterTizenEngine::NotifyLowMemoryWarning () {
94
- embedder_api_.NotifyLowMemoryWarning (flutter_engine );
94
+ embedder_api_.NotifyLowMemoryWarning (engine_ );
95
95
}
96
96
97
97
// Attempts to load AOT data from the given path, which must be absolute and
@@ -176,7 +176,18 @@ bool FlutterTizenEngine::RunEngine(
176
176
args.icu_data_path = engine_properties.icu_data_path ;
177
177
args.command_line_argc = static_cast <int >(argv.size ());
178
178
args.command_line_argv = &argv[0 ];
179
- args.platform_message_callback = OnFlutterPlatformMessage;
179
+ args.platform_message_callback =
180
+ [](const FlutterPlatformMessage* engine_message, void * user_data) {
181
+ if (engine_message->struct_size != sizeof (FlutterPlatformMessage)) {
182
+ FT_LOGE (
183
+ " Invalid message size received. Expected: %zu, but received %zu" ,
184
+ sizeof (FlutterPlatformMessage), engine_message->struct_size );
185
+ return ;
186
+ }
187
+ auto engine = reinterpret_cast <FlutterTizenEngine*>(user_data);
188
+ auto message = engine->ConvertToDesktopMessage (*engine_message);
189
+ engine->message_dispatcher ->HandleMessage (message);
190
+ };
180
191
args.custom_task_runners = &custom_task_runners;
181
192
#ifndef TIZEN_RENDERER_EVAS_GL
182
193
if (IsHeaded ()) {
@@ -199,8 +210,8 @@ bool FlutterTizenEngine::RunEngine(
199
210
FlutterRendererConfig renderer_config = GetRendererConfig ();
200
211
201
212
auto result = embedder_api_.Run (FLUTTER_ENGINE_VERSION, &renderer_config,
202
- &args, this , &flutter_engine );
203
- if (result == kSuccess && flutter_engine != nullptr ) {
213
+ &args, this , &engine_ );
214
+ if (result == kSuccess && engine_ != nullptr ) {
204
215
FT_LOGD (" FlutterEngineRun Success!" );
205
216
} else {
206
217
FT_LOGE (" FlutterEngineRun Failure! result: %d" , result);
@@ -238,15 +249,15 @@ bool FlutterTizenEngine::RunEngine(
238
249
}
239
250
240
251
bool FlutterTizenEngine::StopEngine () {
241
- if (flutter_engine ) {
252
+ if (engine_ ) {
242
253
if (platform_view_channel) {
243
254
platform_view_channel->Dispose ();
244
255
}
245
256
if (plugin_registrar_destruction_callback_) {
246
257
plugin_registrar_destruction_callback_ (plugin_registrar_.get ());
247
258
}
248
- FlutterEngineResult result = embedder_api_.Shutdown (flutter_engine );
249
- flutter_engine = nullptr ;
259
+ FlutterEngineResult result = embedder_api_.Shutdown (engine_ );
260
+ engine_ = nullptr ;
250
261
return (result == kSuccess );
251
262
}
252
263
return false ;
@@ -275,9 +286,9 @@ bool FlutterTizenEngine::SendPlatformMessage(
275
286
if (reply != nullptr && user_data != nullptr ) {
276
287
FlutterEngineResult result =
277
288
embedder_api_.PlatformMessageCreateResponseHandle (
278
- flutter_engine , reply, user_data, &response_handle);
289
+ engine_ , reply, user_data, &response_handle);
279
290
if (result != kSuccess ) {
280
- std::cout << " Failed to create response handle\n " ;
291
+ FT_LOGE ( " Failed to create response handle" ) ;
281
292
return false ;
282
293
}
283
294
}
@@ -291,9 +302,9 @@ bool FlutterTizenEngine::SendPlatformMessage(
291
302
};
292
303
293
304
FlutterEngineResult message_result =
294
- embedder_api_.SendPlatformMessage (flutter_engine , &platform_message);
305
+ embedder_api_.SendPlatformMessage (engine_ , &platform_message);
295
306
if (response_handle != nullptr ) {
296
- embedder_api_.PlatformMessageReleaseResponseHandle (flutter_engine ,
307
+ embedder_api_.PlatformMessageReleaseResponseHandle (engine_ ,
297
308
response_handle);
298
309
}
299
310
return message_result == kSuccess ;
@@ -303,12 +314,11 @@ void FlutterTizenEngine::SendPlatformMessageResponse(
303
314
const FlutterDesktopMessageResponseHandle* handle,
304
315
const uint8_t * data,
305
316
size_t data_length) {
306
- embedder_api_.SendPlatformMessageResponse (flutter_engine, handle, data,
307
- data_length);
317
+ embedder_api_.SendPlatformMessageResponse (engine_, handle, data, data_length);
308
318
}
309
319
310
320
void FlutterTizenEngine::SendPointerEvent (const FlutterPointerEvent& event) {
311
- embedder_api_.SendPointerEvent (flutter_engine , &event, 1 );
321
+ embedder_api_.SendPointerEvent (engine_ , &event, 1 );
312
322
}
313
323
314
324
void FlutterTizenEngine::SendWindowMetrics (int32_t width,
@@ -339,7 +349,7 @@ void FlutterTizenEngine::SendWindowMetrics(int32_t width,
339
349
} else {
340
350
event.pixel_ratio = pixel_ratio;
341
351
}
342
- embedder_api_.SendWindowMetricsEvent (flutter_engine , &event);
352
+ embedder_api_.SendWindowMetricsEvent (engine_ , &event);
343
353
}
344
354
345
355
// This must be called at least once in order to initialize the value of
@@ -388,44 +398,32 @@ void FlutterTizenEngine::OnOrientationChange(int32_t degree) {
388
398
void FlutterTizenEngine::OnVsync (intptr_t baton,
389
399
uint64_t frame_start_time_nanos,
390
400
uint64_t frame_target_time_nanos) {
391
- embedder_api_.OnVsync (flutter_engine , baton, frame_start_time_nanos,
401
+ embedder_api_.OnVsync (engine_ , baton, frame_start_time_nanos,
392
402
frame_target_time_nanos);
393
403
}
394
404
395
405
void FlutterTizenEngine::UpdateLocales (const FlutterLocale** locales,
396
406
size_t locales_count) {
397
- embedder_api_.UpdateLocales (flutter_engine , locales, locales_count);
407
+ embedder_api_.UpdateLocales (engine_ , locales, locales_count);
398
408
}
399
409
400
410
bool FlutterTizenEngine::RegisterExternalTexture (int64_t texture_id) {
401
- return (embedder_api_.RegisterExternalTexture (flutter_engine , texture_id) ==
411
+ return (embedder_api_.RegisterExternalTexture (engine_ , texture_id) ==
402
412
kSuccess );
403
413
}
404
414
405
415
bool FlutterTizenEngine::UnregisterExternalTexture (int64_t texture_id) {
406
- return (embedder_api_.UnregisterExternalTexture (flutter_engine , texture_id) ==
416
+ return (embedder_api_.UnregisterExternalTexture (engine_ , texture_id) ==
407
417
kSuccess );
408
418
}
409
419
410
420
bool FlutterTizenEngine::MarkExternalTextureFrameAvailable (int64_t texture_id) {
411
421
return (embedder_api_.MarkExternalTextureFrameAvailable (
412
- flutter_engine , texture_id) == kSuccess );
422
+ engine_ , texture_id) == kSuccess );
413
423
}
414
424
415
425
// The Flutter Engine calls out to this function when new platform messages are
416
426
// available.
417
- void FlutterTizenEngine::OnFlutterPlatformMessage (
418
- const FlutterPlatformMessage* engine_message,
419
- void * user_data) {
420
- if (engine_message->struct_size != sizeof (FlutterPlatformMessage)) {
421
- FT_LOGE (" Invalid message size received. Expected: %zu, but received %zu" ,
422
- sizeof (FlutterPlatformMessage), engine_message->struct_size );
423
- return ;
424
- }
425
- auto engine = reinterpret_cast <FlutterTizenEngine*>(user_data);
426
- auto message = engine->ConvertToDesktopMessage (*engine_message);
427
- engine->message_dispatcher ->HandleMessage (message);
428
- }
429
427
430
428
// Converts a FlutterPlatformMessage to an equivalent FlutterDesktopMessage.
431
429
FlutterDesktopMessage FlutterTizenEngine::ConvertToDesktopMessage (
0 commit comments