Block some codes by macro what tizen_8.0 not supported 20/315920/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 6 Dec 2024 05:55:32 +0000 (14:55 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 11 Dec 2024 05:57:19 +0000 (14:57 +0900)
Let we make dali codes compiled by tizen_8.0 repo

Change-Id: I33df9fe94aeff8c91a2d433ab92e173eccb80334
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
13 files changed:
build/tizen/configure.ac
build/tizen/vector-animation-renderer/configure.ac
build/tizen/video-player/configure.ac
build/tizen/web-engine-chromium/configure.ac
build/tizen/web-engine-lwe/configure.ac
build/ubuntu/vector-animation-renderer/CMakeLists.txt
dali-extension/vector-animation-renderer/vector-animation-renderer.cpp
dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp
dali-extension/video-player/ecore-wl2/tizen-video-player.h [changed mode: 0755->0644]
dali-extension/web-engine-chromium/tizen-web-engine-chromium.cpp
dali-extension/web-engine-lwe/tizen-web-engine-lwe.cpp
dali-extension/web-engine-lwe/tizen-web-engine-lwe.h
packaging/dali-extension.spec

index b370622afae8cc9c389f243b424db75f2bfa88d2..f44eea5fa50a8a5ada9c88d800590778e98ad3cb 100755 (executable)
@@ -28,6 +28,12 @@ AC_ARG_WITH([tizen_65_or_greater],
             [with_tizen_65_or_greater=yes],
             [with_tizen_65_or_greater=no])
 
+AC_ARG_WITH([tizen_90_or_greater],
+            [AC_HELP_STRING([--with-tizen-90-or-greater],
+                            [Use this conditional when Tizen version is 9.0 or greater])],
+            [with_tizen_90_or_greater=yes],
+            [with_tizen_90_or_greater=no])
+
 AC_ARG_ENABLE([debug],
               [AC_HELP_STRING([--enable-debug],
                               [Turns on debugging])],
index 09079609d55223fb9256be15aa07faf710ed3fb4..1d61f48f843631cf8d02d87e2b8fccc519d724ef 100644 (file)
@@ -20,6 +20,10 @@ if test "x$enable_debug" = "xyes"; then
   DALI_CFLAGS="$DALI_CFLAGS -DDEBUG_ENABLED"
 fi
 
+if test "x$with_tizen_90_or_greater" = "xyes"; then
+  DALI_CFLAGS="$DALI_CFLAGS -DOVER_TIZEN_VERSION_9"
+fi
+
 PKG_CHECK_MODULES([DALI], [dali2-core dali2-adaptor dali2-toolkit])
 PKG_CHECK_MODULES(RLOTTIE, rlottie)
 
index 96ef50ccfd3556024f3b37c13f2bf4fddfbec5e0..fd79dad00d18d82749a453b7ff5913f754fd91fe 100644 (file)
@@ -20,6 +20,10 @@ if test "x$enable_debug" = "xyes"; then
   DALI_CFLAGS="$DALI_CFLAGS -DDEBUG_ENABLED"
 fi
 
+if test "x$with_tizen_90_or_greater" = "xyes"; then
+  DALI_CFLAGS="$DALI_CFLAGS -DOVER_TIZEN_VERSION_9"
+fi
+
 PKG_CHECK_MODULES([DALI], [dali2-core dali2-adaptor dali2-toolkit])
 PKG_CHECK_MODULES(CAPI_MEDIA_PLAYER, capi-media-player)
 PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
index ce71c15333642e2de151b0a7a02951f21604dc3c..471e8253327776f9a8c7a46ba390a1d491a2e55c 100644 (file)
@@ -20,6 +20,10 @@ if test "x$enable_debug" = "xyes"; then
   DALI_CFLAGS="$DALI_CFLAGS -DDEBUG_ENABLED"
 fi
 
+if test "x$with_tizen_90_or_greater" = "xyes"; then
+  DALI_CFLAGS="$DALI_CFLAGS -DOVER_TIZEN_VERSION_9"
+fi
+
 PKG_CHECK_MODULES([DALI], [dali2-core dali2-adaptor dali2-toolkit])
 PKG_CHECK_MODULES(WAYLAND, libtbm)
 PKG_CHECK_MODULES(WEB_ENGINE_CHROMIUM, chromium-efl)
index cb81c23c1d85d907045c3c60ba7a63bb34d3af1b..d0110e1660ff8d83fe1b2da6173942c83ead5948 100644 (file)
@@ -20,6 +20,10 @@ if test "x$enable_debug" = "xyes"; then
   DALI_CFLAGS="$DALI_CFLAGS -DDEBUG_ENABLED"
 fi
 
+if test "x$with_tizen_90_or_greater" = "xyes"; then
+  DALI_CFLAGS="$DALI_CFLAGS -DOVER_TIZEN_VERSION_9"
+fi
+
 PKG_CHECK_MODULES([DALI], [dali2-core dali2-adaptor dali2-toolkit])
 PKG_CHECK_MODULES(WAYLAND, libtbm)
 PKG_CHECK_MODULES([WEB_ENGINE_LWE], [lightweight-web-engine])
index 3ddc0bbbe796c1c7339ec44a6b520fa82f2afa68..4855c7c160666cc378a1397502413aa6704d0a19 100644 (file)
@@ -63,6 +63,9 @@ IF( ENABLE_TRACE )
   ADD_DEFINITIONS("-DTRACE_ENABLED")
 ENDIF()
 
+# Hijack the information of tizen version here
+ADD_DEFINITIONS("-DOVER_TIZEN_VERSION_9")
+
 INCLUDE(CheckCXXCompilerFlag)
 
 ADD_COMPILE_OPTIONS( -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal )
index ce3da485ffff6820c81ea974258223b4a2477931..cf38dc9f0e4767f61aa6b5abde55fff366615f47 100644 (file)
@@ -473,6 +473,7 @@ void VectorAnimationRenderer::AddPropertyValueCallback(const std::string& keyPat
         }
         case VectorProperty::TRIM_START:
         {
+#ifdef OVER_TIZEN_VERSION_9
           mVectorRenderer->setValue<rlottie::Property::TrimStart>(keyPath,
                                                                   [property, callback, id](const rlottie::FrameInfo& info) {
                                                                     Property::Value value = CallbackBase::ExecuteReturn<Property::Value>(*callback, id, property, info.curFrame());
@@ -483,20 +484,23 @@ void VectorAnimationRenderer::AddPropertyValueCallback(const std::string& keyPat
                                                                     }
                                                                     return 0.0f;
                                                                   });
+#endif
           break;
         }
         case VectorProperty::TRIM_END:
         {
+#ifdef OVER_TIZEN_VERSION_9
           mVectorRenderer->setValue<rlottie::Property::TrimEnd>(keyPath,
-                                                                  [property, callback, id](const rlottie::FrameInfo& info) {
-                                                                    Property::Value value = CallbackBase::ExecuteReturn<Property::Value>(*callback, id, property, info.curFrame());
-                                                                    Vector2         position;
-                                                                    if(value.Get(position))
-                                                                    {
-                                                                      return rlottie::Point(position.x, position.y);
-                                                                    }
-                                                                    return rlottie::Point(0.0f, 100.0f);
-                                                                  });
+                                                                [property, callback, id](const rlottie::FrameInfo& info) {
+                                                                  Property::Value value = CallbackBase::ExecuteReturn<Property::Value>(*callback, id, property, info.curFrame());
+                                                                  Vector2         position;
+                                                                  if(value.Get(position))
+                                                                  {
+                                                                    return rlottie::Point(position.x, position.y);
+                                                                  }
+                                                                  return rlottie::Point(0.0f, 100.0f);
+                                                                });
+#endif
           break;
         }
       }
