From 0abeb8958b96af29e5ce835d8bd5afe9262fb9bd Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Wed, 3 Aug 2022 15:20:28 +0900 Subject: [PATCH] Minor code cleanup (#323) --- .../tizen/external_texture_pixel_evas_gl.cc | 3 ++- .../tizen/external_texture_surface_evas_gl.cc | 6 ++--- shell/platform/tizen/flutter_tizen_engine.cc | 25 ++++++++----------- shell/platform/tizen/flutter_tizen_engine.h | 2 +- shell/platform/tizen/tizen_event_loop.h | 11 ++++---- shell/platform/tizen/tizen_renderer.h | 2 +- shell/platform/tizen/tizen_renderer_egl.cc | 2 +- .../platform/tizen/tizen_renderer_evas_gl.cc | 7 +++--- shell/platform/tizen/tizen_vsync_waiter.cc | 2 +- 9 files changed, 28 insertions(+), 32 deletions(-) diff --git a/shell/platform/tizen/external_texture_pixel_evas_gl.cc b/shell/platform/tizen/external_texture_pixel_evas_gl.cc index 10a68a0080c3f..dde52a89f999f 100644 --- a/shell/platform/tizen/external_texture_pixel_evas_gl.cc +++ b/shell/platform/tizen/external_texture_pixel_evas_gl.cc @@ -4,7 +4,8 @@ #include "external_texture_pixel_evas_gl.h" -#include "tizen_evas_gl_helper.h" +#include "flutter/shell/platform/tizen/tizen_evas_gl_helper.h" + extern Evas_GL* g_evas_gl; EVAS_GL_GLOBAL_GLES2_DECLARE(); diff --git a/shell/platform/tizen/external_texture_surface_evas_gl.cc b/shell/platform/tizen/external_texture_surface_evas_gl.cc index 8d56f40e09950..c80133a7fc3e1 100644 --- a/shell/platform/tizen/external_texture_surface_evas_gl.cc +++ b/shell/platform/tizen/external_texture_surface_evas_gl.cc @@ -6,12 +6,12 @@ #include -#include "tizen_evas_gl_helper.h" +#include "flutter/shell/platform/tizen/logger.h" +#include "flutter/shell/platform/tizen/tizen_evas_gl_helper.h" + extern Evas_GL* g_evas_gl; EVAS_GL_GLOBAL_GLES2_DECLARE(); -#include "flutter/shell/platform/tizen/logger.h" - namespace flutter { ExternalTextureSurfaceEvasGL::ExternalTextureSurfaceEvasGL( diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index f92170f8c2ac7..da2592d1c6964 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -199,26 +199,24 @@ bool FlutterTizenEngine::RunEngine() { engine->message_dispatcher_->HandleMessage(message); }; args.custom_task_runners = &custom_task_runners; + if (aot_data_) { + args.aot_data = aot_data_.get(); + } + if (!project_->custom_dart_entrypoint().empty()) { + args.custom_dart_entrypoint = project_->custom_dart_entrypoint().c_str(); + } #ifndef WEARABLE_PROFILE args.update_semantics_node_callback = OnUpdateSemanticsNode; args.update_semantics_custom_action_callback = OnUpdateSemanticsCustomActions; -#endif -#ifndef WEARABLE_PROFILE if (IsHeaded() && renderer_->type() == FlutterDesktopRendererType::kEGL) { - tizen_vsync_waiter_ = std::make_unique(this); + vsync_waiter_ = std::make_unique(this); args.vsync_callback = [](void* user_data, intptr_t baton) -> void { - reinterpret_cast(user_data) - ->tizen_vsync_waiter_->AsyncWaitForVsync(baton); + auto* engine = reinterpret_cast(user_data); + engine->vsync_waiter_->AsyncWaitForVsync(baton); }; } #endif - if (aot_data_) { - args.aot_data = aot_data_.get(); - } - if (!project_->custom_dart_entrypoint().empty()) { - args.custom_dart_entrypoint = project_->custom_dart_entrypoint().c_str(); - } FlutterRendererConfig renderer_config = GetRendererConfig(); @@ -269,10 +267,9 @@ bool FlutterTizenEngine::StopEngine() { plugin_registrar_destruction_callbacks_) { callback(registrar); } - #ifndef WEARABLE_PROFILE - if (IsHeaded() && renderer_->type() == FlutterDesktopRendererType::kEGL) { - tizen_vsync_waiter_.reset(); + if (vsync_waiter_) { + vsync_waiter_.reset(); } #endif FlutterEngineResult result = embedder_api_.Shutdown(engine_); diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index 65dd970ca9a33..6e559d75abc3d 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -286,7 +286,7 @@ class FlutterTizenEngine { #ifndef WEARABLE_PROFILE // The vsync waiter for the embedder. - std::unique_ptr tizen_vsync_waiter_; + std::unique_ptr vsync_waiter_; #endif }; diff --git a/shell/platform/tizen/tizen_event_loop.h b/shell/platform/tizen/tizen_event_loop.h index 66cead0341d32..4d9b6650a9517 100644 --- a/shell/platform/tizen/tizen_event_loop.h +++ b/shell/platform/tizen/tizen_event_loop.h @@ -17,6 +17,7 @@ #include #include "flutter/shell/platform/embedder/embedder.h" +#include "flutter/shell/platform/tizen/tizen_renderer.h" namespace flutter { @@ -69,10 +70,10 @@ class TizenEventLoop { std::priority_queue, Task::Comparer> task_queue_; std::vector expired_tasks_; std::mutex expired_tasks_mutex_; - std::atomic task_order_{0}; + std::atomic task_order_ = 0; private: - Ecore_Pipe* ecore_pipe_; + Ecore_Pipe* ecore_pipe_ = nullptr; // Returns a TaskTimePoint computed from the given target time from Flutter. TaskTimePoint TimePointFromFlutterTime(uint64_t flutter_target_time_nanos); @@ -88,8 +89,6 @@ class TizenPlatformEventLoop : public TizenEventLoop { virtual void OnTaskExpired() override; }; -class TizenRenderer; - class TizenRenderEventLoop : public TizenEventLoop { public: TizenRenderEventLoop(std::thread::id main_thread_id, @@ -101,8 +100,8 @@ class TizenRenderEventLoop : public TizenEventLoop { virtual void OnTaskExpired() override; private: - TizenRenderer* renderer_{nullptr}; - std::atomic_bool has_pending_renderer_callback_{false}; + TizenRenderer* renderer_ = nullptr; + std::atomic_bool has_pending_renderer_callback_ = false; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 0220f51111a12..1416e8b9a0dfa 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -7,7 +7,7 @@ #include -#include "public/flutter_tizen.h" +#include "flutter/shell/platform/tizen/public/flutter_tizen.h" namespace flutter { diff --git a/shell/platform/tizen/tizen_renderer_egl.cc b/shell/platform/tizen/tizen_renderer_egl.cc index af121664a6f8c..4054787c7b5e3 100644 --- a/shell/platform/tizen/tizen_renderer_egl.cc +++ b/shell/platform/tizen/tizen_renderer_egl.cc @@ -27,7 +27,7 @@ bool TizenRendererEgl::CreateSurface(void* render_target, int32_t height) { egl_display_ = eglGetDisplay(static_cast(render_target_display)); - if (EGL_NO_DISPLAY == egl_display_) { + if (egl_display_ == EGL_NO_DISPLAY) { PrintEGLError(); FT_LOG(Error) << "Could not get EGL display."; return false; diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index d777206ec596a..55659a1109bd9 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -4,16 +4,14 @@ #include "tizen_renderer_evas_gl.h" -#include "tizen_evas_gl_helper.h" +#include "flutter/shell/platform/tizen/logger.h" +#include "flutter/shell/platform/tizen/tizen_evas_gl_helper.h" // g_evas_gl is shared with ExternalTextureSurfaceEGL and // ExternalTextureSurfaceEvasGL. Evas_GL* g_evas_gl = nullptr; - EVAS_GL_GLOBAL_GLES2_DEFINE(); -#include "flutter/shell/platform/tizen/logger.h" - namespace flutter { TizenRendererEvasGL::TizenRendererEvasGL() { @@ -81,6 +79,7 @@ bool TizenRendererEvasGL::CreateSurface(void* render_target, glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); OnPresent(); + return true; } diff --git a/shell/platform/tizen/tizen_vsync_waiter.cc b/shell/platform/tizen/tizen_vsync_waiter.cc index 937f1545561ff..0906cae1e9fe9 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.cc +++ b/shell/platform/tizen/tizen_vsync_waiter.cc @@ -171,7 +171,7 @@ void TdmClient::VblankCallback(tdm_client_vblank* vblank, std::lock_guard lock(self->engine_mutex_); if (self->engine_) { uint64_t frame_start_time_nanos = tv_sec * 1e9 + tv_usec * 1e3; - uint64_t frame_target_time_nanos = 16.6 * 1e6 + frame_start_time_nanos; + uint64_t frame_target_time_nanos = frame_start_time_nanos + 16.6 * 1e6; self->engine_->OnVsync(self->baton_, frame_start_time_nanos, frame_target_time_nanos); }