Ensure the use of ShaderEffect in ImageActor is backwards-compatible 43/59243/2
authorXiangyin Ma <x1.ma@samsung.com>
Thu, 11 Feb 2016 16:47:47 +0000 (16:47 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 15 Feb 2016 11:00:54 +0000 (03:00 -0800)
Change-Id: I2994b917eb8f63edbec95838be899073887b2eeb

14 files changed:
automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp
dali-toolkit/devel-api/shader-effects/bendy-effect.h
dali-toolkit/devel-api/shader-effects/carousel-effect.h
dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h
dali-toolkit/devel-api/shader-effects/iris-effect.h
dali-toolkit/devel-api/shader-effects/mirror-effect.h
dali-toolkit/devel-api/shader-effects/ripple-effect.h
dali-toolkit/devel-api/shader-effects/ripple2d-effect.h
dali-toolkit/devel-api/shader-effects/shear-effect.h
dali-toolkit/devel-api/shader-effects/soft-button-effect.h
dali-toolkit/devel-api/shader-effects/spot-effect.h
dali-toolkit/devel-api/shader-effects/swirl-effect.h
dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h
dali-toolkit/internal/controls/page-turn-view/page-turn-effect.cpp

index deb3727..653325c 100644 (file)
@@ -948,7 +948,7 @@ int UtcDaliBuilderShaderEffectP(void)
     "        \"vertexPrefix\": \"\",\n"
     "        \"vertex\": \"void main(void)\\n{\\n  gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n  vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
     "        \"fragmentPrefix\": \"\",\n"
-    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
     "        \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
     "      },\n"
     "      \"geometryHints\": \"HINT_NONE\",\n"
@@ -1058,7 +1058,7 @@ int UtcDaliBuilderShaderEffect2P(void)
     "        \"vertexPrefix\": \"\",\n"
     "        \"vertex\": \"void main(void)\\n{\\n  gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n  vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
     "        \"fragmentPrefix\": \"\",\n"
-    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
     "        \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
     "      },\n"
     "      \"geometryHints\": \"HINT_NONE\",\n"
@@ -1241,7 +1241,7 @@ int UtcDaliBuilderFrameBufferP(void)
     "        \"vertexPrefix\": \"\",\n"
     "        \"vertex\": \"void main(void)\\n{\\n  gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n  vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
     "        \"fragmentPrefix\": \"\",\n"
-    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
     "        \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
     "      },\n"
     "      \"geometryHints\": \"HINT_NONE\",\n"
@@ -1412,7 +1412,7 @@ int UtcDaliBuilderPathConstraintsP(void)
     "        \"vertexPrefix\": \"\",\n"
     "        \"vertex\": \"void main(void)\\n{\\n  gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n  vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
     "        \"fragmentPrefix\": \"\",\n"
-    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
+    "        \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n  highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n  highp float len = length(pos);\\n  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n  gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
     "        \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
     "      },\n"
     "      \"geometryHints\": \"HINT_NONE\",\n"
index 9f9deb5..6708394 100644 (file)
@@ -52,7 +52,7 @@ inline ShaderEffect CreateBendyEffect()
       "void main()\n"
       "{\n"
       " mediump float lighting = 0.25;\n"
-      " mediump vec4 position = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+      " mediump vec4 position = uModelView * vec4(aPosition, 1.0);\n"
       "\n"
       " mediump vec2 d = position.xy - uCenter;\n"
       " mediump float dist = max( 0.0, dot(d,uDirection) );\n"
@@ -70,7 +70,7 @@ inline ShaderEffect CreateBendyEffect()
       "\n"
       "vShade = 1.0 - abs(sn) * lighting;\n"
       "\n"
-      "vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+      "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       "}" );
 
   std::string fragmentShader(
index 67180bd..e7de082 100644 (file)
@@ -63,14 +63,14 @@ inline ShaderEffect CreateCarouselEffect()
                 "\n"
                 "void main()\n"
                 "{\n"
-                "    mediump vec4 world = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+                "    mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
                 "    mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
                 "    mediump float a = length(d);\n"
                 "    mediump float cs = cos(radians(a));\n"
                 "    world.z -= cs * uRadius;\n"
                 "    gl_Position = uProjection * world;\n"
                 "    \n"
-                "    vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+                "    vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
                 "}\n");
 
     ShaderEffect shaderEffect = ShaderEffect::New(
index c91abdc..31dcebd 100644 (file)
@@ -54,7 +54,7 @@ inline ShaderEffect CreateDissolveLocalEffect( unsigned int numberOfDimples )
       "varying float vPercentage;\n"
       "void main()\n"
       "{\n"
-      "  vec4 position = uModelView * vec4( aPosition*uSize.xy, 0.0,  1.0 );\n"
+      "  vec4 position = uModelView * vec4( aPosition, 1.0 );\n"
       "  float percentage = 0.0;\n"
       "  for( int i=0; i<NUMBER_OF_DIMPLE; ++i )\n"
       "  {\n"
@@ -63,7 +63,7 @@ inline ShaderEffect CreateDissolveLocalEffect( unsigned int numberOfDimples )
       "  }\n"
       "  vPercentage = clamp( percentage, 0.0, 1.0 );\n"
       "  gl_Position = uProjection * position;\n"
-      "  vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+      "  vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       "}\n");
   vertexShaderStringStream << vertexShader;
 
