X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fsuper-blur-view%2Fsuper-blur-view-impl.cpp;h=4e7427626c1d5088f74172bf163d596cd38ba771;hb=refs%2Fchanges%2F40%2F106740%2F2;hp=c987ea319cd99398c9a22a771bd241b5e7ff2a74;hpb=41278d3fb755de3cb89edf6d80603b18562b4e01;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 c987ea3..4e74276 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) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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,13 +22,17 @@ #include #include #include -#include #include +#include #include -#include +#include #include #include +// INTERNAL_INCLUDES +#include +#include + namespace //Unnamed namespace { @@ -120,7 +124,7 @@ DALI_TYPE_REGISTRATION_END() } // unnamed namespace SuperBlurView::SuperBlurView( unsigned int blurLevels ) -: Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ), +: Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS ) ), mTargetSize( Vector2::ZERO ), mBlurStrengthPropertyIndex(Property::INVALID_INDEX), mBlurLevels( blurLevels ), @@ -129,7 +133,7 @@ SuperBlurView::SuperBlurView( unsigned int blurLevels ) DALI_ASSERT_ALWAYS( mBlurLevels > 0 && " Minimal blur level is one, otherwise no blur is needed" ); mGaussianBlurView.assign( blurLevels, Toolkit::GaussianBlurView() ); mBlurredImage.assign( blurLevels, FrameBufferImage() ); - mRenderers.assign( blurLevels+1, Toolkit::ControlRenderer() ); + mVisuals.assign( blurLevels+1, Toolkit::Visual::Base() ); } SuperBlurView::~SuperBlurView() @@ -154,35 +158,24 @@ Toolkit::SuperBlurView SuperBlurView::New( unsigned int blurLevels ) void SuperBlurView::OnInitialize() { mBlurStrengthPropertyIndex = Self().RegisterProperty( "blurStrength", 0.f ); - - Property::Map rendererMap; - rendererMap.Insert( "rendererType", "image"); - - Property::Map shaderMap; - std::stringstream verterShaderString; - shaderMap[ "fragmentShader" ] = FRAGMENT_SHADER; - rendererMap.Insert( "shader", shaderMap ); - - Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get(); - for(unsigned int i=0; i<=mBlurLevels; i++) - { - mRenderers[i] = rendererFactory.GetControlRenderer( rendererMap ); - mRenderers[i].SetDepthIndex(i); - } } void SuperBlurView::SetImage(Image inputImage) { - if( mTargetSize == Vector2::ZERO || mInputImage == inputImage) + mInputImage = inputImage; + if( mTargetSize == Vector2::ZERO ) { return; } ClearBlurResource(); - mInputImage = inputImage; - Actor self = Self(); - Toolkit::RendererFactory::Get().ResetRenderer( mRenderers[0], self, mInputImage ); + Actor self( Self() ); + + mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage ); + RegisterVisual( 0, mVisuals[0] ); // Will clean up previously registered visuals for this index. + mVisuals[0].SetDepthIndex(0); + // 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, Dali::Image::NEVER ); - rendererFactory.ResetRenderer( mRenderers[i], self, mBlurredImage[i-1] ); + GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT ); + + 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=0; i<=mBlurLevels;i++) - { - mRenderers[i].SetOnStage( self ); - } - } } } void SuperBlurView::OnStageConnection( int depth ) { - Control::OnStageConnection( depth ); - if( mTargetSize == Vector2::ZERO ) { return; } + // Chaining up first ensures visuals have SetOnStage called to create their renderers + Control::OnStageConnection( depth ); + Actor self = Self(); - mRenderers[0].SetOnStage( self ); - for(unsigned int i=1; i<=mBlurLevels;i++) + for(unsigned int i=0; i<=mBlurLevels;i++) { - mRenderers[i].SetOnStage( self ); - + // 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. 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(); + int depthIndex = renderer.GetProperty(Renderer::Property::DEPTH_INDEX); + if( depthIndex > 0 ) + { + 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(); + } } } void SuperBlurView::OnStageDisconnection( ) { - if( mTargetSize == Vector2::ZERO ) - { - return; - } - - Actor self = Self(); - for(unsigned int i=0; i