Support the synchronization of changing the video player's z-order 20/254420/17
authorWonsik Jung <sidein@samsung.com>
Sat, 27 Feb 2021 13:25:11 +0000 (22:25 +0900)
committerWonsik Jung <sidein@samsung.com>
Wed, 24 Mar 2021 02:25:21 +0000 (11:25 +0900)
If one video view moves the other above or below,
video player's z-order should be changed.
This patch is for supporting that.

Change-Id: I38009d93616d2ef225366d88864e9742b5846e6f

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp
automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.h

index 4a5e76c..9909164 100755 (executable)
@@ -109,6 +109,26 @@ public:
 
   }
 
+  void RaiseAbove(Dali::VideoPlayer target)
+  {
+
+  }
+
+  void LowerBelow(Dali::VideoPlayer target)
+  {
+
+  }
+
+  void RaiseToTop()
+  {
+
+  }
+
+  void LowerToBottom()
+  {
+
+  }
+
 public:
 
   std::string mUrl;
@@ -325,5 +345,25 @@ void VideoPlayer::FinishSynchronization()
   Internal::Adaptor::GetImplementation( *this ).FinishSynchronization();
 }
 
+void VideoPlayer::RaiseAbove(Dali::VideoPlayer target)
+{
+  Internal::Adaptor::GetImplementation( *this ).RaiseAbove(target);
+}
+
+void VideoPlayer::LowerBelow(Dali::VideoPlayer target)
+{
+  Internal::Adaptor::GetImplementation( *this ).LowerBelow(target);
+}
+
+void VideoPlayer::RaiseToTop()
+{
+  Internal::Adaptor::GetImplementation( *this ).RaiseToTop();
+}
+
+void VideoPlayer::LowerToBottom()
+{
+  Internal::Adaptor::GetImplementation( *this ).LowerToBottom();
+}
+
 } // namespace Dali;
 
index e8adb89..9a77bba 100644 (file)
@@ -560,6 +560,65 @@ int UtcDaliVideoViewNew2(void)
   END_TEST;
 }
 
+int UtcDaliVideoViewRaiseAboveLowerBelow(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewRaiseAboveLowerBelow");
+
+  VideoView view = VideoView::New( true );
+  DALI_TEST_CHECK( view );
+
+  application.GetScene().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  VideoView view2 = VideoView::New( "", false );
+  DALI_TEST_CHECK( view2 );
+
+  application.GetScene().Add( view2 );
+  view2.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  view.RaiseAbove(view2);
+  view.LowerBelow(view2);
+
+  END_TEST;
+}
+
+int UtcDaliVideoViewRaiseTopLowerBottom(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewRaiseTopLowerBottom");
+
+  VideoView view = VideoView::New( true );
+  DALI_TEST_CHECK( view );
+
+  application.GetScene().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  VideoView view2 = VideoView::New( "", false );
+  DALI_TEST_CHECK( view2 );
+
+  application.GetScene().Add( view2 );
+  view2.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  view.RaiseToTop();
+  view.LowerToBottom();
+
+  END_TEST;
+}
+
+
 int UtcDaliVideoViewPropertyDisplayMode(void)
 {
   ToolkitTestApplication application;
index 7cfa656..85b219e 100644 (file)
@@ -83,6 +83,8 @@ const char* const CUSTOM_FRAGMENT_SHADER("fragmentShader");
 const char* const DEFAULT_SAMPLER_TYPE_NAME("sampler2D");
 const char* const CUSTOM_SAMPLER_TYPE_NAME("samplerExternalOES");
 
+const char* const IS_VIDEO_VIEW_PROPERTY_NAME = "isVideoView";
+
 } // namespace
 
 VideoView::VideoView(Dali::VideoSyncMode syncMode)
@@ -91,7 +93,8 @@ VideoView::VideoView(Dali::VideoSyncMode syncMode)
   mFrameID(0),
   mIsPlay(false),
   mIsUnderlay(true),
-  mSyncMode(syncMode)
+  mSyncMode(syncMode),
+  mSiblingOrder(0)
 {
 }
 
@@ -111,12 +114,16 @@ Toolkit::VideoView VideoView::New(VideoSyncMode syncMode)
 
 void VideoView::OnInitialize()
 {
+  Actor self = Self();
   mVideoPlayer.FinishedSignal().Connect(this, &VideoView::EmitSignalFinish);
 
-  DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
+  DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
     return std::unique_ptr<Dali::Accessibility::Accessible>(
       new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::VIDEO));
   });
