X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbloom-view%2Fbloom-view-impl.cpp;h=474a16e2fb4270f5d0bd9f85d5c4b54ede5d4905;hp=3c6dca41dd154c7aad12d520de8afee2b71caaa4;hb=e9d852fcdacc5788785bfe0b617bd757794e8208;hpb=397218b6cdd85915f5fe00fa9d3615dfa3867422 diff --git a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp index 3c6dca4..474a16e 100644 --- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp +++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp @@ -149,6 +149,7 @@ BloomView::BloomView() , mTargetSize(Vector2::ZERO) , mLastSize(Vector2::ZERO) , mChildrenRoot(Actor::New()) + , mInternalRoot(Actor::New() ) , mBloomThresholdPropertyIndex(Property::INVALID_INDEX) , mBlurStrengthPropertyIndex(Property::INVALID_INDEX) , mBloomIntensityPropertyIndex(Property::INVALID_INDEX) @@ -172,6 +173,7 @@ BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCur , mTargetSize(Vector2::ZERO) , mLastSize(Vector2::ZERO) , mChildrenRoot(Actor::New()) + , mInternalRoot(Actor::New()) , mBloomThresholdPropertyIndex(Property::INVALID_INDEX) , mBlurStrengthPropertyIndex(Property::INVALID_INDEX) , mBloomIntensityPropertyIndex(Property::INVALID_INDEX) @@ -213,24 +215,6 @@ Toolkit::BloomView BloomView::New(const unsigned int blurNumSamples, const float return handle; } -///////////////////////////////////////////////////////////// -// for creating a subtree for all user added child actors, so that we can have them exclusive to the mRenderChildrenTask and our other actors exclusive to our other tasks -// TODO: overloading Actor::Add()/Remove() not nice since breaks polymorphism. Need another method to pass ownership of added child actors to our internal actor root. -void BloomView::Add(Actor child) -{ - mChildrenRoot.Add(child); -} - -void BloomView::Remove(Actor child) -{ - mChildrenRoot.Remove(child); -} - - - - - - /////////////////////////////////////////////////////////// // // Private methods @@ -239,43 +223,43 @@ void BloomView::Remove(Actor child) void BloomView::OnInitialize() { // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task - mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); + mChildrenRoot.SetParentOrigin( ParentOrigin::CENTER ); + mInternalRoot.SetParentOrigin( ParentOrigin::CENTER ); ////////////////////////////////////////////////////// // Create actors // Create an ImageActor for rendering from the scene texture to the bloom texture mBloomExtractImageActor = Toolkit::ImageView::New(); - mBloomExtractImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); + mBloomExtractImageActor.SetParentOrigin( ParentOrigin::CENTER ); // Create shader used for extracting the bright parts of an image Property::Map customShader; customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE; Property::Map rendererMap; - rendererMap.Insert( "rendererType", "imageRenderer" ); + rendererMap.Insert( "rendererType", "image" ); rendererMap.Insert( "shader", customShader ); mBloomExtractImageActor.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap ); // Create an ImageActor for compositing the result (scene and bloom textures) to output mCompositeImageActor = Toolkit::ImageView::New(); - mCompositeImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); + mCompositeImageActor.SetParentOrigin( ParentOrigin::CENTER ); // Create shader used to composite bloom and original image to output render target customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE; rendererMap[ "shader" ] = customShader; - mCompositeImageActor.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );; + mCompositeImageActor.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap ); // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task mTargetImageActor = Toolkit::ImageView::New(); - mTargetImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - + mTargetImageActor.SetParentOrigin( ParentOrigin::CENTER ); // Create the Gaussian Blur object + render tasks // Note that we use mBloomExtractTarget as the source image and also re-use this as the gaussian blur final render target. This saves the gaussian blur code from creating it // render targets etc internally, so we make better use of resources // Note, this also internally creates the render tasks used by the Gaussian blur, this must occur after the bloom extraction and before the compositing mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(mBlurNumSamples, mBlurBellCurveWidth, mPixelFormat, mDownsampleWidthScale, mDownsampleHeightScale, true); - mGaussianBlurView.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); + mGaussianBlurView.SetParentOrigin( ParentOrigin::CENTER ); ////////////////////////////////////////////////////// @@ -292,12 +276,13 @@ void BloomView::OnInitialize() //////////////////////////////// // Connect to actor tree Self().Add( mChildrenRoot ); - Self().Add( mBloomExtractImageActor ); - Self().Add( mGaussianBlurView ); - Self().Add( mCompositeImageActor ); - Self().Add( mTargetImageActor ); - Self().Add( mRenderDownsampledCamera ); - Self().Add( mRenderFullSizeCamera ); + Self().Add( mInternalRoot ); + mInternalRoot.Add( mBloomExtractImageActor ); + mInternalRoot.Add( mGaussianBlurView ); + mInternalRoot.Add( mCompositeImageActor ); + mInternalRoot.Add( mTargetImageActor ); + mInternalRoot.Add( mRenderDownsampledCamera ); + mInternalRoot.Add( mRenderFullSizeCamera ); // bind properties for / set shader constants to defaults SetupProperties(); @@ -305,6 +290,8 @@ void BloomView::OnInitialize() void BloomView::OnSizeSet(const Vector3& targetSize) { + Control::OnSizeSet( targetSize ); + mTargetSize = Vector2(targetSize); mChildrenRoot.SetSize(targetSize); mCompositeImageActor.SetSize(targetSize); @@ -328,10 +315,27 @@ void BloomView::OnSizeSet(const Vector3& targetSize) } } +void BloomView::OnChildAdd( Actor& child ) +{ + Control::OnChildAdd( child ); + + if( child != mChildrenRoot && child != mInternalRoot) + { + mChildrenRoot.Add( child ); + } +} + +void BloomView::OnChildRemove( Actor& child ) +{ + mChildrenRoot.Remove( child ); + + Control::OnChildRemove( child ); +} + void BloomView::AllocateResources() { // size of render targets etc is based on the size of this actor, ignoring z - if(mTargetSize != mLastSize) + if(mTargetSize != mLastSize || !mActivated) { mLastSize = mTargetSize; @@ -465,6 +469,9 @@ void BloomView::Deactivate() // stop render tasks processing // Note: render target resources are automatically freed since we set the Image::Unused flag RemoveRenderTasks(); + mRenderTargetForRenderingChildren.Reset(); + mBloomExtractTarget.Reset(); + mOutputRenderTarget.Reset(); mActivated = false; }