X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Feffects-view%2Feffects-view-impl.cpp;h=d2e188de39b30d7e011c39c0ea5f139d7f971c17;hp=df8a6ea8803a81166db98f433a0a9a74c3c52dfc;hb=aa4d3eae3c1c35c383e34c075d57dcc9835f8bcf;hpb=2071317d301e9d5af326a3a2efcd2996263fbead diff --git a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp index df8a6ea..d2e188d 100644 --- a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp +++ b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 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. @@ -22,14 +22,24 @@ #include #include #include +#include +#include #include -#include +#include #include +#include +#include // INTERNAL INCLUDES -#include "../../filters/blur-two-pass-filter.h" -#include "../../filters/emboss-filter.h" -#include "../../filters/spread-filter.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace Dali { @@ -45,34 +55,56 @@ namespace Dali::BaseHandle Create() { - return Toolkit::EffectsView::New(); + return EffectsView::New(); } DALI_TYPE_REGISTRATION_BEGIN( Toolkit::EffectsView, Toolkit::Control, Create ) +DALI_PROPERTY_REGISTRATION( Toolkit, EffectsView, "effectSize", INTEGER, EFFECT_SIZE ) +DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, EffectsView, "effectOffset", VECTOR3, EFFECT_OFFSET ) +DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, EffectsView, "effectColor", Color::WHITE, EFFECT_COLOR ) DALI_TYPE_REGISTRATION_END() const Pixel::Format EFFECTS_VIEW_DEFAULT_PIXEL_FORMAT = Pixel::RGBA8888; const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f; -const Vector4 EFFECTS_VIEW_DEFAULT_BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 0.0 ); +const Vector4 EFFECTS_VIEW_DEFAULT_BACKGROUND_COLOR( 0.0f, 0.0f, 0.0f, 0.0 ); const bool EFFECTS_VIEW_REFRESH_ON_DEMAND(false); -// Custom properties -const char* const EFFECT_SIZE_PROPERTY_NAME = "EffectSize"; -const char* const EFFECT_STRENGTH_PROPERTY_NAME = "EffectStrength"; -const char* const EFFECT_OFFSET_PROPERTY_NAME = "EffectOffset"; -const char* const EFFECT_COLOR_PROPERTY_NAME = "EffectColor"; - -const float EFFECT_SIZE_DEFAULT( 1.0f ); -const float EFFECT_STRENGTH_DEFAULT( 0.5f ); -const Vector3 EFFECT_OFFSET_DEFAULT( 0.0f, 0.0f, 0.0f ); -const Vector4 EFFECT_COLOR_DEFAULT( Color::WHITE ); - -const char* const EFFECTS_VIEW_FRAGMENT_SOURCE = - "void main()\n" - "{\n" - " gl_FragColor = uColor;\n" - " gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;\n" - "}\n"; +// Visuals are not stylable or public +const Property::Index CHILD_VISUAL( Toolkit::EffectsView::ANIMATABLE_PROPERTY_START_INDEX - 1); +const Property::Index POST_FILTER_VISUAL( CHILD_VISUAL-1 ); + +#define DALI_COMPOSE_SHADER(STR) #STR + +const char* EFFECTS_VIEW_VERTEX_SOURCE = DALI_COMPOSE_SHADER( + attribute mediump vec2 aPosition;\n + varying mediump vec2 vTexCoord;\n + uniform mediump mat4 uMvpMatrix;\n + uniform mediump vec3 uSize;\n + uniform mediump vec3 effectOffset;\n + \n + void main()\n + {\n + mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n + vertexPosition.xyz *= uSize;\n + vertexPosition.xyz += effectOffset;\n + vertexPosition = uMvpMatrix * vertexPosition;\n + \n + vTexCoord = aPosition + vec2(0.5);\n + gl_Position = vertexPosition;\n + }\n +); + +const char* EFFECTS_VIEW_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER( + varying mediump vec2 vTexCoord;\n + uniform sampler2D sTexture;\n + uniform lowp vec4 effectColor;\n + \n + void main()\n + {\n + gl_FragColor = effectColor;\n + gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;\n + }\n +); const float BLUR_KERNEL0[] = { 12.0f/16.0f, 2.0f/16.0f, 2.0f/16.0f }; @@ -112,18 +144,16 @@ Toolkit::EffectsView EffectsView::New() } EffectsView::EffectsView() -: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), - mEffectType( Toolkit::EffectsView::INVALID_TYPE ), - mPixelFormat( EFFECTS_VIEW_DEFAULT_PIXEL_FORMAT ), - mSpread(0.0f), +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), + mChildrenRoot(Actor::New()), mBackgroundColor( EFFECTS_VIEW_DEFAULT_BACKGROUND_COLOR ), mTargetSize( Vector2::ZERO ), mLastSize( Vector2::ZERO ), - mRefreshOnDemand(EFFECTS_VIEW_REFRESH_ON_DEMAND), - mEffectSizePropertyIndex(Property::INVALID_INDEX), - mEffectStrengthPropertyIndex(Property::INVALID_INDEX), - mEffectOffsetPropertyIndex(Property::INVALID_INDEX), - mEffectColorPropertyIndex(Property::INVALID_INDEX) + mEffectSize(0), + mEffectType( Toolkit::EffectsView::INVALID_TYPE ), + mPixelFormat( EFFECTS_VIEW_DEFAULT_PIXEL_FORMAT ), + mEnabled( false ), + mRefreshOnDemand(EFFECTS_VIEW_REFRESH_ON_DEMAND) { } @@ -136,24 +166,23 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type ) { if( mEffectType != type ) { - mEffectType = type; - RemoveFilters(); - switch( mEffectType ) + Actor self = Self(); + + switch( type ) { case Toolkit::EffectsView::DROP_SHADOW: { - mFilters.push_back( new SpreadFilter ); - mFilters.push_back( new BlurTwoPassFilter ); + mFilters.PushBack( new SpreadFilter ); + mFilters.PushBack( new BlurTwoPassFilter ); break; } case Toolkit::EffectsView::EMBOSS: { - mFilters.push_back( new SpreadFilter ); - mFilters.push_back( new EmbossFilter ); - mFilters.push_back( new BlurTwoPassFilter ); - mActorPostFilter.RemoveShaderEffect(); + mFilters.PushBack( new SpreadFilter ); + mFilters.PushBack( new EmbossFilter ); + mFilters.PushBack( new BlurTwoPassFilter ); break; } default: @@ -161,6 +190,18 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type ) break; } } + + FrameBufferImage dummyImage = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat ); + + Internal::InitializeVisual( self, mVisualPostFilter, dummyImage ); + DevelControl::RegisterVisual( *this, POST_FILTER_VISUAL, mVisualPostFilter ); + + Property::Map customShader; + customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = EFFECTS_VIEW_VERTEX_SOURCE; + customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = EFFECTS_VIEW_FRAGMENT_SOURCE; + Toolkit::GetImplementation( mVisualPostFilter ).SetCustomShader( customShader ); + + mEffectType = type; } } @@ -174,6 +215,7 @@ void EffectsView::Enable() // make sure resources are allocated and start the render tasks processing AllocateResources(); CreateRenderTasks(); + mEnabled = true; } void EffectsView::Disable() @@ -181,6 +223,8 @@ void EffectsView::Disable() // stop render tasks processing // Note: render target resources are automatically freed since we set the Image::Unused flag RemoveRenderTasks(); + mLastSize = Vector2::ZERO; // Ensure resources are reallocated on subsequent enable + mEnabled = false; } void EffectsView::Refresh() @@ -200,176 +244,108 @@ void EffectsView::SetPixelFormat( Pixel::Format pixelFormat ) mPixelFormat = pixelFormat; } -void EffectsView::SetOutputImage( FrameBufferImage image ) -{ - CustomActor self = Self(); - - if( mImageForResult != image ) - { - if( !image ) - { - if( mImageForResult ) - { - self.Remove( mActorForResult ); - mActorForResult.Reset(); - - self.Add( mActorPostFilter ); - self.Add( mActorForChildren ); - } - } - else - { - if( mImageForResult ) - { - self.Remove( mActorForResult ); - } - mActorForResult = Actor::New(); - mActorForResult.SetParentOrigin( ParentOrigin::CENTER ); - mActorForResult.SetSize( mTargetSize ); - mActorForResult.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); - - Self().Add( mActorForResult ); - mActorForResult.Add( mActorPostFilter ); - mActorForResult.Add( mActorForChildren ); - } - mImageForResult = image; - } -} - -FrameBufferImage EffectsView::GetOutputImage() -{ - return mImageForResult; -} - -Property::Index EffectsView::GetEffectSizePropertyIndex() const -{ - return mEffectSizePropertyIndex; -} - -Property::Index EffectsView::GetEffectStrengthPropertyIndex() const -{ - return mEffectStrengthPropertyIndex; -} - -Property::Index EffectsView::GetEffectOffsetPropertyIndex() const +void EffectsView::SetBackgroundColor( const Vector4& color ) { - return mEffectOffsetPropertyIndex; + mBackgroundColor = color; } -Property::Index EffectsView::GetEffectColorPropertyIndex() const +Vector4 EffectsView::GetBackgroundColor() const { - return mEffectColorPropertyIndex; + return mBackgroundColor; } -void EffectsView::SetupProperties() +void EffectsView::SetEffectSize( int effectSize ) { - CustomActor self = Self(); - - // Register a property that the user can control the drop shadow offset - mEffectSizePropertyIndex = self.RegisterProperty(EFFECT_SIZE_PROPERTY_NAME, EFFECT_SIZE_DEFAULT, Property::READ_WRITE); - mEffectStrengthPropertyIndex = self.RegisterProperty(EFFECT_STRENGTH_PROPERTY_NAME, EFFECT_STRENGTH_DEFAULT, Property::READ_WRITE); - mEffectOffsetPropertyIndex = self.RegisterProperty(EFFECT_OFFSET_PROPERTY_NAME, EFFECT_OFFSET_DEFAULT); - mEffectColorPropertyIndex = self.RegisterProperty(EFFECT_COLOR_PROPERTY_NAME, EFFECT_COLOR_DEFAULT); + mEffectSize = effectSize; - Constraint positionConstraint = Constraint::New( mActorPostFilter, Actor::Property::POSITION, EqualToConstraint() ); - positionConstraint.AddSource( Source( self, mEffectOffsetPropertyIndex ) ); - positionConstraint.Apply(); + if( mEnabled ) + { + const size_t numFilters( mFilters.Size() ); + for( size_t i = 0; i < numFilters; ++i ) + { + mFilters[i]->Disable(); + } - Constraint colorConstraint = Constraint::New( mActorPostFilter, Actor::Property::COLOR, EqualToConstraint() ); - colorConstraint.AddSource( Source( self, mEffectColorPropertyIndex ) ); - colorConstraint.Apply(); -} + SetupFilters(); -void EffectsView::SetBackgroundColor( const Vector4& color ) -{ - mBackgroundColor = color; + for( size_t i = 0; i < numFilters; ++i ) + { + mFilters[i]->Enable(); + } + } } -Vector4 EffectsView::GetBackgroundColor() const +int EffectsView::GetEffectSize() { - return mBackgroundColor; + return mEffectSize; } // From Control void EffectsView::OnInitialize() { - ////////////////////////////////////////////////////// - // Create cameras - mCameraForChildren = CameraActor::New(); - mCameraForChildren.SetParentOrigin(ParentOrigin::CENTER); - - mActorForChildren = ImageActor::New(); - mActorForChildren.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mActorForChildren.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); - - mActorPostFilter = ImageActor::New(); - mActorPostFilter.SetParentOrigin( ParentOrigin::CENTER ); - mActorPostFilter.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); - mActorPostFilter.SetShaderEffect( ShaderEffect::New( "", EFFECTS_VIEW_FRAGMENT_SOURCE ) ); - - // Connect to actor tree - Self().Add( mActorPostFilter ); - Self().Add( mActorForChildren ); - Self().Add( mCameraForChildren ); - - SetupProperties(); + CustomActor self = Self(); + mChildrenRoot.SetParentOrigin( ParentOrigin::CENTER ); + self.Add( mChildrenRoot ); } -void EffectsView::OnControlSizeSet(const Vector3& targetSize) +void EffectsView::OnSizeSet(const Vector3& targetSize) { mTargetSize = Vector2(targetSize); // if we are already on stage, need to update render target sizes now to reflect the new size of this actor - if(Self().OnStage()) + if(mEnabled) { - AllocateResources(); + if( mLastSize != Vector2::ZERO ) + { + Disable(); + } + Enable(); } - if( mActorForResult ) - { - mActorForResult.SetSize( targetSize ); - } - if( mActorForChildren ) - { - mActorForChildren.SetSize( targetSize ); - } - if( mActorPostFilter ) - { - mActorPostFilter.SetSize( targetSize ); - } + mChildrenRoot.SetSize( targetSize ); - // Children render camera must move when EffectsView object is resized. - // This is since we cannot change render target size - so we need to remap the child actors' rendering - // accordingly so they still exactly fill the render target. - // Note that this means the effective resolution of the child render changes as the EffectsView object - // changes size, this is the trade off for not being able to modify render target size - // Change camera z position based on EffectsView actor height - if( mCameraForChildren ) - { - const float cameraPosScale( 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f) ); - mCameraForChildren.SetZ( targetSize.height * cameraPosScale ); - } + Control::OnSizeSet( targetSize ); +} - const size_t numFilters( mFilters.size() ); - for( size_t i = 0; i < numFilters; ++i ) - { - mFilters[i]->SetSize( mTargetSize ); - } +void EffectsView::OnStageConnection( int depth ) +{ + Enable(); + Control::OnStageConnection( depth ); } void EffectsView::OnStageDisconnection() { - const size_t numFilters( mFilters.size() ); + Disable(); + + const size_t numFilters( mFilters.Size() ); for( size_t i = 0; i < numFilters; ++i ) { mFilters[i]->Disable(); } + + Control::OnStageDisconnection(); +} + +void EffectsView::OnChildAdd( Actor& child ) +{ + if( child != mChildrenRoot && child != mCameraForChildren ) + { + mChildrenRoot.Add( child ); + } + + Control::OnChildAdd( child ); +} + +void EffectsView::OnChildRemove( Actor& child ) +{ + mChildrenRoot.Remove( child ); + + Control::OnChildRemove( child ); } void EffectsView::SetupFilters() { - int effectSize = static_cast< int >( Self().GetProperty( mEffectSizePropertyIndex ).Get() ); switch( mEffectType ) { case Toolkit::EffectsView::DROP_SHADOW: @@ -377,23 +353,23 @@ void EffectsView::SetupFilters() SpreadFilter* spreadFilter = static_cast< SpreadFilter* >( mFilters[0] ); spreadFilter->SetInputImage( mImageForChildren ); spreadFilter->SetOutputImage( mImagePostFilter ); - spreadFilter->SetRootActor( Self() ); + spreadFilter->SetRootActor( mChildrenRoot ); spreadFilter->SetBackgroundColor( mBackgroundColor ); spreadFilter->SetPixelFormat( mPixelFormat ); spreadFilter->SetSize( mTargetSize ); - spreadFilter->SetSpread( effectSize ); + spreadFilter->SetSpread( mEffectSize ); BlurTwoPassFilter* blurFilter = static_cast< BlurTwoPassFilter* >( mFilters[1] ); blurFilter->SetInputImage( mImagePostFilter ); blurFilter->SetOutputImage( mImagePostFilter ); - blurFilter->SetRootActor( Self() ); + blurFilter->SetRootActor( mChildrenRoot ); blurFilter->SetBackgroundColor( mBackgroundColor ); blurFilter->SetPixelFormat( mPixelFormat ); blurFilter->SetSize( mTargetSize ); const float* kernel(NULL); size_t kernelSize(0); - switch( effectSize ) + switch( mEffectSize ) { case 4: { kernel = BLUR_KERNEL4; kernelSize = sizeof(BLUR_KERNEL4)/sizeof(BLUR_KERNEL4[0]); break; } case 3: { kernel = BLUR_KERNEL3; kernelSize = sizeof(BLUR_KERNEL3)/sizeof(BLUR_KERNEL3[0]); break; } @@ -410,16 +386,16 @@ void EffectsView::SetupFilters() SpreadFilter* spreadFilter = static_cast< SpreadFilter* >( mFilters[0] ); spreadFilter->SetInputImage( mImageForChildren ); spreadFilter->SetOutputImage( mImagePostFilter ); - spreadFilter->SetRootActor( Self() ); + spreadFilter->SetRootActor( mChildrenRoot ); spreadFilter->SetBackgroundColor( mBackgroundColor ); spreadFilter->SetPixelFormat( Pixel::RGBA8888 ); spreadFilter->SetSize( mTargetSize ); - spreadFilter->SetSpread( effectSize ); + spreadFilter->SetSpread( mEffectSize ); EmbossFilter* embossFilter = static_cast< EmbossFilter* >( mFilters[1] ); embossFilter->SetInputImage( mImagePostFilter ); embossFilter->SetOutputImage( mImagePostFilter ); - embossFilter->SetRootActor( Self() ); + embossFilter->SetRootActor( mChildrenRoot ); embossFilter->SetBackgroundColor( mBackgroundColor ); embossFilter->SetPixelFormat( Pixel::RGBA8888 ); embossFilter->SetSize( mTargetSize ); @@ -427,7 +403,7 @@ void EffectsView::SetupFilters() BlurTwoPassFilter* blurFilter = static_cast< BlurTwoPassFilter* >( mFilters[2] ); blurFilter->SetInputImage( mImagePostFilter ); blurFilter->SetOutputImage( mImagePostFilter ); - blurFilter->SetRootActor( Self() ); + blurFilter->SetRootActor( mChildrenRoot ); blurFilter->SetBackgroundColor( Vector4( 0.5f, 0.5f, 0.5f, 0.0 ) ); blurFilter->SetPixelFormat( Pixel::RGBA8888 ); blurFilter->SetSize( mTargetSize ); @@ -446,14 +422,19 @@ void EffectsView::AllocateResources() if(mTargetSize != mLastSize) { mLastSize = mTargetSize; - SetupCameras(); - mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED ); - mActorForChildren.SetImage(mImageForChildren); + Actor self( Self() ); - mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED ); - mActorPostFilter.SetImage(mImagePostFilter); + mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat ); + Internal::InitializeVisual( self, mVisualForChildren, mImageForChildren ); + DevelControl::RegisterVisual( *this, CHILD_VISUAL, mVisualForChildren, DepthIndex::CONTENT + 1 ); + + mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat ); + TextureSet textureSet = TextureSet::New(); + TextureSetImage( textureSet, 0u, mImagePostFilter ); + self.GetRendererAt( 0 ).SetTextures( textureSet ); + mVisualPostFilter.SetDepthIndex( DepthIndex::CONTENT ); SetupFilters(); } @@ -461,26 +442,39 @@ void EffectsView::AllocateResources() void EffectsView::SetupCameras() { - const float cameraPosScale( 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f) ); - - // Create and place a camera for the children render, corresponding to its render target size - mCameraForChildren.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW); - // TODO: how do we pick a reasonable value for near clip? Needs to relate to normal camera the user renders with, but we don't have a handle on it - mCameraForChildren.SetNearClippingPlane(1.0f); - mCameraForChildren.SetAspectRatio(mTargetSize.width / mTargetSize.height); - mCameraForChildren.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor - mCameraForChildren.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosScale); - mCameraForChildren.SetZ( mTargetSize.height * cameraPosScale ); + if( !mCameraForChildren ) + { + // Create a camera for the children render, corresponding to its render target size + mCameraForChildren = CameraActor::New(mTargetSize); + mCameraForChildren.SetParentOrigin(ParentOrigin::CENTER); + mCameraForChildren.SetInvertYAxis( true ); + Self().Add( mCameraForChildren ); + } + else + { + // place the camera for the children render, corresponding to its render target size + const float cameraPosScale( 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f) ); + mCameraForChildren.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW); + mCameraForChildren.SetNearClippingPlane(1.0f); + mCameraForChildren.SetAspectRatio(mTargetSize.width / mTargetSize.height); + mCameraForChildren.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor + mCameraForChildren.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosScale); + mCameraForChildren.SetZ( mTargetSize.height * cameraPosScale ); + } } void EffectsView::CreateRenderTasks() { + if( mTargetSize == Vector2::ZERO ) + { + return; + } RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); // create render task to render our child actors to offscreen buffer mRenderTaskForChildren = taskList.CreateTask(); mRenderTaskForChildren.SetRefreshRate( mRefreshOnDemand ? RenderTask::REFRESH_ONCE : RenderTask::REFRESH_ALWAYS ); - mRenderTaskForChildren.SetSourceActor( Self() ); + mRenderTaskForChildren.SetSourceActor( mChildrenRoot ); mRenderTaskForChildren.SetExclusive(true); mRenderTaskForChildren.SetInputEnabled( false ); mRenderTaskForChildren.SetClearColor( mBackgroundColor ); @@ -489,35 +483,25 @@ void EffectsView::CreateRenderTasks() mRenderTaskForChildren.SetCameraActor(mCameraForChildren); // use camera that covers render target exactly // Enable image filters - const size_t numFilters( mFilters.size() ); + const size_t numFilters( mFilters.Size() ); for( size_t i = 0; i < numFilters; ++i ) { mFilters[i]->Enable(); } - - // create render task to render result of the image filters to the final offscreen - if( mImageForResult ) - { - mRenderTaskForResult = taskList.CreateTask(); - mRenderTaskForResult.SetRefreshRate( mRefreshOnDemand ? RenderTask::REFRESH_ONCE : RenderTask::REFRESH_ALWAYS ); - mRenderTaskForResult.SetSourceActor( mActorForResult ); - mRenderTaskForResult.SetExclusive(true); - mRenderTaskForResult.SetInputEnabled( false ); - mRenderTaskForResult.SetClearColor( mBackgroundColor ); - mRenderTaskForResult.SetClearEnabled( true ); - mRenderTaskForResult.SetTargetFrameBuffer( mImageForResult ); - mRenderTaskForResult.SetCameraActor(mCameraForChildren); // use camera that covers render target exactly - } } void EffectsView::RemoveRenderTasks() { + if( mTargetSize == Vector2::ZERO ) + { + return; + } + RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList(); taskList.RemoveTask(mRenderTaskForChildren); - taskList.RemoveTask(mRenderTaskForResult); - const size_t numFilters( mFilters.size() ); + const size_t numFilters( mFilters.Size() ); for( size_t i = 0; i < numFilters; ++i ) { mFilters[i]->Disable(); @@ -533,12 +517,7 @@ void EffectsView::RefreshRenderTasks() mRenderTaskForChildren.SetRefreshRate( mRefreshOnDemand ? RenderTask::REFRESH_ONCE : RenderTask::REFRESH_ALWAYS ); } - if( mRenderTaskForResult ) - { - mRenderTaskForResult.SetRefreshRate( mRefreshOnDemand ? RenderTask::REFRESH_ONCE : RenderTask::REFRESH_ALWAYS ); - } - - const size_t numFilters( mFilters.size() ); + const size_t numFilters( mFilters.Size() ); for( size_t i = 0; i < numFilters; ++i ) { mFilters[i]->Refresh(); @@ -547,12 +526,63 @@ void EffectsView::RefreshRenderTasks() void EffectsView::RemoveFilters() { - const size_t numFilters( mFilters.size() ); + const size_t numFilters( mFilters.Size() ); for( size_t i = 0; i < numFilters; ++i ) { delete mFilters[i]; } - mFilters.clear(); + mFilters.Release(); +} + +void EffectsView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) +{ + Toolkit::EffectsView effectsView = Toolkit::EffectsView::DownCast( Dali::BaseHandle( object ) ); + + if ( effectsView ) + { + switch ( index ) + { + case Toolkit::EffectsView::Property::EFFECT_SIZE: + { + int effectSize; + if( value.Get( effectSize ) ) + { + GetImpl( effectsView ).SetEffectSize( effectSize ); + } + break; + } + default: + { + break; + } + } + } +} + +Property::Value EffectsView::GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + Property::Value value; + + Toolkit::EffectsView imageview = Toolkit::EffectsView::DownCast( Dali::BaseHandle( object ) ); + + if ( imageview ) + { + EffectsView& impl = GetImpl( imageview ); + switch ( propertyIndex ) + { + case Toolkit::EffectsView::Property::EFFECT_SIZE: + { + value = impl.GetEffectSize(); + break; + } + default: + { + break; + } + } + } + + return value; } } // namespace Internal