From ebff9233f12c27457984dc08581f51ba8a102d23 Mon Sep 17 00:00:00 2001 From: taeyoon Date: Fri, 9 Sep 2016 19:09:40 +0900 Subject: [PATCH] Modified video view impl by considering visual - modified rendering target and custom shader Change-Id: I3f0d1082f4e210f23a2aec0524016bbc08b38ff5 --- .../src/dali-toolkit/utc-Dali-VideoView.cpp | 53 ++++++++++++++++++++++ .../controls/video-view/video-view-impl.cpp | 44 ++++++++++++++---- 2 files changed, 87 insertions(+), 10 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 983ac77..d082f07 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -31,6 +31,34 @@ const char* const VOLUME_LEFT( "volumeLeft" ); const char* const VOLUME_RIGHT( "volumeRight" ); const char* const RENDERING_TYPE( "renderingTarget" ); +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( + attribute mediump vec2 aPosition;\n + varying mediump vec2 vTexCoord;\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 + vertexPosition = uMvpMatrix * vertexPosition;\n + \n + vTexCoord = aPosition + vec2(0.5);\n + gl_Position = vertexPosition;\n + }\n +); + +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( + varying mediump vec2 vTexCoord;\n + uniform sampler2D sTexture;\n + uniform lowp vec4 uColor;\n + \n + void main()\n + {\n + gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n + }\n +); + } void video_view_startup(void) @@ -312,3 +340,28 @@ int UtcDaliVideoViewMethodsForRenderType(void) END_TEST; } + +int UtcDaliVideoViewCustomShaderForCoverage(void) +{ + ToolkitTestApplication application; + VideoView videoView = VideoView::New(); + DALI_TEST_CHECK( videoView ); + Stage::GetCurrent().Add( videoView ); + videoView.SetProperty( VideoView::Property::VIDEO, "testvideo" ); + + Property::Map customShader; + customShader.Insert( "vertexShader", VERTEX_SHADER ); + customShader.Insert( "fragmentShader", FRAGMENT_SHADER ); + + Property::Map map; + map.Insert( "shader", customShader ); + + videoView.SetProperty( VideoView::Property::VIDEO, map ); + + Property::Map map2; + Property::Value value = videoView.GetProperty( VideoView::Property::VIDEO ); + + DALI_TEST_CHECK( !value.Get( map2 ) ); + + 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 1fd4be5..fc0f27d 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -29,6 +29,10 @@ // INTERNAL INCLUDES #include +#include +#include +#include +#include #include namespace Dali @@ -151,6 +155,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(); } @@ -327,25 +343,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; -- 2.7.4