Merge "Changed NPatchRenderer and ImageRenderer to use an "broken image" if they...
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 15 Oct 2015 15:07:20 +0000 (08:07 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 15 Oct 2015 15:07:20 +0000 (08:07 -0700)
automated-tests/src/dali-toolkit/utc-Dali-ShaderEffects.cpp
dali-toolkit/devel-api/shader-effects/dissolve-effect.h
dali-toolkit/devel-api/shader-effects/distance-field-effect.h
dali-toolkit/devel-api/shader-effects/motion-blur-effect.h
dali-toolkit/internal/builder/builder-set-property.cpp
dali-toolkit/internal/text/text-controller.cpp

index 33dfee4..28de790 100644 (file)
@@ -198,12 +198,38 @@ int UtcDaliCreateDissolveLocalEffect(void)
   END_TEST;
 }
 
-int UtcDaliCreateDistanceFieldEffect(void)
+int UtcDaliCreateDissolveEffect(void)
 {
   ToolkitTestApplication application;
 
-  ShaderEffect effect = Toolkit::CreateDistanceFieldEffect();
-  DALI_TEST_CHECK( effect );
+  Property::Map effect = Toolkit::CreateDistanceFieldEffect();
+  DALI_TEST_CHECK( !effect.Empty() );
+
+  Property::Value* customShaderValue = effect.Find( "shader" );
+  DALI_TEST_CHECK( customShaderValue );
+
+  Property::Map customShader;
+  DALI_TEST_CHECK( customShaderValue->Get( customShader ) );
+
+  Property::Value* vertexShaderValue = customShader.Find( "vertex-shader" );
+  DALI_TEST_CHECK( !vertexShaderValue );
+
+  Property::Value* fragmentShaderValue = customShader.Find( "fragment-shader" );
+  DALI_TEST_CHECK( fragmentShaderValue );
+
+  std::string fragmentShader;
+  DALI_TEST_CHECK( fragmentShaderValue->Get( fragmentShader ) );
+  DALI_TEST_CHECK( !fragmentShader.empty() );
+
+  Property::Value* gridXValue = customShader.Find( "subdivide-grid-x" );
+  DALI_TEST_CHECK( !gridXValue );
+
+  Property::Value* hintsValue = customShader.Find( "hints" );
+  DALI_TEST_CHECK( hintsValue );
+
+  std::string hints;
+  DALI_TEST_CHECK( hintsValue->Get( hints ) );
+  DALI_TEST_CHECK( hints == "output-is-transparent" );
 
   END_TEST;
 }