index 48e6f11..6c7f6cd 100644 (file)
@@ -55,10 +55,10 @@ inline ShaderEffect CreateIrisEffect()
       "\n"
       "void main()\n"
       "{\n"
-      "    mediump vec4 world = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+      "    mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
       "    gl_Position = uProjection * world;\n"
       "    \n"
-      "    vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );;\n"
+      "    vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       "    vRelativePosition = vTexCoord - uCenter;\n"
       "}\n");
 
index edf7ffd..a4f8dad 100644 (file)
@@ -43,11 +43,11 @@ inline ShaderEffect CreateMirrorEffect()
   std::string vertexShader(
       "void main()                                  \n"
       "{                                            \n"
-      "  mediump vec3 pos = vec3(aPosition, 0.0)*uSize;              \n"
+      "  mediump vec3 pos = aPosition;              \n"
       "  pos.y = pos.y * 3.0;                       \n"
       "  mediump vec4 world = uModelView * vec4(pos,1.0); \n"
       "  gl_Position = uProjection * world;         \n"
-      "  vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) ); \n"
+      "  vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord ); \n"
       "}                                            \n" );
 
   std::string fragmentShader(
index dd71982..767de60 100644 (file)
@@ -52,7 +52,7 @@ inline ShaderEffect CreateRippleEffect()
       "{\n"
       "float lighting = uAmplitude * 0.02;\n"
       "float waveLength = uAmplitude * 0.0016;\n"
-      "vec4 world = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+      "vec4 world = uModelView * vec4(aPosition, 1.0);\n"
       "vec2 d = vec2(world.x - uCenter.x, world.y - uCenter.y);\n"
       "float dist = length(d);\n"
       "float amplitude = cos(uTime - dist*waveLength);\n"
@@ -67,7 +67,7 @@ inline ShaderEffect CreateRippleEffect()
       "}\n"
       "vShade = 1.0 - (dot * slope);\n"
       "vLight = max(0.0, dot * -slope);\n"
-      "vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+      "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       "}" );
 
   // append the default version
index 782c440..cbef85b 100644 (file)
@@ -47,7 +47,7 @@ inline ShaderEffect CreateRipple2DEffect()
       "uniform float uTime;\n"
       "void main()\n"
       "{\n"
-      "  highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\n"
+      "  highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\n"
       "  highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\n"
       "  highp float len = length(pos);\n"
       "  highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude;\n"
index 5b8faf9..880784f 100644 (file)
@@ -49,14 +49,14 @@ inline ShaderEffect CreateShearEffect()
       "\n"
       "void main()\n"
       "{\n"
-      "mediump vec4 world = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+      "mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
       "\n"
       "world.x = world.x + tan(radians(uAngleXAxis)) * (world.y - uCenter.y * world.w);\n"
       "world.y = world.y + tan(radians(uAngleYAxis)) * (world.x - uCenter.x * world.w);\n"
       "\n"
       "gl_Position = uProjection * world;\n"
       "\n"
-      "vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+      "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       "}" );
 
   // Create the implementation, temporarily owned on stack,
index 55adafb..f02963e 100644 (file)
@@ -117,11 +117,11 @@ inline ShaderEffect CreateSoftButtonEffect(SoftButtonEffectType type)
 
       "void main()\n"
       "{\n"
