X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ffilters%2Fblur-two-pass-filter.cpp;h=f86ffd4df1f4186bdc06da6b0905b1ba9b758c7c;hb=70510385d88cfbd5c232117d8436ca74c523e172;hp=a5adec7ceab89969358833b0a088445f9c372205;hpb=c01f2590ed7bb00d9b3600511d08dc420261ed46;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/filters/blur-two-pass-filter.cpp b/dali-toolkit/internal/filters/blur-two-pass-filter.cpp index a5adec7..f86ffd4 100644 --- a/dali-toolkit/internal/filters/blur-two-pass-filter.cpp +++ b/dali-toolkit/internal/filters/blur-two-pass-filter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -21,13 +21,14 @@ // EXTERNAL INCLUDES #include #include -#include +#include #include #include #include // INTERNAL INCLUDES #include +#include namespace Dali { @@ -58,24 +59,6 @@ const float DEFAULT_KERNEL4[] = { 2.0f/16.0f, 1.5f/16.0f, 1.5f/16.0f, 1.5f/16.0f 1.0f/16.0f, 1.0f/16.0f, 1.0f/16.0f, 0.5f/16.0f, 0.5f/16.0f, 0.5f/16.0f, 0.5f/16.0f }; -const char* BLUR_TWO_PASS_FRAGMENT_SOURCE = -{ - "precision highp float;\n" - "varying mediump vec2 vTexCoord;\n" - "uniform sampler2D sTexture;\n" - "uniform vec2 uSampleOffsets[NUM_SAMPLES];\n" - "uniform float uSampleWeights[NUM_SAMPLES];\n" - "void main()\n" - "{\n" - " vec4 color = vec4(0.0);\n" - " for( int i = 0; i < NUM_SAMPLES; ++i )\n" - " {\n" - " color += texture2D( sTexture, vTexCoord + uSampleOffsets[i] ) * uSampleWeights[i];\n" - " }\n" - " gl_FragColor = color;\n" - "}\n" -}; - std::string GetOffsetUniformName( int index ) { std::ostringstream oss; @@ -90,20 +73,6 @@ std::string GetWeightUniformName( int index ) return oss.str(); } -const char* BLEND_TWO_IMAGES_FRAGMENT_SOURCE = -{ - "precision highp float;\n" - "uniform float uBlurStrength;\n " - "uniform sampler2D sTexture;\n" - "uniform sampler2D sEffect;\n" - "varying mediump vec2 vTexCoord;\n" - "void main()\n" - "{\n" - " gl_FragColor = texture2D( sTexture, vTexCoord ) * uBlurStrength" - " + texture2D( sEffect, vTexCoord )*(1.0-uBlurStrength); \n" - "}\n" -}; - const char* const BLUR_STRENGTH_UNIFORM_NAME( "uBlurStrength" ); const char* const EFFECT_IMAGE_NAME( "sEffect" ); @@ -135,13 +104,13 @@ void BlurTwoPassFilter::Enable() // Set up blur-two-pass custom shader std::ostringstream sstream; sstream << "#define NUM_SAMPLES " << kernelSize << "\n"; - sstream << BLUR_TWO_PASS_FRAGMENT_SOURCE; + sstream << SHADER_BLUR_TWO_PASS_SHADER_FRAG; std::string fragmentSource( sstream.str() ); // create actor to render input with applied emboss effect mActorForInput = Actor::New(); mActorForInput.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); - mActorForInput.SetSize( mTargetSize ); + mActorForInput.SetProperty( Actor::Property::SIZE, mTargetSize ); Renderer rendererForInput = CreateRenderer( BASIC_VERTEX_SOURCE, fragmentSource.c_str() ); SetRendererTexture( rendererForInput, mInputTexture ); mActorForInput.AddRenderer( rendererForInput ); @@ -154,7 +123,7 @@ void BlurTwoPassFilter::Enable() // create an actor to render mImageForHorz for vertical blur pass mActorForHorz = Actor::New(); mActorForHorz.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); - mActorForHorz.SetSize( mTargetSize ); + mActorForHorz.SetProperty( Actor::Property::SIZE, mTargetSize ); Renderer rendererForHorz = CreateRenderer( BASIC_VERTEX_SOURCE, fragmentSource.c_str() ); SetRendererTexture( rendererForHorz, textureForHorz ); mActorForHorz.AddRenderer( rendererForHorz ); @@ -165,13 +134,13 @@ void BlurTwoPassFilter::Enable() mBlurredFrameBuffer.AttachColorTexture( blurredTexture ); // create an actor to blend the blurred image and the input image with the given blur strength - Renderer rendererForBlending = CreateRenderer( BASIC_VERTEX_SOURCE, BLEND_TWO_IMAGES_FRAGMENT_SOURCE ); + Renderer rendererForBlending = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLUR_TWO_IMAGES_SHADER_FRAG ); TextureSet textureSetForBlending = rendererForBlending.GetTextures(); textureSetForBlending.SetTexture( 0u, blurredTexture ); textureSetForBlending.SetTexture( 1u, mInputTexture ); mActorForBlending.AddRenderer( rendererForBlending ); mActorForBlending.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); - mActorForBlending.SetSize( mTargetSize ); + mActorForBlending.SetProperty( Actor::Property::SIZE, mTargetSize ); for( int i = 0; i < kernelSize; ++i ) { @@ -257,15 +226,15 @@ void BlurTwoPassFilter::SetSize( const Vector2& size ) mTargetSize = size; if( mActorForInput ) { - mActorForInput.SetSize(mTargetSize); + mActorForInput.SetProperty( Actor::Property::SIZE, mTargetSize); } if( mActorForHorz ) { - mActorForHorz.SetSize(mTargetSize); + mActorForHorz.SetProperty( Actor::Property::SIZE, mTargetSize); } if( mActorForBlending ) { - mActorForBlending.SetSize(mTargetSize); + mActorForBlending.SetProperty( Actor::Property::SIZE, mTargetSize); } }