From 5a1917ad173cd44fa2bd00e4f312950206eebb1a Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Wed, 23 Jun 2021 14:02:38 +0900 Subject: [PATCH] Use the flutter namespace (#121) * Remove engine dependency of LifecycleChannel * Minor formatting * Organize headers * Use the flutter namespace * Revert "Remove engine dependency of LifecycleChannel" This reverts commit a45473d57e3c40662630889f9f7d8ec47e63a76c. --- .../tizen/channels/key_event_channel.cc | 47 ++++---- .../tizen/channels/key_event_channel.h | 10 +- .../tizen/channels/lifecycle_channel.cc | 19 +++- .../tizen/channels/lifecycle_channel.h | 4 + .../tizen/channels/localization_channel.cc | 4 + .../tizen/channels/localization_channel.h | 4 + .../tizen/channels/navigation_channel.cc | 22 ++-- .../tizen/channels/navigation_channel.h | 13 ++- .../tizen/channels/platform_channel.cc | 106 +++++++++++------- .../tizen/channels/platform_channel.h | 34 +++--- .../tizen/channels/platform_view_channel.cc | 43 +++---- .../tizen/channels/platform_view_channel.h | 21 ++-- .../tizen/channels/settings_channel.cc | 32 ++++-- .../tizen/channels/settings_channel.h | 11 +- .../tizen/channels/text_input_channel.cc | 86 +++++++------- .../tizen/channels/text_input_channel.h | 23 ++-- shell/platform/tizen/external_texture.h | 4 + .../tizen/external_texture_pixel_gl.cc | 4 + .../tizen/external_texture_pixel_gl.h | 4 + .../tizen/external_texture_surface_gl.cc | 4 + .../tizen/external_texture_surface_gl.h | 4 + shell/platform/tizen/flutter_tizen.cc | 20 ++-- shell/platform/tizen/flutter_tizen_engine.cc | 8 +- shell/platform/tizen/flutter_tizen_engine.h | 12 +- .../tizen/flutter_tizen_texture_registrar.cc | 4 + .../tizen/flutter_tizen_texture_registrar.h | 4 + shell/platform/tizen/key_event_handler.cc | 4 + shell/platform/tizen/key_event_handler.h | 4 + shell/platform/tizen/tizen_event_loop.cc | 4 + shell/platform/tizen/tizen_event_loop.h | 4 + shell/platform/tizen/tizen_log.cc | 4 + shell/platform/tizen/tizen_log.h | 6 +- shell/platform/tizen/tizen_renderer.cc | 4 + shell/platform/tizen/tizen_renderer.h | 4 + .../tizen/tizen_renderer_ecore_wl2.cc | 4 + .../platform/tizen/tizen_renderer_ecore_wl2.h | 4 + .../platform/tizen/tizen_renderer_evas_gl.cc | 4 + shell/platform/tizen/tizen_renderer_evas_gl.h | 4 + shell/platform/tizen/tizen_vsync_waiter.cc | 14 ++- shell/platform/tizen/tizen_vsync_waiter.h | 4 + shell/platform/tizen/touch_event_handler.cc | 12 +- shell/platform/tizen/touch_event_handler.h | 4 + 42 files changed, 423 insertions(+), 208 deletions(-) diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index 18e9b3446bb95..6582d4bddf975 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -8,25 +8,29 @@ #include "flutter/shell/platform/tizen/tizen_log.h" -static constexpr char kChannelName[] = "flutter/keyevent"; +namespace flutter { -static constexpr char kKeyMapKey[] = "keymap"; -static constexpr char kKeyCodeKey[] = "keyCode"; -static constexpr char kScanCodeKey[] = "scanCode"; -static constexpr char kTypeKey[] = "type"; -static constexpr char kModifiersKey[] = "modifiers"; -static constexpr char kToolkitKey[] = "toolkit"; -static constexpr char kUnicodeScalarValuesKey[] = "unicodeScalarValues"; +namespace { -static constexpr char kKeyUp[] = "keyup"; -static constexpr char kKeyDown[] = "keydown"; -static constexpr char kGtkToolkit[] = "gtk"; -static constexpr char kLinuxKeyMap[] = "linux"; +constexpr char kChannelName[] = "flutter/keyevent"; + +constexpr char kKeyMapKey[] = "keymap"; +constexpr char kKeyCodeKey[] = "keyCode"; +constexpr char kScanCodeKey[] = "scanCode"; +constexpr char kTypeKey[] = "type"; +constexpr char kModifiersKey[] = "modifiers"; +constexpr char kToolkitKey[] = "toolkit"; +constexpr char kUnicodeScalarValuesKey[] = "unicodeScalarValues"; + +constexpr char kKeyUp[] = "keyup"; +constexpr char kKeyDown[] = "keydown"; +constexpr char kGtkToolkit[] = "gtk"; +constexpr char kLinuxKeyMap[] = "linux"; // Mapping from physical (xkb) to logical (GTK) key codes. // The values are defined in: // - flutter/keyboard_maps.dart (kLinuxToPhysicalKey, kGtkToLogicalKey) -static const std::map kKeyCodeMap = { +const std::map kKeyCodeMap = { {0x00000009, 65307}, // LogicalKeyboardKey.escape {0x0000000a, 49}, // LogicalKeyboardKey.digit1 {0x0000000b, 50}, // LogicalKeyboardKey.digit2 @@ -202,7 +206,7 @@ static const std::map kKeyCodeMap = { // The values are defined in: // - efl/Ecore_Input.h // - flutter/raw_keyboard_linux.dart (GtkKeyHelper) -static const std::map kModifierMap = { +const std::map kModifierMap = { {0x0001, 1 << 0}, // SHIFT (modifierShift) {0x0002, 1 << 2}, // CTRL (modifierControl) {0x0004, 1 << 3}, // ALT (modifierMod1) @@ -212,12 +216,13 @@ static const std::map kModifierMap = { {0x0040, 1 << 1}, // CAPS (modifierCapsLock) }; -KeyEventChannel::KeyEventChannel(flutter::BinaryMessenger* messenger) - : channel_( - std::make_unique>( - messenger, - kChannelName, - &flutter::JsonMessageCodec::GetInstance())) {} +} // namespace + +KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger) + : channel_(std::make_unique>( + messenger, + kChannelName, + &JsonMessageCodec::GetInstance())) {} KeyEventChannel::~KeyEventChannel() {} @@ -251,3 +256,5 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) { } channel_->Send(event); } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/key_event_channel.h b/shell/platform/tizen/channels/key_event_channel.h index 0fc30aa0be20a..833bc10646e0e 100644 --- a/shell/platform/tizen/channels/key_event_channel.h +++ b/shell/platform/tizen/channels/key_event_channel.h @@ -7,20 +7,26 @@ #include +#include + #include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/json_message_codec.h" #include "rapidjson/document.h" +namespace flutter { + class KeyEventChannel { public: - explicit KeyEventChannel(flutter::BinaryMessenger* messenger); + explicit KeyEventChannel(BinaryMessenger* messenger); virtual ~KeyEventChannel(); void SendKeyEvent(Ecore_Event_Key* key, bool is_down); private: - std::unique_ptr> channel_; + std::unique_ptr> channel_; }; +} // namespace flutter + #endif // EMBEDDER_KEY_EVENT_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/lifecycle_channel.cc b/shell/platform/tizen/channels/lifecycle_channel.cc index c873f7933ac4d..f3419be6362cd 100644 --- a/shell/platform/tizen/channels/lifecycle_channel.cc +++ b/shell/platform/tizen/channels/lifecycle_channel.cc @@ -7,11 +7,18 @@ #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/tizen_log.h" -static constexpr char kChannelName[] = "flutter/lifecycle"; -static constexpr char kInactive[] = "AppLifecycleState.inactive"; -static constexpr char kResumed[] = "AppLifecycleState.resumed"; -static constexpr char kPaused[] = "AppLifecycleState.paused"; -static constexpr char kDetached[] = "AppLifecycleState.detached"; +namespace flutter { + +namespace { + +constexpr char kChannelName[] = "flutter/lifecycle"; + +constexpr char kInactive[] = "AppLifecycleState.inactive"; +constexpr char kResumed[] = "AppLifecycleState.resumed"; +constexpr char kPaused[] = "AppLifecycleState.paused"; +constexpr char kDetached[] = "AppLifecycleState.detached"; + +} // namespace LifecycleChannel::LifecycleChannel(FlutterTizenEngine* engine) : engine_(engine) {} @@ -43,3 +50,5 @@ void LifecycleChannel::AppIsDetached() { FT_LOGI("send app lifecycle state detached."); SendLifecycleMessage(kDetached); } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/lifecycle_channel.h b/shell/platform/tizen/channels/lifecycle_channel.h index 43114bf6800b7..98301688e08e8 100644 --- a/shell/platform/tizen/channels/lifecycle_channel.h +++ b/shell/platform/tizen/channels/lifecycle_channel.h @@ -5,6 +5,8 @@ #ifndef EMBEDDER_LIFECYCLE_CHANNEL_H_ #define EMBEDDER_LIFECYCLE_CHANNEL_H_ +namespace flutter { + class FlutterTizenEngine; class LifecycleChannel { @@ -22,4 +24,6 @@ class LifecycleChannel { FlutterTizenEngine* engine_{nullptr}; }; +} // namespace flutter + #endif // EMBEDDER_LIFECYCLE_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/localization_channel.cc b/shell/platform/tizen/channels/localization_channel.cc index 48b788ebf59eb..e86d904a96fff 100644 --- a/shell/platform/tizen/channels/localization_channel.cc +++ b/shell/platform/tizen/channels/localization_channel.cc @@ -14,6 +14,8 @@ static constexpr char kChannelName[] = "flutter/localization"; +namespace flutter { + LocalizationChannel::LocalizationChannel(FlutterTizenEngine* engine) : engine_(engine) {} @@ -197,3 +199,5 @@ void LocalizationChannel::DestroyFlutterLocale(FlutterLocale* flutter_locale) { flutter_locale = nullptr; } } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/localization_channel.h b/shell/platform/tizen/channels/localization_channel.h index 87e8adcc60425..a5743a4cd3da4 100644 --- a/shell/platform/tizen/channels/localization_channel.h +++ b/shell/platform/tizen/channels/localization_channel.h @@ -7,6 +7,8 @@ #include "flutter/shell/platform/embedder/embedder.h" +namespace flutter { + class FlutterTizenEngine; class LocalizationChannel { @@ -24,4 +26,6 @@ class LocalizationChannel { FlutterTizenEngine* engine_; }; +} // namespace flutter + #endif // EMBEDDER_LOCALIZATION_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/navigation_channel.cc b/shell/platform/tizen/channels/navigation_channel.cc index a58b09218027f..849a7f0c990f4 100644 --- a/shell/platform/tizen/channels/navigation_channel.cc +++ b/shell/platform/tizen/channels/navigation_channel.cc @@ -6,17 +6,23 @@ #include "flutter/shell/platform/common/json_method_codec.h" -static constexpr char kChannelName[] = "flutter/navigation"; +namespace flutter { -static constexpr char kSetInitialRouteMethod[] = "setInitialRoute"; -static constexpr char kPushRouteMethod[] = "pushRoute"; -static constexpr char kPopRouteMethod[] = "popRoute"; +namespace { -NavigationChannel::NavigationChannel(flutter::BinaryMessenger* messenger) - : channel_(std::make_unique>( +constexpr char kChannelName[] = "flutter/navigation"; + +constexpr char kSetInitialRouteMethod[] = "setInitialRoute"; +constexpr char kPushRouteMethod[] = "pushRoute"; +constexpr char kPopRouteMethod[] = "popRoute"; + +} // namespace + +NavigationChannel::NavigationChannel(BinaryMessenger* messenger) + : channel_(std::make_unique>( messenger, kChannelName, - &flutter::JsonMethodCodec::GetInstance())) {} + &JsonMethodCodec::GetInstance())) {} NavigationChannel::~NavigationChannel() {} @@ -41,3 +47,5 @@ void NavigationChannel::PushRoute(const std::string& route) { void NavigationChannel::PopRoute() { channel_->InvokeMethod(kPopRouteMethod, nullptr); } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/navigation_channel.h b/shell/platform/tizen/channels/navigation_channel.h index f198abbf411c7..ac22dd2a2e047 100644 --- a/shell/platform/tizen/channels/navigation_channel.h +++ b/shell/platform/tizen/channels/navigation_channel.h @@ -5,13 +5,18 @@ #ifndef EMBEDDER_NAVIGATION_CHANNEL_H_ #define EMBEDDER_NAVIGATION_CHANNEL_H_ +#include +#include + #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" #include "rapidjson/document.h" +namespace flutter { + class NavigationChannel { public: - explicit NavigationChannel(flutter::BinaryMessenger* messenger); + explicit NavigationChannel(BinaryMessenger* messenger); virtual ~NavigationChannel(); void SetInitialRoute(const std::string& initialRoute); @@ -19,7 +24,9 @@ class NavigationChannel { void PopRoute(); private: - std::unique_ptr> channel_; + std::unique_ptr> channel_; }; -#endif // EMBEDDER_NAVIGATION_CHANNEL_H_ +} // namespace flutter + +#endif // EMBEDDER_NAVIGATION_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index 096982cb7a624..ed1c6a76455d1 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -12,27 +12,30 @@ #include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/tizen/tizen_log.h" -static constexpr char kChannelName[] = "flutter/platform"; - -PlatformChannel::PlatformChannel(flutter::BinaryMessenger* messenger, - TizenRenderer* renderer) - : channel_(std::make_unique>( - messenger, - kChannelName, - &flutter::JsonMethodCodec::GetInstance())), - renderer_(renderer) { - channel_->SetMethodCallHandler( - [this]( - const flutter::MethodCall& call, - std::unique_ptr> result) { - HandleMethodCall(call, std::move(result)); - }); -} - -PlatformChannel::~PlatformChannel() {} +namespace flutter { namespace { +constexpr char kChannelName[] = "flutter/platform"; + +constexpr char kGetClipboardDataMethod[] = "Clipboard.getData"; +constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; +constexpr char kPlaySoundMethod[] = "SystemSound.play"; +constexpr char kHapticFeedbackVibrateMethod[] = "HapticFeedback.vibrate"; +constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; +constexpr char kSetPreferredOrientationsMethod[] = + "SystemChrome.setPreferredOrientations"; +constexpr char kSetApplicationSwitcherDescriptionMethod[] = + "SystemChrome.setApplicationSwitcherDescription"; +constexpr char kSetEnabledSystemUIOverlaysMethod[] = + "SystemChrome.setEnabledSystemUIOverlays"; +constexpr char kRestoreSystemUIOverlaysMethod[] = + "SystemChrome.restoreSystemUIOverlays"; +constexpr char kSetSystemUIOverlayStyleMethod[] = + "SystemChrome.setSystemUIOverlayStyle"; + +constexpr char kSoundTypeClick[] = "SystemSoundType.click"; + class FeedbackManager { public: enum class ResultCode { @@ -157,21 +160,37 @@ class FeedbackManager { ResultCode initialization_status_ = ResultCode::kUnknownError; }; -} // namespace +} // namespace + +PlatformChannel::PlatformChannel(BinaryMessenger* messenger, + TizenRenderer* renderer) + : channel_(std::make_unique>( + messenger, + kChannelName, + &JsonMethodCodec::GetInstance())), + renderer_(renderer) { + channel_->SetMethodCallHandler( + [this](const MethodCall& call, + std::unique_ptr> result) { + HandleMethodCall(call, std::move(result)); + }); +} + +PlatformChannel::~PlatformChannel() {} void PlatformChannel::HandleMethodCall( - const flutter::MethodCall& call, - std::unique_ptr> result) { + const MethodCall& call, + std::unique_ptr> result) { const auto method = call.method_name(); - if (method == "SystemNavigator.pop") { + if (method == kSystemNavigatorPopMethod) { ui_app_exit(); result->Success(); - } else if (method == "SystemSound.play") { + } else if (method == kPlaySoundMethod) { const std::string pattern_str = call.arguments()[0].GetString(); const FeedbackManager::FeedbackPattern pattern = - (pattern_str == "SystemSoundType.click") + (pattern_str == kSoundTypeClick) ? FeedbackManager::FeedbackPattern::kClick : FeedbackManager::FeedbackPattern::kAlert; @@ -183,13 +202,13 @@ void PlatformChannel::HandleMethodCall( } const auto error_cause = - FeedbackManager::GetErrorMessage(ret, "SystemSound.play", pattern_str); + 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()); result->Error(error_cause, error_message); - } else if (method == "HapticFeedback.vibrate") { + } else if (method == kHapticFeedbackVibrateMethod) { /* * We use a single type of vibration (FEEDBACK_PATTERN_SIP) to implement * HapticFeedback's vibrate, lightImpact, mediumImpact, heavyImpact @@ -216,11 +235,11 @@ void PlatformChannel::HandleMethodCall( FT_LOGE("%s: %s", error_cause.c_str(), error_message.c_str()); result->Error(error_cause, error_message); - } else if (method == "Clipboard.getData") { - Clipboard::GetData(call, std::move(result)); - } else if (method == "Clipboard.setData") { - Clipboard::SetData(call, std::move(result)); - } else if (method == "SystemChrome.setPreferredOrientations") { + } else if (method == kGetClipboardDataMethod) { + clipboard::GetData(call, std::move(result)); + } else if (method == kSetClipboardDataMethod) { + clipboard::SetData(call, std::move(result)); + } else if (method == kSetPreferredOrientationsMethod) { if (renderer_) { static const std::string kPortraitUp = "DeviceOrientation.portraitUp"; static const std::string kPortraitDown = "DeviceOrientation.portraitDown"; @@ -254,13 +273,13 @@ void PlatformChannel::HandleMethodCall( } else { result->Error("Not supported for service applications"); } - } else if (method == "SystemChrome.setApplicationSwitcherDescription") { + } else if (method == kSetApplicationSwitcherDescriptionMethod) { result->NotImplemented(); - } else if (method == "SystemChrome.setEnabledSystemUIOverlays") { + } else if (method == kSetEnabledSystemUIOverlaysMethod) { result->NotImplemented(); - } else if (method == "SystemChrome.restoreSystemUIOverlays") { + } else if (method == kRestoreSystemUIOverlaysMethod) { result->NotImplemented(); - } else if (method == "SystemChrome.setSystemUIOverlayStyle") { + } else if (method == kSetSystemUIOverlayStyleMethod) { result->NotImplemented(); } else { FT_LOGI("Unimplemented method: %s", method.c_str()); @@ -269,7 +288,7 @@ void PlatformChannel::HandleMethodCall( } // Clipboard constants and variables -namespace Clipboard { +namespace clipboard { // naive implementation using std::string as a container of internal clipboard // data @@ -282,9 +301,8 @@ static constexpr char kUnknownClipboardFormatError[] = static constexpr char kUnknownClipboardError[] = "Unknown error during clipboard data retrieval"; -void GetData( - const flutter::MethodCall& call, - std::unique_ptr> result) { +void GetData(const MethodCall& call, + std::unique_ptr> result) { const rapidjson::Value& format = call.arguments()[0]; // https://api.flutter.dev/flutter/services/Clipboard/kTextPlain-constant.html @@ -303,9 +321,8 @@ void GetData( result->Success(document); } -void SetData( - const flutter::MethodCall& call, - std::unique_ptr> result) { +void SetData(const MethodCall& call, + std::unique_ptr> result) { const rapidjson::Value& document = *call.arguments(); rapidjson::Value::ConstMemberIterator itr = document.FindMember(kTextKey); if (itr == document.MemberEnd()) { @@ -315,4 +332,7 @@ void SetData( string_clipboard = itr->value.GetString(); result->Success(); } -} // namespace Clipboard + +} // namespace clipboard + +} // namespace flutter diff --git a/shell/platform/tizen/channels/platform_channel.h b/shell/platform/tizen/channels/platform_channel.h index b4d13fe574e1d..f773c1fa86ea3 100644 --- a/shell/platform/tizen/channels/platform_channel.h +++ b/shell/platform/tizen/channels/platform_channel.h @@ -5,36 +5,42 @@ #ifndef EMBEDDER_PLATFORM_CHANNEL_H_ #define EMBEDDER_PLATFORM_CHANNEL_H_ +#include + #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" #include "flutter/shell/platform/tizen/tizen_renderer.h" #include "rapidjson/document.h" +namespace flutter { + class PlatformChannel { public: - explicit PlatformChannel(flutter::BinaryMessenger* messenger, - TizenRenderer* renderer); + explicit PlatformChannel(BinaryMessenger* messenger, TizenRenderer* renderer); virtual ~PlatformChannel(); private: void HandleMethodCall( - const flutter::MethodCall& call, - std::unique_ptr> result); + const MethodCall& call, + std::unique_ptr> result); - std::unique_ptr> channel_; + std::unique_ptr> channel_; // A reference to the renderer object managed by FlutterTizenEngine. // This can be nullptr if the engine is running in headless mode. TizenRenderer* renderer_; }; -namespace Clipboard { -void GetData( - const flutter::MethodCall& call, - std::unique_ptr> result); -void SetData( - const flutter::MethodCall& call, - std::unique_ptr> result); -}; // namespace Clipboard +namespace clipboard { + +void GetData(const MethodCall& call, + std::unique_ptr> result); + +void SetData(const MethodCall& call, + std::unique_ptr> result); + +} // namespace clipboard + +} // namespace flutter -#endif // EMBEDDER_PLATFORM_CHANNEL_H_ +#endif // EMBEDDER_PLATFORM_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index aea59f60fe374..bf016fe1f54c7 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -1,6 +1,7 @@ // Copyright 2020 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 "platform_view_channel.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h" @@ -14,12 +15,14 @@ static constexpr char kChannelName[] = "flutter/platform_views"; +namespace flutter { + template -bool GetValueFromEncodableMap(const flutter::EncodableValue& arguments, +bool GetValueFromEncodableMap(const EncodableValue& arguments, std::string key, T* out) { - if (auto pmap = std::get_if(&arguments)) { - auto iter = pmap->find(flutter::EncodableValue(key)); + if (auto pmap = std::get_if(&arguments)) { + auto iter = pmap->find(EncodableValue(key)); if (iter != pmap->end() && !iter->second.IsNull()) { if (auto pval = std::get_if(&iter->second)) { *out = *pval; @@ -30,18 +33,18 @@ bool GetValueFromEncodableMap(const flutter::EncodableValue& arguments, return false; } -PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger, +PlatformViewChannel::PlatformViewChannel(BinaryMessenger* messenger, FlutterTizenEngine* engine) : engine_(engine), - channel_( - std::make_unique>( - messenger, - kChannelName, - &flutter::StandardMethodCodec::GetInstance())) { + channel_(std::make_unique>( + messenger, + kChannelName, + &StandardMethodCodec::GetInstance())) { channel_->SetMethodCallHandler( - [this](const flutter::MethodCall& call, - std::unique_ptr> - result) { HandleMethodCall(call, std::move(result)); }); + [this](const MethodCall& call, + std::unique_ptr> result) { + HandleMethodCall(call, std::move(result)); + }); } PlatformViewChannel::~PlatformViewChannel() { @@ -101,8 +104,8 @@ int PlatformViewChannel::CurrentFocusedViewId() { } void PlatformViewChannel::HandleMethodCall( - const flutter::MethodCall& call, - std::unique_ptr> result) { + const MethodCall& call, + std::unique_ptr> result) { const auto method = call.method_name(); const auto& arguments = *call.arguments(); @@ -122,8 +125,8 @@ void PlatformViewChannel::HandleMethodCall( "PlatformViewChannel create viewType: %s id: %d width: %f height: %f ", view_type.c_str(), view_id, width, height); - flutter::EncodableMap values = std::get(arguments); - flutter::EncodableValue value = values[flutter::EncodableValue("params")]; + EncodableMap values = std::get(arguments); + EncodableValue value = values[EncodableValue("params")]; ByteMessage byte_message; if (std::holds_alternative(value)) { byte_message = std::get(value); @@ -146,7 +149,7 @@ void PlatformViewChannel::HandleMethodCall( engine_->text_input_channel->GetImfContext(); view_instance->SetSoftwareKeyboardContext(context); } - result->Success(flutter::EncodableValue(view_instance->GetTextureId())); + result->Success(EncodableValue(view_instance->GetTextureId())); } else { result->Error("Can't create a webview instance!!"); } @@ -192,7 +195,7 @@ void PlatformViewChannel::HandleMethodCall( int type = 0, button = 0; double x = 0.0, y = 0.0, dx = 0.0, dy = 0.0; - flutter::EncodableList event; + EncodableList event; if (!GetValueFromEncodableMap(arguments, "event", &event) || event.size() != 6) { result->Error("Invalid Arguments"); @@ -216,7 +219,7 @@ void PlatformViewChannel::HandleMethodCall( it->second->SetFocus(true); if (channel_ != nullptr) { - auto id = std::make_unique(view_id); + auto id = std::make_unique(view_id); channel_->InvokeMethod("viewFocused", std::move(id)); } } @@ -234,3 +237,5 @@ void PlatformViewChannel::HandleMethodCall( } } } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/platform_view_channel.h b/shell/platform/tizen/channels/platform_view_channel.h index e0eb9fe4b3863..9d939fdc9338e 100644 --- a/shell/platform/tizen/channels/platform_view_channel.h +++ b/shell/platform/tizen/channels/platform_view_channel.h @@ -8,17 +8,23 @@ #include #include +#include +#include #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" #include "rapidjson/document.h" -class FlutterTizenEngine; class PlatformView; class PlatformViewFactory; + +namespace flutter { + +class FlutterTizenEngine; + class PlatformViewChannel { public: - explicit PlatformViewChannel(flutter::BinaryMessenger* messenger, + explicit PlatformViewChannel(BinaryMessenger* messenger, FlutterTizenEngine* engine); virtual ~PlatformViewChannel(); @@ -36,14 +42,15 @@ class PlatformViewChannel { void DispatchCompositionEndEvent(const std::string& key); private: - void HandleMethodCall( - const flutter::MethodCall& call, - std::unique_ptr> result); + void HandleMethodCall(const MethodCall& call, + std::unique_ptr> result); FlutterTizenEngine* engine_; - std::unique_ptr> channel_; + std::unique_ptr> channel_; std::map> view_factories_; std::map view_instances_; }; -#endif // EMBEDDER_PLATFORM_VIEW_CHANNEL_H_ +} // namespace flutter + +#endif // EMBEDDER_PLATFORM_VIEW_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/settings_channel.cc b/shell/platform/tizen/channels/settings_channel.cc index 92c0044e99e31..54daa65c248a1 100644 --- a/shell/platform/tizen/channels/settings_channel.cc +++ b/shell/platform/tizen/channels/settings_channel.cc @@ -4,17 +4,25 @@ #include "settings_channel.h" -static constexpr char kChannelName[] = "flutter/settings"; -static constexpr char kTextScaleFactorKey[] = "textScaleFactor"; -static constexpr char kAlwaysUse24HourFormatKey[] = "alwaysUse24HourFormat"; -static constexpr char kPlatformBrightnessKey[] = "platformBrightness"; - -SettingsChannel::SettingsChannel(flutter::BinaryMessenger* messenger) - : channel_( - std::make_unique>( - messenger, - kChannelName, - &flutter::JsonMessageCodec::GetInstance())) { +#include "flutter/shell/platform/common/json_message_codec.h" + +namespace flutter { + +namespace { + +constexpr char kChannelName[] = "flutter/settings"; + +constexpr char kTextScaleFactorKey[] = "textScaleFactor"; +constexpr char kAlwaysUse24HourFormatKey[] = "alwaysUse24HourFormat"; +constexpr char kPlatformBrightnessKey[] = "platformBrightness"; + +} // namespace + +SettingsChannel::SettingsChannel(BinaryMessenger* messenger) + : channel_(std::make_unique>( + messenger, + kChannelName, + &JsonMessageCodec::GetInstance())) { system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, OnSettingsChangedCallback, this); SendSettingsEvent(); @@ -44,3 +52,5 @@ void SettingsChannel::OnSettingsChangedCallback(system_settings_key_e key, auto settings_channel = reinterpret_cast(user_data); settings_channel->SendSettingsEvent(); } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/settings_channel.h b/shell/platform/tizen/channels/settings_channel.h index 66956028e3c74..db7af4b5dae4e 100644 --- a/shell/platform/tizen/channels/settings_channel.h +++ b/shell/platform/tizen/channels/settings_channel.h @@ -7,14 +7,17 @@ #include +#include + #include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" -#include "flutter/shell/platform/common/json_message_codec.h" #include "rapidjson/document.h" +namespace flutter { + class SettingsChannel { public: - explicit SettingsChannel(flutter::BinaryMessenger* messenger); + explicit SettingsChannel(BinaryMessenger* messenger); virtual ~SettingsChannel(); private: @@ -22,7 +25,9 @@ class SettingsChannel { void* user_data); void SendSettingsEvent(); - std::unique_ptr> channel_; + std::unique_ptr> channel_; }; +} // namespace flutter + #endif // EMBEDDER_SETTINGS_CHANNEL_H_ diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index a62df152c2549..2761d633e9b53 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -7,35 +7,41 @@ #include #include +#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" -static constexpr char kSetEditingStateMethod[] = "TextInput.setEditingState"; -static constexpr char kClearClientMethod[] = "TextInput.clearClient"; -static constexpr char kSetClientMethod[] = "TextInput.setClient"; -static constexpr char kShowMethod[] = "TextInput.show"; -static constexpr char kHideMethod[] = "TextInput.hide"; -static constexpr char kMultilineInputType[] = "TextInputType.multiline"; -static constexpr char kUpdateEditingStateMethod[] = +namespace flutter { + +namespace { + +constexpr char kChannelName[] = "flutter/textinput"; + +constexpr char kSetEditingStateMethod[] = "TextInput.setEditingState"; +constexpr char kClearClientMethod[] = "TextInput.clearClient"; +constexpr char kSetClientMethod[] = "TextInput.setClient"; +constexpr char kShowMethod[] = "TextInput.show"; +constexpr char kHideMethod[] = "TextInput.hide"; +constexpr char kMultilineInputType[] = "TextInputType.multiline"; +constexpr char kUpdateEditingStateMethod[] = "TextInputClient.updateEditingState"; -static constexpr char kPerformActionMethod[] = "TextInputClient.performAction"; -static constexpr char kSetPlatformViewClient[] = - "TextInput.setPlatformViewClient"; -static constexpr char kTextInputAction[] = "inputAction"; -static constexpr char kTextInputType[] = "inputType"; -static constexpr char kTextInputTypeName[] = "name"; -static constexpr char kComposingBaseKey[] = "composingBase"; -static constexpr char kComposingExtentKey[] = "composingExtent"; -static constexpr char kSelectionAffinityKey[] = "selectionAffinity"; -static constexpr char kAffinityDownstream[] = "TextAffinity.downstream"; -static constexpr char kSelectionBaseKey[] = "selectionBase"; -static constexpr char kSelectionExtentKey[] = "selectionExtent"; -static constexpr char kSelectionIsDirectionalKey[] = "selectionIsDirectional"; -static constexpr char kTextKey[] = "text"; -static constexpr char kChannelName[] = "flutter/textinput"; -static constexpr char kBadArgumentError[] = "Bad Arguments"; -static constexpr char kInternalConsistencyError[] = - "Internal Consistency Error"; +constexpr char kPerformActionMethod[] = "TextInputClient.performAction"; +constexpr char kSetPlatformViewClient[] = "TextInput.setPlatformViewClient"; +constexpr char kTextInputAction[] = "inputAction"; +constexpr char kTextInputType[] = "inputType"; +constexpr char kTextInputTypeName[] = "name"; +constexpr char kComposingBaseKey[] = "composingBase"; +constexpr char kComposingExtentKey[] = "composingExtent"; +constexpr char kSelectionAffinityKey[] = "selectionAffinity"; +constexpr char kAffinityDownstream[] = "TextAffinity.downstream"; +constexpr char kSelectionBaseKey[] = "selectionBase"; +constexpr char kSelectionExtentKey[] = "selectionExtent"; +constexpr char kSelectionIsDirectionalKey[] = "selectionIsDirectional"; +constexpr char kTextKey[] = "text"; +constexpr char kBadArgumentError[] = "Bad Arguments"; +constexpr char kInternalConsistencyError[] = "Internal Consistency Error"; + +} // namespace static const char* GetImfMethod() { Eina_List* modules; @@ -239,17 +245,16 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( return static_cast(lock); } -TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger, +TextInputChannel::TextInputChannel(BinaryMessenger* messenger, FlutterTizenEngine* engine) - : channel_(std::make_unique>( + : channel_(std::make_unique>( messenger, kChannelName, - &flutter::JsonMethodCodec::GetInstance())), + &JsonMethodCodec::GetInstance())), engine_(engine) { channel_->SetMethodCallHandler( - [this]( - const flutter::MethodCall& call, - std::unique_ptr> result) { + [this](const MethodCall& call, + std::unique_ptr> result) { HandleMethodCall(call, std::move(result)); }); @@ -285,8 +290,8 @@ void TextInputChannel::OnKeyDown(Ecore_Event_Key* key) { } void TextInputChannel::HandleMethodCall( - const flutter::MethodCall& method_call, - std::unique_ptr> result) { + const MethodCall& method_call, + std::unique_ptr> result) { const std::string& method = method_call.method_name(); FT_LOGI("Handle Method : %s", method.data()); @@ -336,7 +341,7 @@ void TextInputChannel::HandleMethodCall( input_type_ = input_type_json->value.GetString(); } } - active_model_ = std::make_unique(); + active_model_ = std::make_unique(); } else if (method.compare(kSetEditingStateMethod) == 0) { if (!method_call.arguments() || method_call.arguments()->IsNull()) { result->Error(kBadArgumentError, "Method invoked without args"); @@ -366,8 +371,8 @@ void TextInputChannel::HandleMethodCall( return; } active_model_->SetText(text->value.GetString()); - active_model_->SetSelection(flutter::TextRange( - selection_base->value.GetInt(), selection_extent->value.GetInt())); + active_model_->SetSelection(TextRange(selection_base->value.GetInt(), + selection_extent->value.GetInt())); } else { result->NotImplemented(); return; @@ -377,12 +382,12 @@ void TextInputChannel::HandleMethodCall( result->Success(); } -void TextInputChannel::SendStateUpdate(const flutter::TextInputModel& model) { +void TextInputChannel::SendStateUpdate(const TextInputModel& model) { auto args = std::make_unique(rapidjson::kArrayType); auto& allocator = args->GetAllocator(); args->PushBack(client_id_, allocator); - flutter::TextRange selection = model.selection(); + TextRange selection = model.selection(); rapidjson::Value editing_state(rapidjson::kObjectType); editing_state.AddMember(kComposingBaseKey, -1, allocator); editing_state.AddMember(kComposingExtentKey, -1, allocator); @@ -533,8 +538,7 @@ void TextInputChannel::NonIMFFallback(Ecore_Event_Key* keyDownEvent) { SetEditStatus(EditStatus::kNone); } -void TextInputChannel::EnterPressed(flutter::TextInputModel* model, - bool select) { +void TextInputChannel::EnterPressed(TextInputModel* model, bool select) { if (!select && input_type_ == kMultilineInputType) { model->AddCodePoint('\n'); SendStateUpdate(*model); @@ -707,3 +711,5 @@ void TextInputChannel::ResetCurrentContext() { preedit_end_pos_ = 0; have_preedit_ = false; } + +} // namespace flutter diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 7a0b2d99e7604..a362956d6416d 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -9,14 +9,19 @@ #include #include +#include +#include #include #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" -#include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/common/text_input_model.h" +#include "rapidjson/document.h" + +namespace flutter { class FlutterTizenEngine; + class TextInputChannel { public: struct SoftwareKeyboardGeometry { @@ -25,7 +30,7 @@ class TextInputChannel { enum EditStatus { kNone, kPreeditStart, kPreeditEnd, kCommit }; - explicit TextInputChannel(flutter::BinaryMessenger* messenger, + explicit TextInputChannel(BinaryMessenger* messenger, FlutterTizenEngine* engine); virtual ~TextInputChannel(); @@ -50,19 +55,19 @@ class TextInputChannel { private: void HandleMethodCall( - const flutter::MethodCall& method_call, - std::unique_ptr> result); - void SendStateUpdate(const flutter::TextInputModel& model); + const MethodCall& method_call, + std::unique_ptr> result); + void SendStateUpdate(const TextInputModel& model); bool FilterEvent(Ecore_Event_Key* keyDownEvent); void NonIMFFallback(Ecore_Event_Key* keyDownEvent); - void EnterPressed(flutter::TextInputModel* model, bool select); + void EnterPressed(TextInputModel* model, bool select); void RegisterIMFCallback(); void UnregisterIMFCallback(); void ConsumeLastPreedit(); void ResetCurrentContext(); - std::unique_ptr> channel_; - std::unique_ptr active_model_; + std::unique_ptr> channel_; + std::unique_ptr active_model_; static void CommitCallback(void* data, Ecore_IMF_Context* ctx, @@ -103,4 +108,6 @@ class TextInputChannel { Ecore_IMF_Context* imf_context_{nullptr}; }; +} // namespace flutter + #endif // EMBEDDER_TEXT_INPUT_CHANNEL_H_ diff --git a/shell/platform/tizen/external_texture.h b/shell/platform/tizen/external_texture.h index d9d4b209b0fa3..de5e416a3fa36 100644 --- a/shell/platform/tizen/external_texture.h +++ b/shell/platform/tizen/external_texture.h @@ -17,6 +17,8 @@ #include #endif +namespace flutter { + struct ExternalTextureGLState { GLuint gl_texture; }; @@ -46,4 +48,6 @@ class ExternalTexture : public std::enable_shared_from_this { const long texture_id_{0}; }; +} // namespace flutter + #endif // EMBEDDER_EXTERNAL_TEXTURE_H_ diff --git a/shell/platform/tizen/external_texture_pixel_gl.cc b/shell/platform/tizen/external_texture_pixel_gl.cc index 3ec90031d966d..846bdb0737422 100644 --- a/shell/platform/tizen/external_texture_pixel_gl.cc +++ b/shell/platform/tizen/external_texture_pixel_gl.cc @@ -16,6 +16,8 @@ EVAS_GL_GLOBAL_GLES3_DECLARE(); #include #endif +namespace flutter { + bool ExternalTexturePixelGL::PopulateTexture( size_t width, size_t height, @@ -68,3 +70,5 @@ bool ExternalTexturePixelGL::CopyPixelBuffer(size_t& width, size_t& height) { pixel_buffer->buffer); return true; } + +} // namespace flutter diff --git a/shell/platform/tizen/external_texture_pixel_gl.h b/shell/platform/tizen/external_texture_pixel_gl.h index 119144fb165be..f1c5180f847f1 100644 --- a/shell/platform/tizen/external_texture_pixel_gl.h +++ b/shell/platform/tizen/external_texture_pixel_gl.h @@ -11,6 +11,8 @@ #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/tizen/external_texture.h" +namespace flutter { + // An adaptation class of flutter engine and external texture interface. class ExternalTexturePixelGL : public ExternalTexture { public: @@ -31,4 +33,6 @@ class ExternalTexturePixelGL : public ExternalTexture { void* user_data_ = nullptr; }; +} // namespace flutter + #endif // EMBEDDER_EXTERNAL_TEXTURE_PIXEL_GL_H diff --git a/shell/platform/tizen/external_texture_surface_gl.cc b/shell/platform/tizen/external_texture_surface_gl.cc index 809d918237646..cba8bdf277eac 100644 --- a/shell/platform/tizen/external_texture_surface_gl.cc +++ b/shell/platform/tizen/external_texture_surface_gl.cc @@ -22,6 +22,8 @@ EVAS_GL_GLOBAL_GLES3_DECLARE(); #include "flutter/shell/platform/tizen/tizen_log.h" +namespace flutter { + static void OnCollectTexture(void* textureGL) { auto* weak_texture = reinterpret_cast*>(textureGL); @@ -153,3 +155,5 @@ bool ExternalTextureSurfaceGL::PopulateTexture( void ExternalTextureSurfaceGL::OnDestruction() { destruction_callback_(user_data_); } + +} // namespace flutter diff --git a/shell/platform/tizen/external_texture_surface_gl.h b/shell/platform/tizen/external_texture_surface_gl.h index 552b245ed39ac..7efd5e6b905b4 100644 --- a/shell/platform/tizen/external_texture_surface_gl.h +++ b/shell/platform/tizen/external_texture_surface_gl.h @@ -9,6 +9,8 @@ #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/tizen/external_texture.h" +namespace flutter { + // An adaptation class of flutter engine and external texture interface. class ExternalTextureSurfaceGL : public ExternalTexture { public: @@ -38,4 +40,6 @@ class ExternalTextureSurfaceGL : public ExternalTexture { void* user_data_ = nullptr; }; +} // namespace flutter + #endif // EMBEDDER_EXTERNAL_TEXTURE_SURFACE_GL_H_ diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 6c83d9f446b50..b588eef534d33 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -5,8 +5,6 @@ #include "public/flutter_tizen.h" -#include - #include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h" #include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h" #include "flutter/shell/platform/common/incoming_message_dispatcher.h" @@ -15,21 +13,23 @@ #include "flutter/shell/platform/tizen/tizen_log.h" // Returns the engine corresponding to the given opaque API handle. -static FlutterTizenEngine* EngineFromHandle(FlutterDesktopEngineRef ref) { - return reinterpret_cast(ref); +static flutter::FlutterTizenEngine* EngineFromHandle( + FlutterDesktopEngineRef ref) { + return reinterpret_cast(ref); } // Returns the opaque API handle for the given engine instance. -static FlutterDesktopEngineRef HandleForEngine(FlutterTizenEngine* engine) { +static FlutterDesktopEngineRef HandleForEngine( + flutter::FlutterTizenEngine* engine) { return reinterpret_cast(engine); } FlutterDesktopEngineRef FlutterDesktopRunEngine( const FlutterDesktopEngineProperties& engine_properties, bool headed) { - StartLogging(); + flutter::StartLogging(); - auto engine = std::make_unique(headed); + auto engine = std::make_unique(headed); if (!engine->RunEngine(engine_properties)) { FT_LOGE("Failed to run the Flutter engine."); return nullptr; @@ -142,14 +142,14 @@ void FlutterRegisterViewFactory( } // Returns the texture registrar corresponding to the given opaque API handle. -static FlutterTizenTextureRegistrar* TextureRegistrarFromHandle( +static flutter::FlutterTizenTextureRegistrar* TextureRegistrarFromHandle( FlutterDesktopTextureRegistrarRef ref) { - return reinterpret_cast(ref); + return reinterpret_cast(ref); } // Returns the opaque API handle for the given texture registrar instance. static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar( - FlutterTizenTextureRegistrar* registrar) { + flutter::FlutterTizenTextureRegistrar* registrar) { return reinterpret_cast(registrar); } diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index 3bdf84ad10727..309182e1461ab 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -19,6 +19,8 @@ static constexpr size_t kPlatformTaskRunnerIdentifier = 1; static constexpr size_t kRenderTaskRunnerIdentifier = 2; #endif +namespace flutter { + static DeviceProfile GetDeviceProfile() { char* feature_profile; system_info_get_platform_string("http://tizen.org/feature/profile", @@ -57,7 +59,7 @@ FlutterTizenEngine::FlutterTizenEngine(bool headed) messenger = std::make_unique(); messenger->engine = this; message_dispatcher = - std::make_unique(messenger.get()); + std::make_unique(messenger.get()); plugin_registrar_ = std::make_unique(); plugin_registrar_->engine = this; @@ -226,7 +228,7 @@ bool FlutterTizenEngine::RunEngine( } internal_plugin_registrar_ = - std::make_unique(plugin_registrar_.get()); + std::make_unique(plugin_registrar_.get()); platform_channel = std::make_unique( internal_plugin_registrar_->messenger(), renderer.get()); @@ -497,3 +499,5 @@ FlutterRendererConfig FlutterTizenEngine::GetRendererConfig() { } return config; } + +} // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_engine.h b/shell/platform/tizen/flutter_tizen_engine.h index 1b9935806d52b..1ccdd63ac66a7 100644 --- a/shell/platform/tizen/flutter_tizen_engine.h +++ b/shell/platform/tizen/flutter_tizen_engine.h @@ -36,15 +36,17 @@ // State associated with the plugin registrar. struct FlutterDesktopPluginRegistrar { // The engine that owns this state object. - FlutterTizenEngine* engine; + flutter::FlutterTizenEngine* engine = nullptr; }; // State associated with the messenger used to communicate with the engine. struct FlutterDesktopMessenger { // The engine that owns this state object. - FlutterTizenEngine* engine = nullptr; + flutter::FlutterTizenEngine* engine = nullptr; }; +namespace flutter { + // Custom deleter for FlutterEngineAOTData. struct AOTDataDeleter { void operator()(FlutterEngineAOTData aot_data) { @@ -123,7 +125,7 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { std::unique_ptr messenger; // Message dispatch manager for messages from the Flutter engine. - std::unique_ptr message_dispatcher; + std::unique_ptr message_dispatcher; // The interface between the Flutter rasterizer and the platform. std::unique_ptr renderer; @@ -168,7 +170,7 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { plugin_registrar_destruction_callback_{nullptr}; // The plugin registrar managing internal plugins. - std::unique_ptr internal_plugin_registrar_; + std::unique_ptr internal_plugin_registrar_; // The event loop for the main thread that allows for delayed task execution. std::unique_ptr event_loop_; @@ -189,4 +191,6 @@ class FlutterTizenEngine : public TizenRenderer::Delegate { FlutterTransformation transformation_; }; +} // namespace flutter + #endif // EMBEDDER_FLUTTER_TIZEN_ENGINE_H_ diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar.cc b/shell/platform/tizen/flutter_tizen_texture_registrar.cc index a53b4d3a33644..c7620ed0465f2 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar.cc +++ b/shell/platform/tizen/flutter_tizen_texture_registrar.cc @@ -12,6 +12,8 @@ #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/tizen_log.h" +namespace flutter { + FlutterTizenTextureRegistrar::FlutterTizenTextureRegistrar( FlutterTizenEngine* engine) : engine_(engine) {} @@ -103,3 +105,5 @@ FlutterTizenTextureRegistrar::CreateExternalTexture( return nullptr; } } + +} // namespace flutter diff --git a/shell/platform/tizen/flutter_tizen_texture_registrar.h b/shell/platform/tizen/flutter_tizen_texture_registrar.h index f2b6d048107a4..b7d8ba4790988 100644 --- a/shell/platform/tizen/flutter_tizen_texture_registrar.h +++ b/shell/platform/tizen/flutter_tizen_texture_registrar.h @@ -11,6 +11,8 @@ #include "flutter/shell/platform/tizen/external_texture.h" +namespace flutter { + class FlutterTizenEngine; // An object managing the registration of an external texture. @@ -50,4 +52,6 @@ class FlutterTizenTextureRegistrar { std::mutex map_mutex_; }; +} // namespace flutter + #endif // EMBEDDER_FLUTTER_TIZEN_TEXTURE_REGISTRAR_H_ diff --git a/shell/platform/tizen/key_event_handler.cc b/shell/platform/tizen/key_event_handler.cc index 5c0b6d75a73c7..8a79213820495 100644 --- a/shell/platform/tizen/key_event_handler.cc +++ b/shell/platform/tizen/key_event_handler.cc @@ -8,6 +8,8 @@ static constexpr char kPlatformBackButtonName[] = "XF86Back"; +namespace flutter { + KeyEventHandler::KeyEventHandler(FlutterTizenEngine* engine) : engine_(engine) { key_event_handlers_.push_back( ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, OnKey, this)); @@ -48,3 +50,5 @@ Eina_Bool KeyEventHandler::OnKey(void* data, int type, void* event) { } return ECORE_CALLBACK_PASS_ON; } + +} // namespace flutter diff --git a/shell/platform/tizen/key_event_handler.h b/shell/platform/tizen/key_event_handler.h index 15f7a11bc7b78..07ce8b8615770 100644 --- a/shell/platform/tizen/key_event_handler.h +++ b/shell/platform/tizen/key_event_handler.h @@ -9,6 +9,8 @@ #include +namespace flutter { + class FlutterTizenEngine; class KeyEventHandler { @@ -23,4 +25,6 @@ class KeyEventHandler { static Eina_Bool OnKey(void* data, int type, void* event); }; +} // namespace flutter + #endif // EMBEDDER_KEY_EVENT_HANDLER_H_ diff --git a/shell/platform/tizen/tizen_event_loop.cc b/shell/platform/tizen/tizen_event_loop.cc index a82938804c3b6..33c150b135ae2 100644 --- a/shell/platform/tizen/tizen_event_loop.cc +++ b/shell/platform/tizen/tizen_event_loop.cc @@ -12,6 +12,8 @@ #include "flutter/shell/platform/tizen/tizen_renderer_evas_gl.h" #endif +namespace flutter { + TizenEventLoop::TizenEventLoop(std::thread::id main_thread_id, TaskExpiredCallback on_task_expired) : main_thread_id_(main_thread_id), @@ -149,3 +151,5 @@ void TizenRenderEventLoop::OnTaskExpired() { } } #endif + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_event_loop.h b/shell/platform/tizen/tizen_event_loop.h index 31f213d464010..e275e3bcf940a 100644 --- a/shell/platform/tizen/tizen_event_loop.h +++ b/shell/platform/tizen/tizen_event_loop.h @@ -19,6 +19,8 @@ #include "flutter/shell/platform/embedder/embedder.h" +namespace flutter { + class TizenRenderer; class TizenEventLoop { @@ -99,4 +101,6 @@ class TizenRenderEventLoop : public TizenEventLoop { }; #endif +} // namespace flutter + #endif // EMBEDDER_TIZEN_EVENT_LOOP_H_ diff --git a/shell/platform/tizen/tizen_log.cc b/shell/platform/tizen/tizen_log.cc index ea6fe2eefc36d..17a2dcf146e5f 100644 --- a/shell/platform/tizen/tizen_log.cc +++ b/shell/platform/tizen/tizen_log.cc @@ -14,6 +14,8 @@ static pthread_t stderr_thread; static bool is_running = false; static log_priority min_log_priority = DLOG_ERROR; +namespace flutter { + void SetMinLoggingLevel(log_priority p) { min_log_priority = p; }; @@ -68,3 +70,5 @@ void StartLogging() { } is_running = true; } + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_log.h b/shell/platform/tizen/tizen_log.h index b47d54846d256..f529f36f56052 100644 --- a/shell/platform/tizen/tizen_log.h +++ b/shell/platform/tizen/tizen_log.h @@ -10,6 +10,8 @@ #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(); @@ -37,7 +39,7 @@ log_priority GetMinLoggingLevel(); #define __FT_LOG(prio, fmt, args...) \ do { \ - if (prio >= GetMinLoggingLevel()) { \ + if (prio >= flutter::GetMinLoggingLevel()) { \ __LOG(prio, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, \ ##args); \ } \ @@ -82,4 +84,6 @@ log_priority GetMinLoggingLevel(); #define FT_UNIMPLEMENTED() FT_LOGW("UNIMPLEMENTED!") +} // namespace flutter + #endif // EMBEDDER_TIZEN_LOG_H_ diff --git a/shell/platform/tizen/tizen_renderer.cc b/shell/platform/tizen/tizen_renderer.cc index 5c47b9c5a9ea8..e792904793b15 100644 --- a/shell/platform/tizen/tizen_renderer.cc +++ b/shell/platform/tizen/tizen_renderer.cc @@ -4,7 +4,11 @@ #include "tizen_renderer.h" +namespace flutter { + TizenRenderer::TizenRenderer(TizenRenderer::Delegate& delegate) : delegate_(delegate) {} TizenRenderer::~TizenRenderer() = default; + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 0cf6cf702bd1d..9d5dfadcd4ecd 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -8,6 +8,8 @@ #include #include +namespace flutter { + class TizenRenderer { public: struct TizenWindowGeometry { @@ -51,4 +53,6 @@ class TizenRenderer { TizenRenderer::Delegate& delegate_; }; +} // namespace flutter + #endif // EMBEDDER_TIZEN_RENDERER_H_ diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc index 858bdee95350c..8b5b45f93e193 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.cc @@ -9,6 +9,8 @@ #include "flutter/shell/platform/tizen/tizen_log.h" +namespace flutter { + TizenRendererEcoreWl2::TizenRendererEcoreWl2(TizenRenderer::Delegate& delegate) : TizenRenderer(delegate) { InitializeRenderer(); @@ -594,3 +596,5 @@ void TizenRendererEcoreWl2::SetPreferredOrientations( ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations.data(), rotations.size()); } + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer_ecore_wl2.h b/shell/platform/tizen/tizen_renderer_ecore_wl2.h index 1aec0ae534d01..42027bbb7d107 100644 --- a/shell/platform/tizen/tizen_renderer_ecore_wl2.h +++ b/shell/platform/tizen/tizen_renderer_ecore_wl2.h @@ -11,6 +11,8 @@ #include "flutter/shell/platform/tizen/tizen_renderer.h" +namespace flutter { + class TizenRendererEcoreWl2 : public TizenRenderer { public: explicit TizenRendererEcoreWl2(TizenRenderer::Delegate& delegate); @@ -69,4 +71,6 @@ class TizenRendererEcoreWl2 : public TizenRenderer { EGLSurface egl_resource_surface_ = EGL_NO_SURFACE; }; +} // namespace flutter + #endif // EMBEDDER_TIZEN_RENDERER_ECORE_WL2_H_ diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 2eeea02ea4e51..5dfa505a8a4cc 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -10,6 +10,8 @@ EVAS_GL_GLOBAL_GLES3_DEFINE(); #include "flutter/shell/platform/tizen/tizen_log.h" +namespace flutter { + TizenRendererEvasGL::TizenRendererEvasGL(TizenRenderer::Delegate& delegate) : TizenRenderer(delegate) { InitializeRenderer(); @@ -720,3 +722,5 @@ void TizenRendererEvasGL::SetPreferredOrientations( evas_window_, static_cast(rotations.data()), rotations.size()); } + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index 988fde77498a6..1eb0e8b15bf44 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -12,6 +12,8 @@ #include "flutter/shell/platform/tizen/tizen_renderer.h" +namespace flutter { + class TizenRendererEvasGL : public TizenRenderer { public: explicit TizenRendererEvasGL(TizenRenderer::Delegate& delegate); @@ -66,4 +68,6 @@ class TizenRendererEvasGL : public TizenRenderer { Evas_GL_Surface* gl_resource_surface_{nullptr}; }; +} // namespace flutter + #endif // EMBEDDER_TIZEN_RENDERER_EVAS_GL_H_ diff --git a/shell/platform/tizen/tizen_vsync_waiter.cc b/shell/platform/tizen/tizen_vsync_waiter.cc index 4a71fa8f378ec..a916233324c0e 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.cc +++ b/shell/platform/tizen/tizen_vsync_waiter.cc @@ -9,8 +9,10 @@ #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/tizen_log.h" -static const int QUEUE_QUIT = -1; -static const int QUEUE_REQUEST_VBLANK = 0; +static const int kMessageQuit = -1; +static const int kMessageRequestVblank = 0; + +namespace flutter { typedef struct { Eina_Thread_Queue_Msg head; @@ -33,7 +35,7 @@ TizenVsyncWaiter::TizenVsyncWaiter(FlutterTizenEngine* engine) } TizenVsyncWaiter::~TizenVsyncWaiter() { - SendMessage(QUEUE_QUIT); + SendMessage(kMessageQuit); if (vblank_thread_) { ecore_thread_cancel(vblank_thread_); vblank_thread_ = nullptr; @@ -44,7 +46,7 @@ TizenVsyncWaiter::~TizenVsyncWaiter() { void TizenVsyncWaiter::AsyncWaitForVsync(intptr_t baton) { baton_ = baton; if (TDMValid()) { - SendMessage(QUEUE_REQUEST_VBLANK); + SendMessage(kMessageRequestVblank); } } @@ -78,7 +80,7 @@ void TizenVsyncWaiter::RequestVblankLoop(void* data, Ecore_Thread* thread) { FT_LOGE("Message is null"); continue; } - if (msg->value == QUEUE_QUIT) { + if (msg->value == kMessageQuit) { return; } if (!tizen_vsync_waiter->TDMValid()) { @@ -159,3 +161,5 @@ void TizenVsyncWaiter::TdmClientVblankCallback(tdm_client_vblank* vblank, frame_start_time_nanos, frame_target_time_nanos); } + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_vsync_waiter.h b/shell/platform/tizen/tizen_vsync_waiter.h index b9fd0f160dae3..4dc97d066f8dc 100644 --- a/shell/platform/tizen/tizen_vsync_waiter.h +++ b/shell/platform/tizen/tizen_vsync_waiter.h @@ -10,6 +10,8 @@ #include "flutter/shell/platform/embedder/embedder.h" +namespace flutter { + class FlutterTizenEngine; class TizenVsyncWaiter { @@ -39,4 +41,6 @@ class TizenVsyncWaiter { Ecore_Thread* vblank_thread_{nullptr}; }; +} // namespace flutter + #endif // EMBEDDER_TIZEN_VSYNC_WAITER_H_ diff --git a/shell/platform/tizen/touch_event_handler.cc b/shell/platform/tizen/touch_event_handler.cc index 2bea5f6684f5b..ac8a6baf8b9f5 100644 --- a/shell/platform/tizen/touch_event_handler.cc +++ b/shell/platform/tizen/touch_event_handler.cc @@ -7,8 +7,10 @@ #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/tizen_log.h" -static const int DIRECTION_VERTICAL = 0; -static const int DIRECTION_HORIZONTAL = 1; +static const int kScrollDirectionVertical = 0; +static const int kScrollDirectionHorizontal = 1; + +namespace flutter { TouchEventHandler::TouchEventHandler(FlutterTizenEngine* engine) : engine_(engine) { @@ -94,9 +96,9 @@ Eina_Bool TouchEventHandler::OnTouch(void* data, int type, void* event) { } else if (type == ECORE_EVENT_MOUSE_WHEEL) { auto* wheel_event = reinterpret_cast(event); double scroll_delta_x = 0.0, scroll_delta_y = 0.0; - if (wheel_event->direction == DIRECTION_VERTICAL) { + if (wheel_event->direction == kScrollDirectionVertical) { scroll_delta_y += wheel_event->z; - } else if (wheel_event->direction == DIRECTION_HORIZONTAL) { + } else if (wheel_event->direction == kScrollDirectionHorizontal) { scroll_delta_x += wheel_event->z; } const int kScrollOffsetMultiplier = 20; @@ -108,3 +110,5 @@ Eina_Bool TouchEventHandler::OnTouch(void* data, int type, void* event) { } return ECORE_CALLBACK_PASS_ON; } + +} // namespace flutter diff --git a/shell/platform/tizen/touch_event_handler.h b/shell/platform/tizen/touch_event_handler.h index d6adcf77c7d05..e5f764af86e9a 100644 --- a/shell/platform/tizen/touch_event_handler.h +++ b/shell/platform/tizen/touch_event_handler.h @@ -11,6 +11,8 @@ #include "flutter/shell/platform/embedder/embedder.h" +namespace flutter { + class FlutterTizenEngine; class TouchEventHandler { @@ -36,4 +38,6 @@ class TouchEventHandler { static Eina_Bool OnTouch(void* data, int type, void* event); }; +} // namespace flutter + #endif // EMBEDDER_TOUCH_EVENT_HANDLER_H_