From: taeyoon0.lee Date: Tue, 19 Sep 2017 15:11:51 +0000 (+0900) Subject: Added underlay property X-Git-Tag: dali_1.2.62~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=37aeb39702c4a2de4fb14763e4ba6e2b94bb53de Added underlay property default is underlay video rendering Change-Id: I2b9656b3ded88bfd2306bd05bea734add74df503 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp index 034e416..ce17641 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp @@ -87,6 +87,8 @@ std::string Application::GetResourcePath() //////////////////////////////////////////////////////////////////////////////////////////////////// +bool ToolkitApplication::DECODED_IMAGES_SUPPORTED; + ToolkitApplication::ToolkitApplication() : mApplicationStub(new Application(*this)) { diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h index 7178b68..584a38c 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h @@ -85,6 +85,9 @@ private: // The Application Stub Application* mApplicationStub; friend class Application; + +public: // Test static member + static bool DECODED_IMAGES_SUPPORTED; }; } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp index eee723b..09cc438 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp @@ -15,11 +15,10 @@ * */ -// CLASS HEADER -#include "toolkit-video-player.h" - -// EXTERNAL INCLUDES +#include #include +#include +#include namespace Dali { @@ -226,5 +225,10 @@ void VideoPlayer::Backward( int millisecond ) { } +bool VideoPlayer::IsVideoTextureSupported() const +{ + return ToolkitApplication::DECODED_IMAGES_SUPPORTED; +} + } // namespace Dali; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.h deleted file mode 100644 index 199fa12..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef __DALI_TOOLKIT_VIDEO_PLAYER_H__ -#define __DALI_TOOLKIT_VIDEO_PLAYER_H__ - -/* - * Copyright (c) 2016 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -#include - -namespace Dali -{ - -class Any; - -namespace Internal -{ -namespace Adaptor -{ - -class VideoPlayer; - -} -} - -/** - * @brief VideoPlayer class is used for video playback. - * @SINCE_1_1.38 - */ -class VideoPlayer: public BaseHandle -{ -public: - - VideoPlayer(); - - ~VideoPlayer(); - - static VideoPlayer New(); - - VideoPlayer( const VideoPlayer& player ); - - VideoPlayer& operator=( const VideoPlayer& player ); - - static VideoPlayer DownCast( BaseHandle handle ); - - void SetUrl( const std::string& url ); - - std::string GetUrl(); - - void SetLooping(bool looping); - - bool IsLooping(); - - void Play(); - - void Pause(); - - void Stop(); - - void SetMute( bool mute ); - - bool IsMuted(); - - void SetVolume( float left, float right ); - - void GetVolume( float& left, float& right ); - - void SetRenderingTarget( Any target ); - - void SetPlayPosition( int millisecond ); - - int GetPlayPosition(); - - void SetDisplayArea( DisplayArea area ); - - void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation ); - - Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation(); - - Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal(); - - void Forward( int millisecond ); - - void Backward( int millisecond ); - -private: - - VideoPlayer( Internal::Adaptor::VideoPlayer* internal ); - -}; - -} // namespace Dali; - -#endif diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 884efc4..30a7e8c 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -405,3 +405,38 @@ int UtcDaliVideoViewMethodsForCoverage2(void) END_TEST; } + +int UtcDaliVideoViewPropertyUnderlay(void) +{ + ToolkitTestApplication application; + ToolkitApplication::DECODED_IMAGES_SUPPORTED = true; + + VideoView view = VideoView::New(); + DALI_TEST_CHECK( view ); + + Stage::GetCurrent().Add( view ); + + application.SendNotification(); + application.Render(); + + bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( isUnderlay ); + + view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false ); + isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( !isUnderlay ); + + view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true ); + isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( isUnderlay ); + + // If platform api doesn't provide any API or feature for decoded images of video, + // UNDERLAY should be true + ToolkitApplication::DECODED_IMAGES_SUPPORTED = false; + + view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false ); + isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( isUnderlay ); + + END_TEST; +} 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 2fdb70b..5834950 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -62,6 +62,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "video", MAP, VIDEO ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME ) +DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY ) DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL ) @@ -75,6 +76,8 @@ DALI_TYPE_REGISTRATION_END() const char* const VOLUME_LEFT( "volumeLeft" ); const char* const VOLUME_RIGHT( "volumeRight" ); + +// 3.0 TC uses RENDERING_TARGET. It should be removed in next release const char* const RENDERING_TARGET( "renderingTarget" ); const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" ); const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" ); @@ -128,9 +131,9 @@ VideoView::VideoView() mUpdateTriggerPropertyIndex( Property::INVALID_INDEX), mNotification( NULL ), mCurrentVideoPlayPosition( 0 ), - mIsNativeImageTarget( true ), mIsPlay( false ), - mIsPause( false ) + mIsPause( false ), + mIsUnderlay( true ) { mVideoPlayer = Dali::VideoPlayer::New(); @@ -159,14 +162,9 @@ Toolkit::VideoView VideoView::New() 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 ); - mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true ); + mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); + SetWindowSurfaceTarget(); } void VideoView::SetUrl( const std::string& url ) @@ -177,7 +175,7 @@ void VideoView::SetUrl( const std::string& url ) mPropertyMap.Clear(); } - if( mIsNativeImageTarget ) + if( !mIsUnderlay ) { Actor self( Self() ); Internal::InitializeVisual( self, mVisual, mNativeImage ); @@ -218,11 +216,13 @@ void VideoView::SetPropertyMap( Property::Map map ) if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET ) { - this->SetWindowSurfaceTarget(); + mIsUnderlay = true; + SetWindowSurfaceTarget(); } else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET ) { - this->SetNativeImageTarget(); + mIsUnderlay = false; + SetNativeImageTarget(); } RelayoutRequest(); @@ -465,6 +465,15 @@ void VideoView::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::VideoView::Property::UNDERLAY: + { + bool underlay; + if( value.Get( underlay ) ) + { + impl.SetUnderlay( underlay ); + } + break; + } } } } @@ -513,6 +522,11 @@ Property::Value VideoView::GetProperty( BaseObject* object, Property::Index prop value = map; break; } + case Toolkit::VideoView::Property::UNDERLAY: + { + value = impl.IsUnderlay(); + break; + } } } @@ -609,7 +623,22 @@ void VideoView::SetWindowSurfaceTarget() mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); mVideoPlayer.SetUrl( mUrl ); - mIsNativeImageTarget = false; + if( !mRenderer ) + { + // For underlay rendering mode, video display area have to be transparent. + Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); + Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + mRenderer = Renderer::New( geometry, shader ); + + mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO ); + } + self.AddRenderer( mRenderer ); + + UpdateDisplayArea(); if( mIsPlay ) { @@ -625,22 +654,17 @@ void VideoView::SetWindowSurfaceTarget() { 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() { + if( mVideoPlayer.IsVideoTextureSupported() == false ) + { + DALI_LOG_ERROR( "Platform doesn't support decoded video frame images\n" ); + mIsUnderlay = true; + return; + } + Actor self( Self() ); int curPos = mVideoPlayer.GetPlayPosition(); @@ -652,7 +676,7 @@ void VideoView::SetNativeImageTarget() mVideoPlayer.SetUrl( mUrl ); Internal::InitializeVisual( self, mVisual, mNativeImage ); - mIsNativeImageTarget = true; + Self().RemoveRenderer( mRenderer ); if( mIsPlay ) { @@ -672,6 +696,11 @@ void VideoView::SetNativeImageTarget() void VideoView::UpdateDisplayArea() { + if( !mIsUnderlay ) + { + return; + } + Actor self( Self() ); bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >(); @@ -688,6 +717,28 @@ void VideoView::UpdateDisplayArea() mVideoPlayer.SetDisplayArea( mDisplayArea ); } +void VideoView::SetUnderlay( bool set ) +{ + if( set != mIsUnderlay ) + { + mIsUnderlay = set; + + if( mIsUnderlay ) + { + SetWindowSurfaceTarget(); + } + else + { + SetNativeImageTarget(); + } + } +} + +bool VideoView::IsUnderlay() +{ + return mIsUnderlay; +} + } // namespace Internal } // namespace toolkit diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.h b/dali-toolkit/internal/controls/video-view/video-view-impl.h index 130d2c2..d5a498a 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.h +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.h @@ -207,11 +207,21 @@ public: */ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); - /* + /** * @brief Updates video display area for window rendering target */ void UpdateDisplayArea(); + /** + * @brief Sets underlay flag and initializes new rendering target by flag. + */ + void SetUnderlay( bool set ); + + /** + * @brief Checks underlay flag. + */ + bool IsUnderlay(); + private: // From Control /** @@ -265,14 +275,15 @@ private: Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal; std::string mUrl; Dali::DisplayArea mDisplayArea; + Dali::Renderer mRenderer; Property::Index mUpdateTriggerPropertyIndex; TriggerEventInterface* mNotification; int mCurrentVideoPlayPosition; - bool mIsNativeImageTarget; bool mIsPlay; bool mIsPause; + bool mIsUnderlay; }; } // namespace Internal diff --git a/dali-toolkit/public-api/controls/video-view/video-view.h b/dali-toolkit/public-api/controls/video-view/video-view.h index d6a9bdf..154d93e 100644 --- a/dali-toolkit/public-api/controls/video-view/video-view.h +++ b/dali-toolkit/public-api/controls/video-view/video-view.h @@ -66,6 +66,8 @@ public: // Signal typedef Signal< void (VideoView&) > VideoViewSignalType; ///< Video playback finished signal type @ SINCE_1_1.38 +public: + /** * @brief Enumeration for the start and end property ranges for this control. * @SINCE_1_0.0 @@ -101,7 +103,16 @@ public: * @brief name "volume", left and right volume scalar as float type, Property::Map with two values ( "left" and "right" ). * @SINCE_1_1.38 */ - VOLUME + VOLUME, + + /** + * @brief name "underlay", Video rendering by underlay, true or false + * This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view + * If false, video-view shows decoded frame images sequentially. + * If Platform or video plugin doesn't support decoded frame images, this should always be true. + * @SINCE_1_2.62 + */ + UNDERLAY }; };