Color Controller implementation 23/196723/10
authorSeungho, Baek <sbsh.baek@samsung.com>
Fri, 4 Jan 2019 02:31:19 +0000 (11:31 +0900)
committerSeungho, Baek <sbsh.baek@samsung.com>
Tue, 22 Jan 2019 05:46:24 +0000 (14:46 +0900)
 - color-controller-plugin.h
 - color-controller-impl.cpp

Change-Id: Ieba2b1a8c0f0133630ddb2e09f7f1b408c106f91
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
dali/devel-api/adaptor-framework/color-controller-plugin.h [new file with mode: 0755]
dali/devel-api/adaptor-framework/color-controller.h
dali/devel-api/file.list
dali/internal/system/common/color-controller-impl.cpp [moved from dali/internal/system/tizen-wayland/color-controller-impl-tizen.cpp with 60% similarity]
dali/internal/system/common/color-controller-impl.h
dali/internal/system/file.list
dali/internal/system/ubuntu-x11/color-controller-impl-x.cpp [deleted file]

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 (executable)
index 0000000..2d761dc
--- /dev/null
@@ -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 <cstdlib>
+
+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
index aa43e30..bc067a9 100755 (executable)
@@ -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
index 5a29f71..9e05c21 100755 (executable)
@@ -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 \
@@ -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 <dali/internal/system/common/color-controller-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dlfcn.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry.h>
 
@@ -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;
 }
 
index 972f5e9..58de395 100644 (file)
@@ -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 <dali/devel-api/adaptor-framework/color-controller.h>
+#include <dali/devel-api/adaptor-framework/color-controller-plugin.h>
 
 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
index 62798c8..560f947 100644 (file)
@@ -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 (file)
index db2b380..0000000
+++ /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 <dali/internal/system/common/color-controller-impl.h>
-
-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