From: Seungho, Baek Date: Fri, 4 Jan 2019 02:31:19 +0000 (+0900) Subject: Color Controller implementation X-Git-Tag: dali_1.4.4~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F196723%2F10;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Color Controller implementation - color-controller-plugin.h - color-controller-impl.cpp Change-Id: Ieba2b1a8c0f0133630ddb2e09f7f1b408c106f91 Signed-off-by: Seungho, Baek --- diff --git a/dali/devel-api/adaptor-framework/color-controller-plugin.h b/dali/devel-api/adaptor-framework/color-controller-plugin.h new file mode 100755 index 0000000..2d761dc --- /dev/null +++ b/dali/devel-api/adaptor-framework/color-controller-plugin.h @@ -0,0 +1,68 @@ +#ifndef DALI_COLOR_CONTROLLER_PLUGIN_H +#define DALI_COLOR_CONTROLLER_PLUGIN_H + +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ + +/** + * @brief ColorControllerPlugin is an abstract interface, used by dali-adaptor to access Color Controller plugin. + * A concrete implementation must be created for each platform and provided as dynamic library. + */ +class ColorControllerPlugin +{ +public: + + /** + * @brief Constructor. + */ + ColorControllerPlugin(){} + + /** + * @brief Destructor. + */ + virtual ~ColorControllerPlugin(){} + + /** + * @brief Retrieve the RGBA value by given the color code. + * + * @param[in] colorCode The color code string. + * @param[out] colorValue The RGBA color + * @return true if the color code exists, otherwise false + */ + virtual bool RetrieveColor( const std::string& colorCode, Vector4& colorValue ) const = 0; + + /** + * @brief Retrieve the RGBA value by given the color code. + * + * @param[in] colorCode The color code string. + * @param[out] textColor The text color. + * @param[out] textOutlineColor The text outline color. + * @param[out] textShadowColor The text shadow color. + * @return true if the color code exists, otherwise false + */ + virtual bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor ) const = 0; +}; + +} // namespace Dali; + +#endif // DALI_COLOR_CONTROLLER_PLUGIN_H diff --git a/dali/devel-api/adaptor-framework/color-controller.h b/dali/devel-api/adaptor-framework/color-controller.h index aa43e30..bc067a9 100755 --- a/dali/devel-api/adaptor-framework/color-controller.h +++ b/dali/devel-api/adaptor-framework/color-controller.h @@ -1,8 +1,8 @@ -#ifndef __DALI_COLOR_CONTROLLER_H__ -#define __DALI_COLOR_CONTROLLER_H__ +#ifndef DALI_COLOR_CONTROLLER_H +#define DALI_COLOR_CONTROLLER_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ namespace Adaptor { class ColorController; } + } /** @@ -82,7 +83,7 @@ public: ~ColorController(); /** - * @brief Retrieve the RGB value by given the color code. + * @brief Retrieve the RGBA value by given the color code. * * @param[in] colorCode The color code string. * @param[out] colorValue The RGBA color @@ -91,7 +92,7 @@ public: bool RetrieveColor( const std::string& colorCode, Vector4& colorValue ); /** - * @brief Retrieve the RGB values by given the color code. + * @brief Retrieve the RGBA values by given the color code. * * @param[in] colorCode The color code string. * @param[out] textColor The text color. @@ -113,4 +114,4 @@ public: // Not intended for application developers } //namespace Dali -#endif /* __DALI_COLOR_CONTROLLER_H__ */ +#endif // DALI_COLOR_CONTROLLER_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 5a29f71..9e05c21 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -44,6 +44,7 @@ devel_api_adaptor_framework_header_files = \ $(adaptor_devel_api_dir)/adaptor-framework/bitmap-saver.h \ $(adaptor_devel_api_dir)/adaptor-framework/clipboard-event-notifier.h \ $(adaptor_devel_api_dir)/adaptor-framework/clipboard.h \ + $(adaptor_devel_api_dir)/adaptor-framework/color-controller-plugin.h \ $(adaptor_devel_api_dir)/adaptor-framework/color-controller.h \ $(adaptor_devel_api_dir)/adaptor-framework/drag-and-drop-detector.h \ $(adaptor_devel_api_dir)/adaptor-framework/environment-variable.h \ diff --git a/dali/internal/system/tizen-wayland/color-controller-impl-tizen.cpp b/dali/internal/system/common/color-controller-impl.cpp similarity index 60% rename from dali/internal/system/tizen-wayland/color-controller-impl-tizen.cpp rename to dali/internal/system/common/color-controller-impl.cpp index f39ef1f..c0e8874 100644 --- a/dali/internal/system/tizen-wayland/color-controller-impl-tizen.cpp +++ b/dali/internal/system/common/color-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include #include #include @@ -34,6 +35,11 @@ namespace Internal namespace Adaptor { +namespace // unnamed namespace +{ +const char* COLOR_CONTROLLER_PLUGIN_SO( "libdali-color-controller-plugin.so" ); +} + Dali::ColorController ColorController::Get() { Dali::ColorController colorController; @@ -56,24 +62,64 @@ Dali::ColorController ColorController::Get() } return colorController; - } ColorController::ColorController() +: mLibHandle( NULL ), + mPlugin( NULL ), + mCreateColorControllerPtr( NULL ) { + Initialize(); } ColorController::~ColorController() { } +void ColorController::Initialize() +{ + mLibHandle = dlopen( COLOR_CONTROLLER_PLUGIN_SO, RTLD_LAZY ); + + char* error = dlerror(); + if( mLibHandle == NULL || error != NULL ) + { + DALI_LOG_ERROR( "ColorController::Initialize: dlopen error [%s]\n", error ); + return; + } + + // load plugin + mCreateColorControllerPtr = reinterpret_cast< CreateColorControllerFunction >( dlsym( mLibHandle, "CreateColorControllerPlugin" ) ); + + error = dlerror(); + if( mCreateColorControllerPtr == NULL || error != NULL ) + { + DALI_LOG_ERROR( "ColorController::Initialize: Cannot load symbol CreateColorControllerPlugin(): %s\n", error ); + return; + } + + mPlugin = mCreateColorControllerPtr(); + if( !mPlugin ) + { + DALI_LOG_ERROR("ColorController::Initialize: Plugin creation failed\n"); + return; + } +} + bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue ) { + if( mPlugin ) + { + return mPlugin->RetrieveColor( colorCode, colorValue ); + } return false; } bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor) { + if( mPlugin ) + { + return mPlugin->RetrieveColor( colorCode, textColor, textOutlineColor, textShadowColor ); + } return false; } diff --git a/dali/internal/system/common/color-controller-impl.h b/dali/internal/system/common/color-controller-impl.h index 972f5e9..58de395 100644 --- a/dali/internal/system/common/color-controller-impl.h +++ b/dali/internal/system/common/color-controller-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_COLOR_CONTROLLER_H__ -#define __DALI_INTERNAL_COLOR_CONTROLLER_H__ +#ifndef DALI_INTERNAL_COLOR_CONTROLLER_H +#define DALI_INTERNAL_COLOR_CONTROLLER_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -56,16 +57,32 @@ public: bool RetrieveColor( const std::string& colorCode, Vector4& colorValue ); /** - *copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&, Vector4&, Vector4&) + * @copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&, Vector4&, Vector4&) */ bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor); +private: + + /** + * @brief Initialize + */ + void Initialize(); + protected: /** - * Destructor. + * @brief Destructor. */ virtual ~ColorController(); +private: + + using CreateColorControllerFunction = Dali::ColorControllerPlugin* (*)(); + + void* mLibHandle; ///< Handle for the loaded library + Dali::ColorControllerPlugin* mPlugin; ///< Plugin handle + + CreateColorControllerFunction mCreateColorControllerPtr; ///< Function pointer called in adaptor to create a plugin instance + }; } // namespace Adaptor @@ -89,4 +106,4 @@ inline const Internal::Adaptor::ColorController& GetImplementation(const Dali::C } // namespace Dali -#endif // __DALI_INTERNAL_COLOR_CONTROLLER_H__ +#endif // DALI_INTERNAL_COLOR_CONTROLLER_H diff --git a/dali/internal/system/file.list b/dali/internal/system/file.list index 62798c8..560f947 100644 --- a/dali/internal/system/file.list +++ b/dali/internal/system/file.list @@ -3,6 +3,7 @@ # module: system, backend: common adaptor_system_common_src_files=\ ${adaptor_system_dir}/common/abort-handler.cpp \ + ${adaptor_system_dir}/common/color-controller-impl.cpp \ ${adaptor_system_dir}/common/command-line-options.cpp \ ${adaptor_system_dir}/common/environment-options.cpp \ ${adaptor_system_dir}/common/fps-tracker.cpp \ @@ -37,7 +38,6 @@ adaptor_system_linux_src_files=\ # module: system, backend: tizen-wayland adaptor_system_tizen_wayland_src_files=\ - ${adaptor_system_dir}/tizen-wayland/color-controller-impl-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/system-settings-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/widget-application-impl-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/widget-controller-tizen.cpp @@ -47,7 +47,6 @@ adaptor_system_tizen_wearable_src_files=\ ${adaptor_system_dir}/tizen-wayland/tizen-wearable/capture.cpp \ ${adaptor_system_dir}/tizen-wayland/tizen-wearable/capture-impl-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/tizen-wearable/watch-time.cpp \ - ${adaptor_system_dir}/tizen-wayland/color-controller-impl-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/system-settings-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/widget-application-impl-tizen.cpp \ ${adaptor_system_dir}/tizen-wayland/widget-controller-tizen.cpp @@ -55,7 +54,6 @@ adaptor_system_tizen_wearable_src_files=\ # module: system, backend: ubuntu-x11 adaptor_system_ubuntu_x11_src_files=\ - ${adaptor_system_dir}/ubuntu-x11/color-controller-impl-x.cpp \ ${adaptor_system_dir}/ubuntu-x11/system-settings-x.cpp \ ${adaptor_system_dir}/ubuntu-x11/widget-application-impl-x.cpp \ ${adaptor_system_dir}/ubuntu-x11/widget-controller-x.cpp diff --git a/dali/internal/system/ubuntu-x11/color-controller-impl-x.cpp b/dali/internal/system/ubuntu-x11/color-controller-impl-x.cpp deleted file mode 100644 index db2b380..0000000 --- a/dali/internal/system/ubuntu-x11/color-controller-impl-x.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace Adaptor -{ - -Dali::ColorController ColorController::Get() -{ - return Dali::ColorController( new ColorController() ); -} - -ColorController::ColorController() -{ -} - -ColorController::~ColorController() -{ -} - -bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue ) -{ - return false; -} - -bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor) -{ - return false; -} - -} // namespace Adaptor - -} // namespace Internal - -} // namespace Dali