X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fshader-effects%2Fimage-region-effect.h;h=7d263d98762344ce9d10905d320e162e75370f7d;hp=2bce6b36a0dd73bd58ea39ac5d4b25bc43dae20a;hb=8d522afed46c436b653f991b7e383fae80eee7df;hpb=22b0e346e001a8987baf3aa2530fcf859aa9294c diff --git a/dali-toolkit/devel-api/shader-effects/image-region-effect.h b/dali-toolkit/devel-api/shader-effects/image-region-effect.h index 2bce6b3..7d263d9 100644 --- a/dali-toolkit/devel-api/shader-effects/image-region-effect.h +++ b/dali-toolkit/devel-api/shader-effects/image-region-effect.h @@ -19,7 +19,7 @@ */ // EXTERNAL INCLUDES -#include +#include namespace Dali { @@ -40,14 +40,23 @@ namespace Toolkit * * @return A handle to a newly allocated ShaderEffect */ -inline ShaderEffect CreateImageRegionEffect() +inline Property::Map CreateImageRegionEffect() { std::string vertexShader( + "attribute mediump vec2 aPosition;\n" + "\n" + "uniform mediump mat4 uMvpMatrix;\n" + "uniform vec3 uSize;\n" + "uniform vec4 uTextureRect;" + "\n" + "varying vec2 vTexCoord;\n" + "uniform mediump vec2 uTopLeft;\n" "uniform mediump vec2 uBottomRight;\n" "void main()\n" "{\n" - " mediump vec4 position = vec4(aPosition,1.0);\n" + " mediump vec4 position = vec4(aPosition, 0.0, 1.0);\n" + " position.xyz *= uSize;\n" " gl_Position = uMvpMatrix * position;\n" // The line below is doing the same as the following commented lines: //" vec2 imageSize = sTextureRect.zw - sTextureRect.xy;\n" @@ -55,15 +64,19 @@ inline ShaderEffect CreateImageRegionEffect() //" vec2 bottomRight = sTextureRect.xy + uBottomRight * imageSize;\n" //" vec2 texCoord = (aTexCoord - sTextureRect.xy) / imageSize;\n" //" vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );\n" - " vTexCoord = sTextureRect.xy + uTopLeft * ( sTextureRect.zw - sTextureRect.xy ) + ( aTexCoord - sTextureRect.xy ) * ( uBottomRight - uTopLeft );\n" + + " vec2 texCoord = aPosition + vec2(0.5);\n" + " vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );\n" "}\n" ); - Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( vertexShader, "" ); - shaderEffect.SetUniform( "uTopLeft", Vector2( 0.f, 0.f ) ); - shaderEffect.SetUniform( "uBottomRight", Vector2( 1.f, 1.f ) ); + Property::Map map; + + Property::Map customShader; + customShader[ "vertexShader" ] = vertexShader; - return shaderEffect; + map[ "shader" ] = customShader; + return map; } } // namespace Toolkit