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=181a47e8519d4ddc95a9a08d452b18851bca19e1;hp=5608105a3361ee7ce6aa0c62190e8030862ce96b;hb=2e42ad28cef7d57f759a489710d1f46016fbe3da;hpb=e75380e149afca3f36217c727b9d5eb52a6d49ff 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 5608105..181a47e 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -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,19 @@ 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( new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::VIDEO)); }); + + //Enable highightability + Self().SetProperty(Toolkit::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 +514,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 +540,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; @@ -577,6 +642,9 @@ void VideoView::SetWindowSurfaceTarget() return; } + Dali::Window window = DevelWindow::Get(self); + window.ResizeSignal().Connect(this, &VideoView::OnWindowResized); + int curPos = mVideoPlayer.GetPlayPosition(); if(mIsPlay) @@ -782,6 +850,17 @@ void VideoView::OnAnimationFinished(Animation& animation) SetFrameRenderCallback(); } +void VideoView::OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size) +{ + Dali::VideoPlayerPlugin::DisplayRotation videoAngle = mVideoPlayer.GetDisplayRotation(); + int windowAngle = (DevelWindow::GetPhysicalOrientation(winHandle) / 90); + + if(windowAngle != videoAngle) + { + mVideoPlayer.SetDisplayRotation(static_cast(windowAngle)); + } +} + void VideoView::PlayAnimation(Dali::Animation animation) { if(mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED) @@ -794,7 +873,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; @@ -825,13 +904,15 @@ 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); @@ -879,6 +960,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