X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fvideo-view%2Fvideo-view-impl.cpp;h=b09de6be8f20fa8d40d494b97ba5138e6c106040;hb=3a23cbcd64ab5780928e4a141e497242c9989110;hp=0dd7e1ca0661be279a9595aafa38ffb08c7e1f4b;hpb=79a69ab0b206ee0464a624077062e72f437bad98;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 0dd7e1c..b09de6b 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include // INTERNAL INCLUDES #include @@ -33,6 +36,8 @@ #include #include #include +#include +#include namespace Dali { @@ -74,20 +79,72 @@ const char* const RENDERING_TARGET( "renderingTarget" ); const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" ); const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" ); +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( + attribute mediump vec2 aPosition;\n + uniform mediump mat4 uMvpMatrix;\n + uniform mediump vec3 uSize;\n + \n + void main()\n + {\n + mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n + vertexPosition.xyz *= uSize;\n + gl_Position = uMvpMatrix * vertexPosition;\n + }\n +); + +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( + uniform lowp vec4 uColor;\n + uniform lowp vec3 mixColor;\n + uniform lowp float opacity;\n + \n + void main()\n + {\n + gl_FragColor = vec4(mixColor, opacity)*uColor;\n + }\n +); + +struct TriggerFunctor +{ + TriggerFunctor( TriggerEventInterface* notification ) + : mNotification( notification ) + { + } + + void operator()( bool& current, const PropertyInputContainer& inputs ) + { + if( mNotification != NULL ) + { + mNotification->Trigger(); + } + } + + TriggerEventInterface* mNotification; +}; + } // anonymous namepsace VideoView::VideoView() : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ), + mUpdateTriggerPropertyIndex( Property::INVALID_INDEX), + mNotification( NULL ), mCurrentVideoPlayPosition( 0 ), mIsNativeImageTarget( true ), mIsPlay( false ), mIsPause( false ) { mVideoPlayer = Dali::VideoPlayer::New(); + + TriggerEventFactory triggerEventFactory; + mNotification = triggerEventFactory.CreateTriggerEvent( MakeCallback(this, &VideoView::UpdateDisplayArea ), + TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER); } VideoView::~VideoView() { + if( mNotification != NULL ) + { + delete mNotification; + } } Toolkit::VideoView VideoView::New() @@ -108,6 +165,8 @@ void VideoView::OnInitialize() mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr ); mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); + + mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true ); } void VideoView::SetUrl( const std::string& url ) @@ -542,6 +601,11 @@ void VideoView::SetWindowSurfaceTarget() mVisual.Reset(); } + Constraint constraint = Constraint::New( self, mUpdateTriggerPropertyIndex, TriggerFunctor( mNotification ) ); + constraint.AddSource( Source( self, Actor::Property::POSITION ) ); + constraint.AddSource( Source( self, Actor::Property::SIZE ) ); + constraint.Apply(); + mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); mVideoPlayer.SetUrl( mUrl ); @@ -557,6 +621,18 @@ void VideoView::SetWindowSurfaceTarget() mVideoPlayer.Pause(); } mVideoPlayer.SetPlayPosition( curPos ); + + // For underlay rendering mode, video display area have to be transparent. + Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); + Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + Renderer renderer = Renderer::New( geometry, shader ); + + renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); + renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE ); + renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO ); + renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE ); + renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO ); + self.AddRenderer( renderer ); } void VideoView::SetNativeImageTarget() @@ -587,8 +663,26 @@ void VideoView::SetNativeImageTarget() mVideoPlayer.SetPlayPosition( curPos ); } +void VideoView::UpdateDisplayArea() +{ + Actor self( Self() ); + + bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >(); + Vector3 actorSize = self.GetCurrentSize() * self.GetCurrentScale(); + Vector3 anchorPointOffSet = actorSize * ( positionUsesAnchorPoint ? self.GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT ); + + Vector2 screenPosition = self.GetProperty( DevelActor::Property::SCREEN_POSITION ).Get< Vector2 >(); + + mDisplayArea.x = screenPosition.x - anchorPointOffSet.x; + mDisplayArea.y = screenPosition.y - anchorPointOffSet.y; + mDisplayArea.width = actorSize.x; + mDisplayArea.height = actorSize.y; + + mVideoPlayer.SetDisplayArea( mDisplayArea ); +} + } // namespace Internal -} // namespace Toolkit +} // namespace toolkit } // namespace Dali