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=0dd7e1ca0661be279a9595aafa38ffb08c7e1f4b;hp=51bf9a2e0e76e5e6cf318dcdb2ea72753ca5bf1a;hb=79a69ab0b206ee0464a624077062e72f437bad98;hpb=ccd53048e482f41b00ad1daa7664b3781d6b7626 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 51bf9a2..0dd7e1c 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) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -29,7 +29,10 @@ // INTERNAL INCLUDES #include -#include +#include +#include +#include +#include namespace Dali { @@ -67,7 +70,7 @@ DALI_TYPE_REGISTRATION_END() const char* const VOLUME_LEFT( "volumeLeft" ); const char* const VOLUME_RIGHT( "volumeRight" ); -const char* const RENDERING_TARGET( "RENDERING_TARGET" ); +const char* const RENDERING_TARGET( "renderingTarget" ); const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" ); const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" ); @@ -76,7 +79,7 @@ const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" ); VideoView::VideoView() : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ), mCurrentVideoPlayPosition( 0 ), - mSetRenderingTarget( false ), + mIsNativeImageTarget( true ), mIsPlay( false ), mIsPause( false ) { @@ -97,23 +100,31 @@ Toolkit::VideoView VideoView::New() return handle; } +void VideoView::OnInitialize() +{ + Any source; + Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source ); + mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr ); + + mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr ); + mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); +} + void VideoView::SetUrl( const std::string& url ) { if( mUrl != url || !mPropertyMap.Empty() ) { - mPropertyMap.Clear(); - mUrl = url; + mPropertyMap.Clear(); } - if( mSetRenderingTarget ) - { - mVideoPlayer.SetUrl( mUrl ); - } - else + if( mIsNativeImageTarget ) { - SetNativeImageTarget(); + Actor self( Self() ); + Internal::InitializeVisual( self, mVisual, mNativeImage ); } + + mVideoPlayer.SetUrl( mUrl ); } void VideoView::SetPropertyMap( Property::Map map ) @@ -143,6 +154,18 @@ void VideoView::SetPropertyMap( Property::Map map ) } } + Property::Value* target = map.Find( RENDERING_TARGET ); + std::string targetType; + + if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET ) + { + this->SetWindowSurfaceTarget(); + } + else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET ) + { + this->SetNativeImageTarget(); + } + RelayoutRequest(); } @@ -319,25 +342,33 @@ void VideoView::SetProperty( BaseObject* object, Property::Index index, const Pr case Toolkit::VideoView::Property::VIDEO: { std::string videoUrl; + Property::Map map; + if( value.Get( videoUrl ) ) { impl.SetUrl( videoUrl ); } - - Property::Map map; - if( value.Get( map ) ) + else if( value.Get( map ) ) { - impl.SetPropertyMap( map ); + Property::Value* shaderValue = map.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER ); - Property::Value* target = map.Find( RENDERING_TARGET ); - std::string targetType; - if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET ) + if( map.Count() > 1u || !shaderValue ) { - impl.SetWindowSurfaceTarget(); + impl.SetPropertyMap( map ); } - else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET ) + else if( impl.mVisual && map.Count() == 1u && shaderValue ) { - impl.SetNativeImageTarget(); + Property::Map shaderMap; + if( shaderValue->Get( shaderMap ) ) + { + Internal::Visual::Base& visual = Toolkit::GetImplementation( impl.mVisual ); + visual.SetCustomShader( shaderMap ); + if( videoView.OnStage() ) + { + visual.SetOffStage( videoView ); + visual.SetOnStage( videoView ); + } + } } } break; @@ -439,13 +470,13 @@ void VideoView::SetDepthIndex( int depthIndex ) void VideoView::OnStageConnection( int depth ) { - Control::OnStageConnection( depth ); - if( mVisual ) { CustomActor self = Self(); Toolkit::GetImplementation(mVisual).SetOnStage( self ); } + + Control::OnStageConnection( depth ); } void VideoView::OnStageDisconnection() @@ -505,8 +536,6 @@ void VideoView::SetWindowSurfaceTarget() Actor self = Self(); int curPos = mVideoPlayer.GetPlayPosition(); - mSetRenderingTarget = true; - if( mVisual ) { Toolkit::GetImplementation(mVisual).SetOffStage(self); @@ -515,7 +544,8 @@ void VideoView::SetWindowSurfaceTarget() mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); mVideoPlayer.SetUrl( mUrl ); - mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); + + mIsNativeImageTarget = false; if( mIsPlay ) { @@ -534,17 +564,15 @@ void VideoView::SetNativeImageTarget() Actor self( Self() ); int curPos = mVideoPlayer.GetPlayPosition(); - mSetRenderingTarget = true; - Any source; Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source ); mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr ); mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr ); mVideoPlayer.SetUrl( mUrl ); - mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); Internal::InitializeVisual( self, mVisual, mNativeImage ); + mIsNativeImageTarget = true; if( mIsPlay ) {