#define __DALI_TOOLKIT_IMAGE_REGION_EFFECT_H__
/*
- * Copyright (c) 2015 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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
namespace Dali
{
* "uBottomRight" - The bottom-right corner of the image region. The coordinates are in percentage,
* (0,0) being the top-left and (1,1) the bottom right of the original image
*
- * @return A handle to a newly allocated ShaderEffect
+ * @return A property map of the required shader
*/
-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[ Visual::Shader::Property::VERTEX_SHADER ] = vertexShader;
- return shaderEffect;
+ map[ DevelVisual::Property::SHADER ] = customShader;
+ return map;
}
} // namespace Toolkit