index 95cccc8..e160532 100644 (file)
@@ -150,7 +150,7 @@ inline void DissolveEffectSetCentralLine( Actor& actor, const Vector2& position,
  *    "uPercentage" - This value is proportional to the distortion applied; a value of zero means no distortion.
  *
  *  @param[in] useHighPrecision True if using high precision in fragment shader for fully random noise, false otherwise
- *  @return A handle to a newly allocated ShaderEffect
+ *  @return The newly created Property::Map with the dissolve effect
  */
 
 inline Property::Map CreateDissolveEffect( bool useHighPrecision = true )
index c3b2669..aaeb537 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <string.h>
 #include <dali/public-api/shader-effects/shader-effect.h>
 
 namespace Dali
@@ -32,10 +33,8 @@ namespace Toolkit
  *
  * DistanceFieldEffect is a custom shader effect to achieve distance field on Image actors
  *
- * Animatable/Constrainable uniforms:
+ * Animatable/Constrainable uniforms - These will need to be registered to the actor as a custom property to take into effect:
  *
- *  "uSmoothing"    - Soft edge smoothing. Specify the distance field value for the center of the edge.
-
  *  "uDoGlow"       - The glow state. If true, glow is enabled
  *  "uGlowBoundary" - The glow boundary factor
  *  "uGlowColor"    - The glow color multiplier
@@ -50,132 +49,127 @@ namespace Toolkit
  *                    First value [0-1] Specifies the distance field value for the center of the outline.
  *                    Second value [0-1] Specifies the softness/width/anti-aliasing of the outlines inner edge.
  *
- * @return A handle to a newly allocated ShaderEffect
+ *  @return The newly created Property::Map with the distance field effect
  */
-inline ShaderEffect CreateDistanceFieldEffect()
+inline Dali::Property::Map CreateDistanceFieldEffect()
 {
-  std::string fragmentShaderPrefix(
-      "#extension GL_OES_standard_derivatives : enable\n"
-      "\n"
-  );
-
-  std::string fragmentShader(
-      "uniform mediump float uSmoothing;\n"
-      "uniform mediump float uGlowBoundary;\n"
-      "uniform mediump vec2  uOutlineParams;\n"
-      "uniform lowp    vec4  uOutlineColor;\n"
-      "uniform lowp    vec4  uShadowColor;\n"
-      "uniform mediump vec2  uShadowOffset;\n"
-      "uniform lowp    vec4  uGlowColor;\n"
-      "uniform lowp    float uDoOutline;\n"
-      "uniform lowp    float uDoShadow;\n"
-      "uniform lowp    float uDoGlow;\n"
-      "\n"
-      "void main()\n"
-      "{\n"
-      "  // sample distance field\n"
-      "  mediump float distance = texture2D(sTexture, vTexCoord).a;\n"
-      "  mediump float smoothWidth = fwidth(distance);\n"
-      "  mediump float alphaFactor = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);\n"
-      "  lowp    vec4  color;\n"
-      "  if (uDoShadow == 0.0)\n"
-      "  {\n"
-      "    mediump float alpha = uColor.a * alphaFactor;\n"
-      "    lowp    vec4  rgb = uColor;\n"
-      "\n"
-      "    if (uDoOutline > 0.0)\n"
-      "    {\n"
-      "      mediump float outlineWidth = uOutlineParams[1] + smoothWidth;\n"
-      "      mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);\n"
-      "      alpha = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);\n"
-      "      rgb = mix(uOutlineColor, uColor, outlineBlend);\n"
-      "    }\n"
-      "\n"
-      "    if (uDoGlow > 0.0)\n"
-      "    {\n"
-      "      rgb = mix(uGlowColor, rgb, alphaFactor);\n"
-      "      alpha = smoothstep(uGlowBoundary, uSmoothing, distance);\n"
-      "    }\n"
-      "\n"
-      "    // set fragment color\n"
-      "    color = vec4(rgb.rgb, alpha);\n"
-      "  }\n"
-      "\n"
-      "  else // (uDoShadow > 0.0)\n"
-      "  {\n"
-      "    mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
-      "    mediump float inText = alphaFactor;\n"
-      "    mediump float inShadow = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, shadowDistance);\n"
-      "\n"
-      "    // inside object, outside shadow\n"
-      "    if (inText == 1.0)\n"
-      "    {\n"
-      "      color = uColor;\n"
-      "    }\n"
-      "    // inside object, outside shadow\n"
-      "    else if ((inText != 0.0) && (inShadow == 0.0))\n"
-      "    {\n"
-      "      color = uColor;\n"
-      "      color.a *= inText;\n"
-      "    }\n"
-      "    // outside object, completely inside shadow\n"
-      "    else if ((inText == 0.0) && (inShadow == 1.0))\n"
-      "    {\n"
-      "      color = uShadowColor;\n"
-      "    }\n"
-      "    // inside object, completely inside shadow\n"
-      "    else if ((inText != 0.0) && (inShadow == 1.0))\n"
-      "    {\n"
-      "      color = mix(uShadowColor, uColor, inText);\n"
-      "      color.a = uShadowColor.a;\n"
-      "    }\n"
-      "    // inside object, inside shadow's border\n"
-      "    else if ((inText != 0.0) && (inShadow != 0.0))\n"
-      "    {\n"
-      "      color = mix(uShadowColor, uColor, inText);\n"
-      "      color.a *= max(inText, inShadow);\n"
-      "    }\n"
-      "    // inside shadow's border\n"
-      "    else if (inShadow != 0.0)\n"
-      "    {\n"
-      "      color = uShadowColor;\n"
-      "      color.a *= inShadow;\n"
-      "    }\n"
-      "    // outside shadow and object\n"
-      "    else \n"
-      "    {\n"
-      "      color.a = 0.0;\n"
-      "    }\n"
-      "\n"
-      "  }\n"
-      "\n"
-      "  gl_FragColor = color;\n"
-      "\n"
-      "}\n"
+  const char* fragmentShaderPrefix( "#extension GL_OES_standard_derivatives : enable\n" );
+
+  const char* fragmentShader( DALI_COMPOSE_SHADER(
+      varying mediump vec2 vTexCoord;\n
+      \n
+      uniform mediump float uGlowBoundary;\n
+      uniform mediump vec2  uOutlineParams;\n
+      uniform lowp    vec4  uOutlineColor;\n
+      uniform lowp    vec4  uShadowColor;\n
+      uniform mediump vec2  uShadowOffset;\n
+      uniform lowp    vec4  uGlowColor;\n
+      uniform lowp    float uDoOutline;\n
+      uniform lowp    float uDoShadow;\n
+      uniform lowp    float uDoGlow;\n
+      \n
+      uniform sampler2D sTexture;\n
+      uniform lowp vec4 uColor;\n
+      \n
+      void main()\n
+      {\n
+        // sample distance field\n
+        mediump float smoothing = 0.5;\n
+
+        mediump float distance = texture2D(sTexture, vTexCoord).a;\n
+        mediump float smoothWidth = fwidth(distance);\n
+        mediump float alphaFactor = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);\n
+        lowp    vec4  color;\n
+        if (uDoShadow == 0.0)\n
+        {\n
+          mediump float alpha = uColor.a * alphaFactor;\n
+          lowp    vec4  rgb = uColor;\n
+          \n
+          if (uDoOutline > 0.0)\n
+          {\n
+            mediump float outlineWidth = uOutlineParams[1] + smoothWidth;\n
+            mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);\n
+            alpha = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);\n
+            rgb = mix(uOutlineColor, uColor, outlineBlend);\n
+          }\n
+          \n
+          if (uDoGlow > 0.0)\n
+          {\n
+            rgb = mix(uGlowColor, rgb, alphaFactor);\n
+            alpha = smoothstep(uGlowBoundary, smoothing, distance);\n
+          }\n
+          \n
+          // set fragment color\n
+          color = vec4(rgb.rgb, alpha);\n
+        }\n
+        \n
+        else // (uDoShadow > 0.0)\n
+        {\n
+          mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n
+          mediump float inText = alphaFactor;\n
+          mediump float inShadow = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, shadowDistance);\n
+          \n
+          // inside object, outside shadow\n
+          if (inText == 1.0)\n
+          {\n
+            color = uColor;\n
+          }\n
+          // inside object, outside shadow\n
+          else if ((inText != 0.0) && (inShadow == 0.0))\n
+          {\n
+            color = uColor;\n
+            color.a *= inText;\n
+          }\n
+          // outside object, completely inside shadow\n
+          else if ((inText == 0.0) && (inShadow == 1.0))\n
+          {\n
+            color = uShadowColor;\n
+          }\n
+          // inside object, completely inside shadow\n
+          else if ((inText != 0.0) && (inShadow == 1.0))\n
+          {\n
+            color = mix(uShadowColor, uColor, inText);\n
+            color.a = uShadowColor.a;\n
+          }\n
+          // inside object, inside shadow's border\n
+          else if ((inText != 0.0) && (inShadow != 0.0))\n
+          {\n
+            color = mix(uShadowColor, uColor, inText);\n
+            color.a *= max(inText, inShadow);\n
+          }\n
+          // inside shadow's border\n
+          else if (inShadow != 0.0)\n
+          {\n
+            color = uShadowColor;\n
+            color.a *= inShadow;\n
+          }\n
+          // outside shadow and object\n
+          else \n
+          {\n
+            color.a = 0.0;\n
+          }\n
+          \n
+        }\n
+        \n
+        gl_FragColor = color;\n
+        \n
+      } )
   );
 
