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=4f3f3f175aa0385911537947259fc924adfe89ba;hp=2bce6b36a0dd73bd58ea39ac5d4b25bc43dae20a;hb=40e6eada47390ac9be4db5fbe210cc5d23c8ebcd;hpb=c3f7ea6cb0c0b75c2276193aff88b5c7a679a2d5 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..4f3f3f1 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,30 +40,43 @@ 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" - //" vec2 topLeft = sTextureRect.xy + uTopLeft * imageSize;\n" - //" vec2 bottomRight = sTextureRect.xy + uBottomRight * imageSize;\n" - //" vec2 texCoord = (aTexCoord - sTextureRect.xy) / imageSize;\n" + //" vec2 imageSize = uTextureRect.zw - uTextureRect.xy;\n" + //" vec2 topLeft = uTextureRect.xy + uTopLeft * imageSize;\n" + //" vec2 bottomRight = uTextureRect.xy + uBottomRight * imageSize;\n" + //" vec2 texCoord = (aTexCoord - uTextureRect.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