index 99e7859aacc3bccb236835b7fb3411dc42a2643b..29c2463acefaf079534186263d8d2cea3c0c1aa0 100644 (file)
 #include <dali/devel-api/threading/mutex.h>
 #include <dali/integration-api/debug.h>
 #include <system_info.h>
+
+#ifdef OVER_TIZEN_VERSION_9
 #include <wayland-egl-tizen.h>
+#endif
 
 // INTERNAL INCLUDES
 
@@ -262,6 +265,7 @@ int LogPlayerError(int error)
 
 const char* const VIDEO_PLAYER_SIZE_NAME("videoPlayerSize");
 
+#ifdef OVER_TIZEN_VERSION_9
 struct BufferCommitData
 {
   Ecore_Wl2_VideoShell_Surface_Wrapper* ecoreVideoShellSurfaceWrapper;
@@ -338,6 +342,7 @@ private:
   float                                 mHalfScreenWidth;
   float                                 mHalfScreenHeight;
 };
+#endif
 
 /**
  * @brief Whether set play positoin accurately or not.
@@ -371,7 +376,9 @@ TizenVideoPlayer::TizenVideoPlayer(Dali::Actor actor, Dali::VideoSyncMode syncMo
   mSyncMode(syncMode),
   mIsMovedHandle(false),
   mIsSceneConnected(false),
+#ifdef OVER_TIZEN_VERSION_9
   mEcoreVideoShellSurface(nullptr),
+#endif
   mVideoShellSizePropertyIndex(Property::INVALID_INDEX)
 {
 }
@@ -389,11 +396,13 @@ TizenVideoPlayer::~TizenVideoPlayer()
     mEcoreSubVideoWindow = nullptr;
   }
 
+#ifdef OVER_TIZEN_VERSION_9
   if(mEcoreVideoShellSurface)
   {
     Ecore_Wl2_VideoShell_Surface_del(mEcoreVideoShellSurface);
     mEcoreVideoShellSurface = nullptr;
   }
+#endif
 
   DestroyPlayer();
 }
@@ -873,6 +882,7 @@ void TizenVideoPlayer::InitializeTextureStreamMode(Dali::NativeImageSourcePtr na
 
 void TizenVideoPlayer::InitializeVideoShell(Ecore_Wl2_Window* ecoreWlWindow)
 {
+#ifdef OVER_TIZEN_VERSION_9
   if(mEcoreWlWindow != ecoreWlWindow)
   {
     mEcoreWlWindow = ecoreWlWindow;
@@ -897,6 +907,9 @@ void TizenVideoPlayer::InitializeVideoShell(Ecore_Wl2_Window* ecoreWlWindow)
 
     DALI_LOG_RELEASE_INFO("VideoShell(%p) handle: %s\n", mEcoreVideoShellSurface, videoShellHandle);
   }
+#else
+  DALI_LOG_ERROR("InitializeVideoShell, ecore_wl2_subsurface_new() NOT SUPPORT THIS TIZEN VERSION!\n");
+#endif
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1323,6 +1336,7 @@ void TizenVideoPlayer::FinishSynchronization()
 
 void TizenVideoPlayer::CreateVideoShellConstraint()
 {
+#ifdef OVER_TIZEN_VERSION_9
   DALI_LOG_RELEASE_INFO("Create Video Shell Constraint\n");
   if(mVideoShellSizePropertyIndex == Property::INVALID_INDEX)
   {
@@ -1357,16 +1371,23 @@ void TizenVideoPlayer::CreateVideoShellConstraint()
       mVideoShellSizePropertyConstraint.AddSource(LocalSource(Actor::Property::WORLD_POSITION));
     }
   }
+#else
+  DALI_LOG_ERROR("Video Shell Constraint NOT SUPPORT THIS TIZEN VERSION!\n");
+#endif
 }
 
 void TizenVideoPlayer::DestroyVideoShellConstraint()
 {
+#ifdef OVER_TIZEN_VERSION_9
   DALI_LOG_RELEASE_INFO("Destroy VideoShell Constraint: %d\n", mVideoShellSizePropertyIndex);
   if(mVideoShellSizePropertyIndex != Property::INVALID_INDEX)
   {
     mVideoShellSizePropertyConstraint.Remove();
     mVideoShellSizePropertyIndex = Property::INVALID_INDEX;
   }
+#else
+  DALI_LOG_ERROR("Video Shell Constraint NOT SUPPORT THIS TIZEN VERSION!\n");
+#endif
 }
 
 void TizenVideoPlayer::RaiseAbove(Any videoSurface)
@@ -1418,9 +1439,16 @@ void TizenVideoPlayer::SceneConnection()
 
   if(mSyncMode == Dali::VideoSyncMode::ENABLED && mVideoShellSizePropertyIndex == Property::INVALID_INDEX)
   {
-    DALI_LOG_RELEASE_INFO("mVideoShellSizePropertyConstraint(%d).ApplyPost()\n", mVideoShellSizePropertyIndex);
     CreateVideoShellConstraint();
-    mVideoShellSizePropertyConstraint.ApplyPost();
+    if(mVideoShellSizePropertyConstraint)
+    {
+      DALI_LOG_RELEASE_INFO("mVideoShellSizePropertyConstraint(%d).ApplyPost()\n", mVideoShellSizePropertyIndex);
+      mVideoShellSizePropertyConstraint.ApplyPost();
+    }
+    else
+    {
+      DALI_LOG_ERROR("mVideoShellSizePropertyConstraint() creation failed!\n");
+    }
   }
   mIsSceneConnected = true;
 }
old mode 100755 (executable)
new mode 100644 (file)
index ba4b7a1..5fe3a74
@@ -27,8 +27,8 @@
 #include <dali/public-api/animation/constraints.h>
 #include <dali/public-api/object/weak-handle.h>
 #include <player.h>
-#include <string>
 #include <list>
+#include <string>
 
 #ifndef HAVE_WAYLAND
 #define HAVE_WAYLAND
@@ -305,8 +305,8 @@ private:
   Dali::Vector4              mBackgroundColor;      ///< Current background color, which texturestream mode needs.
   RenderingTargetType        mTargetType;           ///< Current rendering target type
 
-  Dali::Mutex                mPacketMutex;
-  std::list<media_packet_h>  mPacketList;           ///< Container for media packet handle from Tizen player callback
+  Dali::Mutex               mPacketMutex;
+  std::list<media_packet_h> mPacketList; ///< Container for media packet handle from Tizen player callback
 
   sound_stream_info_h mStreamInfo;
   sound_stream_type_e mStreamType;
@@ -320,13 +320,14 @@ private:
   Property::Index               mVideoSizePropertyIndex;
   Dali::VideoSyncMode           mSyncMode;
 
-  bool mIsMovedHandle;     ///< the flag for moved the handle
+  bool mIsMovedHandle; ///< the flag for moved the handle
   bool mIsSceneConnected;
 
-
-  Ecore_Wl2_VideoShell_Surface*        mEcoreVideoShellSurface;
-  Constraint                    mVideoShellSizePropertyConstraint;
-  Property::Index               mVideoShellSizePropertyIndex;
+#ifdef OVER_TIZEN_VERSION_9
+  Ecore_Wl2_VideoShell_Surface* mEcoreVideoShellSurface;
+#endif
+  Constraint      mVideoShellSizePropertyConstraint;
+  Property::Index mVideoShellSizePropertyIndex;
 
 public:
   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
index 5c4ca0fbe233bb84707a922039a9b931356770e7..21f7c75f431a7e924b7a8e468004a1c0dde21173 100644 (file)
@@ -32,8 +32,8 @@
 #include "tizen-web-engine-user-media-permission-request.h"
 
 #include <Ecore_Evas.h>
-#include <Ecore_Wl2.h>
 #include <Ecore_Input_Evas.h>
+#include <Ecore_Wl2.h>
 
 #include <dali/devel-api/common/stage.h>
 #include <dali/integration-api/adaptor-framework/adaptor.h>
@@ -675,7 +675,7 @@ bool TizenWebEngineChromium::FeedTouchEvent(const TouchEvent& touch)
     point.y     = touch.GetScreenPosition(i).y;
     point.state = state;
     pointList   = eina_list_append(pointList, &point);
-    fed = ewk_view_feed_touch_event(mWebView, type, pointList, 0);
+    fed         = ewk_view_feed_touch_event(mWebView, type, pointList, 0);
     eina_list_free(pointList);
     if(!fed)
     {
@@ -699,15 +699,15 @@ bool TizenWebEngineChromium::SendKeyEvent(const Dali::KeyEvent& keyEvent)
     memset(&downEvent, 0, sizeof(Evas_Event_Key_Down));
 
     downEvent.timestamp = keyEvent.GetTime();
-    downEvent.keyname = const_cast<char *>(keyEvent.GetKeyName().c_str());
-    downEvent.key = keyEvent.GetLogicalKey().c_str();
-    downEvent.string = keyEvent.GetKeyString().c_str();
-    downEvent.keycode = keyEvent.GetKeyCode();
-    Evas* evas = ecore_evas_get(WebEngineManager::Get().GetWindow());
+    downEvent.keyname   = const_cast<char*>(keyEvent.GetKeyName().c_str());
+    downEvent.key       = keyEvent.GetLogicalKey().c_str();
+    downEvent.string    = keyEvent.GetKeyString().c_str();
+    downEvent.keycode   = keyEvent.GetKeyCode();
+    Evas* evas          = ecore_evas_get(WebEngineManager::Get().GetWindow());
     ecore_event_evas_modifier_lock_update(evas, (unsigned int)keyEvent.GetKeyModifier());
     downEvent.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas));
-    downEvent.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
-    downEvent.dev = evas_device_get(evas, keyEvent.GetDeviceName().c_str());
+    downEvent.locks     = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
+    downEvent.dev       = evas_device_get(evas, keyEvent.GetDeviceName().c_str());
 
     evasKeyEvent = static_cast<void*>(&downEvent);
     ewk_view_send_key_event(mWebView, evasKeyEvent, true);
@@ -718,15 +718,15 @@ bool TizenWebEngineChromium::SendKeyEvent(const Dali::KeyEvent& keyEvent)
     memset(&upEvent, 0, sizeof(Evas_Event_Key_Up));
 
     upEvent.timestamp = keyEvent.GetTime();
-    upEvent.keyname = const_cast<char *>(keyEvent.GetKeyName().c_str());
-    upEvent.key = keyEvent.GetLogicalKey().c_str();
-    upEvent.string = keyEvent.GetKeyString().c_str();
-    upEvent.keycode = keyEvent.GetKeyCode();
-    Evas* evas = ecore_evas_get(WebEngineManager::Get().GetWindow());
+    upEvent.keyname   = const_cast<char*>(keyEvent.GetKeyName().c_str());
+    upEvent.key       = keyEvent.GetLogicalKey().c_str();
+    upEvent.string    = keyEvent.GetKeyString().c_str();
+    upEvent.keycode   = keyEvent.GetKeyCode();
+    Evas* evas        = ecore_evas_get(WebEngineManager::Get().GetWindow());
     ecore_event_evas_modifier_lock_update(evas, (unsigned int)keyEvent.GetKeyModifier());
     upEvent.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas));
-    upEvent.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
-    upEvent.dev = evas_device_get(evas, keyEvent.GetDeviceName().c_str());
+    upEvent.locks     = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
+    upEvent.dev       = evas_device_get(evas, keyEvent.GetDeviceName().c_str());
 
     evasKeyEvent = static_cast<void*>(&upEvent);
     ewk_view_send_key_event(mWebView, evasKeyEvent, false);
@@ -884,7 +884,9 @@ void TizenWebEngineChromium::GetPlainTextAsynchronously(PlainTextReceivedCallbac
 
 void TizenWebEngineChromium::WebAuthenticationCancel()
 {
+#ifdef OVER_TIZEN_VERSION_9
   ewk_view_webauthn_cancel(mWebView);
+#endif
 }
 
 void TizenWebEngineChromium::RegisterGeolocationPermissionCallback(GeolocationPermissionCallback callback)
@@ -899,8 +901,6 @@ void TizenWebEngineChromium::RegisterUserMediaPermissionRequestCallback(WebEngin
   ewk_view_user_media_permission_callback_set(mWebView, &TizenWebEngineChromium::OnUserMediaPermissonRequest, this);
 }
 
-
-
 void TizenWebEngineChromium::UpdateDisplayArea(Dali::Rect<int32_t> displayArea)
 {
   // Size was changed. Destroy previous native image source, and create new one.
@@ -1272,7 +1272,7 @@ void TizenWebEngineChromium::OnFullscreenExited(void* data, Evas_Object*, void*)
 
 void TizenWebEngineChromium::OnTextFound(void* data, Evas_Object*, void* eventInfo)
 {
-  auto pThis = static_cast<TizenWebEngineChromium*>(data);
+  auto     pThis = static_cast<TizenWebEngineChromium*>(data);
   uint32_t count = *((uint32_t*)(eventInfo));
   DALI_LOG_RELEASE_INFO("#TextFound, count:%u.\n", count);
   ExecuteCallback(pThis->mTextFoundCallback, count);
@@ -1280,7 +1280,7 @@ void TizenWebEngineChromium::OnTextFound(void* data, Evas_Object*, void* eventIn
 
 void TizenWebEngineChromium::OnWebAuthDisplayQR(void* data, Evas_Object*, void* contents)
 {
-  auto pThis = static_cast<TizenWebEngineChromium*>(data);
+  auto        pThis = static_cast<TizenWebEngineChromium*>(data);
   std::string result;
   if(contents != nullptr)
   {
@@ -1328,10 +1328,10 @@ void TizenWebEngineChromium::OnJavaScriptInjected(Evas_Object* o, Ewk_Script_Mes
       resultText = static_cast<char*>(message.body);
     }
 
-    std::string key = static_cast<const char*>(message.name);
-    auto targetCallback = pThis->mJavaScriptInjectedCallbacks.find(key);
+    std::string key            = static_cast<const char*>(message.name);
+    auto        targetCallback = pThis->mJavaScriptInjectedCallbacks.find(key);
 
-    if (targetCallback != pThis->mJavaScriptInjectedCallbacks.end())
+    if(targetCallback != pThis->mJavaScriptInjectedCallbacks.end())
     {
       ExecuteCallback(targetCallback->second, resultText);
     }
@@ -1436,17 +1436,15 @@ Eina_Bool TizenWebEngineChromium::OnGeolocationPermission(Evas_Object*, Ewk_Geol
 
 Eina_Bool TizenWebEngineChromium::OnUserMediaPermissonRequest(Evas_Object*, Ewk_User_Media_Permission_Request* request, void* data)
 {
-  auto pThis = static_cast<TizenWebEngineChromium*>(data);
+  auto                                                       pThis = static_cast<TizenWebEngineChromium*>(data);
   std::unique_ptr<Dali::WebEngineUserMediaPermissionRequest> webUserMediaPermissionRequest(new TizenWebEngineUserMediaPermissionRequest(request));
   DALI_LOG_RELEASE_INFO("#UserMediaPermissonRequest: pThis:%p, permission:%p\n", pThis, request);
   std::string msg = ewk_user_media_permission_request_message_get(request);
 
   ExecuteCallback(pThis->mUserMediaPermissionRequestCallback, std::move(webUserMediaPermissionRequest), msg);
-  return msg.empty()? false: true;
+  return msg.empty() ? false : true;
 }
 
-
-
 } // namespace Plugin
 } // namespace Dali
 
index 9a59493bdd3a8255bd0eb7dda4a04b3ee6e550d8..bcfe70862d86806ebebf8fed841dd0dcea9020b6 100644 (file)
@@ -51,6 +51,33 @@ extern "C" DALI_EXPORT_API void DestroyWebEnginePlugin(Dali::WebEnginePlugin* pl
   }
 }
 
+namespace
+{
+#ifndef OVER_TIZEN_VERSION_9
+#define DB_NAME_LOCAL_STORAGE "LWE_localStorage.db"
+#define DB_NAME_COOKIES "LWE_Cookies.db"
+#define DB_NAME_CACHE "LWE_Cache.db"
+
+class Locker
+{
+public:
+  Locker(pthread_mutex_t& lock)
+  : m_lock(lock)
+  {
+    pthread_mutex_lock(&m_lock);
+  }
+
+  ~Locker()
+  {
+    pthread_mutex_unlock(&m_lock);
+  }
+
+protected:
+  pthread_mutex_t m_lock;
+};
+#endif
+} // namespace
+
 namespace Dali
 {
 namespace Plugin
@@ -332,6 +359,14 @@ TizenWebEngineLWE::TizenWebEngineLWE()
   mIsMouseLbuttonDown(false),
   mCanGoBack(false),
   mCanGoForward(false),
+#ifndef OVER_TIZEN_VERSION_9
+  mOutputWidth(0),
+  mOutputHeight(0),
+  mOutputStride(0),
+  mOutputBuffer(nullptr),
+  mTbmSurface(nullptr),
+  mUpdateBufferTrigger(MakeCallback(this, &TizenWebEngineLWE::LegacyUpdateBuffer)),
+#endif
   mWebContainer(NULL),
   mDaliImageSrc(NativeImageSource::New(0, 0, NativeImageSource::COLOR_DEPTH_DEFAULT)),
   mNativeDisplay(NULL),
@@ -351,10 +386,16 @@ TizenWebEngineLWE::TizenWebEngineLWE()
   mLoadStartedCallback(nullptr),
   mLoadFinishedCallback(nullptr)
 {
+#ifndef OVER_TIZEN_VERSION_9
+  pthread_mutex_init(&mOutputBufferMutex, NULL);
+#endif
 }
 
 TizenWebEngineLWE::~TizenWebEngineLWE()
 {
+#ifndef OVER_TIZEN_VERSION_9
+  pthread_mutex_destroy(&mOutputBufferMutex);
+#endif
 }
 
 static std::string Langset()
@@ -389,6 +430,7 @@ static std::string Timezone()
 
 void TizenWebEngineLWE::Create(uint32_t width, uint32_t height, uint32_t argc, char** argv)
 {
+#ifdef OVER_TIZEN_VERSION_9
   for(uint32_t idx = 0; idx < argc; ++idx)
   {
     if(argv[idx])
@@ -403,11 +445,62 @@ void TizenWebEngineLWE::Create(uint32_t width, uint32_t height, uint32_t argc, c
       }
     }
   }
+#endif
   Create(width, height, Langset(), Timezone());
 }
 
 void TizenWebEngineLWE::Create(uint32_t width, uint32_t height, const std::string& locale, const std::string& timezoneId)
 {
+#ifndef OVER_TIZEN_VERSION_9
+  mOutputWidth  = width;
+  mOutputHeight = height;
+  mOutputStride = width * sizeof(uint32_t);
+  mOutputBuffer = (uint8_t*)malloc(width * height * sizeof(uint32_t));
+
+  mOnRenderedHandler = [this](LWE::WebContainer* c, const LWE::WebContainer::RenderResult& renderResult) {
+    size_t w = mOutputWidth;
+    size_t h = mOutputHeight;
+    if(renderResult.updatedWidth != w || renderResult.updatedHeight != h)
+    {
+      return;
+    }
+    Locker   l(mOutputBufferMutex);
+    uint8_t* dstBuffer;
+    size_t   dstStride;
+
+    tbm_surface_info_s tbmSurfaceInfo;
+    if(tbm_surface_map(mTbmSurface, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &tbmSurfaceInfo) != TBM_SURFACE_ERROR_NONE)
+    {
+      DALI_LOG_ERROR("Fail to map tbm_surface\n");
+    }
+
+    DALI_ASSERT_ALWAYS(tbmSurfaceInfo.format == TBM_FORMAT_ARGB8888 && "Unsupported TizenWebEngineLWE tbm format");
+    dstBuffer = tbmSurfaceInfo.planes[0].ptr;
+    dstStride = tbmSurfaceInfo.planes[0].stride;
+
+    uint32_t srcStride = static_cast<uint32_t>(renderResult.updatedWidth * sizeof(uint32_t));
+    uint8_t* srcBuffer = static_cast<uint8_t*>(renderResult.updatedBufferAddress);
+
+    if(dstStride == srcStride)
+    {
+      memcpy(dstBuffer, srcBuffer, tbmSurfaceInfo.planes[0].size);
+    }
+    else
+    {
+      for(auto y = renderResult.updatedY; y < (renderResult.updatedHeight + renderResult.updatedY); y++)
+      {
+        auto start = renderResult.updatedX;
+        memcpy(dstBuffer + (y * dstStride) + (start * 4), srcBuffer + (y * srcStride) + (start * 4), srcStride);
+      }
+    }
+
+    if(tbm_surface_unmap(mTbmSurface) != TBM_SURFACE_ERROR_NONE)
+    {
+      DALI_LOG_ERROR("Fail to unmap tbm_surface\n");
+    }
+    mUpdateBufferTrigger.Trigger();
+  };
+#endif
   mOnReceivedError = [](LWE::WebContainer* container, LWE::ResourceError error) {
   };
 
@@ -431,13 +524,20 @@ void TizenWebEngineLWE::Create(uint32_t width, uint32_t height, const std::strin
   if(!LWE::LWE::IsInitialized())
   {
     std::string dataPath = DevelApplication::GetDataPath();
+#ifdef OVER_TIZEN_VERSION_9
     LWE::LWE::Initialize((dataPath + "/StarFishStorage").c_str());
+#else
+    LWE::LWE::Initialize((dataPath + DB_NAME_LOCAL_STORAGE).c_str(),
+                         (dataPath + DB_NAME_COOKIES).c_str(),
+                         (dataPath + DB_NAME_CACHE).c_str());
+#endif
 
     gEglCreateSyncKHR     = (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR");
     gEglDestroySyncKHR    = (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR");
     gEglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR");
   }
 
+#ifdef OVER_TIZEN_VERSION_9
   LWE::WebContainer::WebContainerArguments args{
     .width            = static_cast<unsigned>(width),
     .height           = static_cast<unsigned>(height),
@@ -489,6 +589,53 @@ void TizenWebEngineLWE::Create(uint32_t width, uint32_t height, const std::strin
 
   mWebContainer = LWE::WebContainer::CreateGL(args, config);
 
+  mWebContainer->RegisterSetNeedsRenderingCallback(
+    [this](LWE::WebContainer*, const std::function<void()>& doRenderingFunction) {
+      if(!mLWERenderingFunction)
+      {
+        mLWERenderingFunction = doRenderingFunction;
+      }
+
+      if(!mLWERenderingRequested.exchange(true))
+      {
+        PrepareLWERendering();
+      }
+    });
+
+  mWebContainer->RegisterOnIdleHandler(
+    [this](LWE::WebContainer*) {
+      OnIdle();
+    });
+
+  auto settings = mWebContainer->GetSettings();
+  settings.SetWebSecurityMode(LWE::WebSecurityMode::Disable);
+  mWebContainer->SetSettings(settings);
+
+  mWebContainer->LoadURL("about:blank");
+#else
+  mWebContainer = LWE::WebContainer::Create(mOutputWidth, mOutputHeight, 1.0, "", locale.data(), timezoneId.data());
+
+  mWebContainer->RegisterPreRenderingHandler(
+    [this]() -> LWE::WebContainer::RenderInfo {
+      if(mOutputBuffer == NULL)
+      {
+        mOutputBuffer = (uint8_t*)malloc(mOutputWidth * mOutputHeight * sizeof(uint32_t));
+        mOutputStride = mOutputWidth * sizeof(uint32_t);
+      }
+
+      ::LWE::WebContainer::RenderInfo result;
+      result.updatedBufferAddress = mOutputBuffer;
+      result.bufferStride = mOutputStride;
+
+      return result;
+    });
+
+  mWebContainer->RegisterOnRenderedHandler(
+    [this](LWE::WebContainer* container, const LWE::WebContainer::RenderResult& renderResult) {
+      mOnRenderedHandler(container, renderResult);
+    });
+#endif
+
   mWebContainer->RegisterOnReceivedErrorHandler(
     [this](LWE::WebContainer* container, LWE::ResourceError error) {
       mCanGoBack    = container->CanGoBack();
@@ -516,30 +663,6 @@ void TizenWebEngineLWE::Create(uint32_t width, uint32_t height, const std::strin
       mCanGoForward = container->CanGoForward();
       mOnLoadResourceHandler(container, url);
     });
-
-  mWebContainer->RegisterSetNeedsRenderingCallback(
-    [this](LWE::WebContainer*, const std::function<void()>& doRenderingFunction) {
-      if(!mLWERenderingFunction)
-      {
-        mLWERenderingFunction = doRenderingFunction;
-      }
-
-      if(!mLWERenderingRequested.exchange(true))
-      {
-        PrepareLWERendering();
-      }
-    });
-
-  mWebContainer->RegisterOnIdleHandler(
-    [this](LWE::WebContainer*) {
-      OnIdle();
-    });
-
-  auto settings = mWebContainer->GetSettings();
-  settings.SetWebSecurityMode(LWE::WebSecurityMode::Disable);
-  mWebContainer->SetSettings(settings);
-
-  mWebContainer->LoadURL("about:blank");
 }
 
 void TizenWebEngineLWE::TryRendering()
@@ -673,6 +796,13 @@ void TizenWebEngineLWE::Destroy()
     return;
   }
 
+#ifndef OVER_TIZEN_VERSION_9
+  if(mTbmSurface != NULL && tbm_surface_destroy(mTbmSurface) != TBM_SURFACE_ERROR_NONE)
+  {
+    DALI_LOG_ERROR("Failed to destroy tbm_surface\n");
+  }
+#endif
+
   DestroyInstance();
   mWebContainer = NULL;
 }
@@ -852,15 +982,29 @@ void TizenWebEngineLWE::OnFirstRender()
   }
 }
 
+#ifndef OVER_TIZEN_VERSION_9
+void TizenWebEngineLWE::LegacyUpdateBuffer()
+{
+  UpdateImage(mTbmSurface);
+}
+#endif
+
 void TizenWebEngineLWE::UpdateImage(tbm_surface_h image)
 {
   DALI_ASSERT_ALWAYS(mWebContainer);
   if((int)mWebContainer->Width() == tbm_surface_get_width(image) ||
      (int)mWebContainer->Height() == tbm_surface_get_height(image))
   {
-    Any source(image);
-    mDaliImageSrc->SetSource(source);
-    Dali::Stage::GetCurrent().KeepRendering(0.0f);
+#ifndef OVER_TIZEN_VERSION_9
+    {
+      Locker l(mOutputBufferMutex);
+#endif
+      Any source(image);
+      mDaliImageSrc->SetSource(source);
+      Dali::Stage::GetCurrent().KeepRendering(0.0f);
+#ifndef OVER_TIZEN_VERSION_9
+    }
+#endif
 
     if(mFrameRenderedCallback)
     {
@@ -1411,6 +1555,34 @@ void TizenWebEngineLWE::SetSize(uint32_t width, uint32_t height)
   {
     mWebContainer->ResizeTo(width, height);
   }
+
+#ifndef OVER_TIZEN_VERSION_9
+  if(mOutputWidth != (size_t)width || mOutputHeight != (size_t)height)
+  {
+    mOutputWidth  = width;
+    mOutputHeight = height;
+    mOutputStride = width * sizeof(uint32_t);
+
+    tbm_surface_h prevTbmSurface = mTbmSurface;
+    mTbmSurface                  = tbm_surface_create(width, height, TBM_FORMAT_ARGB8888);
+    Dali::Any source(mTbmSurface);
+    mDaliImageSrc->SetSource(source);
+    if(prevTbmSurface != NULL && tbm_surface_destroy(prevTbmSurface) != TBM_SURFACE_ERROR_NONE)
+    {
+      DALI_LOG_ERROR("Failed to destroy tbm_surface\n");
+    }
+
+    auto oldOutputBuffer = mOutputBuffer;
+    mOutputBuffer        = (uint8_t*)malloc(mOutputWidth * mOutputHeight * sizeof(uint32_t));
+    mOutputStride        = mOutputWidth * sizeof(uint32_t);
+    mWebContainer->ResizeTo(mOutputWidth, mOutputHeight);
+
+    if(oldOutputBuffer)
+    {
+      free(oldOutputBuffer);
+    }
+  }
+#endif
 }
 
 void TizenWebEngineLWE::SetDocumentBackgroundColor(Dali::Vector4 color)
@@ -1790,7 +1962,7 @@ void TizenWebEngineLWE::GetPlainTextAsynchronously(PlainTextReceivedCallback cal
 
 void TizenWebEngineLWE::RegisterWebAuthDisplayQRCallback(WebEngineWebAuthDisplayQRCallback callback)
 {
-  // NOT IMPLEMENTED  
+  // NOT IMPLEMENTED
 }
 
 void TizenWebEngineLWE::RegisterWebAuthResponseCallback(WebEngineWebAuthResponseCallback callback)
index 6a3e5a5cb51daaf7e9e89faa301a9479b273a745..105c05e9fe345388a68a13a3984a3660d6f19311 100644 (file)
 #include <dali/devel-api/adaptor-framework/web-engine/web-engine-plugin.h>
 #include <dali/public-api/adaptor-framework/timer.h>
 
+#include <tbm_dummy_display.h>
 #include <tbm_surface.h>
 #include <tbm_surface_internal.h>
 #include <tbm_surface_queue.h>
-#include <tbm_dummy_display.h>
 
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
@@ -37,7 +37,6 @@ namespace Dali
 {
 namespace Plugin
 {
-
 /**
  * @brief Implementation of the Tizen WebEngineLWE class which has Tizen
  * platform dependency.
@@ -597,6 +596,10 @@ public:
   void RegisterUserMediaPermissionRequestCallback(WebEngineUserMediaPermissionRequestCallback callback) override;
 
 private:
+#ifndef OVER_TIZEN_VERSION_9
+  void LegacyUpdateBuffer();
+#endif
+
   void DestroyInstance();
 
   void DispatchMouseDownEvent(float x, float y);
@@ -636,36 +639,51 @@ private:
   void UpdateImage(tbm_surface_h image);
 
 private:
-  std::string        mUrl;
-  bool               mIsMouseLbuttonDown;
-  bool               mCanGoBack;
-  bool               mCanGoForward;
+  std::string mUrl;
+
+  bool mIsMouseLbuttonDown;
+  bool mCanGoBack;
+  bool mCanGoForward;
+
+#ifndef OVER_TIZEN_VERSION_9
+  size_t   mOutputWidth;
+  size_t   mOutputHeight;
+  size_t   mOutputStride;
+  uint8_t* mOutputBuffer;
+
+  pthread_mutex_t mOutputBufferMutex;
+  tbm_surface_h   mTbmSurface;
+
+  std::function<void(LWE::WebContainer*, const LWE::WebContainer::RenderResult&)> mOnRenderedHandler;
+
+  EventThreadCallback mUpdateBufferTrigger;
+#endif
 
   std::function<void(LWE::WebContainer*, LWE::ResourceError)> mOnReceivedError;
   std::function<void(LWE::WebContainer*, const std::string&)> mOnPageFinishedHandler;
   std::function<void(LWE::WebContainer*, const std::string&)> mOnPageStartedHandler;
   std::function<void(LWE::WebContainer*, const std::string&)> mOnLoadResourceHandler;
 
-  LWE::WebContainer*             mWebContainer;
-  Dali::NativeImageSourcePtr     mDaliImageSrc;
-
-  EGLNativeDisplayType           mNativeDisplay;
-  EGLDisplay                     mEglDisplay;
-  EGLConfig                      mEglConfig;
-  EGLSurface                     mEglSurface;
-  EGLContext                     mEglContext;
-  EGLSyncKHR                     mEglSync;
-
-  tbm_surface_queue_h            mTbmQueue;
-  tbm_surface_h                  mLastDrawnTbmSurface;
-  tbm_surface_h                  mIdleTbmSurface;
-
-  std::function<void ()>         mLWERenderingFunction;
-  std::atomic_bool               mLWERenderingRequested;
-  std::atomic_bool               mInImageUpdateState;
-  std::atomic_bool               mInIdleState;
-  std::atomic_bool               mFirstRenderEnded;
-  Dali::Signal<void ()>          mFirstRenderSignal;
+  LWE::WebContainer*         mWebContainer;
+  Dali::NativeImageSourcePtr mDaliImageSrc;
+
+  EGLNativeDisplayType mNativeDisplay;
+  EGLDisplay           mEglDisplay;
+  EGLConfig            mEglConfig;
+  EGLSurface           mEglSurface;
+  EGLContext           mEglContext;
+  EGLSyncKHR           mEglSync;
+
+  tbm_surface_queue_h mTbmQueue;
+  tbm_surface_h       mLastDrawnTbmSurface;
+  tbm_surface_h       mIdleTbmSurface;
+
+  std::function<void()> mLWERenderingFunction;
+  std::atomic_bool      mLWERenderingRequested;
+  std::atomic_bool      mInImageUpdateState;
+  std::atomic_bool      mInIdleState;
+  std::atomic_bool      mFirstRenderEnded;
+  Dali::Signal<void()>  mFirstRenderSignal;
 
   WebEngineFrameRenderedCallback mFrameRenderedCallback;
   WebEnginePageLoadCallback      mLoadStartedCallback;
index f31d7a7673b1d549c7fc199d6806999cffa7359b..cf9555f5f837f22c815ebda23f59b0f7eca81805 100755 (executable)
@@ -30,6 +30,10 @@ Source0:    %{name}-%{version}.tar.gz
 %define tizen_65_or_greater 1
 %endif
 
+%if 0%{?tizen_version_major} >= 9
+%define tizen_90_or_greater 1
+%endif
+
 %if %{undefined NO_WEB_FRAMEWORK}
 %define enable_web_engine_plugin 1
 %endif
@@ -100,14 +104,17 @@ Summary:    Plugin to play a video file for Dali
 Group:      System/Libraries
 BuildRequires: pkgconfig(capi-media-player)
 BuildRequires: pkgconfig(capi-system-info)
-BuildRequires: pkgconfig(wayland-egl)
 # dali-adaptor uses ecore mainloop
-%if 0%{?tizen_version_major} >= 5
+%if 0%{?tizen_50_or_greater}
 BuildRequires:  pkgconfig(ecore-wl2)
 %else
 BuildRequires:  pkgconfig(ecore-wayland)
 %endif
 
+%if 0%{?tizen_90_or_greater}
+BuildRequires: pkgconfig(wayland-egl)
+%endif
+
 %description video-player-plugin
 VideoPlayer plugin to play a video file for Dali
 
@@ -236,7 +243,7 @@ PREFIX+="/usr"
 CXXFLAGS+=" -Wall -g -Os -fPIC -fvisibility-inlines-hidden -fdata-sections -ffunction-sections -DGL_GLEXT_PROTOTYPES"
 LDFLAGS+=" -Wl,--rpath=%{_libdir} -Wl,--as-needed -Wl,--gc-sections -Wl,-Bsymbolic-functions "
 
-%if 0%{?tizen_version_major} >= 5
+%if 0%{?tizen_50_or_greater}
 CFLAGS+=" -DECORE_WL2 -DEFL_BETA_API_SUPPORT"
 CXXFLAGS+=" -DECORE_WL2 -DEFL_BETA_API_SUPPORT"
 configure_flags="--enable-ecore-wl2"
@@ -270,6 +277,9 @@ autoreconf --install
 %if 0%{?tizen_65_or_greater}
            --with-tizen-65-or-greater \
 %endif
+%if 0%{?tizen_90_or_greater}
+           --with-tizen-90-or-greater \
+%endif
 %if 0%{?enable_web_engine_plugin} == 1
            --enable-web-engine-plugin \
 %endif