X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fvideo-view%2Fvideo-view-impl.cpp;h=85b219e5a2408b34d2946cb8d5095fb5e6f01627;hp=7cfa65681eb363e2598e558010fec5961343ea78;hb=HEAD;hpb=9e5047cc2a965c85345363af3b511bcf6234b887 diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index 7cfa656..5fa13de 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include #include @@ -83,6 +84,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 +94,8 @@ VideoView::VideoView(Dali::VideoSyncMode syncMode) mFrameID(0), mIsPlay(false), mIsUnderlay(true), - mSyncMode(syncMode) + mSyncMode(syncMode), + mSiblingOrder(0) { } @@ -111,12 +115,15 @@ Toolkit::VideoView VideoView::New(VideoSyncMode syncMode) void VideoView::OnInitialize() { + Actor self = Self(); mVideoPlayer.FinishedSignal().Connect(this, &VideoView::EmitSignalFinish); - DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) { - return std::unique_ptr( - new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::VIDEO)); - }); + // Accessibility + self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::VIDEO); + self.SetProperty(DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); + + //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(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(Dali::DevelActor::Property::SIBLING_ORDER); + if(currentSiblingOrder != mSiblingOrder) + { + Actor parent = self.GetParent(); + Actor child; + Actor upper; + Actor lower; + + int numChildren = static_cast(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; @@ -543,30 +604,6 @@ Vector3 VideoView::GetNaturalSize() } } -float VideoView::GetHeightForWidth(float width) -{ - if(mVideoSize.GetWidth() > 0 && mVideoSize.GetHeight() > 0) - { - return GetHeightForWidthBase(width); - } - else - { - return Control::GetHeightForWidthBase(width); - } -} - -float VideoView::GetWidthForHeight(float height) -{ - if(mVideoSize.GetWidth() > 0 && mVideoSize.GetHeight() > 0) - { - return GetWidthForHeightBase(height); - } - else - { - return Control::GetWidthForHeightBase(height); - } -} - void VideoView::SetWindowSurfaceTarget() { Actor self = Self(); @@ -608,7 +645,7 @@ void VideoView::SetWindowSurfaceTarget() { // For underlay rendering mode, video display area have to be transparent. Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); - Shader shader = Shader::New(SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG); + Shader shader = Shader::New(SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG, Shader::Hint::NONE, "VIDEO_VIEW_OVERLAY"); mOverlayRenderer = Renderer::New(geometry, shader); mOverlayRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF); } @@ -808,7 +845,7 @@ void VideoView::PlayAnimation(Dali::Animation animation) Dali::Shader VideoView::CreateShader() { - std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; + std::string fragmentShader; std::string vertexShader; std::string customFragmentShader; bool checkShader = false; @@ -839,16 +876,18 @@ Dali::Shader VideoView::CreateShader() if(!fragmentShaderValue || !checkShader) { - fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data(); + fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data(); + DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader); } } else { - vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data(); - fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data(); + vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data(); + fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data(); + DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader); } - return Dali::Shader::New(vertexShader, fragmentShader); + return Dali::Shader::New(vertexShader, fragmentShader, Shader::Hint::NONE, "VIDEO_VIEW"); } bool VideoView::GetStringFromProperty(const Dali::Property::Value& value, std::string& output) @@ -893,6 +932,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(propertyIsVideoView); + } + } + + return isVideoView; +} + +VideoPlayer VideoView::GetVideoPlayer() +{ + return mVideoPlayer; +} + } // namespace Internal } // namespace Toolkit