-  // Create the implementation, temporarily owned on stack
-  Dali::ShaderEffect shaderEffect =  Dali::ShaderEffect::NewWithPrefix(
-      "", "",
-      fragmentShaderPrefix, fragmentShader,
-      ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING));
+  Property::Map map;
 
-  shaderEffect.SetUniform("uSmoothing",0.5f);
-  shaderEffect.SetUniform("uOutlineColor",Color::BLACK);
-  shaderEffect.SetUniform("uOutlineParams",Vector2(0.51f, 0.0f));
-  shaderEffect.SetUniform("uGlowBoundary",0.4f);
-  shaderEffect.SetUniform("uGlowColor",Color::GREEN);
-  shaderEffect.SetUniform("uShadowColor",Vector4(0.0f, 0.0f, 0.0f, 0.4f));
+  Property::Map customShader;
 
-  // TODO: find a way to set the shadow offset in texel coordinates instead of UVs.
-  shaderEffect.SetUniform("uShadowOffset",Vector2(0.05f, 0.05f));
+  std::string fragmentShaderString;
+  fragmentShaderString.reserve( strlen( fragmentShaderPrefix ) + strlen( fragmentShader ) );
+  fragmentShaderString.append( fragmentShaderPrefix );
+  fragmentShaderString.append( fragmentShader );
 
