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=4fb7e85729907da6076b3d4f7585b52b6e823596;hb=aa4d3eae3c1c35c383e34c075d57dcc9835f8bcf;hpb=20acd977722273134a92dab4f2a2335ca1c47630 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 4fb7e85..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) 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. @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -30,11 +31,15 @@ #include // INTERNAL INCLUDES +#include #include -#include +#include +#include #include #include #include +#include +#include namespace Dali { @@ -61,9 +66,13 @@ 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); +// 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( @@ -135,7 +144,7 @@ Toolkit::EffectsView EffectsView::New() } EffectsView::EffectsView() -: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mChildrenRoot(Actor::New()), mBackgroundColor( EFFECTS_VIEW_DEFAULT_BACKGROUND_COLOR ), mTargetSize( Vector2::ZERO ), @@ -160,8 +169,6 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type ) RemoveFilters(); Actor self = Self(); - Property::Map rendererMap; - rendererMap.Insert( "rendererType", "IMAGE" ); switch( type ) { @@ -184,11 +191,15 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type ) } } + 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[ "vertexShader" ] = EFFECTS_VIEW_VERTEX_SOURCE; - customShader[ "fragmentShader" ] = EFFECTS_VIEW_FRAGMENT_SOURCE; - rendererMap[ "shader" ] = customShader; - InitializeControlRenderer( self, mRendererPostFilter, rendererMap ); + 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; } @@ -212,6 +223,7 @@ 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; } @@ -278,8 +290,6 @@ void EffectsView::OnInitialize() void EffectsView::OnSizeSet(const Vector3& targetSize) { - Control::OnSizeSet( 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 @@ -293,23 +303,15 @@ void EffectsView::OnSizeSet(const Vector3& targetSize) } mChildrenRoot.SetSize( targetSize ); + + Control::OnSizeSet( targetSize ); } void EffectsView::OnStageConnection( int depth ) { - Control::OnStageConnection( depth ); - Enable(); - Actor self = Self(); - if( mRendererPostFilter ) - { - mRendererPostFilter.SetOnStage( self ); - } - if( mRendererForChildren ) - { - mRendererForChildren.SetOnStage( self ); - } + Control::OnStageConnection( depth ); } void EffectsView::OnStageDisconnection() @@ -322,27 +324,17 @@ void EffectsView::OnStageDisconnection() mFilters[i]->Disable(); } - Actor self = Self(); - if( mRendererPostFilter ) - { - mRendererPostFilter.SetOffStage( self ); - } - if( mRendererForChildren ) - { - mRendererForChildren.SetOffStage( self ); - } - Control::OnStageDisconnection(); } void EffectsView::OnChildAdd( Actor& child ) { - Control::OnChildAdd( child ); - if( child != mChildrenRoot && child != mCameraForChildren ) { mChildrenRoot.Add( child ); } + + Control::OnChildAdd( child ); } void EffectsView::OnChildRemove( Actor& child ) @@ -434,15 +426,15 @@ void EffectsView::AllocateResources() Actor self( Self() ); - mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED ); - InitializeControlRenderer( self, mRendererForChildren, mImageForChildren ); - mRendererForChildren.SetDepthIndex( DepthIndex::CONTENT+1 ); + 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, Dali::Image::UNUSED ); + mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat ); TextureSet textureSet = TextureSet::New(); TextureSetImage( textureSet, 0u, mImagePostFilter ); self.GetRendererAt( 0 ).SetTextures( textureSet ); - mRendererPostFilter.SetDepthIndex( DepthIndex::CONTENT ); + mVisualPostFilter.SetDepthIndex( DepthIndex::CONTENT ); SetupFilters(); }