X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fsuper-blur-view%2Fsuper-blur-view-impl.cpp;h=a93257d35e33f1dea64e01870fe7c423fd0df17c;hp=28e4eec72e18efba1b466e95171211c13e474b52;hb=0e462103c222ad05916840bc7d7c902cf5fc82a1;hpb=3eb60a0aef6b188727b79bdee2e35c575c432a90 diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index 28e4eec..a93257d 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-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. @@ -31,6 +31,7 @@ // INTERNAL_INCLUDES #include +#include namespace //Unnamed namespace { @@ -161,22 +162,20 @@ void SuperBlurView::OnInitialize() void SuperBlurView::SetImage(Image inputImage) { - if( mTargetSize == Vector2::ZERO || mInputImage == inputImage) + mInputImage = inputImage; + if( mTargetSize == Vector2::ZERO ) { return; } ClearBlurResource(); - mInputImage = inputImage; Actor self( Self() ); - InitializeVisual( self, mVisuals[0], mInputImage ); + + mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage ); + RegisterVisual( 0, mVisuals[0] ); // Will clean up previously registered visuals for this index. mVisuals[0].SetDepthIndex(0); - SetShaderEffect( mVisuals[0] ); - if( self.OnStage() ) - { - mVisuals[0].SetOnStage( self ); - } + // custom shader is not applied on the original image. BlurImage( 0, inputImage); for(unsigned int i=1; i(i); mBlurredImage[i-1] = FrameBufferImage::New( mTargetSize.width/std::pow(2.f,exponent) , mTargetSize.height/std::pow(2.f,exponent), GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT ); - InitializeVisual( self, mVisuals[i], mBlurredImage[i - 1] ); - mVisuals[ i ].SetDepthIndex( i ); - SetShaderEffect( mVisuals[ i ] ); + + mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] ); + RegisterVisual( i, mVisuals[i] ); // Will clean up existing visual with same index. + mVisuals[i].SetDepthIndex( i ); + SetShaderEffect( mVisuals[i] ); } if( mInputImage ) { SetImage( mInputImage ); } - - if( self.OnStage() ) - { - for( unsigned int i = 1; i <= mBlurLevels; i++ ) - { - mVisuals[i].SetOnStage( self ); - } - } } + + Control::OnSizeSet( targetSize ); } void SuperBlurView::OnStageConnection( int depth ) { - Control::OnStageConnection( depth ); - if( mTargetSize == Vector2::ZERO ) { return; } + // Exception to the rule, chaining up first ensures visuals have SetOnStage called to create their renderers + Control::OnStageConnection( depth ); + Actor self = Self(); - if( mVisuals[0] ) + for(unsigned int i=0; i<=mBlurLevels;i++) { - mVisuals[0].SetOnStage( self ); - } - for(unsigned int i=1; i<=mBlurLevels;i++) - { - if( mVisuals[i] ) + // Note that the renderer indices are depending on the order they been added to the actor + // which might be different from the blur level of its texture. + // We can check the depth index of the renderer to know which blurred image it renders. + // All visuals WILL have renderers at this point as we are simply creating visuals with an Image handle. + Renderer renderer = self.GetRendererAt( i ); + int depthIndex = renderer.GetProperty(Renderer::Property::DEPTH_INDEX); + if( depthIndex > 0 ) { - mVisuals[i].SetOnStage( self ); + Property::Index index = renderer.RegisterProperty( ALPHA_UNIFORM_NAME, 0.f ); + Constraint constraint = Constraint::New( renderer, index, ActorOpacityConstraint(mBlurLevels, depthIndex-1) ); + constraint.AddSource( Source( self, mBlurStrengthPropertyIndex ) ); + constraint.Apply(); } - - Renderer renderer = self.GetRendererAt( i ); - Property::Index index = renderer.RegisterProperty( ALPHA_UNIFORM_NAME, 0.f ); - Constraint constraint = Constraint::New( renderer, index, ActorOpacityConstraint(mBlurLevels, i-1) ); - constraint.AddSource( Source( self, mBlurStrengthPropertyIndex ) ); - constraint.Apply(); } } -void SuperBlurView::OnStageDisconnection( ) -{ - if( mTargetSize == Vector2::ZERO ) - { - return; - } - - Actor self = Self(); - for(unsigned int i=0; i