-  // Default:
-  shaderEffect.SetUniform("uDoOutline",false);
-  shaderEffect.SetUniform("uDoGlow",false);
-  shaderEffect.SetUniform("uDoShadow",false);
+  customShader[ "fragment-shader" ] = fragmentShaderString;
+  customShader[ "hints" ] = "output-is-transparent";
 
-  return shaderEffect;
+  map[ "shader" ] = customShader;
+  return map;
 }
 
 
index a4aaa7f..17c2f65 100644 (file)
@@ -102,7 +102,7 @@ inline ShaderEffect CreateMotionBlurEffect( unsigned int numBlurSamples = 8 )
   vertexSource =
       "precision mediump float;\n"
       "uniform mat4 uModelLastFrame;\n"
-      "uniform float uTimeDelta;\n"
+      "float timeDelta = 0.0167;\n"
 
       "uniform float uGeometryStretchFactor;\n"
       "uniform float uSpeedScalingFactor;\n"
@@ -118,7 +118,7 @@ inline ShaderEffect CreateMotionBlurEffect( unsigned int numBlurSamples = 8 )
       " vec4 vertex = vec4(aPosition, 1.0);\n"
       " vec4 viewSpaceVertex = uModelView * vertex;\n"
       " vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertex;\n"
-      " float reciprocalTimeDelta = 1.0 / ((uTimeDelta > 0.0) ? uTimeDelta : 0.01);\n"
+      " float reciprocalTimeDelta = 1.0 / timeDelta;\n"
 
       // work out vertex's last movement in view space
       " vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
index c78e19c..c2d77a7 100644 (file)
@@ -102,7 +102,7 @@ Vector4 HexStringToVector4( const char* s )
 /**
  * A property value type can be forced when its unknown by a disambiguation convention in the json
  * ie  "myarray": [1,2,3,4] ; would be a vector but
- *     "myarray": {'type-cast':'array', 'value':[1,2,3,4]} would be an array
+ *     "myarray": {"type-cast":"array", "value":[1,2,3,4]} would be an array
  * @param child The node whos string to search for a disambiguated type
  * @param value The value to set
  * @param overrideMap The user overriding constant map
index 07cb7fe..bcac025 100644 (file)
@@ -1709,6 +1709,9 @@ void Controller::PasteText( const std::string& stringToPaste )
   InsertText( stringToPaste, Text::Controller::COMMIT );
   mImpl->ChangeState( EventData::EDITING );
   mImpl->RequestRelayout();
+
+  // Do this last since it provides callbacks into application code
+  mImpl->mControlInterface.TextChanged();
 }
 
 void Controller::PasteClipboardItemEvent()