From 3903029638c8f6092eed3079738f00987dc4234f Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 13 Jul 2021 20:27:51 +0900 Subject: [PATCH 1/7] Rewrite tizen_log in the C++ style --- shell/platform/tizen/BUILD.gn | 2 - shell/platform/tizen/flutter_tizen.cc | 4 +- shell/platform/tizen/flutter_tizen_engine.cc | 2 +- shell/platform/tizen/tizen_log.cc | 113 ++++++++++++----- shell/platform/tizen/tizen_log.h | 123 ++++++++----------- shell/platform/tizen/tizen_log_stub.cc | 27 ---- 6 files changed, 134 insertions(+), 137 deletions(-) delete mode 100644 shell/platform/tizen/tizen_log_stub.cc diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 4358b39e2e0b0..ad66c61ceebf0 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -133,7 +133,6 @@ template("embedder_for_profile") { "external_texture_pixel_gl.cc", "external_texture_surface_gl.cc", "system_utils_tizen.cc", - "tizen_log.cc", ] libs = _libs_minimum @@ -250,7 +249,6 @@ template("embedder_executable") { "external_texture_pixel_gl_stub.cc", "external_texture_surface_gl_stub.cc", "system_utils_linux.cc", - "tizen_log_stub.cc", "tizen_renderer_evas_gl.cc", ] diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index fa8a1c72f9fbc..a0ad623965359 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -28,7 +28,9 @@ static FlutterDesktopEngineRef HandleForEngine( FlutterDesktopEngineRef FlutterDesktopRunEngine( const FlutterDesktopWindowProperties& window_properties, const FlutterDesktopEngineProperties& engine_properties) { - flutter::StartLogging(); +#ifndef __X64_SHELL__ + flutter::Logger::Start(); +#endif flutter::FlutterProjectBundle project(engine_properties); auto engine = std::make_unique(project); diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 73fba07c66f11..968bfe1946b9b 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -146,7 +146,7 @@ bool FlutterTizenEngine::RunEngine() { if (std::find(switches.begin(), switches.end(), "--verbose-logging") != switches.end()) { - SetMinLoggingLevel(DLOG_INFO); + Logger::SetLoggingLevel(kLogLevelInfo); } // Configure task runners. diff --git a/shell/platform/tizen/tizen_log.cc b/shell/platform/tizen/tizen_log.cc index 17cb8e735369d..f6e607784819a 100644 --- a/shell/platform/tizen/tizen_log.cc +++ b/shell/platform/tizen/tizen_log.cc @@ -4,36 +4,30 @@ #include "tizen_log.h" -#include +#ifndef __X64_SHELL__ +#include +#endif #include -static int stdout_pipe[2]; -static int stderr_pipe[2]; -static pthread_t stdout_thread; -static pthread_t stderr_thread; -static bool is_running = false; -static log_priority min_log_priority = DLOG_ERROR; +#include namespace flutter { -void SetMinLoggingLevel(log_priority p) { - min_log_priority = p; -}; +namespace { -log_priority GetMinLoggingLevel() { - return min_log_priority; -}; +constexpr char kLogTag[] = "ConsoleMessage"; -static void* LoggingFunction(void* arg) { - int* pipe = static_cast(arg); - auto priority = pipe == stdout_pipe ? DLOG_INFO : DLOG_ERROR; +} // namespace +void* Logger::Redirect(void* arg) { + int* pipe = static_cast(arg); ssize_t size; char buffer[1024]; while ((size = read(pipe[0], buffer, sizeof(buffer) - 1)) > 0) { buffer[size] = 0; - __LOG(priority, "%s", buffer); + Print(pipe == stdout_pipe_ ? kLogLevelInfo : kLogLevelError, + std::string(buffer)); } close(pipe[0]); @@ -42,32 +36,85 @@ static void* LoggingFunction(void* arg) { return nullptr; } -void StartLogging() { - if (is_running) { - FT_LOGI("The threads are already running."); +void Logger::Start() { + if (started_) { + FT_LOG(Info) << "The threads are already running."; return; } - - if (pipe(stdout_pipe) < 0 || pipe(stderr_pipe) < 0) { - FT_LOGE("Failed to create pipes."); + if (pipe(stdout_pipe_) < 0 || pipe(stderr_pipe_) < 0) { + FT_LOG(Error) << "Failed to create pipes."; return; } - - if (dup2(stdout_pipe[1], 1) < 0 || dup2(stderr_pipe[1], 2) < 0) { - FT_LOGE("Failed to duplicate file descriptors."); + if (dup2(stdout_pipe_[1], 1) < 0 || dup2(stderr_pipe_[1], 2) < 0) { + FT_LOG(Error) << "Failed to duplicate file descriptors."; return; } + if (pthread_create(&stdout_thread_, 0, Redirect, stdout_pipe_) != 0 || + pthread_create(&stderr_thread_, 0, Redirect, stderr_pipe_) != 0) { + FT_LOG(Error) << "Failed to create threads."; + return; + } + if (pthread_detach(stdout_thread_) != 0 || + pthread_detach(stderr_thread_) != 0) { + FT_LOG(Warn) << "Failed to detach threads."; + } + started_ = true; +} + +int Logger::GetLoggingLevel() { + return logging_level_; +} + +void Logger::SetLoggingLevel(int level) { + logging_level_ = level; +} + +void Logger::Print(int level, std::string message) { +#ifdef __X64_SHELL__ + std::cerr << message << std::endl; + std::cerr.flush(); +#else + log_priority priority; + if (level == kLogLevelDebug) { + priority = DLOG_DEBUG; + } else if (level == kLogLevelInfo) { + priority = DLOG_INFO; + } else if (level == kLogLevelWarn) { + priority = DLOG_WARN; + } else if (level == kLogLevelError) { + priority = DLOG_ERROR; + } else if (level == kLogLevelFatal) { + priority = DLOG_FATAL; + } else { + priority = DLOG_INFO; + } +#ifdef TV_PROFILE + // LOG_ID_MAIN must be used to display logs properly on TV devices. + // Note: dlog_print(...) is an alias of __dlog_print(LOG_ID_APPS, ...). + __dlog_print(LOG_ID_MAIN, priority, kLogTag, "%s", message.c_str()); +#else + dlog_print(priority, kLogTag, "%s", message.c_str()); +#endif +#endif // __X64_SHELL__ +} + +LogMessage::LogMessage(int level, + const char* file, + const char* function, + int line) + : level_(level), file_(file), function_(function), line_(line) { + stream_ << file_ << ": " << function_ << "(" << line_ << ") > "; +} - if (pthread_create(&stdout_thread, 0, LoggingFunction, stdout_pipe) != 0 || - pthread_create(&stderr_thread, 0, LoggingFunction, stderr_pipe) != 0) { - FT_LOGE("Failed to create threads."); +LogMessage::~LogMessage() { + if (level_ < Logger::GetLoggingLevel()) { return; } + Logger::Print(level_, stream_.str()); - if (pthread_detach(stdout_thread) != 0 || - pthread_detach(stderr_thread) != 0) { - FT_LOGW("Failed to detach threads."); + if (level_ >= kLogLevelFatal) { + abort(); } - is_running = true; } + } // namespace flutter diff --git a/shell/platform/tizen/tizen_log.h b/shell/platform/tizen/tizen_log.h index 8411acd0577e5..6bbfd9c7d141a 100644 --- a/shell/platform/tizen/tizen_log.h +++ b/shell/platform/tizen/tizen_log.h @@ -5,99 +5,76 @@ #ifndef EMBEDDER_TIZEN_LOG_H_ #define EMBEDDER_TIZEN_LOG_H_ -#ifndef __X64_SHELL__ -#include -#else -#define log_priority int -#define DLOG_DEBUG 0 -#define DLOG_WARN 1 -#define DLOG_INFO 2 -#define DLOG_ERROR 3 -int dlog_print(log_priority prio, const char* tag, const char* fmt, ...); -#endif +#include #include -#include +#include +#include namespace flutter { -// Starts logging threads which constantly redirect stdout/stderr to dlog. -// The threads can be started only once per process. -void StartLogging(); +constexpr int kLogLevelDebug = 0; +constexpr int kLogLevelInfo = 1; +constexpr int kLogLevelWarn = 2; +constexpr int kLogLevelError = 3; +constexpr int kLogLevelFatal = 4; -// Handles filtering of logs. -void SetMinLoggingLevel(log_priority p); -log_priority GetMinLoggingLevel(); +class Logger { + public: + // Starts logging threads which constantly redirect stdout/stderr to dlog. + // The threads should be started only once per process. + static void Start(); -#ifdef LOG_TAG -#undef LOG_TAG -#endif -// This is the only valid log tag that TV devices can understand. -#define LOG_TAG "ConsoleMessage" + static int GetLoggingLevel(); + static void SetLoggingLevel(int level); -#ifndef __MODULE__ -#define __MODULE__ strrchr("/" __FILE__, '/') + 1 -#endif + static void Print(int level, std::string message); -#undef __LOG + private: + explicit Logger(); -#ifdef TV_PROFILE -// dlog_print() cannot be used because it implicitly passes LOG_ID_APPS as -// a log id, which is ignored by TV devices. Instead, an internal function -// __dlog_print() that takes a log id as a parameter is used. -#define __LOG(prio, fmt, args...) \ - __dlog_print(LOG_ID_MAIN, prio, LOG_TAG, fmt, ##args) -#else -#define __LOG(prio, fmt, args...) dlog_print(prio, LOG_TAG, fmt, ##args) -#endif + static void* Redirect(void* arg); + + static inline bool started_ = false; + static inline int stdout_pipe_[2]; + static inline int stderr_pipe_[2]; + static inline pthread_t stdout_thread_; + static inline pthread_t stderr_thread_; + + static inline int logging_level_ = kLogLevelError; +}; -#define __FT_LOG(prio, fmt, args...) \ - do { \ - if (prio >= flutter::GetMinLoggingLevel()) { \ - __LOG(prio, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, \ - ##args); \ - } \ - } while (0) +class LogMessage { + public: + LogMessage(int level, const char* file, const char* function, int line); + ~LogMessage(); -#define FT_LOGD(fmt, args...) __FT_LOG(DLOG_DEBUG, fmt, ##args) -#define FT_LOGI(fmt, args...) __FT_LOG(DLOG_INFO, fmt, ##args) -#define FT_LOGW(fmt, args...) __FT_LOG(DLOG_WARN, fmt, ##args) -#define FT_LOGE(fmt, args...) __FT_LOG(DLOG_ERROR, fmt, ##args) + std::ostream& stream() { return stream_; } + + private: + std::ostringstream stream_; + const int level_; + const char* file_; + const char* function_; + const int line_; +}; + +} // namespace flutter + +#define FT_LOG(level) \ + flutter::LogMessage(flutter::kLogLevel##level, __FILE__, __func__, __LINE__) \ + .stream() #if defined(NDEBUG) #define FT_ASSERT(assertion) ((void)0) #define FT_ASSERT_NOT_REACHED() ((void)0) #define FT_ASSERT_STATIC(assertion, reason) #else -#define FT_ASSERT(assertion) assert(assertion); -#define FT_ASSERT_NOT_REACHED() \ - do { \ - assert(false); \ - } while (0) +#define FT_ASSERT(assertion) assert(assertion) +#define FT_ASSERT_NOT_REACHED() assert(false) #define FT_ASSERT_STATIC(assertion, reason) static_assert(assertion, reason) #endif -#define FT_RELEASE_ASSERT(assertion) \ - do { \ - if (!(assertion)) { \ - FT_LOGE("RELEASE_ASSERT"); \ - abort(); \ - } \ - } while (0) - -#define FT_RELEASE_ASSERT_NOT_REACHED() \ - do { \ - FT_LOGE("RELEASE_ASSERT_NOT_REACHED"); \ - abort(); \ - } while (0) - -/* COMPILE_ASSERT */ -#ifndef FT_COMPILE_ASSERT -#define FT_COMPILE_ASSERT(exp, name) static_assert((exp), #name) -#endif - -#define FT_UNIMPLEMENTED() FT_LOGW("UNIMPLEMENTED!") - -} // namespace flutter +#define FT_UNIMPLEMENTED() FT_LOG(Warn) << "UNIMPLEMENTED!" #endif // EMBEDDER_TIZEN_LOG_H_ diff --git a/shell/platform/tizen/tizen_log_stub.cc b/shell/platform/tizen/tizen_log_stub.cc deleted file mode 100644 index b248a4bb464a4..0000000000000 --- a/shell/platform/tizen/tizen_log_stub.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#include "tizen_log.h" - -int dlog_print(log_priority prio, const char* tag, const char* fmt, ...) { - va_list arglist; - va_start(arglist, fmt); - vprintf(fmt, arglist); - va_end(arglist); - printf("\n"); - return 0; -} - -namespace flutter { - -void SetMinLoggingLevel(log_priority p){}; - -log_priority GetMinLoggingLevel() { - return DLOG_ERROR; -}; - -void StartLogging() {} - -} // namespace flutter From 378c9c7c362fa69d0519ca42faa8ff10fcb3dd39 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 13 Jul 2021 20:31:32 +0900 Subject: [PATCH 2/7] Convert logs to streams --- .../tizen/channels/key_event_channel.cc | 1 - .../tizen/channels/lifecycle_channel.cc | 8 +- .../tizen/channels/platform_channel.cc | 25 ++-- .../tizen/channels/platform_view_channel.cc | 11 +- .../tizen/channels/text_input_channel.cc | 27 ++-- .../tizen/external_texture_surface_gl.cc | 10 +- .../platform/tizen/flutter_project_bundle.cc | 13 +- shell/platform/tizen/flutter_tizen.cc | 2 +- shell/platform/tizen/flutter_tizen_engine.cc | 27 ++-- .../tizen/flutter_tizen_texture_registrar.cc | 8 +- shell/platform/tizen/key_event_handler.cc | 5 +- .../tizen/tizen_renderer_ecore_wl2.cc | 140 +++++------------- .../platform/tizen/tizen_renderer_evas_gl.cc | 21 +-- shell/platform/tizen/tizen_vsync_waiter.cc | 22 ++- 14 files changed, 117 insertions(+), 203 deletions(-) diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index f34f55bfdcb02..e025cc58315e1 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -7,7 +7,6 @@ #include #include "flutter/shell/platform/common/json_message_codec.h" -#include "flutter/shell/platform/tizen/tizen_log.h" namespace flutter { diff --git a/shell/platform/tizen/channels/lifecycle_channel.cc b/shell/platform/tizen/channels/lifecycle_channel.cc index 95aca8582746d..13f0a43ce0e32 100644 --- a/shell/platform/tizen/channels/lifecycle_channel.cc +++ b/shell/platform/tizen/channels/lifecycle_channel.cc @@ -29,22 +29,22 @@ LifecycleChannel::LifecycleChannel(BinaryMessenger* messenger) LifecycleChannel::~LifecycleChannel() {} void LifecycleChannel::AppIsInactive() { - FT_LOGI("Sending %s message.", kInactive); + FT_LOG(Info) << "Sending " << kInactive << " message."; channel_->Send(EncodableValue(kInactive)); } void LifecycleChannel::AppIsResumed() { - FT_LOGI("Sending %s message.", kResumed); + FT_LOG(Info) << "Sending " << kResumed << " message."; channel_->Send(EncodableValue(kResumed)); } void LifecycleChannel::AppIsPaused() { - FT_LOGI("Sending %s message.", kPaused); + FT_LOG(Info) << "Sending " << kPaused << " message."; channel_->Send(EncodableValue(kPaused)); } void LifecycleChannel::AppIsDetached() { - FT_LOGI("Sending %s message.", kDetached); + FT_LOG(Info) << "Sending " << kDetached << " message."; channel_->Send(EncodableValue(kDetached)); } diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index ba6e16051b0ed..5e20d2e005d3d 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -99,12 +99,7 @@ class FeedbackManager { FeedbackManager& operator=(const FeedbackManager&) = delete; ResultCode Play(FeedbackType type, FeedbackPattern pattern) { - FT_LOGI("Enter FeedbackManager::Play(): type: [%d], pattern: [%d]", - static_cast(type), static_cast(pattern)); - - if (ResultCode::kOk != initialization_status_) { - FT_LOGE("Cannot run Play(): initialization_status_: [%d]", - static_cast(initialization_status_)); + if (initialization_status_ != ResultCode::kOk) { return initialization_status_; } @@ -113,8 +108,8 @@ class FeedbackManager { if (FEEDBACK_ERROR_NONE == ret) { return ResultCode::kOk; } - FT_LOGE("feedback_play_type() failed with error: [%d] (%s)", ret, - get_error_message(ret)); + FT_LOG(Error) << "feedback_play_type() failed with error: " + << get_error_message(ret); return NativeErrorToResultCode(ret); } @@ -139,8 +134,8 @@ class FeedbackManager { FeedbackManager() { auto ret = feedback_initialize(); if (FEEDBACK_ERROR_NONE != ret) { - FT_LOGE("feedback_initialize() failed with error: [%d] (%s)", ret, - get_error_message(ret)); + FT_LOG(Error) << "feedback_initialize() failed with error: " + << get_error_message(ret); initialization_status_ = NativeErrorToResultCode(ret); return; } @@ -151,8 +146,8 @@ class FeedbackManager { ~FeedbackManager() { auto ret = feedback_deinitialize(); if (FEEDBACK_ERROR_NONE != ret) { - FT_LOGE("feedback_deinitialize() failed with error: [%d] (%s)", ret, - get_error_message(ret)); + FT_LOG(Error) << "feedback_deinitialize() failed with error: " + << get_error_message(ret); return; } } @@ -252,7 +247,7 @@ void PlatformChannel::HandleMethodCall( const auto error_cause = FeedbackManager::GetErrorMessage(ret, kPlaySoundMethod, pattern_str); const std::string error_message = "Could not play sound"; - FT_LOGE("%s: %s", error_cause.c_str(), error_message.c_str()); + FT_LOG(Error) << error_cause << ": " << error_message; result->Error(error_cause, error_message); @@ -280,7 +275,7 @@ void PlatformChannel::HandleMethodCall( FeedbackManager::GetErrorMessage(ret, vibrate_variant_name); const std::string error_message = "Could not vibrate"; - FT_LOGE("%s: %s", error_cause.c_str(), error_message.c_str()); + FT_LOG(Error) << error_cause << ": " << error_message; result->Error(error_cause, error_message); } else if (method == kGetClipboardDataMethod) { @@ -330,7 +325,7 @@ void PlatformChannel::HandleMethodCall( } else if (method == kSetSystemUIOverlayStyleMethod) { result->NotImplemented(); } else { - FT_LOGI("Unimplemented method: %s", method.c_str()); + FT_LOG(Info) << "Unimplemented method: " << method; result->NotImplemented(); } } diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 3dbce1bd14e9e..7503a86a1eb3f 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -121,9 +121,7 @@ void PlatformViewChannel::HandleMethodCall( return; } - FT_LOGI( - "PlatformViewChannel create viewType: %s id: %d width: %f height: %f ", - view_type.c_str(), view_id, width, height); + FT_LOG(Info) << "Creating a platform view: " << view_type; RemoveViewInstanceIfNeeded(view_id); EncodableMap values = std::get(arguments); @@ -149,7 +147,7 @@ void PlatformViewChannel::HandleMethodCall( result->Error("Can't create a webview instance!!"); } } else { - FT_LOGE("can't find view type = %s", view_type.c_str()); + FT_LOG(Error) << "Can't find view type: " << view_type; result->Error("Can't find view type"); } } else if (method == "clearFocus") { @@ -228,11 +226,8 @@ void PlatformViewChannel::HandleMethodCall( } result->Success(); - } else if (method == "setDirection") { - FT_LOGW("PlatformViewChannel setDirection - not implemented"); - result->NotImplemented(); } else { - FT_LOGW("Unimplemented method: %s", method.c_str()); + FT_LOG(Warn) << "Unimplemented method: " << method; result->NotImplemented(); } } else { diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index a885ab66197c2..e5c41c51eba03 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -46,6 +46,7 @@ bool IsASCIIPrintableKey(char c) { } return false; } + } // namespace TextInputChannel::TextInputChannel(BinaryMessenger* messenger, @@ -63,7 +64,7 @@ TextInputChannel::TextInputChannel(BinaryMessenger* messenger, // Set input method callbacks input_method_context_->SetOnCommitCallback([this](std::string str) -> void { - FT_LOGI("OnCommit str[%s]", str.data()); + FT_LOG(Debug) << "OnCommit: " << str; text_editing_context_.edit_status_ = EditStatus::kCommit; ConsumeLastPreedit(); active_model_->AddText(str); @@ -95,9 +96,10 @@ TextInputChannel::TextInputChannel(BinaryMessenger* messenger, active_model_->selection().base(); text_editing_context_.has_preedit_ = true; SendStateUpdate(*active_model_); - FT_LOGI("preedit start pos[%d], preedit end pos[%d]", - text_editing_context_.preedit_start_pos_, - text_editing_context_.preedit_end_pos_); + FT_LOG(Debug) << "Preedit start position: " + << text_editing_context_.preedit_start_pos_ + << ", end position: " + << text_editing_context_.preedit_end_pos_; } }); @@ -133,8 +135,7 @@ void TextInputChannel::HandleMethodCall( const MethodCall& method_call, std::unique_ptr> result) { const std::string& method = method_call.method_name(); - - FT_LOGI("Handle Method : %s", method.data()); + FT_LOG(Debug) << "Handle a method: " << method; if (method.compare(kShowMethod) == 0) { input_method_context_->ShowInputPannel(); @@ -253,7 +254,7 @@ void TextInputChannel::SendStateUpdate(const TextInputModel& model) { kTextKey, rapidjson::Value(model.GetText(), allocator).Move(), allocator); args->PushBack(editing_state, allocator); - FT_LOGI("Send text[%s]", model.GetText().data()); + FT_LOG(Info) << "Send text: " << model.GetText(); channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args)); } @@ -268,7 +269,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) { // FIXME: Only for wearable. if (is_ime && strcmp(event->key, "Select") == 0) { text_editing_context_.is_in_select_mode_ = true; - FT_LOGI("Set select mode[true]"); + FT_LOG(Debug) << "Entering select mode."; } #else bool is_ime = strcmp(ecore_device_name_get(event->dev), "ime") == 0; @@ -277,7 +278,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) { if (ShouldNotFilterEvent(event->key, is_ime)) { ResetTextEditingContext(); input_method_context_->ResetInputMethodContext(); - FT_LOGW("Force redirect IME key-event[%s] to fallback", event->keyname); + FT_LOG(Info) << "Force redirect an IME key event: " << event->keyname; return false; } @@ -292,7 +293,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) { text_editing_context_.is_in_select_mode_) { text_editing_context_.is_in_select_mode_ = false; handled = true; - FT_LOGI("Set select mode[false]"); + FT_LOG(Debug) << "Leaving select mode."; } #endif @@ -303,7 +304,7 @@ void TextInputChannel::HandleUnfilteredEvent(Ecore_Event_Key* event) { #ifdef MOBILE_PROFILE // FIXME: Only for mobile. if (text_editing_context_.edit_status_ == EditStatus::kPreeditEnd) { - FT_LOGW("Ignore key-event[%s]!", event->keyname); + FT_LOG(Warn) << "Ignore a key event: " << event->keyname; ResetTextEditingContext(); return; } @@ -372,8 +373,8 @@ void TextInputChannel::ConsumeLastPreedit() { text_editing_context_.preedit_start_pos_; active_model_->DeleteSurrounding(-count, count); std::string after = active_model_->GetText(); - FT_LOGI("Consume last preedit count:[%d] text:[%s] -> [%s]", count, - before.data(), after.data()); + FT_LOG(Debug) << "Last preedit count: " << count << ", text: " << before + << " -> " << after; SendStateUpdate(*active_model_); } text_editing_context_.has_preedit_ = false; diff --git a/shell/platform/tizen/external_texture_surface_gl.cc b/shell/platform/tizen/external_texture_surface_gl.cc index b748c40c66221..2f690d8607ea0 100644 --- a/shell/platform/tizen/external_texture_surface_gl.cc +++ b/shell/platform/tizen/external_texture_surface_gl.cc @@ -60,12 +60,12 @@ bool ExternalTextureSurfaceGL::PopulateTexture( const FlutterDesktopGpuBuffer* gpu_buffer = texture_callback_(width, height, user_data_); if (!gpu_buffer) { - FT_LOGI("[texture id:%ld] gpu_buffer is null", texture_id_); + FT_LOG(Info) << "gpu_buffer is null for texture ID: " << texture_id_; return false; } if (!gpu_buffer->buffer) { - FT_LOGI("[texture id:%ld] tbm_surface_ is null", texture_id_); + FT_LOG(Info) << "tbm_surface is null for texture ID: " << texture_id_; return false; } const tbm_surface_h tbm_surface = @@ -73,7 +73,7 @@ bool ExternalTextureSurfaceGL::PopulateTexture( tbm_surface_info_s info; if (tbm_surface_get_info(tbm_surface, &info) != TBM_SURFACE_ERROR_NONE) { - FT_LOGI("[texture id:%ld] tbm_surface is invalid", texture_id_); + FT_LOG(Info) << "tbm_surface is invalid for texture ID: " << texture_id_; return false; } @@ -114,8 +114,8 @@ bool ExternalTextureSurfaceGL::PopulateTexture( EGL_NATIVE_SURFACE_TIZEN, tbm_surface, attribs); if (!egl_src_image) { - FT_LOGE("[texture id:%ld] egl_src_image create fail!!, errorcode == %d", - texture_id_, eglGetError()); + FT_LOG(Error) << "eglCreateImageKHR failed with an error " << eglGetError() + << " for texture ID: " << texture_id_; return false; } if (state_->gl_texture == 0) { diff --git a/shell/platform/tizen/flutter_project_bundle.cc b/shell/platform/tizen/flutter_project_bundle.cc index b36ec06fcd488..39176910d2379 100644 --- a/shell/platform/tizen/flutter_project_bundle.cc +++ b/shell/platform/tizen/flutter_project_bundle.cc @@ -48,7 +48,8 @@ FlutterProjectBundle::FlutterProjectBundle( (!aot_library_path_.empty() && aot_library_path_.is_relative())) { std::filesystem::path executable_location = GetExecutableDirectory(); if (executable_location.empty()) { - FT_LOGE("Unable to find executable location to resolve resource paths."); + FT_LOG(Error) + << "Unable to find executable location to resolve resource paths."; assets_path_ = std::filesystem::path(); icu_path_ = std::filesystem::path(); } else { @@ -74,13 +75,13 @@ bool FlutterProjectBundle::HasValidPaths() { UniqueAotDataPtr FlutterProjectBundle::LoadAotData( const FlutterEngineProcTable& engine_procs) { if (aot_library_path_.empty()) { - FT_LOGE( - "Attempted to load AOT data, but no aot_library_path was provided."); + FT_LOG(Error) + << "Attempted to load AOT data, but no aot_library_path was provided."; return UniqueAotDataPtr(nullptr, nullptr); } if (!std::filesystem::exists(aot_library_path_)) { - FT_LOGE("Can't load AOT data from %s; no such file.", - aot_library_path_.u8string().c_str()); + FT_LOG(Error) << "Can't load AOT data from " << aot_library_path_.u8string() + << "; no such file."; return UniqueAotDataPtr(nullptr, nullptr); } std::string path_string = aot_library_path_.u8string(); @@ -90,7 +91,7 @@ UniqueAotDataPtr FlutterProjectBundle::LoadAotData( FlutterEngineAOTData data = nullptr; auto result = engine_procs.CreateAOTData(&source, &data); if (result != kSuccess) { - FT_LOGE("Failed to load AOT data from: %s", path_string.c_str()); + FT_LOG(Error) << "Failed to load AOT data from: " << path_string; return UniqueAotDataPtr(nullptr, nullptr); } return UniqueAotDataPtr(data, engine_procs.CollectAOTData); diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index a0ad623965359..afd74b8e4ffab 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -41,7 +41,7 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine( window_properties.focusable); } if (!engine->RunEngine()) { - FT_LOGE("Failed to run the Flutter engine."); + FT_LOG(Error) << "Failed to start the Flutter engine."; return nullptr; } return HandleForEngine(engine.release()); diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 968bfe1946b9b..54c322642e2b5 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -65,7 +65,7 @@ FlutterTizenEngine::FlutterTizenEngine(const FlutterProjectBundle& project) std::this_thread::get_id(), // main thread embedder_api_.GetCurrentTime, [this](const auto* task) { if (embedder_api_.RunTask(this->engine_, task) != kSuccess) { - FT_LOGE("Could not post an engine task."); + FT_LOG(Error) << "Could not post an engine task."; } }); @@ -99,7 +99,7 @@ void FlutterTizenEngine::InitializeRenderer(int32_t x, embedder_api_.GetCurrentTime, [this](const auto* task) { if (embedder_api_.RunTask(this->engine_, task) != kSuccess) { - FT_LOGE("Could not post an engine task."); + FT_LOG(Error) << "Could not post an engine task."; } }, renderer.get()); @@ -113,16 +113,16 @@ void FlutterTizenEngine::InitializeRenderer(int32_t x, bool FlutterTizenEngine::RunEngine() { if (engine_ != nullptr) { - FT_LOGE("The engine has already started."); + FT_LOG(Error) << "The engine has already started."; return false; } if (IsHeaded() && !renderer->IsValid()) { - FT_LOGE("The display was not valid."); + FT_LOG(Error) << "The display was not valid."; return false; } if (!project_->HasValidPaths()) { - FT_LOGE("Missing or unresolvable paths to assets."); + FT_LOG(Error) << "Missing or unresolvable paths to assets."; return false; } std::string assets_path_string = project_->assets_path().u8string(); @@ -130,7 +130,7 @@ bool FlutterTizenEngine::RunEngine() { if (embedder_api_.RunsAOTCompiledDartCode()) { aot_data_ = project_->LoadAotData(embedder_api_); if (!aot_data_) { - FT_LOGE("Unable to start engine without AOT data."); + FT_LOG(Error) << "Unable to start engine without AOT data."; return false; } } @@ -193,9 +193,9 @@ bool FlutterTizenEngine::RunEngine() { args.platform_message_callback = [](const FlutterPlatformMessage* engine_message, void* user_data) { if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) { - FT_LOGE( - "Invalid message size received. Expected: %zu, but received %zu", - sizeof(FlutterPlatformMessage), engine_message->struct_size); + FT_LOG(Error) << "Invalid message size received. Expected: " + << sizeof(FlutterPlatformMessage) << ", but received " + << engine_message->struct_size; return; } auto engine = reinterpret_cast(user_data); @@ -219,10 +219,9 @@ bool FlutterTizenEngine::RunEngine() { auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config, &args, this, &engine_); - if (result == kSuccess && engine_ != nullptr) { - FT_LOGI("FlutterEngineRun Success!"); - } else { - FT_LOGE("FlutterEngineRun Failure! result: %d", result); + if (result != kSuccess || engine_ == nullptr) { + FT_LOG(Error) << "Failed to start the Flutter engine with error: " + << result; return false; } @@ -297,7 +296,7 @@ bool FlutterTizenEngine::SendPlatformMessage( embedder_api_.PlatformMessageCreateResponseHandle( engine_, reply, user_data, &response_handle); if (result != kSuccess) { - FT_LOGE("Failed to create response handle"); + FT_LOG(Error) << "Failed to create a response handle."; return false; } } diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar.cc b/shell/platform/tizen/flutter_tizen_texture_registrar.cc index 817ff5401f2ae..31a82050bae83 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar.cc +++ b/shell/platform/tizen/flutter_tizen_texture_registrar.cc @@ -22,20 +22,20 @@ int64_t FlutterTizenTextureRegistrar::RegisterTexture( const FlutterDesktopTextureInfo* texture_info) { if (texture_info->type != kFlutterDesktopPixelBufferTexture && texture_info->type != kFlutterDesktopGpuBufferTexture) { - FT_LOGE("Attempted to register texture of unsupport type."); + FT_LOG(Error) << "Attempted to register texture of unsupport type."; return -1; } if (texture_info->type == kFlutterDesktopPixelBufferTexture) { if (!texture_info->pixel_buffer_config.callback) { - FT_LOGE("Invalid pixel buffer texture callback."); + FT_LOG(Error) << "Invalid pixel buffer texture callback."; return -1; } } if (texture_info->type == kFlutterDesktopGpuBufferTexture) { if (!texture_info->gpu_buffer_config.callback) { - FT_LOGE("Invalid gpu buffer texture callback."); + FT_LOG(Error) << "Invalid gpu buffer texture callback."; return -1; } } @@ -101,7 +101,7 @@ FlutterTizenTextureRegistrar::CreateExternalTexture( texture_info->gpu_buffer_config.user_data); break; default: - FT_LOGE("Invalid texture type."); + FT_LOG(Error) << "Invalid texture type."; return nullptr; } } diff --git a/shell/platform/tizen/key_event_handler.cc b/shell/platform/tizen/key_event_handler.cc index 1904485e2c1d7..e75acb764a4cd 100644 --- a/shell/platform/tizen/key_event_handler.cc +++ b/shell/platform/tizen/key_event_handler.cc @@ -40,8 +40,9 @@ Eina_Bool KeyEventHandler::OnKey(void* data, int type, void* event) { auto* engine = self->engine_; auto is_down = type == ECORE_EVENT_KEY_DOWN; - FT_LOGI("Keycode: %d, name: %s, mods: %d, is_down: %d", key->keycode, - key->keyname, key->modifiers, is_down); + if (is_down) { + FT_LOG(Info) << "Key pressed: " << key->key << "(" << key->keycode << ")"; + } if (engine->text_input_channel) { if (engine->text_input_channel->SendKeyEvent(key, is_down)) { diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 18f3fdf246418..0d495bd4f8112 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -25,12 +25,10 @@ TizenRendererEcoreWl2::~TizenRendererEcoreWl2() { bool TizenRendererEcoreWl2::OnMakeCurrent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } if (eglMakeCurrent(egl_display_, egl_surface_, egl_surface_, egl_context_) != EGL_TRUE) { - FT_LOGE("Could not make the onscreen context current"); PrintEGLError(); return false; } @@ -39,12 +37,10 @@ bool TizenRendererEcoreWl2::OnMakeCurrent() { bool TizenRendererEcoreWl2::OnClearCurrent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } if (eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) != EGL_TRUE) { - FT_LOGE("Could not clear context"); PrintEGLError(); return false; } @@ -53,12 +49,10 @@ bool TizenRendererEcoreWl2::OnClearCurrent() { bool TizenRendererEcoreWl2::OnMakeResourceCurrent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } if (eglMakeCurrent(egl_display_, egl_resource_surface_, egl_resource_surface_, egl_resource_context_) != EGL_TRUE) { - FT_LOGE("Could not make the offscreen context current"); PrintEGLError(); return false; } @@ -67,7 +61,6 @@ bool TizenRendererEcoreWl2::OnMakeResourceCurrent() { bool TizenRendererEcoreWl2::OnPresent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } @@ -77,7 +70,6 @@ bool TizenRendererEcoreWl2::OnPresent() { } if (eglSwapBuffers(egl_display_, egl_surface_) != EGL_TRUE) { - FT_LOGE("Could not swap EGl buffer"); PrintEGLError(); return false; } @@ -86,7 +78,6 @@ bool TizenRendererEcoreWl2::OnPresent() { uint32_t TizenRendererEcoreWl2::OnGetFBO() { if (!is_valid_) { - FT_LOGE("Invalid TizenRenderer"); return 999; } return 0; @@ -210,7 +201,7 @@ void* TizenRendererEcoreWl2::OnProcResolver(const char* name) { GL_FUNC(glViewport) #undef GL_FUNC - FT_LOGW("Could not resolve: %s", name); + FT_LOG(Warn) << "Could not resolve: " << name; return nullptr; } @@ -224,7 +215,7 @@ TizenRenderer::WindowGeometry TizenRendererEcoreWl2::GetCurrentGeometry() { int32_t TizenRendererEcoreWl2::GetDpi() { auto* output = ecore_wl2_window_output_find(ecore_wl2_window_); if (!output) { - FT_LOGE("Could not find an output associated with the window."); + FT_LOG(Error) << "Could not find an output associated with the window."; return 0; } return ecore_wl2_output_dpi_get(output); @@ -241,19 +232,19 @@ void* TizenRendererEcoreWl2::GetWindowHandle() { bool TizenRendererEcoreWl2::InitializeRenderer() { int32_t width, height; if (!SetupDisplay(&width, &height)) { - FT_LOGE("SetupDisplay failed."); + FT_LOG(Error) << "SetupDisplay() failed."; return false; } if (!SetupEcoreWlWindow(width, height)) { - FT_LOGE("SetupEcoreWlWindow failed."); + FT_LOG(Error) << "SetupEcoreWlWindow() failed."; return false; } if (!SetupEglWindow(width, height)) { - FT_LOGE("SetupEglWindow failed."); + FT_LOG(Error) << "SetupEglWindow() failed."; return false; } if (!SetupEglSurface()) { - FT_LOGE("SetupEglSurface failed."); + FT_LOG(Error) << "SetupEglSurface() failed."; return false; } Show(); @@ -274,19 +265,19 @@ void TizenRendererEcoreWl2::DestroyRenderer() { bool TizenRendererEcoreWl2::SetupDisplay(int32_t* width, int32_t* height) { if (!ecore_wl2_init()) { - FT_LOGE("Could not initialize ecore_wl2."); + FT_LOG(Error) << "Could not initialize ecore_wl2."; return false; } ecore_wl2_display_ = ecore_wl2_display_connect(nullptr); if (ecore_wl2_display_ == nullptr) { - FT_LOGE("Display not found."); + FT_LOG(Error) << "Display not found."; return false; } ecore_wl2_sync(); ecore_wl2_display_screen_size_get(ecore_wl2_display_, width, height); if (*width == 0 || *height == 0) { - FT_LOGE("Invalid screen size: %d x %d", *width, *height); + FT_LOG(Error) << "Invalid screen size: " << *width << " x " << *height; return false; } if (initial_geometry_.w > 0) { @@ -365,7 +356,7 @@ void TizenRendererEcoreWl2::ShutdownDisplay() { bool TizenRendererEcoreWl2::SetupEglSurface() { if (!ChooseEGLConfiguration()) { - FT_LOGE("ChooseEGLConfiguration fail"); + FT_LOG(Error) << "ChooseEGLConfiguration() failed."; return false; } @@ -388,7 +379,7 @@ bool TizenRendererEcoreWl2::SetupEglSurface() { egl_surface_ = eglCreateWindowSurface(egl_display_, egl_config_, GetEGLNativeWindowType(), ptr); if (egl_surface_ == EGL_NO_SURFACE) { - FT_LOGE("eglCreateWindowSurface failed"); + FT_LOG(Error) << "eglCreateWindowSurface() failed."; return false; } @@ -396,7 +387,7 @@ bool TizenRendererEcoreWl2::SetupEglSurface() { egl_resource_surface_ = eglCreatePbufferSurface(egl_display_, egl_config_, attribs); if (egl_resource_surface_ == EGL_NO_SURFACE) { - FT_LOGE("eglCreatePbufferSurface is Failed"); + FT_LOG(Error) << "eglCreatePbufferSurface() failed."; return false; } @@ -424,12 +415,11 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { int buffer_size = 32; egl_display_ = GetEGLDisplay(); if (EGL_NO_DISPLAY == egl_display_) { - FT_LOGE("EGL Get Display is failed"); + FT_LOG(Error) << "eglGetDisplay() failed."; return false; } if (!eglInitialize(egl_display_, &major, &minor)) { - FT_LOGE("EGL Intialize is Failed major [%d] minor [%d]", major, minor); PrintEGLError(); return false; } @@ -440,16 +430,15 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { } EGLint num_config = 0; - // Query all framebuffer configurations + // Query all framebuffer configurations. if (!eglGetConfigs(egl_display_, NULL, 0, &num_config)) { - FT_LOGE("eglGetConfigs is Failed!!"); PrintEGLError(); return false; } EGLConfig* configs = (EGLConfig*)calloc(num_config, sizeof(EGLConfig)); EGLint num; // Get the List of EGL framebuffer configuration matches with config_attribs - // in list "configs" + // in list "configs". if (!eglChooseConfig(egl_display_, config_attribs, configs, num_config, &num)) { free(configs); @@ -474,85 +463,28 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { void TizenRendererEcoreWl2::PrintEGLError() { EGLint error = eglGetError(); switch (error) { - case EGL_BAD_DISPLAY: { - FT_LOGE("EGL_BAD_DISPLAY : Display is not an EGL display connection"); - break; - } - case EGL_NOT_INITIALIZED: { - FT_LOGE("EGL_NOT_INITIALIZED : Display has not been initialized"); - break; - } - case EGL_BAD_SURFACE: { - FT_LOGE("EGL_BAD_SURFACE : Draw or read is not an EGL surface"); - break; - } - case EGL_BAD_CONTEXT: { - FT_LOGE("EGL_BAD_CONTEXT : Context is not an EGL rendering context"); - break; - } - case EGL_BAD_CONFIG: { - FT_LOGE( - "EGL_BAD_CONFIG : Config is not an EGL frame buffer configuration"); - break; - } - case EGL_BAD_MATCH: { - FT_LOGE( - "EGL_BAD_MATCH : Draw or read are not compatible with context, or if " - "context is set to EGL_NO_CONTEXT and draw or read are not set to " - "EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and " - "context is not set to EGL_NO_CONTEXT"); - break; - } - case EGL_BAD_ACCESS: { - FT_LOGE("EGL_BAD_ACCESS : Context is current to some other thread"); - break; - } - case EGL_BAD_NATIVE_PIXMAP: { - FT_LOGE( - "EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or " - "read is no longer valid"); - break; - } - case EGL_BAD_NATIVE_WINDOW: { - FT_LOGE( - "EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or " - "read is no longer valid"); - break; - } - case EGL_BAD_CURRENT_SURFACE: { - FT_LOGE( - "EGL_BAD_CURRENT_SURFACE : The previous context has unflushed " - "commands and the previous surface is no longer valid"); - break; - } - case EGL_BAD_ALLOC: { - FT_LOGE( - "EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read " - "were delayed until eglMakeCurrent is called, and there are not " - "enough resources to allocate them"); - break; - } - case EGL_CONTEXT_LOST: { - FT_LOGE( - "EGL_CONTEXT_LOST : A power management event has occurred. The " - "application must destroy all contexts and reinitialise OpenGL ES " - "state and objects to continue rendering"); - break; - } - case EGL_BAD_PARAMETER: { - FT_LOGE("Invalid parameter is passed"); - break; - } - case EGL_BAD_ATTRIBUTE: { - FT_LOGE( - "The parameter configAttribs contains an invalid frame buffer " - "configuration attribute or an attribute value that is unrecognized " - "or out of range"); - break; - } +#define CASE_PRINT(value) \ + case value: { \ + FT_LOG(Error) << #value; \ + break; \ + } + CASE_PRINT(EGL_NOT_INITIALIZED) + CASE_PRINT(EGL_BAD_ACCESS) + CASE_PRINT(EGL_BAD_ALLOC) + CASE_PRINT(EGL_BAD_ATTRIBUTE) + CASE_PRINT(EGL_BAD_CONTEXT) + CASE_PRINT(EGL_BAD_CONFIG) + CASE_PRINT(EGL_BAD_CURRENT_SURFACE) + CASE_PRINT(EGL_BAD_DISPLAY) + CASE_PRINT(EGL_BAD_SURFACE) + CASE_PRINT(EGL_BAD_MATCH) + CASE_PRINT(EGL_BAD_PARAMETER) + CASE_PRINT(EGL_BAD_NATIVE_PIXMAP) + CASE_PRINT(EGL_BAD_NATIVE_WINDOW) + CASE_PRINT(EGL_CONTEXT_LOST) +#undef CASE_PRINT default: { - FT_LOGE("Unknown error with code: %d", error); - break; + FT_LOG(Error) << "Unknown EGL error: " << error; } } } diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index b4416dcb1a565..fef2491eaa2fb 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -40,7 +40,6 @@ void TizenRendererEvasGL::ClearColor(float r, float g, float b, float a) { bool TizenRendererEvasGL::OnMakeCurrent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } if (evas_gl_make_current(evas_gl_, gl_surface_, gl_context_) != EINA_TRUE) { @@ -52,7 +51,6 @@ bool TizenRendererEvasGL::OnMakeCurrent() { bool TizenRendererEvasGL::OnClearCurrent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } if (evas_gl_make_current(evas_gl_, NULL, NULL) != EINA_TRUE) { @@ -63,7 +61,6 @@ bool TizenRendererEvasGL::OnClearCurrent() { bool TizenRendererEvasGL::OnMakeResourceCurrent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } if (evas_gl_make_current(evas_gl_, gl_resource_surface_, @@ -75,7 +72,6 @@ bool TizenRendererEvasGL::OnMakeResourceCurrent() { bool TizenRendererEvasGL::OnPresent() { if (!IsValid()) { - FT_LOGE("Invalid TizenRenderer"); return false; } @@ -89,7 +85,6 @@ bool TizenRendererEvasGL::OnPresent() { uint32_t TizenRendererEvasGL::OnGetFBO() { if (!is_valid_) { - FT_LOGE("Invalid TizenRenderer"); return 999; } return 0; @@ -546,7 +541,7 @@ void* TizenRendererEvasGL::OnProcResolver(const char* name) { GL_FUNC(glTexStorage3DMultisample) #undef GL_FUNC - FT_LOGW("Could not resolve: %s", name); + FT_LOG(Warn) << "Could not resolve: " << name; return nullptr; } @@ -580,7 +575,7 @@ Evas_Object* TizenRendererEvasGL::GetImageHandle() { bool TizenRendererEvasGL::InitializeRenderer() { if (!SetupEvasGL()) { - FT_LOGE("SetupEvasGL fail"); + FT_LOG(Error) << "SetupEvasGL() failed."; return false; } Show(); @@ -603,7 +598,7 @@ bool TizenRendererEvasGL::SetupEvasGL() { evas_gl_ = evas_gl_new(evas_object_evas_get(SetupEvasWindow(&width, &height))); if (!evas_gl_) { - FT_LOGE("Could not set up an Evas window object."); + FT_LOG(Error) << "Could not set up an Evas window object."; return false; } @@ -620,17 +615,15 @@ bool TizenRendererEvasGL::SetupEvasGL() { evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_3_X); #endif if (gl_context_ == nullptr) { - FT_LOGW( - "Failed to create evas gl context with EVAS_GL_GLES_3_X, try to use " - "EVAS_GL_GLES_2_X,"); + FT_LOG(Error) << "Failed to create an Evas GL context with " + "EVAS_GL_GLES_3_X; trying with EVAS_GL_GLES_2_X."; gl_context_ = evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_2_X); gl_resource_context_ = evas_gl_context_version_create(evas_gl_, gl_context_, EVAS_GL_GLES_2_X); } if (gl_context_ == nullptr) { - FT_LOGE("Failed to create evas gl context!"); - FT_RELEASE_ASSERT_NOT_REACHED(); + FT_LOG(Fatal) << "Failed to create an Evas GL context."; } EVAS_GL_GLOBAL_GLES3_USE(g_evas_gl, gl_context_); @@ -659,7 +652,7 @@ Evas_Object* TizenRendererEvasGL::SetupEvasWindow(int32_t* width, ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, width, height); if (*width == 0 || *height == 0) { - FT_LOGE("Invalid screen size: %d x %d", *width, *height); + FT_LOG(Error) << "Invalid screen size: " << *width << " x " << *height; return nullptr; } if (initial_geometry_.w > 0) { diff --git a/shell/platform/tizen/tizen_vsync_waiter.cc b/shell/platform/tizen/tizen_vsync_waiter.cc index f36d3189344ca..cdd49db064da9 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.cc +++ b/shell/platform/tizen/tizen_vsync_waiter.cc @@ -40,12 +40,12 @@ void TizenVsyncWaiter::AsyncWaitForVsync(intptr_t baton) { void TizenVsyncWaiter::Send(int event, intptr_t baton) { if (!vblank_thread_ || ecore_thread_check(vblank_thread_)) { - FT_LOGE("vblank thread not valid"); + FT_LOG(Error) << "Invalid vblank thread."; return; } if (!vblank_thread_queue_) { - FT_LOGE("vblank thread queue not valid"); + FT_LOG(Error) << "Invalid vblank thread queue."; return; } @@ -63,13 +63,13 @@ void TizenVsyncWaiter::RequestVblankLoop(void* data, Ecore_Thread* thread) { reinterpret_cast(data); TdmClient tdm_client(tizen_vsync_waiter->engine_); if (!tdm_client.IsValid()) { - FT_LOGE("Tdm client not valid"); + FT_LOG(Error) << "Invalid tdm_client."; ecore_thread_cancel(thread); return; } Eina_Thread_Queue* vblank_thread_queue = eina_thread_queue_new(); if (!vblank_thread_queue) { - FT_LOGE("Vblank thread queue is not valid"); + FT_LOG(Error) << "Invalid vblank thread queue."; ecore_thread_cancel(thread); return; } @@ -82,7 +82,7 @@ void TizenVsyncWaiter::RequestVblankLoop(void* data, Ecore_Thread* thread) { if (msg) { eina_thread_queue_wait_done(vblank_thread_queue, ref); } else { - FT_LOGE("Message is null"); + FT_LOG(Error) << "Received a null message."; continue; } if (msg->event == kMessageQuit) { @@ -96,9 +96,7 @@ void TizenVsyncWaiter::RequestVblankLoop(void* data, Ecore_Thread* thread) { } TdmClient::TdmClient(FlutterTizenEngine* engine) { - if (!CreateTdm()) { - FT_LOGE("Create tdm client failed"); - } + CreateTdm(); engine_ = engine; } @@ -110,7 +108,7 @@ void TdmClient::WaitVblank(intptr_t baton) { baton_ = baton; tdm_error error = tdm_client_vblank_wait(vblank_, 1, VblankCallback, this); if (error != TDM_ERROR_NONE) { - FT_LOGE("tdm client wait vblank error %d", error); + FT_LOG(Error) << "tdm_client_vblank_wait() failed."; return; } tdm_client_handle_events(client_); @@ -120,19 +118,19 @@ bool TdmClient::CreateTdm() { tdm_error ret; client_ = tdm_client_create(&ret); if (ret != TDM_ERROR_NONE && client_ != NULL) { - FT_LOGE("create client fail"); + FT_LOG(Error) << "Failed to create a TDM client."; return false; } output_ = tdm_client_get_output(client_, const_cast("default"), &ret); if (ret != TDM_ERROR_NONE && output_ != NULL) { - FT_LOGE("get output fail"); + FT_LOG(Error) << "Could not obtain the default client output."; return false; } vblank_ = tdm_client_output_create_vblank(output_, &ret); if (ret != TDM_ERROR_NONE && vblank_ != NULL) { - FT_LOGE("create vblank fail"); + FT_LOG(Error) << "Failed to create a vblank object"; return false; } From 7f5127dbacb68460ecfd55667f4ec24fb65005a3 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 13 Jul 2021 20:43:27 +0900 Subject: [PATCH 3/7] Rename tizen_log to logger --- shell/platform/tizen/BUILD.gn | 1 + shell/platform/tizen/channels/lifecycle_channel.cc | 2 +- shell/platform/tizen/channels/platform_channel.cc | 2 +- shell/platform/tizen/channels/platform_view_channel.cc | 2 +- shell/platform/tizen/channels/text_input_channel.cc | 2 +- shell/platform/tizen/external_texture_surface_gl.cc | 2 +- shell/platform/tizen/flutter_project_bundle.cc | 2 +- shell/platform/tizen/flutter_tizen.cc | 2 +- shell/platform/tizen/flutter_tizen_engine.cc | 2 +- shell/platform/tizen/flutter_tizen_texture_registrar.cc | 2 +- shell/platform/tizen/key_event_handler.cc | 2 +- shell/platform/tizen/{tizen_log.cc => logger.cc} | 2 +- shell/platform/tizen/{tizen_log.h => logger.h} | 2 +- shell/platform/tizen/tizen_renderer_ecore_wl2.cc | 2 +- shell/platform/tizen/tizen_renderer_evas_gl.cc | 2 +- shell/platform/tizen/tizen_vsync_waiter.cc | 2 +- shell/platform/tizen/touch_event_handler.cc | 2 +- 17 files changed, 17 insertions(+), 16 deletions(-) rename shell/platform/tizen/{tizen_log.cc => logger.cc} (99%) rename shell/platform/tizen/{tizen_log.h => logger.h} (96%) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index ad66c61ceebf0..3378b1e64a6e9 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -37,6 +37,7 @@ _flutter_tizen_source = [ "flutter_tizen_engine.cc", "flutter_tizen_texture_registrar.cc", "key_event_handler.cc", + "logger.cc", "tizen_event_loop.cc", "tizen_input_method_context.cc", "tizen_renderer.cc", diff --git a/shell/platform/tizen/channels/lifecycle_channel.cc b/shell/platform/tizen/channels/lifecycle_channel.cc index 13f0a43ce0e32..ed999041e04ad 100644 --- a/shell/platform/tizen/channels/lifecycle_channel.cc +++ b/shell/platform/tizen/channels/lifecycle_channel.cc @@ -5,7 +5,7 @@ #include "lifecycle_channel.h" #include "flutter/shell/platform/tizen/channels/string_codec.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index 5e20d2e005d3d..1bf2a11548bf8 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -10,7 +10,7 @@ #include #include "flutter/shell/platform/common/json_method_codec.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 7503a86a1eb3f..553d2e306db82 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -9,8 +9,8 @@ #include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h" #include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" -#include "flutter/shell/platform/tizen/tizen_log.h" namespace flutter { diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index e5c41c51eba03..e9eb6d83dbf6c 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -8,7 +8,7 @@ #include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/external_texture_surface_gl.cc b/shell/platform/tizen/external_texture_surface_gl.cc index 2f690d8607ea0..0f124a47810d5 100644 --- a/shell/platform/tizen/external_texture_surface_gl.cc +++ b/shell/platform/tizen/external_texture_surface_gl.cc @@ -20,7 +20,7 @@ EVAS_GL_GLOBAL_GLES3_DECLARE(); #include -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/flutter_project_bundle.cc b/shell/platform/tizen/flutter_project_bundle.cc index 39176910d2379..982217c381020 100644 --- a/shell/platform/tizen/flutter_project_bundle.cc +++ b/shell/platform/tizen/flutter_project_bundle.cc @@ -13,7 +13,7 @@ #include -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index afd74b8e4ffab..08f57c49127b2 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -10,8 +10,8 @@ #include "flutter/shell/platform/common/incoming_message_dispatcher.h" #include "flutter/shell/platform/tizen/flutter_project_bundle.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" +#include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" -#include "flutter/shell/platform/tizen/tizen_log.h" // Returns the engine corresponding to the given opaque API handle. static flutter::FlutterTizenEngine* EngineFromHandle( diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 54c322642e2b5..e1bc902ed6b6a 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -9,8 +9,8 @@ #include #include +#include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/system_utils.h" -#include "flutter/shell/platform/tizen/tizen_log.h" namespace flutter { diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar.cc b/shell/platform/tizen/flutter_tizen_texture_registrar.cc index 31a82050bae83..9cf5f5b36c54e 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar.cc +++ b/shell/platform/tizen/flutter_tizen_texture_registrar.cc @@ -10,7 +10,7 @@ #include "flutter/shell/platform/tizen/external_texture_pixel_gl.h" #include "flutter/shell/platform/tizen/external_texture_surface_gl.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/key_event_handler.cc b/shell/platform/tizen/key_event_handler.cc index e75acb764a4cd..cc9adfdcbfb1e 100644 --- a/shell/platform/tizen/key_event_handler.cc +++ b/shell/platform/tizen/key_event_handler.cc @@ -9,7 +9,7 @@ #endif #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/tizen_log.cc b/shell/platform/tizen/logger.cc similarity index 99% rename from shell/platform/tizen/tizen_log.cc rename to shell/platform/tizen/logger.cc index f6e607784819a..ddd44e0065c00 100644 --- a/shell/platform/tizen/tizen_log.cc +++ b/shell/platform/tizen/logger.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "tizen_log.h" +#include "logger.h" #ifndef __X64_SHELL__ #include diff --git a/shell/platform/tizen/tizen_log.h b/shell/platform/tizen/logger.h similarity index 96% rename from shell/platform/tizen/tizen_log.h rename to shell/platform/tizen/logger.h index 6bbfd9c7d141a..1bb27695dd578 100644 --- a/shell/platform/tizen/tizen_log.h +++ b/shell/platform/tizen/logger.h @@ -1,4 +1,4 @@ -// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. +// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 0d495bd4f8112..6873e3ba06a9e 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -7,7 +7,7 @@ #include #include -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index fef2491eaa2fb..fef794a6e51a9 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -12,7 +12,7 @@ Evas_GL* g_evas_gl = nullptr; EVAS_GL_GLOBAL_GLES3_DEFINE(); -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/tizen_vsync_waiter.cc b/shell/platform/tizen/tizen_vsync_waiter.cc index cdd49db064da9..8c1537d61ebbd 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.cc +++ b/shell/platform/tizen/tizen_vsync_waiter.cc @@ -7,7 +7,7 @@ #include #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" static const int kMessageQuit = -1; static const int kMessageRequestVblank = 0; diff --git a/shell/platform/tizen/touch_event_handler.cc b/shell/platform/tizen/touch_event_handler.cc index 8214ac1b94c32..2b077fbdfcc70 100644 --- a/shell/platform/tizen/touch_event_handler.cc +++ b/shell/platform/tizen/touch_event_handler.cc @@ -5,7 +5,7 @@ #include "touch_event_handler.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" static const int kScrollDirectionVertical = 0; static const int kScrollDirectionHorizontal = 1; From c7cfd4e453be7f6384f7a25a913deb5222064b24 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 13 Jul 2021 20:58:49 +0900 Subject: [PATCH 4/7] Misc fixes - Replace __FILE__ with __MODULE__. - Resolve unused variable warning: kLogTag. - Typo fix and etc. --- shell/platform/tizen/channels/platform_channel.cc | 2 +- .../tizen/flutter_tizen_texture_registrar.cc | 2 +- shell/platform/tizen/logger.cc | 13 ++++--------- shell/platform/tizen/logger.h | 15 ++++++++++----- shell/platform/tizen/tizen_renderer_ecore_wl2.cc | 8 ++++---- shell/platform/tizen/touch_event_handler.cc | 1 - 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index 1bf2a11548bf8..e22fbaa1748b6 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -99,7 +99,7 @@ class FeedbackManager { FeedbackManager& operator=(const FeedbackManager&) = delete; ResultCode Play(FeedbackType type, FeedbackPattern pattern) { - if (initialization_status_ != ResultCode::kOk) { + if (ResultCode::kOk != initialization_status_) { return initialization_status_; } diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar.cc b/shell/platform/tizen/flutter_tizen_texture_registrar.cc index 9cf5f5b36c54e..5eb15ef2e0eae 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar.cc +++ b/shell/platform/tizen/flutter_tizen_texture_registrar.cc @@ -35,7 +35,7 @@ int64_t FlutterTizenTextureRegistrar::RegisterTexture( if (texture_info->type == kFlutterDesktopGpuBufferTexture) { if (!texture_info->gpu_buffer_config.callback) { - FT_LOG(Error) << "Invalid gpu buffer texture callback."; + FT_LOG(Error) << "Invalid GPU buffer texture callback."; return -1; } } diff --git a/shell/platform/tizen/logger.cc b/shell/platform/tizen/logger.cc index ddd44e0065c00..d30482e3e06af 100644 --- a/shell/platform/tizen/logger.cc +++ b/shell/platform/tizen/logger.cc @@ -9,16 +9,11 @@ #endif #include +#include #include namespace flutter { -namespace { - -constexpr char kLogTag[] = "ConsoleMessage"; - -} // namespace - void* Logger::Redirect(void* arg) { int* pipe = static_cast(arg); ssize_t size; @@ -38,7 +33,7 @@ void* Logger::Redirect(void* arg) { void Logger::Start() { if (started_) { - FT_LOG(Info) << "The threads are already running."; + FT_LOG(Info) << "The threads have already started."; return; } if (pipe(stdout_pipe_) < 0 || pipe(stderr_pipe_) < 0) { @@ -91,9 +86,9 @@ void Logger::Print(int level, std::string message) { #ifdef TV_PROFILE // LOG_ID_MAIN must be used to display logs properly on TV devices. // Note: dlog_print(...) is an alias of __dlog_print(LOG_ID_APPS, ...). - __dlog_print(LOG_ID_MAIN, priority, kLogTag, "%s", message.c_str()); + __dlog_print(LOG_ID_MAIN, priority, "ConsoleMessage", "%s", message.c_str()); #else - dlog_print(priority, kLogTag, "%s", message.c_str()); + dlog_print(priority, "ConsoleMessage", "%s", message.c_str()); #endif #endif // __X64_SHELL__ } diff --git a/shell/platform/tizen/logger.h b/shell/platform/tizen/logger.h index 1bb27695dd578..288c983188d9c 100644 --- a/shell/platform/tizen/logger.h +++ b/shell/platform/tizen/logger.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EMBEDDER_TIZEN_LOG_H_ -#define EMBEDDER_TIZEN_LOG_H_ +#ifndef EMBEDDER_LOGGER_H_ +#define EMBEDDER_LOGGER_H_ #include @@ -61,8 +61,13 @@ class LogMessage { } // namespace flutter -#define FT_LOG(level) \ - flutter::LogMessage(flutter::kLogLevel##level, __FILE__, __func__, __LINE__) \ +#ifndef __MODULE__ +#define __MODULE__ strrchr("/" __FILE__, '/') + 1 +#endif + +#define FT_LOG(level) \ + flutter::LogMessage(flutter::kLogLevel##level, __MODULE__, __func__, \ + __LINE__) \ .stream() #if defined(NDEBUG) @@ -77,4 +82,4 @@ class LogMessage { #define FT_UNIMPLEMENTED() FT_LOG(Warn) << "UNIMPLEMENTED!" -#endif // EMBEDDER_TIZEN_LOG_H_ +#endif // EMBEDDER_LOGGER_H_ diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 6873e3ba06a9e..4fbc9d2315389 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -463,10 +463,10 @@ bool TizenRendererEcoreWl2::ChooseEGLConfiguration() { void TizenRendererEcoreWl2::PrintEGLError() { EGLint error = eglGetError(); switch (error) { -#define CASE_PRINT(value) \ - case value: { \ - FT_LOG(Error) << #value; \ - break; \ +#define CASE_PRINT(value) \ + case value: { \ + FT_LOG(Error) << "EGL error: " << #value; \ + break; \ } CASE_PRINT(EGL_NOT_INITIALIZED) CASE_PRINT(EGL_BAD_ACCESS) diff --git a/shell/platform/tizen/touch_event_handler.cc b/shell/platform/tizen/touch_event_handler.cc index 2b077fbdfcc70..98345554d34e1 100644 --- a/shell/platform/tizen/touch_event_handler.cc +++ b/shell/platform/tizen/touch_event_handler.cc @@ -5,7 +5,6 @@ #include "touch_event_handler.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/logger.h" static const int kScrollDirectionVertical = 0; static const int kScrollDirectionHorizontal = 1; From 1825692c7fa0a7ee7e9329a3850aeb44032376bf Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Thu, 15 Jul 2021 11:33:00 +0900 Subject: [PATCH 5/7] Change min logging level to Debug when --verbose-logging is set --- shell/platform/tizen/flutter_tizen_engine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index e1bc902ed6b6a..442ceda0a05a8 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -146,7 +146,7 @@ bool FlutterTizenEngine::RunEngine() { if (std::find(switches.begin(), switches.end(), "--verbose-logging") != switches.end()) { - Logger::SetLoggingLevel(kLogLevelInfo); + Logger::SetLoggingLevel(kLogLevelDebug); } // Configure task runners. From fb70196cd48389a04145311b8e55d35ab1e89ed5 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Fri, 16 Jul 2021 18:27:00 +0900 Subject: [PATCH 6/7] Resolve conflicts & additional clean-up --- .../tizen/external_texture_pixel_gl.cc | 2 +- .../tizen/external_texture_pixel_gl_stub.cc | 2 +- .../tizen/external_texture_surface_gl.cc | 3 +-- .../tizen/tizen_input_method_context.cc | 26 +++++++++---------- shell/platform/tizen/tizen_vsync_waiter.cc | 6 +++-- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/shell/platform/tizen/external_texture_pixel_gl.cc b/shell/platform/tizen/external_texture_pixel_gl.cc index 085a2f19e408d..7d3ab6b2c42c6 100644 --- a/shell/platform/tizen/external_texture_pixel_gl.cc +++ b/shell/platform/tizen/external_texture_pixel_gl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/tizen/external_texture_pixel_gl.h" +#include "external_texture_pixel_gl.h" #ifdef TIZEN_RENDERER_EVAS_GL #undef EFL_BETA_API_SUPPORT diff --git a/shell/platform/tizen/external_texture_pixel_gl_stub.cc b/shell/platform/tizen/external_texture_pixel_gl_stub.cc index f6a1ae0a1a5cc..e956879f13103 100644 --- a/shell/platform/tizen/external_texture_pixel_gl_stub.cc +++ b/shell/platform/tizen/external_texture_pixel_gl_stub.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/tizen/external_texture_pixel_gl.h" +#include "external_texture_pixel_gl.h" namespace flutter { diff --git a/shell/platform/tizen/external_texture_surface_gl.cc b/shell/platform/tizen/external_texture_surface_gl.cc index 0f124a47810d5..0bce628f77a38 100644 --- a/shell/platform/tizen/external_texture_surface_gl.cc +++ b/shell/platform/tizen/external_texture_surface_gl.cc @@ -4,8 +4,6 @@ #include "external_texture_surface_gl.h" -#include "flutter/shell/platform/common/public/flutter_texture_registrar.h" - #ifdef TIZEN_RENDERER_EVAS_GL #undef EFL_BETA_API_SUPPORT #include @@ -20,6 +18,7 @@ EVAS_GL_GLOBAL_GLES3_DECLARE(); #include +#include "flutter/shell/platform/common/public/flutter_texture_registrar.h" #include "flutter/shell/platform/tizen/logger.h" namespace flutter { diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index e476ca564ed47..8edd198599c3d 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "flutter/shell/platform/tizen/tizen_input_method_context.h" +#include "tizen_input_method_context.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace { @@ -44,10 +44,8 @@ bool TextInputTypeToEcoreIMFInputPanelLayout( *panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD; } else if (text_input_type == "TextInputType.name" || text_input_type == "TextInputType.address") { - FT_LOGW( - "Actual requested text input type is [%s], but select " - "TextInputType.text as fallback type", - text_input_type.c_str()); + FT_LOG(Warn) << "The requested input type " << text_input_type + << "is not supported."; *panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL; } else { return false; @@ -138,6 +136,7 @@ void InputPanelStateChangedCallback(void* data, self->OnInputPannelStateChanged(value); } + } // namespace namespace flutter { @@ -158,18 +157,17 @@ void TizenInputMethodContext::Init() { const char* imf_id = ecore_imf_context_default_id_get(); if (imf_id == nullptr) { - // Try to get fallback id + // Try to get a fallback ID. imf_id = GetEcoreImfContextAvailableID(); } - if (imf_id == nullptr) { - FT_LOGE("Failed to get imf context id"); + FT_LOG(Error) << "Failed to get an IMF context ID."; return; } imf_context_ = ecore_imf_context_add(imf_id); if (imf_context_ == nullptr) { - FT_LOGE("Failed to create Ecore_IMF_Context"); + FT_LOG(Error) << "Failed to create Ecore_IMF_Context."; return; } @@ -241,7 +239,7 @@ void TizenInputMethodContext::HideInputPannel() { void TizenInputMethodContext::OnCommit(std::string str) { if (!on_commit_callback_) { - FT_LOGW("Please, set OnCommitCallback"); + FT_LOG(Warn) << "SetOnCommitCallback() has not been called."; return; } on_commit_callback_(str); @@ -249,7 +247,7 @@ void TizenInputMethodContext::OnCommit(std::string str) { void TizenInputMethodContext::OnPreedit(std::string str, int cursor_pos) { if (!on_preedit_callback_) { - FT_LOGW("Please, set OnInputPannelStateChangedCallback"); + FT_LOG(Warn) << "SetOnPreeditCallback() has not been called."; return; } on_preedit_callback_(str, cursor_pos); @@ -257,7 +255,8 @@ void TizenInputMethodContext::OnPreedit(std::string str, int cursor_pos) { void TizenInputMethodContext::OnInputPannelStateChanged(int state) { if (!on_input_pannel_state_changed_callback_) { - FT_LOGW("Please, set OnPreeditCallback"); + FT_LOG(Warn) + << "SetOnInputPannelStateChangedCallback() has not been called."; return; } on_input_pannel_state_changed_callback_(state); @@ -310,4 +309,5 @@ void TizenInputMethodContext::SetInputPannelOptions() { ecore_imf_context_input_panel_language_set( imf_context_, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC); } + } // namespace flutter diff --git a/shell/platform/tizen/tizen_vsync_waiter.cc b/shell/platform/tizen/tizen_vsync_waiter.cc index 8c1537d61ebbd..c4e2c406f539e 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.cc +++ b/shell/platform/tizen/tizen_vsync_waiter.cc @@ -96,7 +96,9 @@ void TizenVsyncWaiter::RequestVblankLoop(void* data, Ecore_Thread* thread) { } TdmClient::TdmClient(FlutterTizenEngine* engine) { - CreateTdm(); + if (!CreateTdm()) { + FT_LOG(Error) << "CreateTdm() failed."; + } engine_ = engine; } @@ -130,7 +132,7 @@ bool TdmClient::CreateTdm() { vblank_ = tdm_client_output_create_vblank(output_, &ret); if (ret != TDM_ERROR_NONE && vblank_ != NULL) { - FT_LOG(Error) << "Failed to create a vblank object"; + FT_LOG(Error) << "Failed to create a vblank object."; return false; } From 18651b0ad6c7763bcf57f4236504f9ed76681b05 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 20 Jul 2021 20:04:49 +0900 Subject: [PATCH 7/7] Resolve conflicts again --- shell/platform/tizen/system_utils_tizen.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/tizen/system_utils_tizen.cc b/shell/platform/tizen/system_utils_tizen.cc index 75e6c226499b8..8627b6208128d 100644 --- a/shell/platform/tizen/system_utils_tizen.cc +++ b/shell/platform/tizen/system_utils_tizen.cc @@ -6,7 +6,7 @@ #include -#include "flutter/shell/platform/tizen/tizen_log.h" +#include "flutter/shell/platform/tizen/logger.h" namespace flutter { @@ -17,7 +17,7 @@ std::vector GetPreferredLanguageInfo() { i18n_ulocale_set_default(getenv("LANG")); int ret = i18n_ulocale_get_default(&locale); if (ret != I18N_ERROR_NONE) { - FT_LOGE("i18n_ulocale_get_default() failed."); + FT_LOG(Error) << "i18n_ulocale_get_default() failed."; return languages; } std::string preferred_locale(locale); @@ -60,7 +60,7 @@ std::vector GetPreferredLanguageInfo() { languages.push_back(info); } } - FT_LOGI("Found %zu locales.", languages.size()); + FT_LOG(Info) << "Found " << languages.size() << " locales."; return languages; }