-      "  vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+      "  vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       // Get the rect coords of the effect region in -1..1 range, i.e. circle centred around the center of the rect
       // Done in the vertex shader itself to make use of gl interpolation for varying.
       "  vCentredCoord = vec2( ( (vTexCoord.x - uEffectRegion.x)/(uEffectRegion.z - uEffectRegion.x) * 2.0 - 1.0 ), ( (vTexCoord.y - uEffectRegion.y)/(uEffectRegion.w - uEffectRegion.y) * 2.0 - 1.0  ) );\n"
-      "  gl_Position = uMvpMatrix * vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+      "  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);\n"
       "}\n";
 
   std::string fragmentSourceFixed;
index 2cff9ee..054942e 100644 (file)
@@ -48,7 +48,7 @@ inline ShaderEffect CreateSpotEffect()
       "\n"
       "void main()\n"
       "{\n"
-      "  mediump vec4 world = vec4(aPosition*uSize.xy, 0.0, 1.0);\n"
+      "  mediump vec4 world = vec4(aPosition, 1.0);\n"
       "  \n"
       "  mediump vec2 d = vec2(world.xy - uCenter);\n"
       "  mediump float dist = length(d);\n"
@@ -57,7 +57,7 @@ inline ShaderEffect CreateSpotEffect()
       "  vRange = max(0.1, range);\n"
       "  \n"
       "  gl_Position = uMvpMatrix * world;\n"
-      "  vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n"
+      "  vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
       "}");
 
   std::string fragmentShader(
index 3c8b36f..020b320 100644 (file)
@@ -50,7 +50,7 @@ inline ShaderEffect CreateSwirlEffect( bool warp )
       "uniform mediump vec2  uCenter;\n"
       "void main()\n"
       "{\n"
-      "  highp vec2 textureCenter = (uTextureRect.xy + uTextureRect.zw) * 0.5;\n"
+      "  highp vec2 textureCenter = (sTextureRect.xy + sTextureRect.zw) * 0.5;\n"
       "  textureCenter = vTexCoord.st - textureCenter;\n"
       "  highp float distance = length(textureCenter);\n"
       "  if (distance >= uRadius)\n"
index 532f553..efe112c 100644 (file)
@@ -61,11 +61,11 @@ inline ShaderEffect CreatePageTurnBookSpineEffect()
       {\n
       // flip the image horizontally by changing the x component of the texture coordinate
         if( uIsBackImageVisible == 1.0 )\n
-          gl_FragColor = texture2D( sTexture, vec2( uTextureRect.p+uTextureRect.s-vTexCoord.x, vTexCoord.y ) ) * uColor; \n
+          gl_FragColor = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) ) * uColor; \n
         else\n
         gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
       // display book spine, a stripe of shadowed texture
-        float pixelPos = (vTexCoord.x-uTextureRect.s)*uPageWidth; \n
+        float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageWidth; \n
         if(pixelPos < uSpineShadowParameter.x) \n
         {\n
           float x = pixelPos - uSpineShadowParameter.x;\n
index 233a3a1..f4ada4f 100644 (file)
@@ -127,7 +127,7 @@ ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect()
       \n
       void main()\n
       {\n
-        vec4 position = vec4( aPosition*uSize.xy, 0.0, 1.0);\n
+        vec4 position = vec4( aPosition, 1.0);\n
         vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);\n
         vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);\n
         vec3 normal = vec3(0.0,0.0,1.0);\n
@@ -248,7 +248,7 @@ ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect()
         }\n
         gl_Position = uMvpMatrix * position;\n
         // varying parameters for fragment shader
-        vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;
+        vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n;
         vNormal = uNormalMatrix*normal;\n
         vPosition = uModelView * position;\n
       }\n
@@ -270,11 +270,11 @@ ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect()
         float spineShadowCoef = 1.0; \n
         // display page content
         // display back image of the page, flip the texture
-        if(  dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( uTextureRect.p+uTextureRect.s-vTexCoord.x, vTexCoord.y ) );\n
+        if(  dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) );\n
         // display front image of the page
         else texel = texture2D( sTexture, vTexCoord );\n
         // display book spine, a stripe of shadowed texture
-        float pixelPos = (vTexCoord.x-uTextureRect.s)*uPageSize.x; \n
+        float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageSize.x; \n
         if(pixelPos < uSpineShadowParameter.x) \n
         {\n
           float x = pixelPos - uSpineShadowParameter.x;\n