+
+  //update self property
+  self.RegisterProperty(IS_VIDEO_VIEW_PROPERTY_NAME, true, Property::READ_WRITE);
 }
 
 void VideoView::SetUrl(const std::string& url)
@@ -503,12 +510,15 @@ void VideoView::SetDepthIndex(int depthIndex)
 
 void VideoView::OnSceneConnection(int depth)
 {
-  Control::OnSceneConnection(depth);
-
+  Actor self = Self();
   if(mIsUnderlay)
   {
+    mSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+    DevelActor::ChildOrderChangedSignal(self.GetParent()).Connect(this, &VideoView::OnChildOrderChanged);
     SetWindowSurfaceTarget();
   }
+
+  Control::OnSceneConnection(depth);
 }
 
 void VideoView::OnSceneDisconnection()
@@ -526,6 +536,57 @@ void VideoView::OnSizeSet(const Vector3& targetSize)
   Control::OnSizeSet(targetSize);
 }
 
+void VideoView::OnChildOrderChanged(Actor actor)
+{
+  Actor self                = Self();
+  int   currentSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+  if(currentSiblingOrder != mSiblingOrder)
+  {
+    Actor parent = self.GetParent();
+    Actor child;
+    Actor upper;
+    Actor lower;
+
+    int numChildren = static_cast<int>(parent.GetChildCount());
+    for(int i = 0; i < numChildren; i++)
+    {
+      child = parent.GetChildAt(i);
+      if(!IsVideoView(child))
+      {
+        continue;
+      }
+
+      if(child == self)
+      {
+        continue;
+      }
+
+      if(i < currentSiblingOrder)
+      {
+        lower = child;
+      }
+      else if(i > currentSiblingOrder)
+      {
+        upper = child;
+        break;
+      }
+    }
+
+    if(lower)
+    {
+      Toolkit::VideoView lowerView = Toolkit::VideoView::DownCast(lower);
+      mVideoPlayer.RaiseAbove(GetImpl(lowerView).GetVideoPlayer());
+    }
+
+    if(upper)
+    {
+      Toolkit::VideoView upperView = Toolkit::VideoView::DownCast(upper);
+      mVideoPlayer.LowerBelow(GetImpl(upperView).GetVideoPlayer());
+    }
+    mSiblingOrder = currentSiblingOrder;
+  }
+}
+
 Vector3 VideoView::GetNaturalSize()
 {
   Vector3 size;
@@ -893,6 +954,28 @@ void VideoView::SetFrameRenderCallback()
                                         mFrameID);
 }
 
+bool VideoView::IsVideoView(Actor actor) const
+{
+  // Check whether the actor is a VideoView
+  bool isVideoView = false;
+
+  if(actor)
+  {
+    Property::Index propertyIsVideoView = actor.GetPropertyIndex(IS_VIDEO_VIEW_PROPERTY_NAME);
+    if(propertyIsVideoView != Property::INVALID_INDEX)
+    {
+      isVideoView = actor.GetProperty<bool>(propertyIsVideoView);
+    }
+  }
+
+  return isVideoView;
+}
+
+VideoPlayer VideoView::GetVideoPlayer()
+{
+  return mVideoPlayer;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 363cb9d..d1605ce 100644 (file)
@@ -263,6 +263,21 @@ public:
    */
   void PlayAnimation(Dali::Animation animation);
 
+  /**
+   * @brief Checks whether the actor is set as a video view or not.
+   *
+   * @param[in] actor The actor to be checked
+   * @return True if actor is video view.
+   */
+  bool IsVideoView(Actor actor) const;
+
+  /**
+   * @brief Gets the Video Player.
+   *
+   * @return The return of video player.
+   */
+  VideoPlayer GetVideoPlayer();
+
 private: // From Control
   /**
    * @copydoc Toolkit::Control::OnInitialize()
@@ -375,6 +390,13 @@ private:
    */
   void OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size);
 
+  /**
+   * @brief This signal is emitted when an actor's children change their sibling order
+   *
+   * @param[in] actor parent actor.
+   */
+  void OnChildOrderChanged(Actor actor);
+
 private:
   Dali::VideoPlayer     mVideoPlayer;
   Dali::ImageDimensions mVideoSize;
@@ -402,6 +424,7 @@ private:
   bool mIsUnderlay;
 
   Dali::VideoSyncMode mSyncMode;
+  int                 mSiblingOrder;
 };
 
 } // namespace Internal