[dali_2.1.23] Merge branch 'devel/master' 18/275318/1
authorAdam Bialogonski <adam.b@samsung.com>
Fri, 20 May 2022 10:16:59 +0000 (11:16 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Fri, 20 May 2022 10:16:59 +0000 (11:16 +0100)
Change-Id: I0f9e4473257f375ef14525df4d1ec2b2208a576b

53 files changed:
automated-tests/resources/AnimatedCube.gltf
automated-tests/src/dali-scene-loader/utc-Dali-Gltf2Loader.cpp
automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinitionFactory.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.h [new file with mode: 0644]
automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.frag
dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.vert
dali-scene-loader/public-api/environment-definition.cpp
dali-scene-loader/public-api/environment-definition.h
dali-scene-loader/public-api/gltf2-loader.cpp
dali-scene-loader/public-api/material-definition.cpp
dali-scene-loader/public-api/material-definition.h
dali-scene-loader/public-api/mesh-definition.cpp
dali-scene-loader/public-api/mesh-definition.h
dali-scene-loader/public-api/node-definition.cpp
dali-scene-loader/public-api/shader-definition-factory.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/image-loader/image-atlas-impl.cpp
dali-toolkit/internal/image-loader/image-atlas-impl.h
dali-toolkit/internal/text/rendering/text-typesetter.cpp
dali-toolkit/internal/text/rendering/text-typesetter.h
dali-toolkit/internal/texture-manager/texture-cache-manager.cpp
dali-toolkit/internal/texture-manager/texture-cache-manager.h
dali-toolkit/internal/texture-manager/texture-manager-impl.cpp
dali-toolkit/internal/texture-manager/texture-manager-impl.h
dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp
dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/image-cache.h
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h
dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/image-atlas-manager.cpp
dali-toolkit/internal/visuals/image-atlas-manager.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/svg/svg-rasterize-thread.cpp
dali-toolkit/internal/visuals/svg/svg-rasterize-thread.h
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.h
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.h
dali-toolkit/internal/visuals/visual-url.cpp
dali-toolkit/internal/visuals/visual-url.h
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index 2f78e20..995d3b1 100644 (file)
             "baseColorTexture" : {
                "index" : 0
             },
-            "metallicRoughnessTexture" : {
-               "index" : 1
-            },
             "baseColorFactor": [ 1.000, 0.766, 0.336, 1.0 ],
             "metallicFactor": 1.0,
             "roughnessFactor": 0.0
index b4dceb9..4a40524 100644 (file)
@@ -161,28 +161,30 @@ int UtcDaliGltfLoaderSuccess1(void)
   DALI_TEST_EQUAL(1u, ctx.scene.GetRoots().size());
   DALI_TEST_EQUAL(6u, ctx.scene.GetNodeCount());
 
-  DALI_TEST_EQUAL(0u, ctx.resources.mEnvironmentMaps.size());
+  // Default envmap is used
+  DALI_TEST_EQUAL(1u, ctx.resources.mEnvironmentMaps.size());
 
   auto& materials = ctx.resources.mMaterials;
   DALI_TEST_EQUAL(2u, materials.size());
   const MaterialDefinition materialGroundTruth[]{
-    {MaterialDefinition::ALBEDO | MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS |
-       MaterialDefinition::EMISSIVE | MaterialDefinition::OCCLUSION |
-       MaterialDefinition::NORMAL | MaterialDefinition::TRANSPARENCY | MaterialDefinition::GLTF_CHANNELS |
+    {MaterialDefinition::ALBEDO | MaterialDefinition::EMISSIVE | MaterialDefinition::OCCLUSION |
+       MaterialDefinition::NORMAL | MaterialDefinition::TRANSPARENCY |
        (0x80 << MaterialDefinition::ALPHA_CUTOFF_SHIFT),
      0,
-     Vector4(1.f, .766f, .336f, 1.f),
-     Vector3(0.2, 0.1, 0.0),
+     Color::WHITE,
      1.f,
      0.f,
+     Vector4(1.000, 0.766, 0.336, 1.0),
+     1.f,
      1.f,
+     Vector3(0.2, 0.1, 0.0),
+     true,
+     false,
+     true,
      {
        {MaterialDefinition::ALBEDO,
         {"AnimatedCube_BaseColor.png",
          SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT)}},
-       {MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS | MaterialDefinition::GLTF_CHANNELS,
-        {"AnimatedCube_MetallicRoughness.png",
-         SamplerFlags::Encode(FilterMode::NEAREST_MIPMAP_LINEAR, FilterMode::NEAREST, WrapMode::CLAMP_TO_EDGE, WrapMode::MIRRORED_REPEAT)}},
        {MaterialDefinition::NORMAL,
         {"AnimatedCube_BaseColor.png",
          SamplerFlags::Encode(FilterMode::LINEAR_MIPMAP_LINEAR, FilterMode::LINEAR, WrapMode::CLAMP_TO_EDGE, WrapMode::REPEAT)}},
@@ -197,11 +199,16 @@ int UtcDaliGltfLoaderSuccess1(void)
        MaterialDefinition::EMISSIVE | MaterialDefinition::OCCLUSION |
        MaterialDefinition::NORMAL | MaterialDefinition::GLTF_CHANNELS,
      0,
-     Vector4(1.f, .766f, .336f, 1.f),
-     Vector3(0.2, 0.1, 0.0),
+     Color::WHITE,
      1.f,
      0.f,
+     Vector4(1.000, 0.766, 0.336, 1.0),
      1.f,
+     1.f,
+     Vector3(0.2, 0.1, 0.0),
+     true,
+     true,
+     true,
      {
        {MaterialDefinition::ALBEDO,
         {"AnimatedCube_BaseColor.png",
@@ -231,6 +238,13 @@ int UtcDaliGltfLoaderSuccess1(void)
     DALI_TEST_EQUAL(md.mColor, m.mColor);
     DALI_TEST_EQUAL(md.mMetallic, m.mMetallic);
     DALI_TEST_EQUAL(md.mRoughness, m.mRoughness);
+    DALI_TEST_EQUAL(md.mBaseColorFactor, m.mBaseColorFactor);
+    DALI_TEST_EQUAL(md.mNormalScale, m.mNormalScale);
+    DALI_TEST_EQUAL(md.mOcclusionStrength, m.mOcclusionStrength);
+    DALI_TEST_EQUAL(md.mEmissiveFactor, m.mEmissiveFactor);
+    DALI_TEST_EQUAL(md.mNeedAlbedoTexture, m.mNeedAlbedoTexture);
+    DALI_TEST_EQUAL(md.mNeedMetallicRoughnessTexture, m.mNeedMetallicRoughnessTexture);
+    DALI_TEST_EQUAL(md.mNeedNormalTexture, m.mNeedNormalTexture);
 
     DALI_TEST_EQUAL(md.mTextureStages.size(), m.mTextureStages.size());
     auto iTexture = md.mTextureStages.begin();
@@ -260,6 +274,7 @@ int UtcDaliGltfLoaderSuccess1(void)
       Accessor{Blob{0, 0}, {}},
       Accessor{Blob{0, 0}, {}},
       Accessor{Blob{0, 0}, {}},
+      Accessor{Blob{0, 0}, {}},
     },
     {
       0,
@@ -270,6 +285,7 @@ int UtcDaliGltfLoaderSuccess1(void)
       Accessor{Blob{0, 0}, {}},
       Accessor{Blob{0, 0}, {}},
       Accessor{Blob{0, 0}, {}},
+      Accessor{Blob{0, 0}, {}},
     },
   };
 
@@ -286,6 +302,7 @@ int UtcDaliGltfLoaderSuccess1(void)
           &MeshDefinition::mPositions,
           &MeshDefinition::mNormals,
           &MeshDefinition::mTexCoords,
+          &MeshDefinition::mColors,
           &MeshDefinition::mTangents,
           &MeshDefinition::mJoints0,
           &MeshDefinition::mWeights0})
@@ -333,6 +350,7 @@ int UtcDaliGltfLoaderSuccessShort(void)
         "MorphPrimitivesTest",
         "MRendererTest",
         "SimpleSparseAccessor",
+        "AnimatedCube",
       })
   {
     Context ctx;
@@ -405,7 +423,6 @@ int UtcDaliGltfLoaderMRendererTest(void)
   ShaderDefinitionFactory sdf;
   sdf.SetResources(ctx.resources);
   auto& resources = ctx.resources;
-  resources.mEnvironmentMaps.push_back({});
 
   LoadGltfScene(TEST_RESOURCE_DIR "/MRendererTest.gltf", sdf, ctx.loadResult);
 
@@ -448,8 +465,12 @@ int UtcDaliGltfLoaderMRendererTest(void)
   }
 
   DALI_TEST_EQUAL(root.GetChildCount(), 1u);
-  DALI_TEST_EQUAL(root.GetChildAt(0).GetProperty(Actor::Property::NAME).Get<std::string>(), "RootNode");
-  DALI_TEST_EQUAL(root.GetChildAt(0).GetProperty(Actor::Property::SCALE).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f));
+  Actor child = root.GetChildAt(0);
+
+  DALI_TEST_EQUAL(child.GetProperty(Actor::Property::NAME).Get<std::string>(), "RootNode");
+  DALI_TEST_EQUAL(child.GetProperty(Actor::Property::SCALE).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f));
+  DALI_TEST_EQUAL(child.GetRendererCount(), 1u);
+  DALI_TEST_EQUAL(child.GetRendererAt(0).GetTextures().GetTextureCount(), 4u);
 
   END_TEST;
 }
index 3fd8fbb..534189e 100644 (file)
@@ -108,7 +108,7 @@ int UtcDaliShaderDefinitionFactoryProduceShader(void)
   Permutation permutations[]{
     {
       [](ShaderParameters& p) {},
-      {},
+      {"THREE_TEX"},
       RendererState::DEPTH_TEST | RendererState::DEPTH_WRITE | RendererState::CULL_BACK,
     },
     {
@@ -250,8 +250,6 @@ int UtcDaliShaderDefinitionFactoryProduceShader(void)
 
   for(auto& ps : permSets)
   {
-    printf("%ld\n", &ps - permSets);
-
     auto modelNode          = new ModelNode();
     modelNode->mMeshIdx     = 0;
     modelNode->mMaterialIdx = 0;
@@ -279,9 +277,9 @@ int UtcDaliShaderDefinitionFactoryProduceShader(void)
     DALI_TEST_EQUAL(shaderDef.mRendererState, rendererState);
 
     uint32_t definesUnmatched = shaderDef.mDefines.size();
-    for(auto& d : shaderDef.mDefines)
+    for(auto& define : shaderDef.mDefines)
     {
-      auto iFind = defines.find(d);
+      auto iFind = defines.find(define);
       if(iFind != defines.end())
       {
         defines.erase(iFind);
@@ -289,7 +287,6 @@ int UtcDaliShaderDefinitionFactoryProduceShader(void)
       }
       else
       {
-        printf("mismatched: %s\n", d.c_str());
         break;
       }
     }
@@ -297,8 +294,6 @@ int UtcDaliShaderDefinitionFactoryProduceShader(void)
     DALI_TEST_CHECK(defines.empty());
     DALI_TEST_EQUAL(0, definesUnmatched);
 
-    printf("defines OK\n");
-
     auto uMaxLOD = shaderDef.mUniforms["uMaxLOD"];
     DALI_TEST_EQUAL(uMaxLOD.GetType(), Property::FLOAT);
 
index d39b00c..e2ff409 100755 (executable)
@@ -160,7 +160,7 @@ int UtcDaliDebugRenderingGetVisual1(void)
   propertyMap5.Insert(ImageVisual::Property::URL, TEST_SVG_FILE_NAME);
   Visual::Base svgVisual = factory.CreateVisual(propertyMap5);
   DALI_TEST_CHECK(svgVisual);
-  TestDebugVisual(application.GetScene(), svgVisual, Visual::SVG, Vector2(100.f, 100.f));
+  TestDebugVisual(application.GetScene(), svgVisual, Visual::SVG, Vector2::ZERO);
 
   // Test that AnimatedImageVisual is replaced with debug visual
   // TEST_GIF_FILE: anim.gif
index af42955..bd5ab62 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -19,6 +19,8 @@
 
 #include <stdlib.h>
 
+#include <dali/devel-api/common/hash.h>
+
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
 
@@ -26,420 +28,445 @@ using namespace Dali::Toolkit::Internal;
 
 int UtcDaliVisualUrlConstructor(void)
 {
-  const char* url="file://bar.org/foobar.gif";
-  VisualUrl visualUrl(url);
-  DALI_TEST_EQUALS( true, visualUrl.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl.GetType(), VisualUrl::GIF, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+  const char* url = "file://bar.org/foobar.gif";
+  VisualUrl   visualUrl(url);
+  DALI_TEST_EQUALS(true, visualUrl.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl.GetType(), VisualUrl::GIF, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION);
 
   VisualUrl visualUrl2("foobar.jpeg");
   visualUrl2 = visualUrl;
-  DALI_TEST_EQUALS( true, visualUrl2.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl2.GetType(), VisualUrl::GIF, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl2.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+  DALI_TEST_EQUALS(true, visualUrl2.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl2.GetType(), VisualUrl::GIF, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl2.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION);
 
-  VisualUrl visualUrl3( visualUrl );
-  DALI_TEST_EQUALS( true, visualUrl3.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl3.GetType(), VisualUrl::GIF, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl3.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+  VisualUrl visualUrl3(visualUrl);
+  DALI_TEST_EQUALS(true, visualUrl3.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl3.GetType(), VisualUrl::GIF, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl3.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION);
 
   VisualUrl visualUrl4("dali://0");
   visualUrl4 = visualUrl;
-  DALI_TEST_EQUALS( true, visualUrl4.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl4.GetType(), VisualUrl::GIF, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl4.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+  DALI_TEST_EQUALS(true, visualUrl4.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl4.GetType(), VisualUrl::GIF, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl4.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION);
 
   VisualUrl visualUrl5("dali://1");
   visualUrl4 = visualUrl5;
-  DALI_TEST_EQUALS( true, visualUrl4.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl4.GetType(), VisualUrl::REGULAR_IMAGE, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl4.GetProtocolType(), VisualUrl::TEXTURE, TEST_LOCATION );
+  DALI_TEST_EQUALS(true, visualUrl4.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl4.GetType(), VisualUrl::REGULAR_IMAGE, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl4.GetProtocolType(), VisualUrl::TEXTURE, TEST_LOCATION);
 
   VisualUrl visualUrl6("enbuf://0");
   visualUrl6 = visualUrl;
-  DALI_TEST_EQUALS( true, visualUrl6.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl6.GetType(), VisualUrl::GIF, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl6.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION );
+  DALI_TEST_EQUALS(true, visualUrl6.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl6.GetType(), VisualUrl::GIF, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl6.GetProtocolType(), VisualUrl::LOCAL, TEST_LOCATION);
 
   VisualUrl visualUrl7("enbuf://1");
   visualUrl6 = visualUrl7;
-  DALI_TEST_EQUALS( true, visualUrl6.IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl6.GetType(), VisualUrl::REGULAR_IMAGE, TEST_LOCATION );
-  DALI_TEST_EQUALS( visualUrl6.GetProtocolType(), VisualUrl::BUFFER, TEST_LOCATION );
+  DALI_TEST_EQUALS(true, visualUrl6.IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl6.GetType(), VisualUrl::REGULAR_IMAGE, TEST_LOCATION);
+  DALI_TEST_EQUALS(visualUrl6.GetProtocolType(), VisualUrl::BUFFER, TEST_LOCATION);
   END_TEST;
 }
 
-
 int UtcDaliVisualUrlRegularImage(void)
 {
-  tet_infoline( "UtcDaliVisualUrl REGULAR_IMAGE" );
+  tet_infoline("UtcDaliVisualUrl REGULAR_IMAGE");
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.jpeg").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.jpeg").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.PNG").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.PNG").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.Png123").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.Png123").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.Png1.23").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("foobar.Png1.23").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl(" ").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl(" ").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl(".").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl(".").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("9").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("9").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("dali://bar.org/foobar.gif").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("dali://bar.org/foobar.gif").GetType(), TEST_LOCATION);
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlSvg(void)
 {
-  tet_infoline( "UtcDaliVisualUrl SVG" );
+  tet_infoline("UtcDaliVisualUrl SVG");
 
-  DALI_TEST_EQUALS( VisualUrl::SVG, VisualUrl("foobar.svg").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::SVG, VisualUrl("foobar.svg").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::SVG, VisualUrl("foobar.svg.svg").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::SVG, VisualUrl("foobar.svg.svg").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::SVG, VisualUrl("foobar.svG").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::SVG, VisualUrl("foobar.svG").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::SVG, VisualUrl("foobar.SVG").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::SVG, VisualUrl("foobar.SVG").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::SVG, VisualUrl(".SvG").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::SVG, VisualUrl(".SvG").GetType(), TEST_LOCATION);
 
   // SVGs aren't N-patch
-  DALI_TEST_EQUALS( VisualUrl::SVG, VisualUrl("foobar.9.svg").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::SVG, VisualUrl("foobar.9.svg").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("svg.png").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("svg.png").GetType(), TEST_LOCATION);
 
   // maybe controversial, but for now we expect the suffix to be exactly .svg
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("svg.svg1").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("svg.svg1").GetType(), TEST_LOCATION);
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlNPatch(void)
 {
-  tet_infoline( "UtcDaliVisualUrl N_PATCH" );
+  tet_infoline("UtcDaliVisualUrl N_PATCH");
 
-  DALI_TEST_EQUALS( VisualUrl::N_PATCH, VisualUrl("foobar.#.png").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::N_PATCH, VisualUrl("foobar.#.png").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::N_PATCH, VisualUrl("foobar.9.9.bmp").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::N_PATCH, VisualUrl("foobar.9.9.bmp").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::N_PATCH, VisualUrl("foobar.9.9.jpg[]=$$").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::N_PATCH, VisualUrl("foobar.9.9.jpg[]=$$").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::N_PATCH, VisualUrl("foobar.9.#.#.9.wbpm123").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::N_PATCH, VisualUrl("foobar.9.#.#.9.wbpm123").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("svg.##.png").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("svg.##.png").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("svg.99.jpeg").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("svg.99.jpeg").GetType(), TEST_LOCATION);
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlGif(void)
 {
-  tet_infoline( "UtcDaliVisualUrl GIF" );
+  tet_infoline("UtcDaliVisualUrl GIF");
 
-  DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl("foobar.gif").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::GIF, VisualUrl("foobar.gif").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl("foobar.gif.gif").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::GIF, VisualUrl("foobar.gif.gif").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl("foobar.giF").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::GIF, VisualUrl("foobar.giF").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl("foobar.GIF").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::GIF, VisualUrl("foobar.GIF").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl(".GiF").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::GIF, VisualUrl(".GiF").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::N_PATCH, VisualUrl("foobar.9.gif").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::N_PATCH, VisualUrl("foobar.9.gif").GetType(), TEST_LOCATION);
 
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("gif.png").GetType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("gif.gif1").GetType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("dali://.gif").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("gif.png").GetType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("gif.gif1").GetType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REGULAR_IMAGE, VisualUrl("dali://.gif").GetType(), TEST_LOCATION);
 
   END_TEST;
 }
 
-
 int UtcDaliVisualUrlLocationP(void)
 {
-  tet_infoline( "UtcDaliVisualUrl Location" );
-
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.jpeg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ftp://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ssh://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("http://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("https://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("FTP://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("FTP://BAR.ORG/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("SSH://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("SSH://BAR.ORG/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTP://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTPS://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://1234").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("DALI://1234").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://1234").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("ENBUF://1234").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
+  tet_infoline("UtcDaliVisualUrl Location");
+
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.jpeg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ftp://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ftp://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ssh://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("ssh://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("http://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("http://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("https://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("https://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("FTP://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("FTP://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("FTP://BAR.ORG/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("SSH://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("SSH://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("SSH://BAR.ORG/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTP://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTP://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTPS://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.GIF").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::REMOTE, VisualUrl("HTTPS://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://1234").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("DALI://1234").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::TEXTURE, VisualUrl("dali://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://1234").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("ENBUF://1234").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::BUFFER, VisualUrl("enbuf://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
 
   END_TEST;
 }
 
-
 int UtcDaliVisualUrlLocationN(void)
 {
-  tet_infoline( "UtcDaliVisualUrl Location negative tests" );
-
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("h://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ht://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("htp://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("htpp://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("httt://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("http;//bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("http:x/bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("http:/xbar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("sshttp://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("http:https://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("https:http://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("HPPT://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ftp:/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ftp:a/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("fpp://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ftt://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ssh;//bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ssh:/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ssh:a/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("shh://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("sss://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("fsh://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("stp://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("http:/bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("h1tps://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("ht2ps://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("htt3s://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("http4://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("https5/bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("https:6/bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("https:/7bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("dal://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("d1li://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("da2i://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("dal3://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("dali4//1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("dali:5/1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("dali:/61").GetProtocolType(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("eunki://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("enbu://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("eubnf://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("1nbuf://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("e2bun://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("en3uf://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("enb4f://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("enbu5://1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("enbuf6//1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("enbuf:7/1").GetProtocolType(), TEST_LOCATION );
-  DALI_TEST_EQUALS( VisualUrl::LOCAL, VisualUrl("enbuf:/81").GetProtocolType(), TEST_LOCATION );
+  tet_infoline("UtcDaliVisualUrl Location negative tests");
+
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("h://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ht://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("htp://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("htpp://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("httt://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("http;//bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("http:x/bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("http:/xbar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("sshttp://bar.org/foobar.svg").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("http:https://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("https:http://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("HPPT://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ftp:/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ftp:a/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("fpp://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ftt://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ssh;//bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ssh:/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ssh:a/bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("shh://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("sss://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("fsh://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("stp://bar.org/foobar.9.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("http:/bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("h1tps://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("ht2ps://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("htt3s://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("http4://bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("https5/bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("https:6/bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("https:/7bar.org/foobar.gif").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("file://bar.org/foobar.png").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("dal://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("d1li://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("da2i://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("dal3://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("dali4//1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("dali:5/1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("dali:/61").GetProtocolType(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("eunki://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("enbu://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("eubnf://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("1nbuf://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("e2bun://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("en3uf://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("enb4f://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("enbu5://1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("enbuf6//1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("enbuf:7/1").GetProtocolType(), TEST_LOCATION);
+  DALI_TEST_EQUALS(VisualUrl::LOCAL, VisualUrl("enbuf:/81").GetProtocolType(), TEST_LOCATION);
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlIsValid(void)
 {
-  tet_infoline( "UtcDaliVisualUrl IsValid" );
-
-  DALI_TEST_EQUALS( false, VisualUrl().IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("").IsValid(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.gif").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.png").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.svg").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.GIF").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.9.png").IsValid(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( true, VisualUrl("http://bar.org/foobar.gif").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("http://bar.org/foobar.png").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("http://bar.org/foobar.svg").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("http://bar.org/foobar.GIF").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("http://bar.org/foobar.9.png").IsValid(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( true, VisualUrl("https://bar.org/foobar.gif").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("https://bar.org/foobar.png").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("https://bar.org/foobar.svg").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("https://bar.org/foobar.GIF").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("https://bar.org/foobar.9.png").IsValid(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( true, VisualUrl("HTTP://bar.org/foobar.gif").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTP://bar.org/foobar.png").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTP://bar.org/foobar.svg").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTP://bar.org/foobar.GIF").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTP://bar.org/foobar.9.png").IsValid(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( true, VisualUrl("HTTPS://bar.org/foobar.gif").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTPS://bar.org/foobar.png").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTPS://bar.org/foobar.svg").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTPS://bar.org/foobar.GIF").IsValid(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("HTTPS://bar.org/foobar.9.png").IsValid(), TEST_LOCATION );
+  tet_infoline("UtcDaliVisualUrl IsValid");
+
+  DALI_TEST_EQUALS(false, VisualUrl().IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("").IsValid(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.gif").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.png").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.svg").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.GIF").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.9.png").IsValid(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(true, VisualUrl("http://bar.org/foobar.gif").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("http://bar.org/foobar.png").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("http://bar.org/foobar.svg").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("http://bar.org/foobar.GIF").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("http://bar.org/foobar.9.png").IsValid(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(true, VisualUrl("https://bar.org/foobar.gif").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("https://bar.org/foobar.png").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("https://bar.org/foobar.svg").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("https://bar.org/foobar.GIF").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("https://bar.org/foobar.9.png").IsValid(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(true, VisualUrl("HTTP://bar.org/foobar.gif").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTP://bar.org/foobar.png").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTP://bar.org/foobar.svg").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTP://bar.org/foobar.GIF").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTP://bar.org/foobar.9.png").IsValid(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(true, VisualUrl("HTTPS://bar.org/foobar.gif").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTPS://bar.org/foobar.png").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTPS://bar.org/foobar.svg").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTPS://bar.org/foobar.GIF").IsValid(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("HTTPS://bar.org/foobar.9.png").IsValid(), TEST_LOCATION);
 
   END_TEST;
 }
 
-
 int UtcDaliVisualUrlIsLocalResource(void)
 {
-  tet_infoline( "UtcDaliVisualUrl IsLocalResource" );
-
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.gif").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.png").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.svg").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.GIF").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( true, VisualUrl("foobar.9.png").IsLocalResource(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( false, VisualUrl("http://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("http://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("http://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("http://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("http://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( false, VisualUrl("https://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("https://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("https://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("https://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("https://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( false, VisualUrl("HTTP://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTP://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTP://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTP://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTP://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION );
-
-  DALI_TEST_EQUALS( false, VisualUrl("HTTPS://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTPS://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTPS://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTPS://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION );
-  DALI_TEST_EQUALS( false, VisualUrl("HTTPS://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION );
+  tet_infoline("UtcDaliVisualUrl IsLocalResource");
+
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.gif").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.png").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.svg").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.GIF").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(true, VisualUrl("foobar.9.png").IsLocalResource(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(false, VisualUrl("http://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("http://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("http://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("http://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("http://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(false, VisualUrl("https://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("https://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("https://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("https://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("https://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(false, VisualUrl("HTTP://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTP://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTP://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTP://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTP://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION);
+
+  DALI_TEST_EQUALS(false, VisualUrl("HTTPS://bar.org/foobar.gif").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTPS://bar.org/foobar.png").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTPS://bar.org/foobar.svg").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTPS://bar.org/foobar.GIF").IsLocalResource(), TEST_LOCATION);
+  DALI_TEST_EQUALS(false, VisualUrl("HTTPS://bar.org/foobar.9.png").IsLocalResource(), TEST_LOCATION);
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlGetLocationP(void)
 {
-  tet_infoline( "UtcDaliVisualUrl GetLocation Positive" );
+  tet_infoline("UtcDaliVisualUrl GetLocation Positive");
 
-  DALI_TEST_EQUAL( "a", VisualUrl("http://a").GetLocation() );
-  DALI_TEST_EQUAL( "1", VisualUrl("dali://1").GetLocation() );
-  DALI_TEST_EQUAL( "4", VisualUrl("enbuf://4").GetLocation() );
-  DALI_TEST_EQUAL( "", VisualUrl("ftp://").GetLocation() );
-  DALI_TEST_EQUAL( "http://", VisualUrl("http://http://").GetLocation() );
+  DALI_TEST_EQUAL("a", VisualUrl("http://a").GetLocation());
+  DALI_TEST_EQUAL("1", VisualUrl("dali://1").GetLocation());
+  DALI_TEST_EQUAL("4", VisualUrl("enbuf://4").GetLocation());
+  DALI_TEST_EQUAL("", VisualUrl("ftp://").GetLocation());
+  DALI_TEST_EQUAL("http://", VisualUrl("http://http://").GetLocation());
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlGetLocationN(void)
 {
-  tet_infoline( "UtcDaliVisualUrl GetLocation Negative" );
+  tet_infoline("UtcDaliVisualUrl GetLocation Negative");
 
-  DALI_TEST_EQUAL( "", VisualUrl("").GetLocation() );
-  DALI_TEST_EQUAL( "a", VisualUrl("a").GetLocation() );
-  DALI_TEST_EQUAL( "dali:/1", VisualUrl("dali:/1").GetLocation() );
-  DALI_TEST_EQUAL( "dali//1", VisualUrl("dali//1").GetLocation() );
-  DALI_TEST_EQUAL( "enbuf:/2", VisualUrl("enbuf:/2").GetLocation() );
-  DALI_TEST_EQUAL( "", VisualUrl("http:/http://").GetLocation() );
+  DALI_TEST_EQUAL("", VisualUrl("").GetLocation());
+  DALI_TEST_EQUAL("a", VisualUrl("a").GetLocation());
+  DALI_TEST_EQUAL("dali:/1", VisualUrl("dali:/1").GetLocation());
+  DALI_TEST_EQUAL("dali//1", VisualUrl("dali//1").GetLocation());
+  DALI_TEST_EQUAL("enbuf:/2", VisualUrl("enbuf:/2").GetLocation());
+  DALI_TEST_EQUAL("", VisualUrl("http:/http://").GetLocation());
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlCreateTextureUrl(void)
 {
-  tet_infoline( "UtcDaliVisualUrl CreateTextureUrl" );
+  tet_infoline("UtcDaliVisualUrl CreateTextureUrl");
 
-  DALI_TEST_EQUAL( "dali://a", VisualUrl::CreateTextureUrl( "a" ) );
-  DALI_TEST_EQUAL( "dali://1234", VisualUrl::CreateTextureUrl( "1234" ) );
-  DALI_TEST_EQUAL( "dali://", VisualUrl::CreateTextureUrl( "" ) );
+  DALI_TEST_EQUAL("dali://a", VisualUrl::CreateTextureUrl("a"));
+  DALI_TEST_EQUAL("dali://1234", VisualUrl::CreateTextureUrl("1234"));
+  DALI_TEST_EQUAL("dali://", VisualUrl::CreateTextureUrl(""));
 
   END_TEST;
 }
 
 int UtcDaliVisualUrlCreateBufferUrl(void)
 {
-  tet_infoline( "UtcDaliVisualUrl CreateBufferUrl" );
+  tet_infoline("UtcDaliVisualUrl CreateBufferUrl");
 
-  DALI_TEST_EQUAL( "enbuf://a", VisualUrl::CreateBufferUrl( "a" ) );
-  DALI_TEST_EQUAL( "enbuf://1234", VisualUrl::CreateBufferUrl( "1234" ) );
-  DALI_TEST_EQUAL( "enbuf://", VisualUrl::CreateBufferUrl( "" ) );
+  DALI_TEST_EQUAL("enbuf://a", VisualUrl::CreateBufferUrl("a"));
+  DALI_TEST_EQUAL("enbuf://1234", VisualUrl::CreateBufferUrl("1234"));
+  DALI_TEST_EQUAL("enbuf://", VisualUrl::CreateBufferUrl(""));
 
   END_TEST;
 }
+
+int UtcDaliVisualUrlGetUrlHash(void)
+{
+  tet_infoline("UtcDaliVisualUrl GetUrlHash");
+
+  std::vector<std::string> testUrlLists =
+    {
+      "", // empty string.
+      "/opt/usr/home/owner/media/resources/test.png",
+      "hello.world",
+      "image.jpg",
+      "not_suffix",
+      "https://bar.org/foo/bar.gif",
+      "dali://0",
+      "enbuf://1",
+    };
+
+  for(auto& url : testUrlLists)
+  {
+    VisualUrl visualUrl(url);
+
+    std::uint64_t exceptHash = Dali::CalculateHash(url);
+    std::uint64_t visualHash = visualUrl.GetUrlHash();
+
+    DALI_TEST_EQUAL(visualHash, exceptHash);
+  }
+
+  END_TEST;
+}
\ No newline at end of file
index cf276f4..d809e66 100644 (file)
@@ -21,6 +21,7 @@
 #include <sys/stat.h>
 #include <toolkit-application.h>
 #include <toolkit-event-thread-callback.h>
+#include <toolkit-vector-image-renderer.h>
 #include <cstring>
 #include <memory>
 
@@ -30,13 +31,15 @@ namespace Internal
 {
 namespace Adaptor
 {
+namespace
+{
+Dali::Internal::Adaptor::VectorImageRenderer* gVectorImageRenderer = nullptr;
+}
+
 class VectorImageRenderer : public Dali::BaseObject
 {
 public:
   VectorImageRenderer()
-  : mWidth(0),
-    mHeight(0),
-    mRasterizeSuccess(true)
   {
   }
 
@@ -46,6 +49,7 @@ public:
 
   bool Load(const Vector<uint8_t>& data, float dpi)
   {
+    mLoadCount++;
     if(strncmp(reinterpret_cast<char*>(data.Begin()), "invalid", 7) == 0)
     {
       return false;
@@ -57,6 +61,11 @@ public:
     return true;
   }
 
+  bool IsLoaded() const
+  {
+    return mLoadCount > 0 ? true : false;
+  }
+
   Dali::Devel::PixelBuffer Rasterize(uint32_t width, uint32_t height)
   {
     if(mRasterizeSuccess)
@@ -74,9 +83,10 @@ public:
   }
 
 public:
-  uint32_t mWidth;
-  uint32_t mHeight;
-  bool     mRasterizeSuccess;
+  uint32_t mWidth{0};
+  uint32_t mHeight{0};
+  uint32_t mLoadCount{0};
+  bool     mRasterizeSuccess{true};
 };
 
 inline VectorImageRenderer& GetImplementation(Dali::VectorImageRenderer& renderer)
@@ -105,6 +115,8 @@ VectorImageRenderer VectorImageRenderer::New()
 {
   Internal::Adaptor::VectorImageRenderer* imageRenderer = new Internal::Adaptor::VectorImageRenderer();
 
+  Internal::Adaptor::gVectorImageRenderer = imageRenderer;
+
   return VectorImageRenderer(imageRenderer);
 }
 
@@ -126,6 +138,11 @@ bool VectorImageRenderer::Load(const Vector<uint8_t>& data, float dpi)
   return Internal::Adaptor::GetImplementation(*this).Load(data, dpi);
 }
 
+bool VectorImageRenderer::IsLoaded() const
+{
+  return Internal::Adaptor::GetImplementation(*this).IsLoaded();
+}
+
 Dali::Devel::PixelBuffer VectorImageRenderer::Rasterize(uint32_t width, uint32_t height)
 {
   return Internal::Adaptor::GetImplementation(*this).Rasterize(width, height);
@@ -137,3 +154,15 @@ void VectorImageRenderer::GetDefaultSize(uint32_t& width, uint32_t& height) cons
 }
 
 } // namespace Dali
+
+namespace Test
+{
+namespace VectorImageRenderer
+{
+uint32_t GetLoadCount()
+{
+  return Dali::Internal::Adaptor::gVectorImageRenderer->mLoadCount;
+}
+
+} // namespace VectorImageRenderer
+} // namespace Test
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-image-renderer.h
new file mode 100644 (file)
index 0000000..37cc362
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef DALI_TOOLKIT_TEST_VECTOR_IMAGE_RENDERER_H
+#define DALI_TOOLKIT_TEST_VECTOR_IMAGE_RENDERER_H
+
+/*
+ * Copyright (c) 2022 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Test
+{
+namespace VectorImageRenderer
+{
+uint32_t GetLoadCount();
+
+} // namespace VectorImageRenderer
+} // namespace Test
+
+#endif // DALI_TOOLKIT_TEST_VECTOR_IMAGE_RENDERER_H
index 55745fb..dce317b 100644 (file)
@@ -525,7 +525,6 @@ int UtcDaliAnimatedImageVisualSynchronousLoading(void)
   END_TEST;
 }
 
-
 int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask(void)
 {
   ToolkitTestApplication application;
@@ -789,6 +788,7 @@ int UtcDaliAnimatedImageVisualAnimatedImage01(void)
   ToolkitTestApplication application;
   TestGlAbstraction&     gl = application.GetGlAbstraction();
 
+  tet_infoline("Set cache size same as GIF frame, and try to load same image at another ImageView");
   {
     Property::Map propertyMap;
     propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
@@ -815,6 +815,7 @@ int UtcDaliAnimatedImageVisualAnimatedImage01(void)
 
     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
 
+    // Batch 2 frames. Now frame 0, 1 cached.
     application.SendNotification();
     application.Render(20);
 
@@ -832,12 +833,54 @@ int UtcDaliAnimatedImageVisualAnimatedImage01(void)
 
     DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
 
+    // 0 frame removed. and after, batch 2 frames. Now frame 1, 2, 3 cached.
     application.SendNotification();
     application.Render(20);
 
     DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 4, TEST_LOCATION);
 
+    Visual::Base        visual2       = factory.CreateVisual(propertyMap);
+    DummyControl        dummyControl2 = DummyControl::New(true);
+    Impl::DummyControl& dummyImpl2    = static_cast<Impl::DummyControl&>(dummyControl2.GetImplementation());
+    dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual2);
+    application.GetScene().Add(dummyControl2);
+
+    tet_infoline("Add new view with same url");
+
+    application.SendNotification();
+    application.Render();
+
+    // Note that we only re-load 0 frame.
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    tet_infoline("Test that we don't try to re-load new image cause it cached");
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
+
+    // Batch 2 frames. Now visual frame 1, 2, 3 cached and visual2 frame 0, 1 cached.
+    application.SendNotification();
+    application.Render(20);
+
+    DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
+
+    textureTrace.Reset();
+
+    tet_infoline("Load some many frames");
+
+    const int repeatCount = 10;
+    for(int repeat = 0; repeat < repeatCount; ++repeat)
+    {
+      Test::EmitGlobalTimerSignal();
+      application.SendNotification();
+      application.Render(2000);
+    }
+
+    DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION); // A new texture should NOT be generated.
+    DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 5, TEST_LOCATION);
+
+    textureTrace.Reset();
+
     dummyControl.Unparent();
+    dummyControl2.Unparent();
   }
   tet_infoline("Test that removing the visual from stage deletes all textures");
   application.SendNotification();
@@ -861,7 +904,6 @@ int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
     propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
     propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
 
-
     VisualFactory factory = VisualFactory::Get();
     Visual::Base  visual  = factory.CreateVisual(propertyMap);
 
index 6745fea..3ae49cc 100644 (file)
@@ -73,7 +73,7 @@ static void TestKeyInputFocusCallback(Control control)
 
 const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
 const char* TEST_IMAGE_FILE_NAME       = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
-const char* TEST_SVG_FILE_NAME         = TEST_RESOURCE_DIR "/Kid1.svg";
+const char* TEST_SVG_FILE_NAME         = TEST_RESOURCE_DIR "/svg1.svg";
 
 Vector4 GetControlBackgroundColor(Control& control)
 {
@@ -269,8 +269,8 @@ int UtcDaliControlNavigationProperties(void)
   DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::UP_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
-  DALI_TEST_EQUALS(-1, control.GetProperty( DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
-  DALI_TEST_EQUALS(-1, control.GetProperty( DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+  DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
+  DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
 
   control.SetProperty(DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1);
   DALI_TEST_EQUALS(1, control.GetProperty(DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
@@ -290,9 +290,9 @@ int UtcDaliControlNavigationProperties(void)
   control.SetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18);
   DALI_TEST_EQUALS(18, control.GetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   control.SetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, 19);
-  DALI_TEST_EQUALS(19, control.GetProperty( DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+  DALI_TEST_EQUALS(19, control.GetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
   control.SetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, 20);
-  DALI_TEST_EQUALS(20, control.GetProperty( DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+  DALI_TEST_EQUALS(20, control.GetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
 
   END_TEST;
 }
@@ -1074,6 +1074,9 @@ int UtcDaliControlResourcesReady02(void)
   application.SendNotification();
   application.Render();
 
+  // Wait for rasterization
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
   DALI_TEST_EQUALS(control.IsResourceReady(), true, TEST_LOCATION);
   DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
   gResourceReadySignalFired = false;
index e16e93e..edaeec1 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <dali-toolkit-test-suite-utils.h>
 #include <toolkit-event-thread-callback.h>
+#include <toolkit-vector-image-renderer.h>
 #include "dummy-control.h"
 
 #include <test-encoded-image-buffer.h>
@@ -784,9 +785,25 @@ int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
   Property::Map imageMap;
 
   imageMap[ImageVisual::Property::URL]            = url.GetUrl();
+  imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 600;
+  imageMap[ImageVisual::Property::DESIRED_WIDTH]  = 600;
+  imageMap[ImageVisual::Property::ATLASING]       = true;
+
+  // No atlasing with big image
+  ImageView imageView_bigdesired = ImageView::New();
+  imageView_bigdesired.SetProperty(ImageView::Property::IMAGE, imageMap);
+  imageView_bigdesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
+
+  imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 0;
+  imageMap[ImageVisual::Property::DESIRED_WIDTH]  = 0;
+
+  // No atlasing with zero desired size
+  ImageView imageView_nodesired = ImageView::New();
+  imageView_nodesired.SetProperty(ImageView::Property::IMAGE, imageMap);
+  imageView_nodesired.SetProperty(Toolkit::Control::Property::PADDING, Extents(10u, 10u, 10u, 10u));
+
   imageMap[ImageVisual::Property::DESIRED_HEIGHT] = 34;
   imageMap[ImageVisual::Property::DESIRED_WIDTH]  = 34;
-  imageMap[ImageVisual::Property::ATLASING]       = true;
 
   ImageView imageView = ImageView::New();
   imageView.SetProperty(ImageView::Property::IMAGE, imageMap);
@@ -794,10 +811,15 @@ int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void)
 
   // By default, Aysnc loading is used
   // loading is not started if the actor is offScene
-
   application.GetScene().Add(imageView);
+  application.GetScene().Add(imageView_bigdesired);
+  application.GetScene().Add(imageView_nodesired);
   application.SendNotification();
   application.Render(16);
+
+  // loading started, this waits for the loader thread for max 30 seconds
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
   application.Render(16);
   application.SendNotification();
 
@@ -848,6 +870,7 @@ int UtcDaliImageViewSyncLoadingEncodedBuffer(void)
     // Sync loading is used
     Property::Map syncLoadingMap;
     syncLoadingMap["url"]                = url.GetUrl();
+    syncLoadingMap["alphaMaskUrl"]       = gImage_34_RGBA;
     syncLoadingMap["desiredHeight"]      = 34;
     syncLoadingMap["desiredWidth"]       = 34;
     syncLoadingMap["synchronousLoading"] = true;
@@ -2705,12 +2728,7 @@ int UtcDaliImageViewSyncSVGLoading(void)
 
   tet_infoline("ImageView Testing SVG image sync loading");
 
-  // Sync loading, automatic atlasing for small size image
   {
-    TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
-    callStack.Reset();
-    callStack.Enable(true);
-
     ImageView imageView = ImageView::New();
 
     // Sync loading is used
@@ -2724,7 +2742,6 @@ int UtcDaliImageViewSyncSVGLoading(void)
     DALI_TEST_CHECK(imageView);
 
     application.SendNotification();
-    application.Render(16);
     Vector3 naturalSize = imageView.GetNaturalSize();
 
     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
@@ -2739,28 +2756,27 @@ int UtcDaliImageViewAsyncSVGLoading(void)
 
   tet_infoline("ImageView Testing SVG image async loading");
 
-  // Sync loading, automatic atlasing for small size image
   {
-    TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
-    callStack.Reset();
-    callStack.Enable(true);
-
     ImageView imageView = ImageView::New();
 
-    // Sync loading is used
-    Property::Map syncLoadingMap;
-    syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
-    syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
-    syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
-    imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
+    // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
+    Property::Map propertyMap;
+    propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
+    propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
+    imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
 
     application.GetScene().Add(imageView);
     DALI_TEST_CHECK(imageView);
 
     application.SendNotification();
+
+    // Wait for rasterization
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    application.SendNotification();
     application.Render(16);
-    Vector3 naturalSize = imageView.GetNaturalSize();
 
+    Vector3 naturalSize = imageView.GetNaturalSize();
     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
     DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
   }
@@ -2773,12 +2789,8 @@ int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
 
   tet_infoline("ImageView Testing SVG image async loading");
 
-  // Sync loading, automatic atlasing for small size image
+  // Sync loading
   {
-    TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
-    callStack.Reset();
-    callStack.Enable(true);
-
     ImageView imageView = ImageView::New();
 
     // Sync loading is used
@@ -2797,7 +2809,13 @@ int UtcDaliImageViewSVGLoadingSyncSetInvalidValue(void)
     DALI_TEST_CHECK(imageView);
 
     application.SendNotification();
+
+    // Wait for rasterization
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    application.SendNotification();
     application.Render(16);
+
     Vector3 naturalSize = imageView.GetNaturalSize();
     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
     DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
@@ -2834,6 +2852,11 @@ int UtcDaliImageViewSvgLoadingFailure(void)
     application.GetScene().Add(imageView);
 
     application.SendNotification();
+
+    // loading started, this waits for the loader thread
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    application.SendNotification();
     application.Render(16);
 
     DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
@@ -2858,6 +2881,11 @@ int UtcDaliImageViewSvgLoadingFailure(void)
     application.GetScene().Add(imageView);
 
     application.SendNotification();
+
+    // loading started, this waits for the loader thread
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    application.SendNotification();
     application.Render(16);
 
     DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
@@ -2883,6 +2911,11 @@ int UtcDaliImageViewSvgLoadingFailure(void)
     application.GetScene().Add(imageView);
 
     application.SendNotification();
+
+    // loading started, this waits for the loader thread
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    application.SendNotification();
     application.Render(16);
 
     DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
@@ -2993,6 +3026,44 @@ int UtcDaliImageViewSvgRasterizationFailure(void)
   END_TEST;
 }
 
+int UtcDaliImageViewSvgChageSize(void)
+{
+  ToolkitTestApplication application;
+
+  TestGlAbstraction& gl           = application.GetGlAbstraction();
+  TraceCallStack&    textureTrace = gl.GetTextureTrace();
+  textureTrace.Enable(true);
+
+  ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
+  application.GetScene().Add(imageView);
+
+  application.SendNotification();
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render(16);
+
+  DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
+
+  // Change actor size, then rasterization should be done again
+  imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+
+  application.SendNotification();
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  application.SendNotification();
+  application.Render(16);
+
+  // We should not load the file again.
+  DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliImageViewTVGLoading(void)
 {
   ToolkitTestApplication application;
@@ -3000,12 +3071,17 @@ int UtcDaliImageViewTVGLoading(void)
   tet_infoline("ImageView Testing TVG image loading");
 
   {
-    ImageView imageView = ImageView::New();
-
-    imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
-
+    ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
     application.GetScene().Add(imageView);
     DALI_TEST_CHECK(imageView);
+
+    application.SendNotification();
+
+    DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+    application.SendNotification();
+    application.Render(16);
+
     Vector3 naturalSize = imageView.GetNaturalSize();
 
     DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
@@ -3581,7 +3657,7 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
 
   // Test broken case
   TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
-  TestResourceReadyUrl(0, 0, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
+  TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
   TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
   TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION);  // 1 image loading
   TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
@@ -3611,7 +3687,7 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void)
 
   // Test broken case
   TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
-  TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
+  TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
   TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
   TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
   TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
index 9a40691..ccab3e0 100644 (file)
@@ -2309,49 +2309,6 @@ int UtcDaliKeyboardFocusManagerWithHide(void)
   END_TEST;
 }
 
-int UtcDaliKeyboardFocusManagerWithVisible(void)
-{
-  ToolkitTestApplication application;
-
-  tet_infoline(" UtcDaliKeyboardFocusManagerWithVisible");
-
-  KeyboardFocusManager manager = KeyboardFocusManager::Get();
-  DALI_TEST_CHECK(manager);
-
-  // Create the first actor and add it to the stage
-  Actor first = Actor::New();
-  first.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
-  application.GetScene().Add(first);
-
-  // Create the second actor and add it to the first actor.
-  Actor second = Actor::New();
-  second.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
-  first.Add(second);
-
-  // Check that no actor is being focused yet.
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
-  // Check that the focus is set on the first actor
-  DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
-
-  // Set visible false.
-  first.SetProperty(Actor::Property::VISIBLE, false);
-
-  // Check that it will fail to set focus on the second actor as it's not focusable
-  DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == false);
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
-
-  // Set visible true.
-  first.SetProperty(Actor::Property::VISIBLE, true);
-
-  // Check that the focus is set on the second actor
-  DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
-
-  END_TEST;
-}
-
 int UtcDaliKeyboardFocusManagerFocusFinderRootActor(void)
 {
   ToolkitTestApplication application;
@@ -2480,4 +2437,4 @@ int UtcDaliKeyboardFocusManagerFocusFinderRootActor(void)
   Dali::Toolkit::DevelKeyboardFocusManager::ResetFocusFinderRootActor(manager);
 
   END_TEST;
-}
\ No newline at end of file
+}
index c810939..dab40a2 100644 (file)
@@ -644,6 +644,21 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
 
+  // Check the transparent strikethrough property for coverage.
+  strikethroughMapSet.Clear();
+  strikethroughMapSet.Insert("enable", true);
+  strikethroughMapSet.Insert("color", Color::TRANSPARENT);
+  strikethroughMapSet.Insert("height", 2.0f);
+
+  label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
+
+  application.SendNotification();
+  application.Render();
+
+  strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
+  DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
+  DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
+
   strikethroughMapSet.Clear();
   strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true);
   strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED);
@@ -803,6 +818,24 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
 
+  // Check the transparent double underline property for coverage.
+  underlineMapSet.Clear();
+  underlineMapSet.Insert("enable", true);
+  underlineMapSet.Insert("color", Color::TRANSPARENT);
+  underlineMapSet.Insert("height", 1);
+  underlineMapSet.Insert("type", Text::Underline::DOUBLE);
+  underlineMapSet.Insert("dashWidth", 2);
+  underlineMapSet.Insert("dashGap", 1);
+
+  label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
+
+  application.SendNotification();
+  application.Render();
+
+  underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
+  DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
+  DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
+
   underlineMapSet.Clear();
   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
@@ -931,6 +964,19 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
 
+  // Check the transparent background property for coverage
+  backgroundMapSet.Clear();
+  backgroundMapSet["enable"] = true;
+  backgroundMapSet["color"]  = Color::TRANSPARENT;
+  label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
+
+  application.SendNotification();
+  application.Render();
+
+  backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
+  DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
+  DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
+
   backgroundMapSet.Clear();
   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR]  = Color::GREEN;
index c17567a..bd3469a 100644 (file)
@@ -325,7 +325,6 @@ int UtcDaliVisualSize(void)
   DALI_TEST_EQUALS(naturalSize, Vector2::ZERO, TEST_LOCATION);
 
   // animated gradient visual
-  Vector2 animated_gradient_visual_size(10.f, 10.f);
   propertyMap.Clear();
   propertyMap.Insert(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
   Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
@@ -333,20 +332,6 @@ int UtcDaliVisualSize(void)
   animatedGradientVisual.SetTransformAndSize(DefaultTransform(), controlSize);
   DALI_TEST_EQUALS(naturalSize, Vector2::ZERO, TEST_LOCATION);
 
-  // svg visual
-  Visual::Base svgVisual = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions());
-  svgVisual.GetNaturalSize(naturalSize);
-  // TEST_SVG_FILE:
-  //  <svg width="100" height="100">
-  //  <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
-  //  </svg>
-  DALI_TEST_EQUALS(naturalSize, Vector2(100.f, 100.f), TEST_LOCATION);
-
-  // svg visual with a size
-  Visual::Base svgVisual2 = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions(200, 200));
-  svgVisual2.GetNaturalSize(naturalSize);
-  DALI_TEST_EQUALS(naturalSize, Vector2(100.f, 100.f), TEST_LOCATION); // Natural size should still be 100, 100
-
   // Text visual.
 
   // Load some fonts to get the same metrics on different platforms.
index 2581ad6..3c295e3 100644 (file)
@@ -1,14 +1,30 @@
 #version 300 es
 
+// Original Code
+// https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/glTF-WebGL-PBR/shaders/pbr-frag.glsl
+// Commit dc84b5e374fb3d23153d2248a338ef88173f9eb6
+//
+// This fragment shader defines a reference implementation for Physically Based Shading of
+// a microfacet surface material defined by a glTF model.For the DamagedHelmet.gltf and its Assets
+//
+// References:
+// [1] Real Shading in Unreal Engine 4
+//     http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
+// [2] Physically Based Shading at Disney
+//     http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf
+// [3] README.md - Environment Maps
+//     https://github.com/KhronosGroup/glTF-Sample-Viewer/#environment-maps
+// [4] \"An Inexpensive BRDF Model for Physically based Rendering\" by Christophe Schlick
+//     https://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf
+
 #ifdef HIGHP
-  precision highp float;
+precision highp float;
 #else
-  precision mediump float;
+precision mediump float;
 #endif
 
 #ifdef THREE_TEX
 #ifdef GLTF_CHANNELS
-// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#pbrmetallicroughnessmetallicroughnesstexture
 #define METALLIC b
 #define ROUGHNESS g
 #else //GLTF_CHANNELS
 #endif //GLTF_CHANNELS
 #endif //THREE_TEX
 
-#ifdef THREE_TEX
-  uniform sampler2D sAlbedoAlpha;
-  uniform sampler2D sMetalRoughness;
-  uniform sampler2D sNormal;
-
-#ifdef ALPHA_TEST
-  uniform float uAlphaThreshold;
-#endif //ALPHA_TEST
+uniform lowp vec4 uColorFactor;
+uniform lowp float uMetallicFactor;
+uniform lowp float uRoughnessFactor;
 
-#else
-  uniform sampler2D sAlbedoMetal;
-  uniform sampler2D sNormalRoughness;
+#ifdef THREE_TEX
+#ifdef BASECOLOR_TEX
+uniform sampler2D sAlbedoAlpha;
+#endif // BASECOLOR_TEX
+#ifdef METALLIC_ROUGHNESS_TEX
+uniform sampler2D sMetalRoughness;
+#endif // METALLIC_ROUGHNESS_TEX
+#ifdef NORMAL_TEX
+uniform sampler2D sNormal;
+uniform float uNormalScale;
+#endif // NORMAL_TEX
+#else // THREE_TEX
+uniform sampler2D sAlbedoMetal;
+uniform sampler2D sNormalRoughness;
 #endif
 
 #ifdef OCCLUSION
-  uniform sampler2D sOcclusion;
-  uniform float uOcclusionStrength;
+uniform sampler2D sOcclusion;
+uniform float uOcclusionStrength;
 #endif
 
 #ifdef EMISSIVE
-  uniform sampler2D sEmissive;
-  uniform vec3 uEmissiveFactor;
+uniform sampler2D sEmissive;
+uniform vec3 uEmissiveFactor;
 #endif
 
-uniform samplerCube sDiffuse;
-uniform samplerCube sSpecular;
-
-// Number of mip map levels in the texture
-uniform float uMaxLOD;
-
-// Transformation matrix of the cubemap texture
-uniform mat4 uCubeMatrix;
-
-uniform vec4 uColor;
-uniform float uMetallicFactor;
-uniform float uRoughnessFactor;
-
-//IBL Light intensity
+//// For IBL
+uniform samplerCube sDiffuseEnvSampler;
+uniform samplerCube sSpecularEnvSampler;
+uniform sampler2D sbrdfLUT;
 uniform float uIblIntensity;
 
+// For Alpha Mode.
+uniform lowp float uOpaque;
+uniform lowp float uMask;
+uniform lowp float uAlphaThreshold;
+
 // TODO: Multiple texture coordinate will be supported.
-in vec2 vUV;
-in vec3 vNormal;
-in vec3 vTangent;
-in vec3 vViewVec;
+in lowp vec2 vUV;
+in lowp mat3 vTBN;
+in lowp vec4 vColor;
+in highp vec3 vPositionToCamera;
 
 out vec4 FragColor;
 
-// Functions for BRDF calculation come from
-// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
-// Based on the paper by Dimitar Lazarov
-// http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf
-vec3 EnvBRDFApprox( vec3 SpecularColor, float Roughness, float NoV )
+struct PBRInfo
 {
-  const vec4 c0 = vec4( -1.0, -0.0275, -0.572, 0.022 );
-  const vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04 );
-  vec4 r = Roughness * c0 + c1;
-  float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;
-  vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;
-
-  return SpecularColor * AB.x + AB.y;
+  mediump float NdotL;        // cos angle between normal and light direction
+  mediump float NdotV;        // cos angle between normal and view direction
+  mediump float NdotH;        // cos angle between normal and half vector
+  mediump float VdotH;        // cos angle between view direction and half vector
+  mediump vec3 reflectance0;  // full reflectance color (normal incidence angle)
+  mediump vec3 reflectance90; // reflectance color at grazing angle
+  lowp float alphaRoughness;  // roughness mapped to a more linear change in the roughness (proposed by [2])
+};
+
+const float M_PI = 3.141592653589793;
+const float c_MinRoughness = 0.04;
+
+vec3 specularReflection(PBRInfo pbrInputs)
+{
+  return pbrInputs.reflectance0 + (pbrInputs.reflectance90 - pbrInputs.reflectance0) * pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);
 }
 
-void main()
+float geometricOcclusion(PBRInfo pbrInputs)
 {
-  // We get information from the maps (albedo, normal map, roughness, metalness
-  // I access the maps in the order they will be used
-#ifdef THREE_TEX
-  vec4 albedoAlpha = texture(sAlbedoAlpha, vUV.st);
-  float alpha = albedoAlpha.a;
-#ifdef ALPHA_TEST
-  if (alpha <= uAlphaThreshold)
-  {
-    discard;
-  }
-#endif //ALPHA_TEST
-  vec3 albedoColor = albedoAlpha.rgb * uColor.rgb;
-
-  vec4 metalRoughness = texture(sMetalRoughness, vUV.st);
-  float metallic = metalRoughness.METALLIC * uMetallicFactor;
-  float roughness = metalRoughness.ROUGHNESS * uRoughnessFactor;
-
-  vec3 normalMap = texture(sNormal, vUV.st).rgb;
-#else  //THREE_TEX
-  vec4 albedoMetal = texture(sAlbedoMetal, vUV.st);
-  vec3 albedoColor = albedoMetal.rgb * uColor.rgb;
-  float metallic = albedoMetal.a * uMetallicFactor;
-
-  vec4 normalRoughness = texture(sNormalRoughness, vUV.st);
-  vec3 normalMap = normalRoughness.rgb;
-  float roughness = normalRoughness.a * uRoughnessFactor;
-#endif
-  //Normalize vectors
-  vec3 normal = normalize(vNormal);
-  vec3 tangent = normalize(vTangent);
-
-  // NOTE: normal and tangent have to be orthogonal for the result of the cross()
-  // product to be a unit vector. We might find that we need to normalize().
-  vec3 bitangent = cross(normal, tangent);
-
-  vec3 viewVec = normalize(vViewVec);
-
-  // Create Inverse Local to world matrix
-  mat3 vInvTBN = mat3(tangent, bitangent, normal);
-
-  // Get normal map info in world space
-  normalMap = normalize(normalMap - 0.5);
-  vec3 newNormal = vInvTBN * normalMap.rgb;
+  mediump float NdotL = pbrInputs.NdotL;
+  mediump float NdotV = pbrInputs.NdotV;
+  lowp float r = pbrInputs.alphaRoughness;
 
-  // Calculate normal dot view vector
-  float NoV = max(dot(newNormal, -viewVec), 0.0);
-
-  // Reflect vector
-  vec3 reflectionVec = reflect(viewVec, newNormal);
-
-  //transform it now to environment coordinates (used when the environment rotates)
-  vec3 reflecCube = (uCubeMatrix * vec4( reflectionVec, 0.0 ) ).xyz;
-  reflecCube = normalize( reflecCube );
-
-  //transform it now to environment coordinates
-  vec3 normalCube = ( uCubeMatrix * vec4( newNormal, 0.0 ) ).xyz;
-  normalCube = normalize( normalCube );
-
-  // Get irradiance from diffuse cubemap
-  vec3 irradiance = texture( sDiffuse, normalCube ).rgb;
-
-  // Access reflection color using roughness value
-  float finalLod = mix( 0.0, uMaxLOD - 2.0, roughness);
-  vec3 reflectionColor = textureLod(sSpecular, reflecCube, finalLod).rgb;
-
-  // We are supposed to be using DielectricColor (0.04) of a plastic (almost everything)
-  // http://blog.selfshadow.com/publications/s2014-shading-course/hoffman/s2014_pbs_physics_math_slides.pdf
-  // however that seems to prevent achieving very dark tones (i.e. get dark gray blacks).
-  vec3 DiffuseColor = albedoColor - albedoColor * metallic;  // 1 mad
-  vec3 SpecularColor = mix( vec3(0.04), albedoColor, metallic); // 2 mad
-
-  // Calculate specular color using Magic Function (takes original roughness and normal dot view).
-  vec3 specColor =  reflectionColor.rgb * EnvBRDFApprox(SpecularColor, roughness, NoV );
+  lowp float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
+  lowp float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
+  return attenuationL * attenuationV;
+}
 
-  // Multiply the result by albedo texture and do energy conservation
-  vec3 diffuseColor = irradiance * DiffuseColor;
+float microfacetDistribution(PBRInfo pbrInputs)
+{
+  mediump float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
+  lowp float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;
+  return roughnessSq / (M_PI * f * f);
+}
 
-  // Final color is the sum of the diffuse and specular term
-  vec3 finalColor = diffuseColor + specColor;
+vec3 linear(vec3 color)
+{
+  return pow(color, vec3(2.2));
+}
 
-  finalColor = sqrt( finalColor ) * uIblIntensity;
+void main()
+{
+  // Metallic and Roughness material properties are packed together
+  // In glTF, these factors can be specified by fixed scalar values
+  // or from a metallic-roughness map
+  // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
+  // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
+  lowp float metallic = uMetallicFactor;
+  lowp float perceptualRoughness = uRoughnessFactor;
+  // If there isn't normal texture, use surface normal
+  mediump vec3 n = normalize(vTBN[2].xyz);
 
+#ifdef THREE_TEX
+  // The albedo may be defined from a base texture or a flat color
+#ifdef BASECOLOR_TEX
+  lowp vec4 baseColor = texture(sAlbedoAlpha, vUV);
+  baseColor = vec4(linear(baseColor.rgb), baseColor.w) * uColorFactor;
+#else // BASECOLOR_TEX
+  lowp vec4 baseColor = vColor * uColorFactor;
+#endif // BASECOLOR_TEX
+
+#ifdef METALLIC_ROUGHNESS_TEX
+  lowp vec4 metrou = texture(sMetalRoughness, vUV);
+  metallic = metrou.METALLIC * metallic;
+  perceptualRoughness = metrou.ROUGHNESS * perceptualRoughness;
+#endif // METALLIC_ROUGHNESS_TEX
+
+#ifdef NORMAL_TEX
+  n = texture(sNormal, vUV).rgb;
+  n = normalize(vTBN * ((2.0 * n - 1.0) * vec3(uNormalScale, uNormalScale, 1.0)));
+#endif // NORMAL_TEX
+#else // THREE_TEX
+  vec4 albedoMetal = texture(sAlbedoMetal, vUV);
+  lowp vec4 baseColor = vec4(linear(albedoMetal.rgb), 1.0) * vColor * uColorFactor;
+
+  metallic = albedoMetal.METALLIC * metallic;
+
+  vec4 normalRoughness = texture(sNormalRoughness, vUV);
+  perceptualRoughness = normalRoughness.ROUGHNESS * perceptualRoughness;
+
+  n = normalRoughness.rgb;
+  n = normalize(vTBN * ((2.0 * n - 1.0) * vec3(uNormalScale, uNormalScale, 1.0)));
+#endif // THREE_TEX
+
+  // The value of uOpaque and uMask can be 0.0 or 1.0.
+  // If uOpaque is 1.0, alpha value of final color is 1.0;
+  // If uOpaque is 0.0 and uMask is 1.0, alpha value of final color is 0.0 when input alpha is lower than uAlphaThreshold or
+  // 1.0 when input alpha is larger than uAlphaThreshold.
+  // https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#_material_alphamode
+  baseColor.a = mix(baseColor.a, 1.0, uOpaque);
+  baseColor.a = min(mix(baseColor.a, floor(baseColor.a - uAlphaThreshold + 1.0), uMask), 1.0);
+
+  metallic = clamp(metallic, 0.0, 1.0);
+  // Roughness is authored as perceptual roughness; as is convention,
+  // convert to material roughness by squaring the perceptual roughness [2].
+  perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
+  lowp float alphaRoughness = perceptualRoughness * perceptualRoughness;
+
+  lowp vec3 f0 = vec3(0.04);
+  lowp vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
+  diffuseColor *= (1.0 - metallic);
+  lowp vec3 specularColor = mix(f0, baseColor.rgb, metallic);
+
+  // Compute reflectance.
+  lowp float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
+
+  // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect.
+  // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%.
+  lowp float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
+  lowp vec3 specularEnvironmentR0 = specularColor.rgb;
+  lowp vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
+
+  mediump vec3 v = normalize(vPositionToCamera); // Vector from surface point to camera
+  mediump float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
+  mediump vec3 reflection = -normalize(reflect(v, n));
+
+  lowp vec3 color = vec3(0.0);
+  lowp vec3 diffuseLight = linear(texture(sDiffuseEnvSampler, n).rgb);
+  lowp vec3 specularLight = linear(texture(sSpecularEnvSampler, reflection).rgb);
+  // retrieve a scale and bias to F0. See [1], Figure 3
+  lowp vec3 brdf = linear(texture(sbrdfLUT, vec2(NdotV, 1.0 - perceptualRoughness)).rgb);
+
+  lowp vec3 diffuse = diffuseLight * diffuseColor;
+  lowp vec3 specular = specularLight * (specularColor * brdf.x + brdf.y);
+  color += (diffuse + specular) * uIblIntensity;
 
 #ifdef OCCLUSION
-  float ao = texture(sOcclusion, vUV.st).r;
-  finalColor = mix( finalColor, finalColor * ao, uOcclusionStrength );
-#endif
+  lowp float ao = texture(sOcclusion, vUV).r;
+  color = mix(color, color * ao, uOcclusionStrength);
+#endif // OCCLUSION
 
 #ifdef EMISSIVE
-  vec3 emissive = texture( sEmissive, vUV.st ).rgb * uEmissiveFactor;
-  finalColor += emissive;
-#endif
+  lowp vec3 emissive = linear(texture(sEmissive, vUV).rgb) * uEmissiveFactor;
+  color += emissive;
+#endif // EMISSIVE
 
-#ifdef THREE_TEX
-  FragColor = vec4( finalColor, alpha );
-#else //THREE_TEX
-  FragColor = vec4( finalColor, 1.0 );
-#endif //THREE_TEX
+  FragColor = vec4(pow(color, vec3(1.0 / 2.2)), baseColor.a);
 }
index e9381c5..2bae244 100644 (file)
@@ -1,5 +1,9 @@
 #version 300 es
 
+// Original Code
+// https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/glTF-WebGL-PBR/shaders/pbr-vert.glsl
+// Commit dc84b5e374fb3d23153d2248a338ef88173f9eb6
+
 #ifdef HIGHP
   precision highp float;
 #else
 in vec3 aPosition;
 in vec2 aTexCoord;
 in vec3 aNormal;
+
+#ifdef VEC4_TANGENT
+in vec4 aTangent;
+#else
 in vec3 aTangent;
+#endif
+
+in vec4 aVertexColor;
 
 #ifdef MORPH
   uniform sampler2D sBlendShapeGeometry;
 #endif
 
 out vec2 vUV;
-out vec3 vNormal;
-out vec3 vTangent;
-out vec3 vViewVec;
+out lowp mat3 vTBN;
+out lowp vec4 vColor;
+out highp vec3 vPositionToCamera;
 
-uniform highp mat4 uMvpMatrix;
 uniform highp mat4 uViewMatrix;
 uniform mat3 uNormalMatrix;
 uniform mat4 uModelMatrix;
-uniform mat4 uModelView;
 uniform mat4 uProjection;
+uniform lowp float uHasVertexColor;
 
 #ifdef SKINNING
   in vec4 aJoints;
@@ -48,9 +58,9 @@ uniform int uBlendShapeComponentSize;                               ///< The siz
 
 void main()
 {
-  vec4 position = vec4(aPosition, 1.0);
+  highp vec4 position = vec4(aPosition, 1.0);
   vec3 normal = aNormal;
-  vec3 tangent = aTangent;
+  vec3 tangent = aTangent.xyz;
 
 #ifdef MORPH
   int width = textureSize( sBlendShapeGeometry, 0 ).x;
@@ -120,7 +130,7 @@ void main()
 #endif
 
 #ifdef SKINNING
-  mat4 bone = uBone[int(aJoints.x)] * aWeights.x +
+  highp mat4 bone = uBone[int(aJoints.x)] * aWeights.x +
     uBone[int(aJoints.y)] * aWeights.y +
     uBone[int(aJoints.z)] * aWeights.z +
     uBone[int(aJoints.w)] * aWeights.w;
@@ -129,15 +139,16 @@ void main()
   tangent = (bone * vec4(tangent, 0.0)).xyz;
 #endif
 
-  vec4 vPosition = uModelMatrix * position;
+  highp vec4 positionW = uModelMatrix * position;
+  highp vec4 positionV = uViewMatrix * positionW;
 
-  vNormal = normalize(uNormalMatrix * normal);
+  vPositionToCamera = transpose(mat3(uViewMatrix)) * -vec3(positionV.xyz / positionV.w);
 
-  vTangent = normalize(uNormalMatrix * tangent);
-
-
-  vec4 viewPosition = uViewMatrix * vPosition;
-  gl_Position = uProjection * viewPosition;
+  vec3 bitangent = cross(normal, tangent);
+#ifdef VEC4_TANGENT
+  bitangent *= aTangent.w;
+#endif
+  vTBN = mat3(uModelMatrix) * mat3(tangent, bitangent, normal);
 
 #ifdef FLIP_V
   vUV = vec2(aTexCoord.x, 1.0 - aTexCoord.y);
@@ -145,5 +156,7 @@ void main()
   vUV = aTexCoord;
 #endif
 
-  vViewVec = viewPosition.xyz;
+  vColor = mix(vec4(1.0f), aVertexColor, uHasVertexColor);
+
+  gl_Position = uProjection * positionV;
 }
index c95883f..cc4e7e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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/devel-api/adaptor-framework/environment-variable.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
+
 // INTERNAL INCLUDES
 #include "dali-scene-loader/public-api/environment-definition.h"
 #include "dali-scene-loader/public-api/utils.h"
 
+namespace
+{
+#define TOKEN_STRING(x) #x
+std::string GetDaliImagePath()
+{
+  return (nullptr == DALI_IMAGE_DIR) ? Dali::EnvironmentVariable::GetEnvironmentVariable(TOKEN_STRING(DALI_IMAGE_DIR)) : DALI_IMAGE_DIR;
+}
+} // unnamed namespace
+
 namespace Dali
 {
 namespace SceneLoader
 {
+namespace
+{
+const std::string PRE_COMPUTED_BRDF_TEXTURE_FILE_NAME = "brdfLUT.png";
+}
+
 EnvironmentDefinition::RawData
 EnvironmentDefinition::LoadRaw(const std::string& environmentsPath) const
 {
@@ -44,6 +62,15 @@ EnvironmentDefinition::LoadRaw(const std::string& environmentsPath) const
 
   loadFn(mDiffuseMapPath, raw.mDiffuse);
   loadFn(mSpecularMapPath, raw.mSpecular);
+
+  if(mUseBrdfTexture)
+  {
+    Devel::PixelBuffer pixelBuffer = LoadImageFromFile(GetDaliImagePath() + PRE_COMPUTED_BRDF_TEXTURE_FILE_NAME);
+    if(pixelBuffer)
+    {
+      raw.mBrdf = Devel::PixelBuffer::Convert(pixelBuffer);
+    }
+  }
   return raw;
 }
 
@@ -62,6 +89,12 @@ EnvironmentDefinition::Textures EnvironmentDefinition::Load(RawData&& raw) const
   {
     textures.mSpecular = raw.mSpecular.CreateTexture();
   }
+
+  if(raw.mBrdf)
+  {
+    textures.mBrdf = Texture::New(TextureType::TEXTURE_2D, raw.mBrdf.GetPixelFormat(), raw.mBrdf.GetWidth(), raw.mBrdf.GetHeight());
+    textures.mBrdf.Upload(raw.mBrdf);
+  }
   return textures;
 }
 
index 066f6fa..90b0f9e 100644 (file)
@@ -39,6 +39,7 @@ struct DALI_SCENE_LOADER_API EnvironmentDefinition
   {
     Texture mDiffuse;  // irradiance
     Texture mSpecular; // radiance
+    Texture mBrdf;     // pre-computed brdf
 
     bool IsLoaded() const
     {
@@ -48,8 +49,9 @@ struct DALI_SCENE_LOADER_API EnvironmentDefinition
 
   struct RawData
   {
-    CubeData mDiffuse;
-    CubeData mSpecular;
+    CubeData  mDiffuse;
+    CubeData  mSpecular;
+    PixelData mBrdf;
   };
 
   using EnvironmentData = std::pair<EnvironmentDefinition, Textures>;
@@ -81,6 +83,7 @@ public: // DATA
   std::string mSpecularMapPath;
   Quaternion  mCubeOrientation = Quaternion::IDENTITY;
   float       mIblIntensity    = 1.0f;
+  bool        mUseBrdfTexture  = false;
 };
 
 } // namespace SceneLoader
index be7e538..8af87a1 100644 (file)
@@ -42,12 +42,12 @@ const std::string POSITION_PROPERTY("position");
 const std::string ORIENTATION_PROPERTY("orientation");
 const std::string SCALE_PROPERTY("scale");
 const std::string BLEND_SHAPE_WEIGHTS_UNIFORM("uBlendShapeWeight");
-
 const std::string MRENDERER_MODEL_IDENTIFICATION("M-Renderer");
-
 const std::string ROOT_NODE_NAME("RootNode");
 const Vector3     SCALE_TO_ADJUST(100.0f, 100.0f, 100.0f);
 
+constexpr float DEFAULT_INTENSITY = 0.5f;
+
 const Geometry::Type GLTF2_TO_DALI_PRIMITIVES[]{
   Geometry::POINTS,
   Geometry::LINES,
@@ -66,6 +66,7 @@ struct AttributeMapping
   {gt::Attribute::NORMAL, &MeshDefinition::mNormals, sizeof(Vector3)},
   {gt::Attribute::TANGENT, &MeshDefinition::mTangents, sizeof(Vector3)},
   {gt::Attribute::TEXCOORD_0, &MeshDefinition::mTexCoords, sizeof(Vector2)},
+  {gt::Attribute::COLOR_0, &MeshDefinition::mColors, sizeof(Vector4)},
   {gt::Attribute::JOINTS_0, &MeshDefinition::mJoints0, sizeof(Vector4)},
   {gt::Attribute::WEIGHTS_0, &MeshDefinition::mWeights0, sizeof(Vector4)},
 };
@@ -439,7 +440,7 @@ void ConvertMaterial(const gt::Material& m, decltype(ResourceBundle::mMaterials)
     matDef.SetAlphaCutoff(std::min(1.f, std::max(0.f, m.mAlphaCutoff)));
   }
 
-  matDef.mColor = pbr.mBaseColorFactor;
+  matDef.mBaseColorFactor = pbr.mBaseColorFactor;
 
   matDef.mTextureStages.reserve(!!pbr.mBaseColorTexture + !!pbr.mMetallicRoughnessTexture + !!m.mNormalTexture + !!m.mOcclusionTexture + !!m.mEmissiveTexture);
   if(pbr.mBaseColorTexture)
@@ -449,6 +450,10 @@ void ConvertMaterial(const gt::Material& m, decltype(ResourceBundle::mMaterials)
     // TODO: and there had better be one
     matDef.mFlags |= semantic;
   }
+  else
+  {
+    matDef.mNeedAlbedoTexture = false;
+  }
 
   matDef.mMetallic  = pbr.mMetallicFactor;
   matDef.mRoughness = pbr.mRoughnessFactor;
@@ -461,7 +466,12 @@ void ConvertMaterial(const gt::Material& m, decltype(ResourceBundle::mMaterials)
     // TODO: and there had better be one
     matDef.mFlags |= semantic;
   }
+  else
+  {
+    matDef.mNeedMetallicRoughnessTexture = false;
+  }
 
+  matDef.mNormalScale = m.mNormalTexture.mScale;
   if(m.mNormalTexture)
   {
     const auto semantic = MaterialDefinition::NORMAL;
@@ -469,6 +479,10 @@ void ConvertMaterial(const gt::Material& m, decltype(ResourceBundle::mMaterials)
     // TODO: and there had better be one
     matDef.mFlags |= semantic;
   }
+  else
+  {
+    matDef.mNeedNormalTexture = false;
+  }
 
   // TODO: handle doubleSided
   if(m.mOcclusionTexture)
@@ -580,6 +594,9 @@ void ConvertMeshes(const gt::Document& doc, ConversionContext& cctx)
 
       auto& accPositions = *attribs.find(gt::Attribute::POSITION)->second;
       meshDef.mPositions = ConvertMeshPrimitiveAccessor(accPositions);
+      // glTF2 support vector4 tangent for mesh.
+      // https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#meshes-overview
+      meshDef.mTangentType = Property::VECTOR4;
 
       const bool needNormalsTangents = accPositions.mType == gt::AccessorType::VEC3;
       for(auto& am : ATTRIBUTE_MAPPINGS)
@@ -591,14 +608,6 @@ void ConvertMeshes(const gt::Document& doc, ConversionContext& cctx)
           auto& accessor = meshDef.*(am.mAccessor);
           accessor       = ConvertMeshPrimitiveAccessor(*iFind->second);
 
-          // Fixing up -- a few of glTF2 sample models have VEC4 tangents; we need VEC3s.
-          if(iFind->first == gt::Attribute::TANGENT && (accessor.mBlob.mElementSizeHint > am.mElementSizeRequired))
-          {
-            accessor.mBlob.mStride          = std::max(static_cast<uint16_t>(accessor.mBlob.mStride + accessor.mBlob.mElementSizeHint - am.mElementSizeRequired),
-                                              accessor.mBlob.mElementSizeHint);
-            accessor.mBlob.mElementSizeHint = am.mElementSizeRequired;
-          }
-
           if(iFind->first == gt::Attribute::JOINTS_0)
           {
             meshDef.mFlags |= (iFind->second->mComponentType == gt::Component::UNSIGNED_SHORT) * MeshDefinition::U16_JOINT_IDS;
@@ -1156,6 +1165,14 @@ void SetObjectReaders()
   js::SetObjectReader(SCENE_READER);
 }
 
+void SetDefaultEnvironmentMap(const gt::Document& doc, ConversionContext& cctx)
+{
+  EnvironmentDefinition envDef;
+  envDef.mUseBrdfTexture = true;
+  envDef.mIblIntensity = DEFAULT_INTENSITY;
+  cctx.mOutput.mResources.mEnvironmentMaps.push_back({std::move(envDef), EnvironmentDefinition::Textures()});
+}
+
 } // namespace
 
 void LoadGltfScene(const std::string& url, ShaderDefinitionFactory& shaderFactory, LoadResult& params)
@@ -1211,11 +1228,12 @@ void LoadGltfScene(const std::string& url, ShaderDefinitionFactory& shaderFactor
   ConvertMeshes(doc, cctx);
   ConvertNodes(doc, cctx, isMRendererModel);
   ConvertAnimations(doc, cctx);
-
   ProcessSkins(doc, cctx);
-
   ProduceShaders(shaderFactory, params.mScene);
   params.mScene.EnsureUniqueSkinningShaderInstances(params.mResources);
+
+  // Set Default Environment map
+  SetDefaultEnvironmentMap(doc, cctx);
 }
 
 } // namespace SceneLoader
index 1342ced..1766c3f 100644 (file)
@@ -150,7 +150,7 @@ MaterialDefinition::LoadRaw(const std::string& imagesPath) const
       raw.mTextures.push_back({SyncImageLoader::Load(imagesPath + iTexture->mTexture.mImageUri), iTexture->mTexture.mSamplerFlags});
       ++iTexture;
     }
-    else // single value albedo, albedo-alpha or albedo-metallic
+    else if(mNeedAlbedoTexture) // single value albedo, albedo-alpha or albedo-metallic
     {
       uint32_t bufferSize = 4;
       uint8_t* buffer     = nullptr;
@@ -184,7 +184,7 @@ MaterialDefinition::LoadRaw(const std::string& imagesPath) const
       raw.mTextures.push_back({SyncImageLoader::Load(imagesPath + iTexture->mTexture.mImageUri), iTexture->mTexture.mSamplerFlags});
       ++iTexture;
     }
-    else if(createMetallicRoughnessAndNormal)
+    else if(createMetallicRoughnessAndNormal && mNeedMetallicRoughnessTexture)
     {
       // NOTE: we want to set both metallic and roughness to 1.0; dli uses the R & A channels,
       // glTF2 uses B & G, so we might as well just set all components to 1.0.
@@ -198,17 +198,20 @@ MaterialDefinition::LoadRaw(const std::string& imagesPath) const
       raw.mTextures.push_back({SyncImageLoader::Load(imagesPath + iTexture->mTexture.mImageUri), iTexture->mTexture.mSamplerFlags});
       ++iTexture;
     }
-    else if(createMetallicRoughnessAndNormal)
+    else if(mNeedNormalTexture)
     {
-      const auto bufferSize = 3;
-      uint8_t*   buffer     = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff}; // normal of (0, 0, 1)
-      raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGB888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
-    }
-    else // single-value normal-roughness
-    {
-      const auto bufferSize = 4;
-      uint8_t*   buffer     = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff, 0xff}; // normal of (0, 0, 1), roughness of 1.0
-      raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+      if(createMetallicRoughnessAndNormal)
+      {
+        const auto bufferSize = 3;
+        uint8_t*   buffer     = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff}; // normal of (0, 0, 1)
+        raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGB888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+      }
+      else // single-value normal-roughness
+      {
+        const auto bufferSize = 4;
+        uint8_t*   buffer     = new uint8_t[bufferSize]{0x7f, 0x7f, 0xff, 0xff}; // normal of (0, 0, 1), roughness of 1.0
+        raw.mTextures.push_back({PixelData::New(buffer, bufferSize, 1, 1, Pixel::RGBA8888, PixelData::DELETE_ARRAY), SINGLE_VALUE_SAMPLER});
+      }
     }
   }
 
@@ -273,6 +276,13 @@ TextureSet MaterialDefinition::Load(const EnvironmentDefinition::Vector& environ
 
       textureSet.SetTexture(n, envTextures.mSpecular);
       textureSet.SetSampler(n, specularSampler);
+      ++n;
+    }
+
+    // If pre-computed brdf texture is defined, set the texture.
+    if(envTextures.mBrdf)
+    {
+      textureSet.SetTexture(n, envTextures.mBrdf);
     }
   }
   else
index e36f74b..2c9ed6c 100644 (file)
@@ -219,12 +219,20 @@ struct DALI_SCENE_LOADER_API MaterialDefinition
 public: // DATA
   uint32_t mFlags = 0x0;
 
-  Index                     mEnvironmentIdx    = 0;
-  Vector4                   mColor             = Color::WHITE;
-  Vector3                   mEmissiveFactor    = Vector3::ZERO;
-  float                     mMetallic          = 1.f;
-  float                     mRoughness         = 1.f;
-  float                     mOcclusionStrength = 1.f;
+  Index   mEnvironmentIdx    = 0;
+  Vector4 mColor             = Color::WHITE;
+  float   mMetallic          = 1.f;
+  float   mRoughness         = 1.f;
+  Vector4 mBaseColorFactor   = Vector4::ONE;
+  float   mNormalScale       = 1.f;
+  float   mOcclusionStrength = 1.f;
+  Vector3 mEmissiveFactor    = Vector3::ZERO;
+
+  // For the glTF, each of albedo, metallicRoughness, normal textures are not essential.
+  bool mNeedAlbedoTexture            = true;
+  bool mNeedMetallicRoughnessTexture = true;
+  bool mNeedNormalTexture            = true;
+
   std::vector<TextureStage> mTextureStages;
 };
 
index de37e30..373b445 100644 (file)
@@ -681,8 +681,9 @@ MeshDefinition::LoadRaw(const std::string& modelsPath) const
 
   if(mTangents.IsDefined())
   {
-    DALI_ASSERT_ALWAYS(((mTangents.mBlob.mLength % sizeof(Vector3) == 0) ||
-                        mTangents.mBlob.mStride >= sizeof(Vector3)) &&
+    uint32_t propertySize = (mTangentType == Property::VECTOR4) ? sizeof(Vector4) : sizeof(Vector3);
+    DALI_ASSERT_ALWAYS(((mTangents.mBlob.mLength % propertySize == 0) ||
+                        mTangents.mBlob.mStride >= propertySize) &&
                        "Tangents buffer length not a multiple of element size");
     const auto           bufferSize = mTangents.mBlob.GetBufferSize();
     std::vector<uint8_t> buffer(bufferSize);
@@ -690,10 +691,9 @@ MeshDefinition::LoadRaw(const std::string& modelsPath) const
     {
       ExceptionFlinger(ASSERT_LOCATION) << "Failed to read tangents from '" << meshPath << "'.";
     }
+    mTangents.mBlob.ApplyMinMax(bufferSize / propertySize, reinterpret_cast<float*>(buffer.data()));
 
-    mTangents.mBlob.ApplyMinMax(bufferSize / sizeof(Vector3), reinterpret_cast<float*>(buffer.data()));
-
-    raw.mAttribs.push_back({"aTangent", Property::VECTOR3, static_cast<uint32_t>(bufferSize / sizeof(Vector3)), std::move(buffer)});
+    raw.mAttribs.push_back({"aTangent", mTangentType, static_cast<uint32_t>(bufferSize / propertySize), std::move(buffer)});
   }
   else if(mTangents.mBlob.mLength != 0 && hasNormals && isTriangles)
   {
@@ -701,6 +701,27 @@ MeshDefinition::LoadRaw(const std::string& modelsPath) const
     hasUvs ? GenerateTangentsWithUvs(raw) : GenerateTangents(raw);
   }
 
+  if(mColors.IsDefined())
+  {
+    uint32_t propertySize = mColors.mBlob.mElementSizeHint;
+    Property::Type propertyType = (propertySize == sizeof(Vector4)) ? Property::VECTOR4 : ((propertySize == sizeof(Vector3)) ? Property::VECTOR3 : Property::NONE);
+    if(propertyType != Property::NONE)
+    {
+      DALI_ASSERT_ALWAYS(((mColors.mBlob.mLength % propertySize == 0) ||
+                          mColors.mBlob.mStride >= propertySize) &&
+                         "Colors buffer length not a multiple of element size");
+      const auto           bufferSize = mColors.mBlob.GetBufferSize();
+      std::vector<uint8_t> buffer(bufferSize);
+      if(!ReadAccessor(mColors, binFile, buffer.data()))
+      {
+        ExceptionFlinger(ASSERT_LOCATION) << "Failed to read colors from '" << meshPath << "'.";
+      }
+      mColors.mBlob.ApplyMinMax(bufferSize / propertySize, reinterpret_cast<float*>(buffer.data()));
+
+      raw.mAttribs.push_back({"aVertexColor", propertyType, static_cast<uint32_t>(bufferSize / propertySize), std::move(buffer)});
+    }
+  }
+
   if(IsSkinned())
   {
     if(MaskMatch(mFlags, U16_JOINT_IDS))
index d03fa0b..2fe4394 100644 (file)
@@ -243,9 +243,11 @@ public: // DATA
   Accessor       mPositions;
   Accessor       mNormals; // data can be generated based on positions
   Accessor       mTexCoords;
+  Accessor       mColors;
   Accessor       mTangents; // data can be generated based on normals and texCoords (the latter isn't mandatory; the results will be better if available)
   Accessor       mJoints0;
   Accessor       mWeights0;
+  Property::Type mTangentType{Property::VECTOR3};
 
   Blob                    mBlendShapeHeader;
   std::vector<BlendShape> mBlendShapes;
index e8f6b82..7542782 100644 (file)
@@ -150,9 +150,13 @@ void ModelNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParam
 
   actor.SetProperty(Actor::Property::COLOR, mColor);
 
+  actor.RegisterProperty("uHasVertexColor", static_cast<float>(mesh.first.mColors.IsDefined()));
+
   auto& matDef = resources.mMaterials[mMaterialIdx].first;
+  actor.RegisterProperty("uColorFactor", matDef.mBaseColorFactor);
   actor.RegisterProperty("uMetallicFactor", matDef.mMetallic);
   actor.RegisterProperty("uRoughnessFactor", matDef.mRoughness);
+  actor.RegisterProperty("uNormalScale", matDef.mNormalScale);
   if(matDef.mFlags & MaterialDefinition::OCCLUSION)
   {
     actor.RegisterProperty("uOcclusionStrength", matDef.mOcclusionStrength);
@@ -165,11 +169,23 @@ void ModelNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParam
   Index envIdx = matDef.mEnvironmentIdx;
   actor.RegisterProperty("uIblIntensity", resources.mEnvironmentMaps[envIdx].first.mIblIntensity);
 
-  const auto alphaCutoff = matDef.GetAlphaCutoff();
-  if(alphaCutoff > 0.f)
+  float opaque = 0.0f;
+  float mask = 0.0f;
+  float alphaCutoff = matDef.GetAlphaCutoff();
+  if(!MaskMatch(matDef.mFlags, MaterialDefinition::TRANSPARENCY))
+  {
+    opaque = 1.0f;
+  }
+  else
   {
-    actor.RegisterProperty("uAlphaThreshold", alphaCutoff);
+    if(alphaCutoff > 0.f)
+    {
+      mask = 1.0f;
+    }
   }
+  actor.RegisterProperty("uOpaque", opaque);
+  actor.RegisterProperty("uMask", mask);
+  actor.RegisterProperty("uAlphaThreshold", alphaCutoff);
 }
 
 void ArcNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParams& params, Actor& actor) const
index 6f9ab4e..e025ebe 100644 (file)
@@ -204,11 +204,27 @@ Index ShaderDefinitionFactory::ProduceShader(const NodeDefinition& nodeDef)
   }
 
   if(hasTransparency ||
-     materialDef.CheckTextures(MaterialDefinition::ALBEDO) ||
-     materialDef.CheckTextures(MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS) ||
-     materialDef.CheckTextures(MaterialDefinition::NORMAL))
+     !materialDef.CheckTextures(MaterialDefinition::ALBEDO | MaterialDefinition::METALLIC) ||
+     !materialDef.CheckTextures(MaterialDefinition::NORMAL | MaterialDefinition::ROUGHNESS))
+
   {
     shaderDef.mDefines.push_back("THREE_TEX");
+
+    // For the glTF, each of basecolor, metallic_roughness, normal texture is not essential.
+    if(MaskMatch(materialDef.mFlags, MaterialDefinition::ALBEDO))
+    {
+      shaderDef.mDefines.push_back("BASECOLOR_TEX");
+    }
+
+    if(materialDef.CheckTextures(MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS))
+    {
+      shaderDef.mDefines.push_back("METALLIC_ROUGHNESS_TEX");
+    }
+
+    if(MaskMatch(materialDef.mFlags, MaterialDefinition::NORMAL))
+    {
+      shaderDef.mDefines.push_back("NORMAL_TEX");
+    }
   }
 
   if(materialDef.GetAlphaCutoff() > 0.f)
@@ -280,6 +296,11 @@ Index ShaderDefinitionFactory::ProduceShader(const NodeDefinition& nodeDef)
     }
   }
 
+  if(meshDef.mTangentType == Property::VECTOR4)
+  {
+    shaderDef.mDefines.push_back("VEC4_TANGENT");
+  }
+
   shaderDef.mUniforms["uMaxLOD"]     = 6.f;
   shaderDef.mUniforms["uCubeMatrix"] = Matrix::IDENTITY;
 
index b77b2b8..c65abbb 100644 (file)
@@ -213,13 +213,13 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor)
      actor.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) &&
      actor.GetProperty<bool>(Actor::Property::VISIBLE))
   {
-    // If the parent's KEYBOARD_FOCUSABLE_CHILDREN is false or VISIBLE is false, it cannot have focus.
+    // If the parent's KEYBOARD_FOCUSABLE_CHILDREN is false, it cannot have focus.
     Actor parent = actor.GetParent();
     while(parent)
     {
-      if(!parent.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) || !parent.GetProperty<bool>(Actor::Property::VISIBLE))
+      if(!parent.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN))
       {
-        DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] Parent Actor has KEYBOARD_FOCUSABLE_CHILDREN false or VISIBLE false,\n", __FUNCTION__, __LINE__);
+        DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] Parent Actor has KEYBOARD_FOCUSABLE_CHILDREN false\n", __FUNCTION__, __LINE__);
         return false;
       }
       parent = parent.GetParent();
@@ -420,11 +420,11 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction
   bool succeed = false;
 
   // Go through the actor's hierarchy until we find a layout control that knows how to move the focus
-  Toolkit::Control parentLayoutControl = GetParentLayoutControl(currentFocusActor);
-  while(parentLayoutControl && !succeed)
+  Toolkit::Control layoutControl = IsLayoutControl(currentFocusActor) ? Toolkit::Control::DownCast(currentFocusActor) : GetParentLayoutControl(currentFocusActor);
+  while(layoutControl && !succeed)
   {
-    succeed             = DoMoveFocusWithinLayoutControl(parentLayoutControl, currentFocusActor, direction);
-    parentLayoutControl = GetParentLayoutControl(parentLayoutControl);
+    succeed       = DoMoveFocusWithinLayoutControl(layoutControl, currentFocusActor, direction);
+    layoutControl = GetParentLayoutControl(layoutControl);
   }
 
   if(!succeed)
@@ -556,9 +556,9 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction
         Toolkit::Control layoutControl = Toolkit::Control::DownCast(nextFocusableActor);
         succeed                        = DoMoveFocusWithinLayoutControl(layoutControl, currentFocusActor, direction);
       }
-      else
+      if(!succeed)
       {
-        // Otherwise, just set focus to the next focusable actor
+        // Just set focus to the next focusable actor
         succeed = SetCurrentFocusActor(nextFocusableActor);
       }
     }
@@ -595,7 +595,7 @@ bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control contr
       if(committedFocusActor && committedFocusActor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) && committedFocusActor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED))
       {
         // Whether the commited focusable actor is a layout control
-        if(IsLayoutControl(committedFocusActor))
+        if(IsLayoutControl(committedFocusActor) && committedFocusActor != control)
         {
           // If so, move the focus inside it.
           Toolkit::Control layoutControl = Toolkit::Control::DownCast(committedFocusActor);
index 31c3351..08b4cd0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -33,8 +33,6 @@ namespace Toolkit
 {
 namespace Internal
 {
-typedef unsigned char PixelBuffer;
-
 Texture ImageAtlas::PackToAtlas(const std::vector<PixelData>& pixelData, Dali::Vector<Vector4>& textureRects)
 {
   // Record each block size
@@ -68,7 +66,7 @@ Texture ImageAtlas::PackToAtlas(const std::vector<PixelData>& pixelData, Dali::V
 
     // Apply the half pixel correction to avoid the color bleeding between neighbour blocks
     textureRects[index].x = (static_cast<float>(packPositionX) + 0.5f) / atlasWidth;                                 // left
-    textureRects[index].y = (static_cast<float>(packPositionY) + 0.5f) / atlasHeight;                                // right
+    textureRects[index].y = (static_cast<float>(packPositionY) + 0.5f) / atlasHeight;                                // top
     textureRects[index].z = (static_cast<float>(packPositionX + pixelData[index].GetWidth()) - 0.5f) / atlasWidth;   // right
     textureRects[index].w = (static_cast<float>(packPositionY + pixelData[index].GetHeight()) - 0.5f) / atlasHeight; // bottom
   }
@@ -158,15 +156,15 @@ bool ImageAtlas::Upload(Vector4&             textureRect,
     }
   }
 
-  unsigned int packPositionX = 0;
-  unsigned int packPositionY = 0;
+  uint32_t packPositionX = 0;
+  uint32_t packPositionY = 0;
   if(mPacker.Pack(dimensions.GetWidth(), dimensions.GetHeight(), packPositionX, packPositionY))
   {
-    unsigned short loadId = GetImplementation(mAsyncLoader).Load(url, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF);
+    uint32_t loadId = GetImplementation(mAsyncLoader).Load(url, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF);
     mLoadingTaskInfoContainer.PushBack(new LoadingTaskInfo(loadId, packPositionX, packPositionY, dimensions.GetWidth(), dimensions.GetHeight(), atlasUploadObserver));
     // apply the half pixel correction
     textureRect.x = (static_cast<float>(packPositionX) + 0.5f) / mWidth;                      // left
-    textureRect.y = (static_cast<float>(packPositionY) + 0.5f) / mHeight;                     // right
+    textureRect.y = (static_cast<float>(packPositionY) + 0.5f) / mHeight;                     // top
     textureRect.z = (static_cast<float>(packPositionX + dimensions.GetX()) - 0.5f) / mWidth;  // right
     textureRect.w = (static_cast<float>(packPositionY + dimensions.GetY()) - 0.5f) / mHeight; // bottom
 
@@ -183,17 +181,66 @@ bool ImageAtlas::Upload(Vector4&             textureRect,
   return false;
 }
 
+bool ImageAtlas::Upload(Vector4&                  textureRect,
+                        const EncodedImageBuffer& encodedImageBuffer,
+                        ImageDimensions           size,
+                        FittingMode::Type         fittingMode,
+                        bool                      orientationCorrection,
+                        AtlasUploadObserver*      atlasUploadObserver)
+{
+  ImageDimensions zero;
+  if(size == zero) // image size not provided
+  {
+    DALI_LOG_ERROR("Desired size is zero! We need to setup desired size for Atlas.\n");
+    // EncodedImageBuffer didn't support to get closest image size.
+    // Just draw broken image.
+    if(!mBrokenImageUrl.empty())
+    {
+      return Upload(textureRect, mBrokenImageUrl, mBrokenImageSize, FittingMode::DEFAULT, true, atlasUploadObserver);
+    }
+    else
+    {
+      textureRect = Vector4::ZERO;
+      return true;
+    }
+  }
+
+  uint32_t packPositionX = 0;
+  uint32_t packPositionY = 0;
+  if(mPacker.Pack(size.GetWidth(), size.GetHeight(), packPositionX, packPositionY))
+  {
+    uint32_t loadId = GetImplementation(mAsyncLoader).LoadEncodedImageBuffer(encodedImageBuffer, size, fittingMode, SamplingMode::BOX_THEN_LINEAR, orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF);
+    mLoadingTaskInfoContainer.PushBack(new LoadingTaskInfo(loadId, packPositionX, packPositionY, size.GetWidth(), size.GetHeight(), atlasUploadObserver));
+    // apply the half pixel correction
+    textureRect.x = (static_cast<float>(packPositionX) + 0.5f) / mWidth;                // left
+    textureRect.y = (static_cast<float>(packPositionY) + 0.5f) / mHeight;               // top
+    textureRect.z = (static_cast<float>(packPositionX + size.GetX()) - 0.5f) / mWidth;  // right
+    textureRect.w = (static_cast<float>(packPositionY + size.GetY()) - 0.5f) / mHeight; // bottom
+
+    if(atlasUploadObserver)
+    {
+      // register to the observer,
+      // Not that a matching unregister call should be invoked in UploadToAtlas if the observer is still alive by then.
+      atlasUploadObserver->Register(*this);
+    }
+
+    return true;
+  }
+
+  return false;
+}
+
 bool ImageAtlas::Upload(Vector4& textureRect, PixelData pixelData)
 {
-  unsigned int packPositionX = 0;
-  unsigned int packPositionY = 0;
+  uint32_t packPositionX = 0;
+  uint32_t packPositionY = 0;
   if(mPacker.Pack(pixelData.GetWidth(), pixelData.GetHeight(), packPositionX, packPositionY))
   {
     mAtlas.Upload(pixelData, 0u, 0u, packPositionX, packPositionY, pixelData.GetWidth(), pixelData.GetHeight());
 
     // apply the half pixel correction
     textureRect.x = (static_cast<float>(packPositionX) + 0.5f) / mWidth;                          // left
-    textureRect.y = (static_cast<float>(packPositionY) + 0.5f) / mHeight;                         // right
+    textureRect.y = (static_cast<float>(packPositionY) + 0.5f) / mHeight;                         // top
     textureRect.z = (static_cast<float>(packPositionX + pixelData.GetWidth()) - 0.5f) / mWidth;   // right
     textureRect.w = (static_cast<float>(packPositionY + pixelData.GetHeight()) - 0.5f) / mHeight; // bottom
 
@@ -228,7 +275,7 @@ void ImageAtlas::UploadToAtlas(uint32_t id, PixelData pixelData)
 {
   if(mLoadingTaskInfoContainer[0]->loadTaskId == id)
   {
-    Rect<unsigned int> packRect(mLoadingTaskInfoContainer[0]->packRect);
+    Rect<uint32_t> packRect(mLoadingTaskInfoContainer[0]->packRect);
     if(!pixelData || (pixelData.GetWidth() == 0 && pixelData.GetHeight() == 0))
     {
       if(!mBrokenImageUrl.empty()) // replace with the broken image
@@ -260,7 +307,7 @@ void ImageAtlas::UploadToAtlas(uint32_t id, PixelData pixelData)
   }
 }
 
-void ImageAtlas::UploadBrokenImage(const Rect<unsigned int>& area)
+void ImageAtlas::UploadBrokenImage(const Rect<uint32_t>& area)
 {
   Devel::PixelBuffer brokenBuffer = LoadImageFromFile(mBrokenImageUrl, ImageDimensions(area.width, area.height));
   SizeType           loadedWidth  = brokenBuffer.GetWidth();
index eab1551..e302d92 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_IMAGE_ATLAS_IMPL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -19,6 +19,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/common/owner-container.h>
+#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/signals/connection-tracker.h>
@@ -26,8 +27,8 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
 #include <dali-toolkit/internal/image-loader/atlas-packer.h>
-#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
+#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
 
 namespace Dali
 {
@@ -86,6 +87,32 @@ public:
               AtlasUploadObserver* atlasUploadObserver);
 
   /**
+   * @brief Upload a resource image to the atlas by encoded buffer.
+   *
+   * @note To make the atlasing efficient, a valid size should be provided.
+   *       If size is not provided, then SegFault occured.
+   *       Do not set a size that is bigger than the actual image size, as the up-scaling is not available,
+   *       the content of the area not covered by actual image is undefined, it will not be cleared.
+   *
+   * SamplingMode::BOX_THEN_LINEAR is used to sampling pixels from the input image while fitting it to desired size.
+   *
+   * @param [out] textureRect The texture area of the resource image in the atlas.
+   * @param [in] encodedImageBuffer The encoded raw buffer of the resource image file to use.
+   * @param [in] size The width and height to fit the loaded image to.
+   * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
+   * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+   * @param [in] atlasUploadObserver The observer to observe the upload state inside the ImageAtlas.
+   * @return True if there is enough space to fit this image in,false otherwise.
+   * @note The valid callback function here is required to have the signature of void( void ).
+   */
+  bool Upload(Vector4&                  textureRect,
+              const EncodedImageBuffer& encodedImageBuffer,
+              ImageDimensions           size,
+              FittingMode::Type         fittingMode,
+              bool                      orientationCorrection,
+              AtlasUploadObserver*      atlasUploadObserver);
+
+  /**
    * @copydoc Toolkit::ImageAtlas::Upload( Vector4&, PixelData )
    */
   bool Upload(Vector4& textureRect, PixelData pixelData);
@@ -117,7 +144,7 @@ private:
    *
    * @param[in] area The pixel area for uploading.
    */
-  void UploadBrokenImage(const Rect<unsigned int>& area);
+  void UploadBrokenImage(const Rect<uint32_t>& area);
 
   // Undefined
   ImageAtlas(const ImageAtlas& imageAtlas);
@@ -132,11 +159,11 @@ private:
    */
   struct LoadingTaskInfo
   {
-    LoadingTaskInfo(unsigned short       loadTaskId,
-                    unsigned int         packPositionX,
-                    unsigned int         packPositionY,
-                    unsigned int         width,
-                    unsigned int         height,
+    LoadingTaskInfo(uint32_t             loadTaskId,
+                    uint32_t             packPositionX,
+                    uint32_t             packPositionY,
+                    uint32_t             width,
+                    uint32_t             height,
                     AtlasUploadObserver* observer)
     : loadTaskId(loadTaskId),
       packRect(packPositionX, packPositionY, width, height),
@@ -144,8 +171,8 @@ private:
     {
     }
 
-    unsigned short       loadTaskId;
-    Rect<unsigned int>   packRect;
+    uint32_t             loadTaskId;
+    Rect<uint32_t>       packRect;
     AtlasUploadObserver* observer;
   };
 
index 500a081..826e894 100644 (file)
@@ -41,6 +41,20 @@ namespace
 {
 const float HALF(0.5f);
 const float ONE_AND_A_HALF(1.5f);
+
+/**
+ * @brief Fast multiply & divide by 255. It wiil be useful when we applying alpha value in color
+ *
+ * @param x The value between [0..255]
+ * @param y The value between [0..255]
+ * @return (x*y)/255
+ */
+inline uint8_t MultiplyAndNormalizeColor(const uint8_t& x, const uint8_t& y) noexcept
+{
+  const uint32_t xy = static_cast<const uint32_t>(x) * y;
+  return ((xy << 15) + (xy << 7) + xy) >> 23;
+}
+
 /**
  * @brief Data struct used to set the buffer of the glyph's bitmap into the final bitmap's buffer.
  */
@@ -49,16 +63,16 @@ struct GlyphData
   Devel::PixelBuffer                           bitmapBuffer;     ///< The buffer of the whole bitmap. The format is RGBA8888.
   Vector2*                                     position;         ///< The position of the glyph.
   TextAbstraction::FontClient::GlyphBufferData glyphBitmap;      ///< The glyph's bitmap.
-  unsigned int                                 width;            ///< The bitmap's width.
-  unsigned int                                 height;           ///< The bitmap's height.
-  int                                          horizontalOffset; ///< The horizontal offset to be added to the 'x' glyph's position.
-  int                                          verticalOffset;   ///< The vertical offset to be added to the 'y' glyph's position.
+  uint32_t                                     width;            ///< The bitmap's width.
+  uint32_t                                     height;           ///< The bitmap's height.
+  int32_t                                      horizontalOffset; ///< The horizontal offset to be added to the 'x' glyph's position.
+  int32_t                                      verticalOffset;   ///< The vertical offset to be added to the 'y' glyph's position.
 };
 
 /**
  * @brief Sets the glyph's buffer into the bitmap's buffer.
  *
- * @param[in] data Struct which contains the glyph's data and the bitmap's data.
+ * @param[in, out] data Struct which contains the glyph's data and the bitmap's data.
  * @param[in] position The position of the glyph.
  * @param[in] color The color of the glyph.
  * @param[in] style The style of the text.
@@ -76,46 +90,70 @@ void TypesetGlyph(GlyphData&           data,
     return;
   }
 
-  const int widthMinusOne  = static_cast<int>(data.width - 1u);
-  const int heightMinusOne = static_cast<int>(data.height - 1u);
+  // Initial vertical / horizontal offset.
+  const int32_t yOffset = data.verticalOffset + position->y;
+  const int32_t xOffset = data.horizontalOffset + position->x;
+
+  // Whether the given glyph is a color one.
+  const bool     isColorGlyph   = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
+  const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
+  const uint32_t alphaIndex     = glyphPixelSize - 1u;
+
+  // Determinate iterator range.
+  const int32_t lineIndexRangeMin = std::max(0, -yOffset);
+  const int32_t lineIndexRangeMax = std::min(static_cast<int32_t>(data.glyphBitmap.height), static_cast<int32_t>(data.height) - yOffset);
+  const int32_t indexRangeMin     = std::max(0, -xOffset);
+  const int32_t indexRangeMax     = std::min(static_cast<int32_t>(data.glyphBitmap.width), static_cast<int32_t>(data.width) - xOffset);
+
+  // If current glyph don't need to be rendered, just ignore.
+  if(lineIndexRangeMax <= lineIndexRangeMin || indexRangeMax <= indexRangeMin)
+  {
+    return;
+  }
 
   if(Pixel::RGBA8888 == pixelFormat)
   {
-    // Whether the given glyph is a color one.
-    const bool     isColorGlyph   = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
-    const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
-    const uint32_t alphaIndex     = glyphPixelSize - 1u;
-    const bool     swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
+    const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
+
+    uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(data.bitmapBuffer.GetBuffer());
+
+    // Fast-cut if style is MASK or OUTLINE. Outline not shown for color glyph.
+    // Just overwrite transparent color and return.
+    if(isColorGlyph && (Typesetter::STYLE_MASK == style || Typesetter::STYLE_OUTLINE == style))
+    {
+      for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+      {
+        const int32_t yOffsetIndex   = yOffset + lineIndex;
+        const int32_t verticalOffset = yOffsetIndex * data.width;
+
+        // We can use memset here.
+        memset(bitmapBuffer + verticalOffset + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+      }
+      return;
+    }
 
     // Pointer to the color glyph if there is one.
     const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast<uint32_t*>(data.glyphBitmap.buffer) : NULL;
 
-    // Initial vertical offset.
-    const int yOffset = data.verticalOffset + position->y;
+    // Precalculate input color's packed result.
+    uint32_t packedInputColor       = 0u;
+    uint8_t* packedInputColorBuffer = reinterpret_cast<uint8_t*>(&packedInputColor);
 
-    uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(data.bitmapBuffer.GetBuffer());
+    *(packedInputColorBuffer + 3u) = static_cast<uint8_t>(color->a * 255);
+    *(packedInputColorBuffer + 2u) = static_cast<uint8_t>(color->b * 255);
+    *(packedInputColorBuffer + 1u) = static_cast<uint8_t>(color->g * 255);
+    *(packedInputColorBuffer)      = static_cast<uint8_t>(color->r * 255);
 
     // Traverse the pixels of the glyph line per line.
-    for(int lineIndex = 0, glyphHeight = static_cast<int>(data.glyphBitmap.height); lineIndex < glyphHeight; ++lineIndex)
+    for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
     {
-      const int yOffsetIndex = yOffset + lineIndex;
-      if((0 > yOffsetIndex) || (yOffsetIndex > heightMinusOne))
-      {
-        // Do not write out of bounds.
-        continue;
-      }
+      const int32_t yOffsetIndex = yOffset + lineIndex;
 
-      const int verticalOffset    = yOffsetIndex * data.width;
-      const int xOffset           = data.horizontalOffset + position->x;
-      const int glyphBufferOffset = lineIndex * static_cast<int>(data.glyphBitmap.width);
-      for(int index = 0, glyphWidth = static_cast<int>(data.glyphBitmap.width); index < glyphWidth; ++index)
+      const int32_t verticalOffset    = yOffsetIndex * data.width;
+      const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
+      for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
       {
-        const int xOffsetIndex = xOffset + index;
-        if((0 > xOffsetIndex) || (xOffsetIndex > widthMinusOne))
-        {
-          // Don't write out of bounds.
-          continue;
-        }
+        const int32_t xOffsetIndex = xOffset + index;
 
         if(isColorGlyph)
         {
@@ -124,43 +162,32 @@ void TypesetGlyph(GlyphData&           data,
           uint8_t* packedColorGlyphBuffer = reinterpret_cast<uint8_t*>(&packedColorGlyph);
 
           // Update the alpha channel.
-          if(Typesetter::STYLE_MASK == style || Typesetter::STYLE_OUTLINE == style) // Outline not shown for color glyph
+          const uint8_t colorAlpha       = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 3u), *(packedColorGlyphBuffer + 3u));
+          *(packedColorGlyphBuffer + 3u) = colorAlpha;
+
+          if(Typesetter::STYLE_SHADOW == style)
           {
-            // Create an alpha mask for color glyph.
-            *(packedColorGlyphBuffer + 3u) = 0u;
-            *(packedColorGlyphBuffer + 2u) = 0u;
-            *(packedColorGlyphBuffer + 1u) = 0u;
-            *packedColorGlyphBuffer        = 0u;
+            // The shadow of color glyph needs to have the shadow color.
+            *(packedColorGlyphBuffer + 2u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 2u), colorAlpha);
+            *(packedColorGlyphBuffer + 1u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 1u), colorAlpha);
+            *packedColorGlyphBuffer        = MultiplyAndNormalizeColor(*packedInputColorBuffer, colorAlpha);
           }
           else
           {
-            const uint8_t colorAlpha       = static_cast<uint8_t>(color->a * static_cast<float>(*(packedColorGlyphBuffer + 3u)));
-            *(packedColorGlyphBuffer + 3u) = colorAlpha;
-
-            if(Typesetter::STYLE_SHADOW == style)
+            if(swapChannelsBR)
             {
-              // The shadow of color glyph needs to have the shadow color.
-              *(packedColorGlyphBuffer + 2u) = static_cast<uint8_t>(color->b * colorAlpha);
-              *(packedColorGlyphBuffer + 1u) = static_cast<uint8_t>(color->g * colorAlpha);
-              *packedColorGlyphBuffer        = static_cast<uint8_t>(color->r * colorAlpha);
+              std::swap(*packedColorGlyphBuffer, *(packedColorGlyphBuffer + 2u)); // Swap B and R.
             }
-            else
+
+            *(packedColorGlyphBuffer + 2u) = MultiplyAndNormalizeColor(*(packedColorGlyphBuffer + 2u), colorAlpha);
+            *(packedColorGlyphBuffer + 1u) = MultiplyAndNormalizeColor(*(packedColorGlyphBuffer + 1u), colorAlpha);
+            *packedColorGlyphBuffer        = MultiplyAndNormalizeColor(*packedColorGlyphBuffer, colorAlpha);
+
+            if(data.glyphBitmap.isColorBitmap)
             {
-              if(swapChannelsBR)
-              {
-                std::swap(*packedColorGlyphBuffer, *(packedColorGlyphBuffer + 2u)); // Swap B and R.
-              }
-
-              *(packedColorGlyphBuffer + 2u) = (*(packedColorGlyphBuffer + 2u) * colorAlpha / 255);
-              *(packedColorGlyphBuffer + 1u) = (*(packedColorGlyphBuffer + 1u) * colorAlpha / 255);
-              *packedColorGlyphBuffer        = (*(packedColorGlyphBuffer)*colorAlpha / 255);
-
-              if(data.glyphBitmap.isColorBitmap)
-              {
-                *(packedColorGlyphBuffer + 2u) = static_cast<uint8_t>(*(packedColorGlyphBuffer + 2u) * color->b);
-                *(packedColorGlyphBuffer + 1u) = static_cast<uint8_t>(*(packedColorGlyphBuffer + 1u) * color->g);
-                *packedColorGlyphBuffer        = static_cast<uint8_t>(*packedColorGlyphBuffer * color->r);
-              }
+              *(packedColorGlyphBuffer + 2u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 2u), *(packedColorGlyphBuffer + 2u));
+              *(packedColorGlyphBuffer + 1u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 1u), *(packedColorGlyphBuffer + 1u));
+              *packedColorGlyphBuffer        = MultiplyAndNormalizeColor(*packedInputColorBuffer, *packedColorGlyphBuffer);
             }
           }
 
@@ -190,15 +217,22 @@ void TypesetGlyph(GlyphData&           data,
             // happen, for example, in the RTL text when we copy glyphs from right to left).
             uint8_t currentAlpha = *(packedCurrentColorBuffer + 3u);
             currentAlpha         = std::max(currentAlpha, alpha);
-
-            // Color is pre-muliplied with its alpha.
-            *(packedColorBuffer + 3u) = static_cast<uint8_t>(color->a * currentAlpha);
-            *(packedColorBuffer + 2u) = static_cast<uint8_t>(color->b * currentAlpha);
-            *(packedColorBuffer + 1u) = static_cast<uint8_t>(color->g * currentAlpha);
-            *(packedColorBuffer)      = static_cast<uint8_t>(color->r * currentAlpha);
-
-            // Set the color into the final pixel buffer.
-            currentColor = packedColor;
+            if(currentAlpha == 255)
+            {
+              // Fast-cut to avoid float type operation.
+              currentColor = packedInputColor;
+            }
+            else
+            {
+              // Color is pre-muliplied with its alpha.
+              *(packedColorBuffer + 3u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 3u), currentAlpha);
+              *(packedColorBuffer + 2u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 2u), currentAlpha);
+              *(packedColorBuffer + 1u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 1u), currentAlpha);
+              *(packedColorBuffer)      = MultiplyAndNormalizeColor(*packedInputColorBuffer, currentAlpha);
+
+              // Set the color into the final pixel buffer.
+              currentColor = packedColor;
+            }
           }
         }
       }
@@ -206,40 +240,22 @@ void TypesetGlyph(GlyphData&           data,
   }
   else
   {
-    // Whether the given glyph is a color one.
-    const bool     isColorGlyph   = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
-    const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
-    const uint32_t alphaIndex     = glyphPixelSize - 1u;
-
-    // Initial vertical offset.
-    const int yOffset = data.verticalOffset + position->y;
-
-    uint8_t* bitmapBuffer = reinterpret_cast<uint8_t*>(data.bitmapBuffer.GetBuffer());
-
-    // Traverse the pixels of the glyph line per line.
-    for(int lineIndex = 0, glyphHeight = static_cast<int>(data.glyphBitmap.height); lineIndex < glyphHeight; ++lineIndex)
+    // Below codes required only if not color glyph.
+    if(!isColorGlyph)
     {
-      const int yOffsetIndex = yOffset + lineIndex;
-      if((0 > yOffsetIndex) || (yOffsetIndex > heightMinusOne))
-      {
-        // Do not write out of bounds.
-        continue;
-      }
+      uint8_t* bitmapBuffer = reinterpret_cast<uint8_t*>(data.bitmapBuffer.GetBuffer());
 
-      const int verticalOffset    = yOffsetIndex * data.width;
-      const int xOffset           = data.horizontalOffset + position->x;
-      const int glyphBufferOffset = lineIndex * static_cast<int>(data.glyphBitmap.width);
-      for(int index = 0, glyphWidth = static_cast<int>(data.glyphBitmap.width); index < glyphWidth; ++index)
+      // Traverse the pixels of the glyph line per line.
+      for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
       {
-        const int xOffsetIndex = xOffset + index;
-        if((0 > xOffsetIndex) || (xOffsetIndex > widthMinusOne))
-        {
-          // Don't write out of bounds.
-          continue;
-        }
+        const int32_t yOffsetIndex = yOffset + lineIndex;
 
-        if(!isColorGlyph)
+        const int32_t verticalOffset    = yOffsetIndex * data.width;
+        const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
+        for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
         {
+          const int32_t xOffsetIndex = xOffset + index;
+
           // Update the alpha channel.
           const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
 
@@ -261,38 +277,16 @@ void TypesetGlyph(GlyphData&           data,
   }
 }
 
-/// Draws the specified color to the pixel buffer
-void WriteColorToPixelBuffer(
-  GlyphData&         glyphData,
-  uint32_t*          bitmapBuffer,
-  const Vector4&     color,
-  const unsigned int x,
-  const unsigned int y)
-{
-  // Always RGBA image for text with styles
-  uint32_t pixel       = *(bitmapBuffer + y * glyphData.width + x);
-  uint8_t* pixelBuffer = reinterpret_cast<uint8_t*>(&pixel);
-
-  // Write the color to the pixel buffer
-  uint8_t colorAlpha  = static_cast<uint8_t>(color.a * 255.f);
-  *(pixelBuffer + 3u) = colorAlpha;
-  *(pixelBuffer + 2u) = static_cast<uint8_t>(color.b * colorAlpha);
-  *(pixelBuffer + 1u) = static_cast<uint8_t>(color.g * colorAlpha);
-  *(pixelBuffer)      = static_cast<uint8_t>(color.r * colorAlpha);
-
-  *(bitmapBuffer + y * glyphData.width + x) = pixel;
-}
-
 /// Draws the specified underline color to the buffer
 void DrawUnderline(
-  const unsigned int              bufferWidth,
-  const unsigned int              bufferHeight,
+  const uint32_t&                 bufferWidth,
+  const uint32_t&                 bufferHeight,
   GlyphData&                      glyphData,
-  const float                     baseline,
-  const float                     currentUnderlinePosition,
-  const float                     maxUnderlineHeight,
-  const float                     lineExtentLeft,
-  const float                     lineExtentRight,
+  const float&                    baseline,
+  const float&                    currentUnderlinePosition,
+  const float&                    maxUnderlineHeight,
+  const float&                    lineExtentLeft,
+  const float&                    lineExtentRight,
   const UnderlineStyleProperties& commonUnderlineProperties,
   const UnderlineStyleProperties& currentUnderlineProperties,
   const LineRun&                  line)
@@ -302,76 +296,118 @@ void DrawUnderline(
   const float                 dashedUnderlineWidth = currentUnderlineProperties.dashWidthDefined ? currentUnderlineProperties.dashWidth : commonUnderlineProperties.dashWidth;
   const float                 dashedUnderlineGap   = currentUnderlineProperties.dashGapDefined ? currentUnderlineProperties.dashGap : commonUnderlineProperties.dashGap;
 
-  int       underlineYOffset = glyphData.verticalOffset + baseline + currentUnderlinePosition;
-  uint32_t* bitmapBuffer     = reinterpret_cast<uint32_t*>(glyphData.bitmapBuffer.GetBuffer());
+  int32_t underlineYOffset = glyphData.verticalOffset + baseline + currentUnderlinePosition;
+
+  const uint32_t yRangeMin = underlineYOffset;
+  const uint32_t yRangeMax = std::min(bufferHeight, underlineYOffset + static_cast<uint32_t>(maxUnderlineHeight));
+  const uint32_t xRangeMin = static_cast<uint32_t>(glyphData.horizontalOffset + lineExtentLeft);
+  const uint32_t xRangeMax = std::min(bufferWidth, static_cast<uint32_t>(glyphData.horizontalOffset + lineExtentRight + 1)); // Due to include last point, we add 1 here
+
+  // If current glyph don't need to be rendered, just ignore.
+  if((underlineType != Text::Underline::DOUBLE && yRangeMax <= yRangeMin) || xRangeMax <= xRangeMin)
+  {
+    return;
+  }
+
+  // We can optimize by memset when underlineColor.a is near zero
+  uint8_t underlineColorAlpha = static_cast<uint8_t>(underlineColor.a * 255.f);
 
-  for(unsigned int y = underlineYOffset; y < underlineYOffset + maxUnderlineHeight; y++)
+  uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(glyphData.bitmapBuffer.GetBuffer());
+
+  // Skip yRangeMin line.
+  bitmapBuffer += yRangeMin * glyphData.width;
+
+  // Note if underlineType is DASHED, we cannot setup color by memset.
+  if(underlineType != Text::Underline::DASHED && underlineColorAlpha == 0)
   {
-    if(y > bufferHeight - 1)
+    for(uint32_t y = yRangeMin; y < yRangeMax; y++)
     {
-      // Do not write out of bounds.
-      break;
+      // We can use memset.
+      memset(bitmapBuffer + xRangeMin, 0, (xRangeMax - xRangeMin) * sizeof(uint32_t));
+      bitmapBuffer += glyphData.width;
     }
-    if(underlineType == Text::Underline::DASHED)
+    if(underlineType == Text::Underline::DOUBLE)
     {
-      float dashWidth = dashedUnderlineWidth;
-      float dashGap   = 0;
+      int32_t        secondUnderlineYOffset = underlineYOffset - ONE_AND_A_HALF * maxUnderlineHeight;
+      const uint32_t secondYRangeMin        = static_cast<uint32_t>(std::max(0, secondUnderlineYOffset));
+      const uint32_t secondYRangeMax        = static_cast<uint32_t>(std::max(0, std::min(static_cast<int32_t>(bufferHeight), secondUnderlineYOffset + static_cast<int32_t>(maxUnderlineHeight))));
 
-      for(unsigned int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++)
+      // Rewind bitmapBuffer pointer, and skip secondYRangeMin line.
+      bitmapBuffer = reinterpret_cast<uint32_t*>(glyphData.bitmapBuffer.GetBuffer()) + yRangeMin * glyphData.width;
+
+      for(uint32_t y = secondYRangeMin; y < secondYRangeMax; y++)
       {
-        if(x > bufferWidth - 1)
-        {
-          // Do not write out of bounds.
-          break;
-        }
-        if(dashGap == 0 && dashWidth > 0)
-        {
-          WriteColorToPixelBuffer(glyphData, bitmapBuffer, underlineColor, x, y);
-          dashWidth--;
-        }
-        else if(dashGap < dashedUnderlineGap)
-        {
-          dashGap++;
-        }
-        else
-        {
-          //reset
-          dashWidth = dashedUnderlineWidth;
-          dashGap   = 0;
-        }
+        // We can use memset.
+        memset(bitmapBuffer + xRangeMin, 0, (xRangeMax - xRangeMin) * sizeof(uint32_t));
+        bitmapBuffer += glyphData.width;
       }
     }
-    else
+  }
+  else
+  {
+    uint32_t packedUnderlineColor       = 0u;
+    uint8_t* packedUnderlineColorBuffer = reinterpret_cast<uint8_t*>(&packedUnderlineColor);
+
+    // Write the color to the pixel buffer
+    *(packedUnderlineColorBuffer + 3u) = underlineColorAlpha;
+    *(packedUnderlineColorBuffer + 2u) = static_cast<uint8_t>(underlineColor.b * underlineColorAlpha);
+    *(packedUnderlineColorBuffer + 1u) = static_cast<uint8_t>(underlineColor.g * underlineColorAlpha);
+    *(packedUnderlineColorBuffer)      = static_cast<uint8_t>(underlineColor.r * underlineColorAlpha);
+
+    for(uint32_t y = yRangeMin; y < yRangeMax; y++)
     {
-      for(unsigned int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++)
+      if(underlineType == Text::Underline::DASHED)
       {
-        if(x > bufferWidth - 1)
+        float dashWidth = dashedUnderlineWidth;
+        float dashGap   = 0;
+
+        for(uint32_t x = xRangeMin; x < xRangeMax; x++)
         {
-          // Do not write out of bounds.
-          break;
+          if(dashGap == 0 && dashWidth > 0)
+          {
+            // Note : this is same logic as bitmap[y][x] = underlineColor;
+            *(bitmapBuffer + x) = packedUnderlineColor;
+            dashWidth--;
+          }
+          else if(dashGap < dashedUnderlineGap)
+          {
+            dashGap++;
+          }
+          else
+          {
+            //reset
+            dashWidth = dashedUnderlineWidth;
+            dashGap   = 0;
+          }
         }
-        WriteColorToPixelBuffer(glyphData, bitmapBuffer, underlineColor, x, y);
       }
-    }
-  }
-  if(underlineType == Text::Underline::DOUBLE)
-  {
-    int secondUnderlineYOffset = underlineYOffset - ONE_AND_A_HALF * maxUnderlineHeight;
-    for(unsigned int y = secondUnderlineYOffset; y < secondUnderlineYOffset + maxUnderlineHeight; y++)
-    {
-      if(y > bufferHeight - 1)
+      else
       {
-        // Do not write out of bounds.
-        break;
+        for(uint32_t x = xRangeMin; x < xRangeMax; x++)
+        {
+          // Note : this is same logic as bitmap[y][x] = underlineColor;
+          *(bitmapBuffer + x) = packedUnderlineColor;
+        }
       }
-      for(unsigned int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++)
+      bitmapBuffer += glyphData.width;
+    }
+    if(underlineType == Text::Underline::DOUBLE)
+    {
+      int32_t        secondUnderlineYOffset = underlineYOffset - ONE_AND_A_HALF * maxUnderlineHeight;
+      const uint32_t secondYRangeMin        = static_cast<uint32_t>(std::max(0, secondUnderlineYOffset));
+      const uint32_t secondYRangeMax        = static_cast<uint32_t>(std::max(0, std::min(static_cast<int32_t>(bufferHeight), secondUnderlineYOffset + static_cast<int32_t>(maxUnderlineHeight))));
+
+      // Rewind bitmapBuffer pointer, and skip secondYRangeMin line.
+      bitmapBuffer = reinterpret_cast<uint32_t*>(glyphData.bitmapBuffer.GetBuffer()) + yRangeMin * glyphData.width;
+
+      for(uint32_t y = secondYRangeMin; y < secondYRangeMax; y++)
       {
-        if(x > bufferWidth - 1)
+        for(uint32_t x = xRangeMin; x < xRangeMax; x++)
         {
-          // Do not write out of bounds.
-          break;
+          // Note : this is same logic as bitmap[y][x] = underlineColor;
+          *(bitmapBuffer + x) = packedUnderlineColor;
         }
-        WriteColorToPixelBuffer(glyphData, bitmapBuffer, underlineColor, x, y);
+        bitmapBuffer += glyphData.width;
       }
     }
   }
@@ -379,39 +415,67 @@ void DrawUnderline(
 
 /// Draws the background color to the buffer
 void DrawBackgroundColor(
-  Vector4            backgroundColor,
-  const unsigned int bufferWidth,
-  const unsigned int bufferHeight,
-  GlyphData&         glyphData,
-  const float        baseline,
-  const LineRun&     line,
-  const float        lineExtentLeft,
-  const float        lineExtentRight)
+  Vector4         backgroundColor,
+  const uint32_t& bufferWidth,
+  const uint32_t& bufferHeight,
+  GlyphData&      glyphData,
+  const float&    baseline,
+  const LineRun&  line,
+  const float&    lineExtentLeft,
+  const float&    lineExtentRight)
 {
+  const int32_t yRangeMin = std::max(0, static_cast<int32_t>(glyphData.verticalOffset + baseline - line.ascender));
+  const int32_t yRangeMax = std::min(static_cast<int32_t>(bufferHeight), static_cast<int32_t>(glyphData.verticalOffset + baseline - line.descender));
+  const int32_t xRangeMin = std::max(0, static_cast<int32_t>(glyphData.horizontalOffset + lineExtentLeft));
+  const int32_t xRangeMax = std::min(static_cast<int32_t>(bufferWidth), static_cast<int32_t>(glyphData.horizontalOffset + lineExtentRight + 1)); // Due to include last point, we add 1 here
+
+  // If current glyph don't need to be rendered, just ignore.
+  if(yRangeMax <= yRangeMin || xRangeMax <= xRangeMin)
+  {
+    return;
+  }
+
+  // We can optimize by memset when backgroundColor.a is near zero
+  uint8_t backgroundColorAlpha = static_cast<uint8_t>(backgroundColor.a * 255.f);
+
   uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(glyphData.bitmapBuffer.GetBuffer());
 
-  for(int y = glyphData.verticalOffset + baseline - line.ascender; y < glyphData.verticalOffset + baseline - line.descender; y++)
+  // Skip yRangeMin line.
+  bitmapBuffer += yRangeMin * glyphData.width;
+
+  if(backgroundColorAlpha == 0)
   {
-    if((y < 0) || (y > static_cast<int>(bufferHeight - 1)))
+    for(int32_t y = yRangeMin; y < yRangeMax; y++)
     {
-      // Do not write out of bounds.
-      continue;
+      // We can use memset.
+      memset(bitmapBuffer + xRangeMin, 0, (xRangeMax - xRangeMin) * sizeof(uint32_t));
+      bitmapBuffer += glyphData.width;
     }
+  }
+  else
+  {
+    uint32_t packedBackgroundColor       = 0u;
+    uint8_t* packedBackgroundColorBuffer = reinterpret_cast<uint8_t*>(&packedBackgroundColor);
+
+    // Write the color to the pixel buffer
+    *(packedBackgroundColorBuffer + 3u) = backgroundColorAlpha;
+    *(packedBackgroundColorBuffer + 2u) = static_cast<uint8_t>(backgroundColor.b * backgroundColorAlpha);
+    *(packedBackgroundColorBuffer + 1u) = static_cast<uint8_t>(backgroundColor.g * backgroundColorAlpha);
+    *(packedBackgroundColorBuffer)      = static_cast<uint8_t>(backgroundColor.r * backgroundColorAlpha);
 
-    for(int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++)
+    for(int32_t y = yRangeMin; y < yRangeMax; y++)
     {
-      if((x < 0) || (x > static_cast<int>(bufferWidth - 1)))
+      for(int32_t x = xRangeMin; x < xRangeMax; x++)
       {
-        // Do not write out of bounds.
-        continue;
+        // Note : this is same logic as bitmap[y][x] = backgroundColor;
+        *(bitmapBuffer + x) = packedBackgroundColor;
       }
-
-      WriteColorToPixelBuffer(glyphData, bitmapBuffer, backgroundColor, x, y);
+      bitmapBuffer += glyphData.width;
     }
   }
 }
 
-Devel::PixelBuffer DrawGlyphsBackground(const ViewModel* model, Devel::PixelBuffer& buffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, int horizontalOffset, int verticalOffset)
+Devel::PixelBuffer DrawGlyphsBackground(const ViewModel* model, Devel::PixelBuffer& buffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, int32_t horizontalOffset, int32_t verticalOffset)
 {
   // Retrieve lines, glyphs, positions and colors from the view model.
   const Length            modelNumberOfLines           = model->GetNumberOfLines();
@@ -439,16 +503,16 @@ Devel::PixelBuffer DrawGlyphsBackground(const ViewModel* model, Devel::PixelBuff
     const LineRun& line = *(modelLinesBuffer + lineIndex);
 
     // Sets the horizontal offset of the line.
-    glyphData.horizontalOffset = ignoreHorizontalAlignment ? 0 : static_cast<int>(line.alignmentOffset);
+    glyphData.horizontalOffset = ignoreHorizontalAlignment ? 0 : static_cast<int32_t>(line.alignmentOffset);
     glyphData.horizontalOffset += horizontalOffset;
 
     // Increases the vertical offset with the line's ascender.
-    glyphData.verticalOffset += static_cast<int>(line.ascender);
+    glyphData.verticalOffset += static_cast<int32_t>(line.ascender);
 
     // Include line spacing after first line
     if(lineIndex > 0u)
     {
-      glyphData.verticalOffset += static_cast<int>(line.lineSpacing);
+      glyphData.verticalOffset += static_cast<int32_t>(line.lineSpacing);
     }
 
     float left     = bufferWidth;
@@ -515,71 +579,98 @@ Devel::PixelBuffer DrawGlyphsBackground(const ViewModel* model, Devel::PixelBuff
     }
 
     // Increases the vertical offset with the line's descender.
-    glyphData.verticalOffset += static_cast<int>(-line.descender);
+    glyphData.verticalOffset += static_cast<int32_t>(-line.descender);
   }
 
   return glyphData.bitmapBuffer;
 }
 
 /// Draws the specified strikethrough color to the buffer
-void DrawStrikethrough(const unsigned int                  bufferWidth,
-                       const unsigned int                  bufferHeight,
+void DrawStrikethrough(const uint32_t&                     bufferWidth,
+                       const uint32_t&                     bufferHeight,
                        GlyphData&                          glyphData,
-                       const float                         baseline,
-                       const float                         strikethroughStartingYPosition,
-                       const float                         maxStrikethroughHeight,
-                       const float                         lineExtentLeft,
-                       const float                         lineExtentRight,
+                       const float&                        baseline,
+                       const float&                        strikethroughStartingYPosition,
+                       const float&                        maxStrikethroughHeight,
+                       const float&                        lineExtentLeft,
+                       const float&                        lineExtentRight,
                        const StrikethroughStyleProperties& commonStrikethroughProperties,
                        const StrikethroughStyleProperties& currentStrikethroughProperties,
                        const LineRun&                      line)
 {
   const Vector4& strikethroughColor = currentStrikethroughProperties.colorDefined ? currentStrikethroughProperties.color : commonStrikethroughProperties.color;
 
+  const uint32_t yRangeMin = static_cast<uint32_t>(strikethroughStartingYPosition);
+  const uint32_t yRangeMax = std::min(bufferHeight, static_cast<uint32_t>(strikethroughStartingYPosition + maxStrikethroughHeight));
+  const uint32_t xRangeMin = static_cast<uint32_t>(glyphData.horizontalOffset + lineExtentLeft);
+  const uint32_t xRangeMax = std::min(bufferWidth, static_cast<uint32_t>(glyphData.horizontalOffset + lineExtentRight + 1)); // Due to include last point, we add 1 here
+
+  // If current glyph don't need to be rendered, just ignore.
+  if(yRangeMax <= yRangeMin || xRangeMax <= xRangeMin)
+  {
+    return;
+  }
+
+  // We can optimize by memset when strikethroughColor.a is near zero
+  uint8_t strikethroughColorAlpha = static_cast<uint8_t>(strikethroughColor.a * 255.f);
+
   uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(glyphData.bitmapBuffer.GetBuffer());
 
-  for(unsigned int y = strikethroughStartingYPosition; y < strikethroughStartingYPosition + maxStrikethroughHeight; y++)
+  // Skip yRangeMin line.
+  bitmapBuffer += yRangeMin * glyphData.width;
+
+  if(strikethroughColorAlpha == 0)
   {
-    if(y > bufferHeight - 1)
+    for(uint32_t y = yRangeMin; y < yRangeMax; y++)
     {
-      // Do not write out of bounds.
-      break;
+      // We can use memset.
+      memset(bitmapBuffer + xRangeMin, 0, (xRangeMax - xRangeMin) * sizeof(uint32_t));
+      bitmapBuffer += glyphData.width;
     }
+  }
+  else
+  {
+    uint32_t packedStrikethroughColor       = 0u;
+    uint8_t* packedStrikethroughColorBuffer = reinterpret_cast<uint8_t*>(&packedStrikethroughColor);
+
+    // Write the color to the pixel buffer
+    *(packedStrikethroughColorBuffer + 3u) = strikethroughColorAlpha;
+    *(packedStrikethroughColorBuffer + 2u) = static_cast<uint8_t>(strikethroughColor.b * strikethroughColorAlpha);
+    *(packedStrikethroughColorBuffer + 1u) = static_cast<uint8_t>(strikethroughColor.g * strikethroughColorAlpha);
+    *(packedStrikethroughColorBuffer)      = static_cast<uint8_t>(strikethroughColor.r * strikethroughColorAlpha);
 
-    for(unsigned int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++)
+    for(uint32_t y = yRangeMin; y < yRangeMax; y++)
     {
-      if(x > bufferWidth - 1)
+      for(uint32_t x = xRangeMin; x < xRangeMax; x++)
       {
-        // Do not write out of bounds.
-        break;
+        // Note : this is same logic as bitmap[y][x] = strikethroughColor;
+        *(bitmapBuffer + x) = packedStrikethroughColor;
       }
-
-      WriteColorToPixelBuffer(glyphData, bitmapBuffer, strikethroughColor, x, y);
+      bitmapBuffer += glyphData.width;
     }
   }
 }
 
-} // namespace
-
-TypesetterPtr Typesetter::New(const ModelInterface* const model)
-{
-  return TypesetterPtr(new Typesetter(model));
-}
-
-ViewModel* Typesetter::GetViewModel()
-{
-  return mModel;
-}
-
-Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Pixel::Format pixelFormat)
+/**
+ * @brief Create an initialized image buffer filled with transparent color.
+ *
+ * Creates the pixel data used to generate the final image with the given size.
+ *
+ * @param[in] bufferWidth The width of the image buffer.
+ * @param[in] bufferHeight The height of the image buffer.
+ * @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
+ *
+ * @return An image buffer.
+ */
+inline Devel::PixelBuffer CreateTransparentImageBuffer(const uint32_t& bufferWidth, const uint32_t& bufferHeight, const Pixel::Format& pixelFormat)
 {
   Devel::PixelBuffer imageBuffer = Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat);
 
   if(Pixel::RGBA8888 == pixelFormat)
   {
-    const unsigned int bufferSizeInt  = bufferWidth * bufferHeight;
-    const unsigned int bufferSizeChar = 4u * bufferSizeInt;
-    memset(imageBuffer.GetBuffer(), 0u, bufferSizeChar);
+    const uint32_t bufferSizeInt  = bufferWidth * bufferHeight;
+    const uint32_t bufferSizeChar = sizeof(uint32_t) * bufferSizeInt;
+    memset(imageBuffer.GetBuffer(), 0, bufferSizeChar);
   }
   else
   {
@@ -589,6 +680,125 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
   return imageBuffer;
 }
 
+/**
+ * @brief Combine the two RGBA image buffers together.
+ *
+ * The top layer buffer will blend over the bottom layer buffer:
+ * - If the pixel is not fully opaque from either buffer, it will be blended with
+ *   the pixel from the other buffer and copied to the combined buffer.
+ * - If the pixels from both buffers are fully opaque, the pixels from the top layer
+ *   buffer will be copied to the combined buffer.
+ *
+ * Due to the performance issue, We need to re-use input'ed pixelBuffer memory.
+ * We can determine which pixelBuffer's memory is destination
+ *
+ * @param[in, out] topPixelBuffer The top layer buffer.
+ * @param[in, out] bottomPixelBuffer The bottom layer buffer.
+ * @param[in] bufferWidth The width of the image buffer.
+ * @param[in] bufferHeight The height of the image buffer.
+ * @param[in] storeResultIntoTop True if we store the combined image buffer result into topPixelBuffer.
+ * False if we store the combined image buffer result into bottomPixelBuffer.
+ *
+ */
+void CombineImageBuffer(Devel::PixelBuffer& topPixelBuffer, Devel::PixelBuffer& bottomPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool storeResultIntoTop)
+{
+  // Assume that we always combine two RGBA images
+  // Jump with 4bytes for optimize runtime.
+  uint32_t* topBuffer    = reinterpret_cast<uint32_t*>(topPixelBuffer.GetBuffer());
+  uint32_t* bottomBuffer = reinterpret_cast<uint32_t*>(bottomPixelBuffer.GetBuffer());
+
+  if(topBuffer == NULL && bottomBuffer == NULL)
+  {
+    // Nothing to do if both buffers are empty.
+    return;
+  }
+
+  if(topBuffer == NULL)
+  {
+    // Nothing to do if topBuffer is empty.
+    // If we need to store the result into top, change topPixelBuffer as bottomPixelBuffer.
+    if(storeResultIntoTop)
+    {
+      topPixelBuffer = bottomPixelBuffer;
+    }
+    return;
+  }
+
+  if(bottomBuffer == NULL)
+  {
+    // Nothing to do if bottomBuffer is empty.
+    // If we need to store the result into bottom, change bottomPixelBuffer as topPixelBuffer.
+    if(!storeResultIntoTop)
+    {
+      bottomPixelBuffer = topPixelBuffer;
+    }
+    return;
+  }
+
+  const uint32_t bufferSizeInt = bufferWidth * bufferHeight;
+
+  uint32_t* combinedBuffer        = storeResultIntoTop ? topBuffer : bottomBuffer;
+  uint8_t*  topAlphaBufferPointer = reinterpret_cast<uint8_t*>(topBuffer) + 3;
+
+  for(uint32_t pixelIndex = 0; pixelIndex < bufferSizeInt; ++pixelIndex)
+  {
+    // If the alpha of the pixel in either buffer is not fully opaque, blend the two pixels.
+    // Otherwise, copy pixel from topBuffer to combinedBuffer.
+    // Note : Be careful when we read & write into combinedBuffer. It can be write into same pointer.
+
+    uint8_t topAlpha = *topAlphaBufferPointer;
+
+    if(topAlpha == 0)
+    {
+      // Copy the pixel from bottomBuffer to combinedBuffer
+      if(storeResultIntoTop)
+      {
+        *(combinedBuffer) = *(bottomBuffer);
+      }
+    }
+    else if(topAlpha == 255)
+    {
+      // Copy the pixel from topBuffer to combinedBuffer
+      if(!storeResultIntoTop)
+      {
+        *(combinedBuffer) = *(topBuffer);
+      }
+    }
+    else
+    {
+      // At least one pixel is not fully opaque
+      // "Over" blend the the pixel from topBuffer with the pixel in bottomBuffer
+      uint32_t blendedBottomBufferColor       = *(bottomBuffer);
+      uint8_t* blendedBottomBufferColorBuffer = reinterpret_cast<uint8_t*>(&blendedBottomBufferColor);
+
+      blendedBottomBufferColorBuffer[0] = MultiplyAndNormalizeColor(blendedBottomBufferColorBuffer[0], 255 - topAlpha);
+      blendedBottomBufferColorBuffer[1] = MultiplyAndNormalizeColor(blendedBottomBufferColorBuffer[1], 255 - topAlpha);
+      blendedBottomBufferColorBuffer[2] = MultiplyAndNormalizeColor(blendedBottomBufferColorBuffer[2], 255 - topAlpha);
+      blendedBottomBufferColorBuffer[3] = MultiplyAndNormalizeColor(blendedBottomBufferColorBuffer[3], 255 - topAlpha);
+
+      *(combinedBuffer) = *(topBuffer) + blendedBottomBufferColor;
+    }
+
+    // Increase each buffer's pointer.
+    ++combinedBuffer;
+    ++topBuffer;
+    ++bottomBuffer;
+    topAlphaBufferPointer += sizeof(uint32_t) / sizeof(uint8_t);
+  }
+}
+
+} // namespace
+
+TypesetterPtr Typesetter::New(const ModelInterface* const model)
+{
+  return TypesetterPtr(new Typesetter(model));
+}
+
+ViewModel* Typesetter::GetViewModel()
+{
+  return mModel;
+}
+
 PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirection::Type textDirection, RenderBehaviour behaviour, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat)
 {
   // @todo. This initial implementation for a TextLabel has only one visible page.
@@ -599,10 +809,10 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
   // Retrieves the layout size.
   const Size& layoutSize = mModel->GetLayoutSize();
 
-  const int outlineWidth = static_cast<int>(mModel->GetOutlineWidth());
+  const int32_t outlineWidth = static_cast<int32_t>(mModel->GetOutlineWidth());
 
   // Set the offset for the horizontal alignment according to the text direction and outline width.
-  int penX = 0;
+  int32_t penX = 0;
 
   switch(mModel->GetHorizontalAlignment())
   {
@@ -624,7 +834,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
   }
 
   // Set the offset for the vertical alignment.
-  int penY = 0u;
+  int32_t penY = 0u;
 
   switch(mModel->GetVerticalAlignment())
   {
@@ -635,13 +845,13 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
     }
     case VerticalAlignment::CENTER:
     {
-      penY = static_cast<int>(0.5f * (size.height - layoutSize.height));
+      penY = static_cast<int32_t>(0.5f * (size.height - layoutSize.height));
       penY = penY < 0.f ? 0.f : penY;
       break;
     }
     case VerticalAlignment::BOTTOM:
     {
-      penY = static_cast<int>(size.height - layoutSize.height);
+      penY = static_cast<int32_t>(size.height - layoutSize.height);
       break;
     }
   }
@@ -657,14 +867,14 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
     {
       const auto& line = *mModel->GetLines();
       penY -= line.descender;
-      penY += static_cast<int>(line.lineSpacing * 0.5f + line.descender);
+      penY += static_cast<int32_t>(line.lineSpacing * 0.5f + line.descender);
       break;
     }
     case DevelText::VerticalLineAlignment::BOTTOM:
     {
       const auto& line       = *mModel->GetLines();
       const auto  lineHeight = line.ascender + (-line.descender) + line.lineSpacing;
-      penY += static_cast<int>(lineHeight - (line.ascender - line.descender));
+      penY += static_cast<int32_t>(lineHeight - (line.ascender - line.descender));
       break;
     }
   }
@@ -674,11 +884,11 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
   // do all of these in CPU only, so that once the final texture is generated,
   // no calculation is needed in GPU during each frame.
 
-  const unsigned int bufferWidth  = static_cast<unsigned int>(size.width);
-  const unsigned int bufferHeight = static_cast<unsigned int>(size.height);
+  const uint32_t bufferWidth  = static_cast<uint32_t>(size.width);
+  const uint32_t bufferHeight = static_cast<uint32_t>(size.height);
 
-  const unsigned int bufferSizeInt  = bufferWidth * bufferHeight;
-  const unsigned int bufferSizeChar = 4u * bufferSizeInt;
+  const uint32_t bufferSizeInt  = bufferWidth * bufferHeight;
+  const uint32_t bufferSizeChar = sizeof(uint32_t) * bufferSizeInt;
 
   //Elided text in ellipsis at START could start on index greater than 0
   auto startIndexOfGlyphs = mModel->GetStartIndexOfElidedGlyphs();
@@ -713,7 +923,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
       Devel::PixelBuffer outlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_OUTLINE, ignoreHorizontalAlignment, pixelFormat, penX, penY, startIndexOfGlyphs, endIndexOfGlyphs);
 
       // Combine the two buffers
-      imageBuffer = CombineImageBuffer(imageBuffer, outlineImageBuffer, bufferWidth, bufferHeight);
+      CombineImageBuffer(imageBuffer, outlineImageBuffer, bufferWidth, bufferHeight, true);
     }
 
     // @todo. Support shadow and underline for partial text later on.
@@ -734,7 +944,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
       }
 
       // Combine the two buffers
-      imageBuffer = CombineImageBuffer(imageBuffer, shadowImageBuffer, bufferWidth, bufferHeight);
+      CombineImageBuffer(imageBuffer, shadowImageBuffer, bufferWidth, bufferHeight, true);
     }
 
     // Generate the underline if enabled
@@ -745,7 +955,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
       Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, penX, penY, startIndexOfGlyphs, endIndexOfGlyphs);
 
       // Combine the two buffers
-      imageBuffer = CombineImageBuffer(imageBuffer, underlineImageBuffer, bufferWidth, bufferHeight);
+      CombineImageBuffer(imageBuffer, underlineImageBuffer, bufferWidth, bufferHeight, true);
     }
 
     // Generate the background if enabled
@@ -761,7 +971,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
       }
       else
       {
-        backgroundImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, pixelFormat);
+        backgroundImageBuffer = CreateTransparentImageBuffer(bufferWidth, bufferHeight, pixelFormat);
       }
 
       if(backgroundMarkupSet)
@@ -770,7 +980,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
       }
 
       // Combine the two buffers
-      imageBuffer = CombineImageBuffer(imageBuffer, backgroundImageBuffer, bufferWidth, bufferHeight);
+      CombineImageBuffer(imageBuffer, backgroundImageBuffer, bufferWidth, bufferHeight, true);
     }
 
     // Generate the strikethrough if enabled
@@ -781,7 +991,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
       Devel::PixelBuffer strikethroughImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_STRIKETHROUGH, ignoreHorizontalAlignment, pixelFormat, penX, penY, 0u, endIndexOfGlyphs);
 
       // Combine the two buffers
-      imageBuffer = CombineImageBuffer(imageBuffer, strikethroughImageBuffer, bufferWidth, bufferHeight);
+      CombineImageBuffer(imageBuffer, strikethroughImageBuffer, bufferWidth, bufferHeight, true);
     }
 
     // Markup-Processor
@@ -795,7 +1005,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect
   return pixelData;
 }
 
-Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Typesetter::Style style, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset, GlyphIndex fromGlyphIndex, GlyphIndex toGlyphIndex)
+Devel::PixelBuffer Typesetter::CreateImageBuffer(const uint32_t& bufferWidth, const uint32_t& bufferHeight, Typesetter::Style style, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset, GlyphIndex fromGlyphIndex, GlyphIndex toGlyphIndex)
 {
   // Retrieve lines, glyphs, positions and colors from the view model.
   const Length            modelNumberOfLines = mModel->GetNumberOfLines();
@@ -824,7 +1034,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
   glyphData.verticalOffset   = verticalOffset;
   glyphData.width            = bufferWidth;
   glyphData.height           = bufferHeight;
-  glyphData.bitmapBuffer     = CreateImageBuffer(bufferWidth, bufferHeight, pixelFormat);
+  glyphData.bitmapBuffer     = CreateTransparentImageBuffer(bufferWidth, bufferHeight, pixelFormat);
   glyphData.horizontalOffset = 0;
 
   // Get a handle of the font client. Used to retrieve the bitmaps of the glyphs.
@@ -842,11 +1052,11 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
     const LineRun& line = *(modelLinesBuffer + lineIndex);
 
     // Sets the horizontal offset of the line.
-    glyphData.horizontalOffset = ignoreHorizontalAlignment ? 0 : static_cast<int>(line.alignmentOffset);
+    glyphData.horizontalOffset = ignoreHorizontalAlignment ? 0 : static_cast<int32_t>(line.alignmentOffset);
     glyphData.horizontalOffset += horizontalOffset;
 
     // Increases the vertical offset with the line's ascender.
-    glyphData.verticalOffset += static_cast<int>(line.ascender);
+    glyphData.verticalOffset += static_cast<int32_t>(line.ascender);
 
     // Retrieves the glyph's outline width
     float outlineWidth = static_cast<float>(mModel->GetOutlineWidth());
@@ -930,18 +1140,12 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
     bool  addHyphen       = false;
 
     // Traverses the glyphs of the line.
-    const GlyphIndex startGlyphIndex = std::max(line.glyphRun.glyphIndex, startIndexOfGlyphs);
+    const GlyphIndex startGlyphIndex = std::max(std::max(line.glyphRun.glyphIndex, startIndexOfGlyphs), fromGlyphIndex);
     GlyphIndex       endGlyphIndex   = (line.isSplitToTwoHalves ? line.glyphRunSecondHalf.glyphIndex + line.glyphRunSecondHalf.numberOfGlyphs : line.glyphRun.glyphIndex + line.glyphRun.numberOfGlyphs) - 1u;
-    endGlyphIndex                    = std::min(endGlyphIndex, endIndexOfGlyphs);
+    endGlyphIndex                    = std::min(std::min(endGlyphIndex, endIndexOfGlyphs), toGlyphIndex);
 
     for(GlyphIndex glyphIndex = startGlyphIndex; glyphIndex <= endGlyphIndex; ++glyphIndex)
     {
-      if(glyphIndex < fromGlyphIndex || glyphIndex > toGlyphIndex)
-      {
-        // Ignore any glyph that out of the specified range
-        continue;
-      }
-
       //To handle START case of ellipsis, the first glyph has been shifted
       //glyphIndex represent indices in whole glyphs but elidedGlyphIndex represents indices in elided Glyphs
       GlyphIndex elidedGlyphIndex = glyphIndex - startIndexOfGlyphs;
@@ -1085,7 +1289,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
                                 glyphInfo->isItalicRequired,
                                 glyphInfo->isBoldRequired,
                                 glyphData.glyphBitmap,
-                                static_cast<int>(outlineWidth));
+                                static_cast<int32_t>(outlineWidth));
       }
 
       // Sets the glyph's bitmap into the bitmap of the whole text.
@@ -1153,75 +1357,13 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer(const unsigned int bufferWidth,
     }
 
     // Increases the vertical offset with the line's descender & line spacing.
-    glyphData.verticalOffset += static_cast<int>(-line.descender+line.lineSpacing);
+    glyphData.verticalOffset += static_cast<int32_t>(-line.descender + line.lineSpacing);
   }
 
   return glyphData.bitmapBuffer;
 }
 
-Devel::PixelBuffer Typesetter::CombineImageBuffer(Devel::PixelBuffer topPixelBuffer, Devel::PixelBuffer bottomPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight)
-{
-  unsigned char* topBuffer    = topPixelBuffer.GetBuffer();
-  unsigned char* bottomBuffer = bottomPixelBuffer.GetBuffer();
-
-  Devel::PixelBuffer combinedPixelBuffer;
-
-  if(topBuffer == NULL && bottomBuffer == NULL)
-  {
-    // Nothing to do if both buffers are empty.
-    return combinedPixelBuffer;
-  }
-
-  if(topBuffer == NULL)
-  {
-    // Nothing to do if topBuffer is empty.
-    return bottomPixelBuffer;
-  }
-
-  if(bottomBuffer == NULL)
-  {
-    // Nothing to do if bottomBuffer is empty.
-    return topPixelBuffer;
-  }
-
-  // Always combine two RGBA images
-  const unsigned int bufferSizeInt  = bufferWidth * bufferHeight;
-  const unsigned int bufferSizeChar = 4u * bufferSizeInt;
-
-  combinedPixelBuffer     = Devel::PixelBuffer::New(bufferWidth, bufferHeight, Pixel::RGBA8888);
-  uint8_t* combinedBuffer = reinterpret_cast<uint8_t*>(combinedPixelBuffer.GetBuffer());
-  memset(combinedBuffer, 0u, bufferSizeChar);
-
-  for(unsigned int pixelIndex = 0; pixelIndex < bufferSizeInt; pixelIndex++)
-  {
-    // If the alpha of the pixel in either buffer is not fully opaque, blend the two pixels.
-    // Otherwise, copy pixel from topBuffer to combinedBuffer.
-
-    unsigned int alphaBuffer1 = topBuffer[pixelIndex * 4 + 3];
-
-    if(alphaBuffer1 != 255)
-    {
-      // At least one pixel is not fully opaque
-      // "Over" blend the the pixel from topBuffer with the pixel in bottomBuffer
-      combinedBuffer[pixelIndex * 4]     = topBuffer[pixelIndex * 4] + (bottomBuffer[pixelIndex * 4] * (255 - topBuffer[pixelIndex * 4 + 3]) / 255);
-      combinedBuffer[pixelIndex * 4 + 1] = topBuffer[pixelIndex * 4 + 1] + (bottomBuffer[pixelIndex * 4 + 1] * (255 - topBuffer[pixelIndex * 4 + 3]) / 255);
-      combinedBuffer[pixelIndex * 4 + 2] = topBuffer[pixelIndex * 4 + 2] + (bottomBuffer[pixelIndex * 4 + 2] * (255 - topBuffer[pixelIndex * 4 + 3]) / 255);
-      combinedBuffer[pixelIndex * 4 + 3] = topBuffer[pixelIndex * 4 + 3] + (bottomBuffer[pixelIndex * 4 + 3] * (255 - topBuffer[pixelIndex * 4 + 3]) / 255);
-    }
-    else
-    {
-      // Copy the pixel from topBuffer to combinedBuffer
-      combinedBuffer[pixelIndex * 4]     = topBuffer[pixelIndex * 4];
-      combinedBuffer[pixelIndex * 4 + 1] = topBuffer[pixelIndex * 4 + 1];
-      combinedBuffer[pixelIndex * 4 + 2] = topBuffer[pixelIndex * 4 + 2];
-      combinedBuffer[pixelIndex * 4 + 3] = topBuffer[pixelIndex * 4 + 3];
-    }
-  }
-
-  return combinedPixelBuffer;
-}
-
-Devel::PixelBuffer Typesetter::ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset)
+Devel::PixelBuffer Typesetter::ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset)
 {
   // Underline-tags (this is for Markup case)
   // Get the underline runs.
@@ -1244,7 +1386,8 @@ Devel::PixelBuffer Typesetter::ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffe
     // Create the image buffer for underline
     Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset, startGlyphIndex, endGlyphIndex);
     // Combine the two buffers
-    topPixelBuffer = CombineImageBuffer(underlineImageBuffer, topPixelBuffer, bufferWidth, bufferHeight);
+    // Result pixel buffer will be stored into topPixelBuffer.
+    CombineImageBuffer(underlineImageBuffer, topPixelBuffer, bufferWidth, bufferHeight, false);
 
     itGlyphRun++;
   }
@@ -1252,7 +1395,7 @@ Devel::PixelBuffer Typesetter::ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffe
   return topPixelBuffer;
 }
 
-Devel::PixelBuffer Typesetter::ApplyStrikethroughMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset)
+Devel::PixelBuffer Typesetter::ApplyStrikethroughMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset)
 {
   // strikethrough-tags (this is for Markup case)
   // Get the strikethrough runs.
@@ -1275,7 +1418,8 @@ Devel::PixelBuffer Typesetter::ApplyStrikethroughMarkupImageBuffer(Devel::PixelB
     // Create the image buffer for strikethrough
     Devel::PixelBuffer strikethroughImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_STRIKETHROUGH, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset, startGlyphIndex, endGlyphIndex);
     // Combine the two buffers
-    topPixelBuffer = CombineImageBuffer(strikethroughImageBuffer, topPixelBuffer, bufferWidth, bufferHeight);
+    // Result pixel buffer will be stored into topPixelBuffer.
+    CombineImageBuffer(strikethroughImageBuffer, topPixelBuffer, bufferWidth, bufferHeight, false);
 
     itGlyphRun++;
   }
@@ -1283,7 +1427,7 @@ Devel::PixelBuffer Typesetter::ApplyStrikethroughMarkupImageBuffer(Devel::PixelB
   return topPixelBuffer;
 }
 
-Devel::PixelBuffer Typesetter::ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset)
+Devel::PixelBuffer Typesetter::ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset)
 {
   // Apply the markup-Processor if enabled
   const bool markupProcessorEnabled = mModel->IsMarkupProcessorEnabled();
index bf46b90..3f9dd66 100644 (file)
@@ -144,39 +144,7 @@ private:
    *
    * @return An image buffer with the text.
    */
-  Devel::PixelBuffer CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Typesetter::Style style, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset, TextAbstraction::GlyphIndex fromGlyphIndex, TextAbstraction::GlyphIndex toGlyphIndex);
-
-  /**
-   * @brief Create an initialized image buffer.
-   *
-   * Creates the pixel data used to generate the final image with the given size.
-   *
-   * @param[in] bufferWidth The width of the image buffer.
-   * @param[in] bufferHeight The height of the image buffer.
-   * @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
-   *
-   * @return An image buffer.
-   */
-  Devel::PixelBuffer CreateImageBuffer(const unsigned int bufferWidth, const unsigned int bufferHeight, Pixel::Format pixelFormat);
-
-  /**
-   * @brief Combine the two RGBA image buffers together.
-   *
-   * The top layer buffer will blend over the bottom layer buffer:
-   * - If the pixel is not fully opaque from either buffer, it will be blended with
-   *   the pixel from the other buffer and copied to the combined buffer.
-   * - If the pixels from both buffers are fully opaque, the pixels from the top layer
-   *   buffer will be copied to the combined buffer.
-   *
-   * @param[in] topPixelBuffer The top layer buffer.
-   * @param[in] bottomPixelBuffer The bottom layer buffer.
-   * @param[in] bufferWidth The width of the image buffer.
-   * @param[in] bufferHeight The height of the image buffer.
-   *
-   * @return The combined image buffer with the text.
-   *
-   */
-  Devel::PixelBuffer CombineImageBuffer(Devel::PixelBuffer topPixelBuffer, Devel::PixelBuffer bottomPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeightbool);
+  Devel::PixelBuffer CreateImageBuffer(const uint32_t& bufferWidth, const uint32_t& bufferHeight, Typesetter::Style style, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset, TextAbstraction::GlyphIndex fromGlyphIndex, TextAbstraction::GlyphIndex toGlyphIndex);
 
   /**
    * @brief Apply behaviour of tags if the markup-processor is enabled.
@@ -191,7 +159,7 @@ private:
    *
    * @return The image buffer with the markup.
    */
-  Devel::PixelBuffer ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+  Devel::PixelBuffer ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset);
 
   /**
    * @brief Apply markup underline tags.
@@ -212,7 +180,7 @@ private:
    *
    * @return The image buffer with the markup.
    */
-  Devel::PixelBuffer ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+  Devel::PixelBuffer ApplyUnderlineMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset);
 
   /**
    * @brief Apply markup strikethrough tags.
@@ -233,7 +201,7 @@ private:
    *
    * @return The image buffer with the markup.
    */
-  Devel::PixelBuffer ApplyStrikethroughMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+  Devel::PixelBuffer ApplyStrikethroughMarkupImageBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t& bufferWidth, const uint32_t& bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, const int32_t& horizontalOffset, const int32_t& verticalOffset);
 
 protected:
   /**
index a561161..85d2e87 100644 (file)
@@ -481,19 +481,19 @@ TextureCacheManager::TextureHash TextureCacheManager::GenerateHash(
   const Dali::SamplingMode::Type&       samplingMode,
   const TextureCacheManager::UseAtlas&  useAtlas,
   const TextureCacheManager::TextureId& maskTextureId,
-  const bool&                           cropToMask)
+  const bool&                           cropToMask,
+  const std::uint32_t&                  frameIndex)
 {
-  std::vector<std::uint8_t> hashTarget(url.GetUrl().begin(), url.GetUrl().end());
-  const size_t              urlLength = hashTarget.size();
-  const uint16_t            width     = size.GetWidth();
-  const uint16_t            height    = size.GetWidth();
+  std::vector<std::uint8_t> hashTarget;
+  const uint16_t            width  = size.GetWidth();
+  const uint16_t            height = size.GetWidth();
 
   // If either the width or height has been specified, include the resizing options in the hash
   if(width != 0 || height != 0)
   {
     // We are appending 5 bytes to the URL to form the hash input.
-    hashTarget.resize(urlLength + 5u);
-    std::uint8_t* hashTargetPtr = &(hashTarget[urlLength]);
+    hashTarget.resize(5u);
+    std::uint8_t* hashTargetPtr = &(hashTarget[0u]);
 
     // Pack the width and height (4 bytes total).
     *hashTargetPtr++ = size.GetWidth() & 0xff;
@@ -508,19 +508,19 @@ TextureCacheManager::TextureHash TextureCacheManager::GenerateHash(
   else
   {
     // We are not including sizing information, but we still need an extra byte for atlasing.
-    hashTarget.resize(urlLength + 1u);
+    hashTarget.resize(1u);
 
     // Add the atlasing to the hash input.
     switch(useAtlas)
     {
       case UseAtlas::NO_ATLAS:
       {
-        hashTarget[urlLength] = 'f';
+        hashTarget[0u] = 'f';
         break;
       }
       case UseAtlas::USE_ATLAS:
       {
-        hashTarget[urlLength] = 't';
+        hashTarget[0u] = 't';
         break;
       }
     }
@@ -543,7 +543,23 @@ TextureCacheManager::TextureHash TextureCacheManager::GenerateHash(
     *hashTargetPtr++ = (cropToMask ? 'C' : 'M');
   }
 
-  return Dali::CalculateHash(hashTarget);
+  // Append the frameIndex. We don't do additional job when frameIndex = 0u due to the non-animated image case.
+  if(frameIndex > 0u)
+  {
+    auto textureIdIndex = hashTarget.size();
+    hashTarget.resize(hashTarget.size() + sizeof(std::uint32_t));
+    std::uint8_t* hashTargetPtr = reinterpret_cast<std::uint8_t*>(&(hashTarget[textureIdIndex]));
+
+    // Append the frame index to the end of the URL byte by byte:
+    std::uint32_t saltedFrameIndex = frameIndex;
+    for(size_t byteIter = 0; byteIter < sizeof(std::uint8_t); ++byteIter)
+    {
+      *hashTargetPtr++ = saltedFrameIndex & 0xff;
+      saltedFrameIndex >>= 8u;
+    }
+  }
+
+  return url.GetUrlHash() ^ Dali::CalculateHash(hashTarget);
 }
 
 TextureCacheManager::TextureCacheIndex TextureCacheManager::FindCachedTexture(
@@ -556,7 +572,8 @@ TextureCacheManager::TextureCacheIndex TextureCacheManager::FindCachedTexture(
   const TextureCacheManager::TextureId&      maskTextureId,
   const bool&                                cropToMask,
   const TextureCacheManager::MultiplyOnLoad& preMultiplyOnLoad,
-  const bool&                                isAnimatedImage)
+  const bool&                                isAnimatedImage,
+  const std::uint32_t&                       frameIndex)
 {
   // Iterate through our hashes to find a match.
   const auto& hashIterator = mTextureHashContainer.find(hash);
@@ -576,6 +593,7 @@ TextureCacheManager::TextureCacheIndex TextureCacheManager::FindCachedTexture(
            (cropToMask == textureInfo.cropToMask) &&
            (size == textureInfo.desiredSize) &&
            (isAnimatedImage == textureInfo.isAnimatedImageFormat) &&
+           (frameIndex == textureInfo.frameIndex) &&
            ((size.GetWidth() == 0 && size.GetHeight() == 0) ||
             (fittingMode == textureInfo.fittingMode &&
              samplingMode == textureInfo.samplingMode)))
index dbd3e62..ac70426 100644 (file)
@@ -208,6 +208,7 @@ public:
    * @param[in] useAtlas         True if atlased
    * @param[in] maskTextureId    The masking texture id (or INVALID_TEXTURE_ID)
    * @param[in] cropToMask       True if crop to mask
+   * @param[in] frameIndex       The frame index to use
    * @return                     A hash of the provided data for caching.
    */
   TextureCacheManager::TextureHash GenerateHash(
@@ -217,7 +218,8 @@ public:
     const Dali::SamplingMode::Type&       samplingMode,
     const TextureCacheManager::UseAtlas&  useAtlas,
     const TextureCacheManager::TextureId& maskTextureId,
-    const bool&                           cropToMask);
+    const bool&                           cropToMask,
+    const std::uint32_t&                  frameIndex);
 
   /**
    * @brief Looks up a cached texture by its hash.
@@ -229,9 +231,10 @@ public:
    * @param[in] samplingMode      The SamplingMode to use
    * @param[in] useAtlas          True if atlased
    * @param[in] maskTextureId     Optional texture ID to use to mask this image
+   * @param[in] cropToMask        True if crop to mask
    * @param[in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha.
    * @param[in] isAnimatedImage   True if the texture is from animated image.
-   * @param[in] cropToMask        True if crop to mask
+   * @param[in] frameIndex        The frame index to use
    * @return                      A TextureCacheIndex of a cached Texture if found. Or INVALID_CACHE_INDEX if not found.
    */
   TextureCacheManager::TextureCacheIndex FindCachedTexture(
@@ -244,7 +247,8 @@ public:
     const TextureCacheManager::TextureId&      maskTextureId,
     const bool&                                cropToMask,
     const TextureCacheManager::MultiplyOnLoad& preMultiplyOnLoad,
-    const bool&                                isAnimatedImage);
+    const bool&                                isAnimatedImage,
+    const std::uint32_t&                       frameIndex);
 
   /**
    * @brief Append a Texture to the TextureCacheManager.
index 880a075..81a73db 100644 (file)
@@ -139,6 +139,7 @@ TextureManager::~TextureManager()
 }
 
 TextureSet TextureManager::LoadAnimatedImageTexture(
+  const VisualUrl&                url,
   Dali::AnimatedImageLoading      animatedImageLoading,
   const uint32_t&                 frameIndex,
   TextureManager::TextureId&      textureId,
@@ -147,7 +148,6 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
   const Dali::WrapMode::Type&     wrapModeU,
   const Dali::WrapMode::Type&     wrapModeV,
   const bool&                     synchronousLoading,
-  const bool&                     useCache,
   TextureUploadObserver*          textureObserver)
 {
   TextureSet textureSet;
@@ -201,7 +201,7 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
     }
 
     auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
-    textureId        = RequestLoadInternal(animatedImageLoading.GetUrl(), alphaMaskId, contentScaleFactor, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, UseAtlas::NO_ATLAS, cropToMask, StorageType::UPLOAD_TO_TEXTURE, textureObserver, true, TextureManager::ReloadPolicy::CACHED, preMultiply, animatedImageLoading, frameIndex, false, useCache);
+    textureId        = RequestLoadInternal(url, alphaMaskId, contentScaleFactor, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, UseAtlas::NO_ATLAS, cropToMask, StorageType::UPLOAD_TO_TEXTURE, textureObserver, true, TextureManager::ReloadPolicy::CACHED, preMultiply, animatedImageLoading, frameIndex, false);
 
     TextureManager::LoadState loadState = mTextureCacheManager.GetTextureStateInternal(textureId);
     if(loadState == TextureManager::LoadState::UPLOADED)
@@ -256,7 +256,7 @@ Devel::PixelBuffer TextureManager::LoadPixelBuffer(
   }
   else
   {
-    RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, desiredSize, fittingMode, samplingMode, UseAtlas::NO_ATLAS, false, StorageType::RETURN_PIXEL_BUFFER, textureObserver, orientationCorrection, TextureManager::ReloadPolicy::FORCED, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, false, false);
+    RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, desiredSize, fittingMode, samplingMode, UseAtlas::NO_ATLAS, false, StorageType::RETURN_PIXEL_BUFFER, textureObserver, orientationCorrection, TextureManager::ReloadPolicy::FORCED, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, false);
   }
 
   return pixelBuffer;
@@ -306,43 +306,48 @@ TextureSet TextureManager::LoadTexture(
   else
   {
     // For Atlas
-    if(synchronousLoading && atlasingStatus && imageAtlasManager->CheckAtlasAvailable(url, desiredSize))
+    if(synchronousLoading && atlasingStatus)
     {
-      Devel::PixelBuffer pixelBuffer = LoadImageSynchronously(url, desiredSize, fittingMode, samplingMode, orientationCorrection);
-
-      if(maskInfo && maskInfo->mAlphaMaskUrl.IsValid())
+      const bool synchronousAtlasAvaliable = (desiredSize != ImageDimensions() || url.IsLocalResource()) ? imageAtlasManager->CheckAtlasAvailable(url, desiredSize)
+                                                                                                         : false;
+      if(synchronousAtlasAvaliable)
       {
-        Devel::PixelBuffer maskPixelBuffer = LoadImageSynchronously(maskInfo->mAlphaMaskUrl.GetUrl(), ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true);
-        if(maskPixelBuffer)
+        Devel::PixelBuffer pixelBuffer = LoadImageSynchronously(url, desiredSize, fittingMode, samplingMode, orientationCorrection);
+
+        if(pixelBuffer && maskInfo && maskInfo->mAlphaMaskUrl.IsValid())
         {
-          pixelBuffer.ApplyMask(maskPixelBuffer, maskInfo->mContentScaleFactor, maskInfo->mCropToMask);
+          Devel::PixelBuffer maskPixelBuffer = LoadImageSynchronously(maskInfo->mAlphaMaskUrl, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true);
+          if(maskPixelBuffer)
+          {
+            pixelBuffer.ApplyMask(maskPixelBuffer, maskInfo->mContentScaleFactor, maskInfo->mCropToMask);
+          }
         }
-      }
-
-      PixelData data;
-      if(pixelBuffer)
-      {
-        PreMultiply(pixelBuffer, preMultiplyOnLoad);
-        data = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
 
-        if(data)
+        PixelData data;
+        if(pixelBuffer)
         {
-          textureSet = imageAtlasManager->Add(textureRect, data);
-          if(textureSet)
+          PreMultiply(pixelBuffer, preMultiplyOnLoad);
+          data = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
+
+          if(data)
+          {
+            textureSet = imageAtlasManager->Add(textureRect, data);
+            if(textureSet)
+            {
+              textureRectSize.SetWidth(data.GetWidth());
+              textureRectSize.SetHeight(data.GetHeight());
+            }
+          }
+          else
           {
-            textureRectSize.SetWidth(data.GetWidth());
-            textureRectSize.SetHeight(data.GetHeight());
+            DALI_LOG_ERROR("TextureManager::LoadTexture: Synchronous Texture loading with atlasing is failed.\n");
           }
         }
-        else
+        if(!textureSet)
         {
-          DALI_LOG_ERROR("TextureManager::LoadTexture: Synchronous Texture loading with atlasing is failed.\n");
+          atlasingStatus = false;
         }
       }
-      if(!textureSet)
-      {
-        atlasingStatus = false;
-      }
     }
 
     if(!textureSet)
@@ -354,7 +359,18 @@ TextureSet TextureManager::LoadTexture(
       Dali::ImageDimensions atlasDesiredSize = desiredSize;
       if(atlasingStatus)
       {
-        textureSet = imageAtlasManager->Add(textureRect, url.GetUrl(), atlasDesiredSize, fittingMode, true, atlasObserver);
+        if(url.IsBufferResource())
+        {
+          const EncodedImageBuffer& encodedImageBuffer = GetEncodedImageBuffer(url.GetUrl());
+          if(encodedImageBuffer)
+          {
+            textureSet = imageAtlasManager->Add(textureRect, encodedImageBuffer, desiredSize, fittingMode, true, atlasObserver);
+          }
+        }
+        else
+        {
+          textureSet = imageAtlasManager->Add(textureRect, url, atlasDesiredSize, fittingMode, true, atlasObserver);
+        }
       }
       if(!textureSet) // big image, no atlasing or atlasing failed
       {
@@ -442,7 +458,7 @@ TextureManager::TextureId TextureManager::RequestLoad(
   TextureManager::MultiplyOnLoad&     preMultiplyOnLoad,
   const bool&                         synchronousLoading)
 {
-  return RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, desiredSize, fittingMode, samplingMode, useAtlas, false, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, synchronousLoading, true);
+  return RequestLoadInternal(url, INVALID_TEXTURE_ID, 1.0f, desiredSize, fittingMode, samplingMode, useAtlas, false, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, synchronousLoading);
 }
 
 TextureManager::TextureId TextureManager::RequestLoad(
@@ -460,7 +476,7 @@ TextureManager::TextureId TextureManager::RequestLoad(
   TextureManager::MultiplyOnLoad&     preMultiplyOnLoad,
   const bool&                         synchronousLoading)
 {
-  return RequestLoadInternal(url, maskTextureId, contentScale, desiredSize, fittingMode, samplingMode, useAtlas, cropToMask, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, synchronousLoading, true);
+  return RequestLoadInternal(url, maskTextureId, contentScale, desiredSize, fittingMode, samplingMode, useAtlas, cropToMask, StorageType::UPLOAD_TO_TEXTURE, observer, orientationCorrection, reloadPolicy, preMultiplyOnLoad, Dali::AnimatedImageLoading(), 0u, synchronousLoading);
 }
 
 TextureManager::TextureId TextureManager::RequestMaskLoad(
@@ -469,7 +485,7 @@ TextureManager::TextureId TextureManager::RequestMaskLoad(
 {
   // Use the normal load procedure to get the alpha mask.
   auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
-  return RequestLoadInternal(maskUrl, INVALID_TEXTURE_ID, 1.0f, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, UseAtlas::NO_ATLAS, false, StorageType::KEEP_PIXEL_BUFFER, NULL, true, TextureManager::ReloadPolicy::CACHED, preMultiply, Dali::AnimatedImageLoading(), 0u, synchronousLoading, true);
+  return RequestLoadInternal(maskUrl, INVALID_TEXTURE_ID, 1.0f, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, UseAtlas::NO_ATLAS, false, StorageType::KEEP_PIXEL_BUFFER, NULL, true, TextureManager::ReloadPolicy::CACHED, preMultiply, Dali::AnimatedImageLoading(), 0u, synchronousLoading);
 }
 
 TextureManager::TextureId TextureManager::RequestLoadInternal(
@@ -488,17 +504,16 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
   TextureManager::MultiplyOnLoad&     preMultiplyOnLoad,
   Dali::AnimatedImageLoading          animatedImageLoading,
   const std::uint32_t&                frameIndex,
-  const bool&                         synchronousLoading,
-  const bool&                         useCache)
+  const bool&                         synchronousLoading)
 {
   TextureHash       textureHash = INITIAL_HASH_NUMBER;
   TextureCacheIndex cacheIndex  = INVALID_CACHE_INDEX;
-  if(storageType != StorageType::RETURN_PIXEL_BUFFER && useCache)
+  if(storageType != StorageType::RETURN_PIXEL_BUFFER)
   {
-    textureHash = mTextureCacheManager.GenerateHash(url, desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask);
+    textureHash = mTextureCacheManager.GenerateHash(url, desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask, frameIndex);
 
     // Look up the texture by hash. Note: The extra parameters are used in case of a hash collision.
-    cacheIndex = mTextureCacheManager.FindCachedTexture(textureHash, url, desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask, preMultiplyOnLoad, (animatedImageLoading) ? true : false);
+    cacheIndex = mTextureCacheManager.FindCachedTexture(textureHash, url, desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask, preMultiplyOnLoad, (animatedImageLoading) ? true : false, frameIndex);
   }
 
   TextureManager::TextureId textureId = INVALID_TEXTURE_ID;
@@ -516,7 +531,7 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
     // Update preMultiplyOnLoad value. It should be changed according to preMultiplied value of the cached info.
     preMultiplyOnLoad = mTextureCacheManager[cacheIndex].preMultiplied ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
-    DALI_LOG_INFO(gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) Using cached texture id@%d, textureId=%d premultiplied=%d\n", url.GetUrl().c_str(), observer, cacheIndex.GetIndex(), textureId, mTextureCacheManager[cacheIndex].preMultiplied ? 1 : 0);
+    DALI_LOG_INFO(gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) Using cached texture id@%d, textureId=%d, frameindex=%d, premultiplied=%d\n", url.GetUrl().c_str(), observer, cacheIndex.GetIndex(), textureId, frameIndex, mTextureCacheManager[cacheIndex].preMultiplied ? 1 : 0);
   }
 
   if(textureId == INVALID_TEXTURE_ID) // There was no caching, or caching not required
@@ -528,7 +543,7 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
     // Cache new texutre, and get cacheIndex.
     cacheIndex = mTextureCacheManager.AppendCache(TextureInfo(textureId, maskTextureId, url, desiredSize, contentScale, fittingMode, samplingMode, false, cropToMask, useAtlas, textureHash, orientationCorrection, preMultiply, animatedImageLoading, frameIndex));
 
-    DALI_LOG_INFO(gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) New texture, cacheIndex:%d, textureId=%d\n", url.GetUrl().c_str(), observer, cacheIndex.GetIndex(), textureId);
+    DALI_LOG_INFO(gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) New texture, cacheIndex:%d, textureId=%d, frameindex=%d\n", url.GetUrl().c_str(), observer, cacheIndex.GetIndex(), textureId, frameIndex);
   }
 
   // The below code path is common whether we are using the cache or not.
@@ -1066,9 +1081,12 @@ void TextureManager::NotifyObservers(TextureManager::TextureInfo& textureInfo, c
 
   mQueueLoadFlag = true;
 
+  // Reverse observer list that we can pop_back the observer.
+  std::reverse(info->observerList.Begin(), info->observerList.End());
+
   while(info->observerList.Count())
   {
-    TextureUploadObserver* observer = info->observerList[0];
+    TextureUploadObserver* observer = *(info->observerList.End() - 1u);
 
     // During LoadComplete() a Control ResourceReady() signal is emitted.
     // During that signal the app may add remove /add Textures (e.g. via
@@ -1084,7 +1102,7 @@ void TextureManager::NotifyObservers(TextureManager::TextureInfo& textureInfo, c
     // Disconnect and remove the observer first.
     observer->DestructionSignal().Disconnect(this, &TextureManager::ObserverDestroyed);
 
-    info->observerList.Erase(info->observerList.Begin());
+    info->observerList.Erase(info->observerList.End() - 1u);
 
     EmitLoadComplete(observer, *info, success);
 
index 36219cc..91f7778 100644 (file)
@@ -112,6 +112,7 @@ public:
    * The parameters are used to specify how the animated image is loaded.
    * The observer has the LoadComplete method called when the load is ready.
    *
+   * @param[in]  url                   The URL of the image to load
    * @param[in]  animatedImageLoading  The AnimatedImageLoading that contain the animated image information
    * @param[in]  frameIndex            The frame index to load.
    * @param[out] textureId             The textureId of the frame
@@ -120,13 +121,13 @@ public:
    * @param[in]  wrapModeU             Horizontal Wrap mode
    * @param[in]  wrapModeV             Vertical Wrap mode
    * @param[in]  synchronousLoading    true if the frame should be loaded synchronously
-   * @param[in]  useCache              true if this frame loading uses cache.
    * @param[in]  textureObserver       The client object should inherit from this and provide the "LoadCompleted" virtual.
    *                                   This is called when an image load completes (or fails).
    *
    * @return                           The texture set containing the frame of animated image, or empty if still loading.
    */
-  TextureSet LoadAnimatedImageTexture(Dali::AnimatedImageLoading      animatedImageLoading,
+  TextureSet LoadAnimatedImageTexture(const VisualUrl&                url,
+                                      Dali::AnimatedImageLoading      animatedImageLoading,
                                       const uint32_t&                 frameIndex,
                                       TextureManager::TextureId&      textureId,
                                       MaskingDataPointer&             maskInfo,
@@ -134,7 +135,6 @@ public:
                                       const Dali::WrapMode::Type&     wrapModeU,
                                       const Dali::WrapMode::Type&     wrapModeV,
                                       const bool&                     synchronousLoading,
-                                      const bool&                     useCache,
                                       TextureUploadObserver*          textureObserver);
 
   /**
@@ -456,7 +456,6 @@ private:
    * @param[in] frameIndex            The frame index of a frame to be loaded frame
    * @param[in] synchronousLoading    True if the frame should be loaded synchronously. If you skip this parameter,
    *                                  default is false.
-   * @param[in] useCache              True if the texture will be cached.
    * @return                          A TextureId to use as a handle to reference this Texture
    */
   TextureId RequestLoadInternal(
@@ -475,8 +474,7 @@ private:
     TextureManager::MultiplyOnLoad&     preMultiplyOnLoad,
     Dali::AnimatedImageLoading          animatedImageLoading,
     const std::uint32_t&                frameIndex,
-    const bool&                         synchronousLoading,
-    const bool&                         useCache);
+    const bool&                         synchronousLoading);
 
   /**
    * @brief Load a new image synchronously.
index b704d34..719329d 100644 (file)
@@ -163,7 +163,7 @@ AnimatedImageVisualPtr AnimatedImageVisual::New(VisualFactoryCache& factoryCache
 
 void AnimatedImageVisual::InitializeAnimatedImage(const VisualUrl& imageUrl)
 {
-  mImageUrl = imageUrl;
+  mImageUrl             = imageUrl;
   mAnimatedImageLoading = AnimatedImageLoading::New(imageUrl.GetUrl(), imageUrl.IsLocalResource());
 }
 
@@ -253,7 +253,7 @@ void AnimatedImageVisual::GetNaturalSize(Vector2& naturalSize)
       ImageDimensions dimensions = Dali::GetClosestImageSize(mMaskingData->mAlphaMaskUrl.GetUrl());
       if(dimensions != ImageDimensions(0, 0))
       {
-        mImageSize = dimensions;
+        mImageSize    = dimensions;
         naturalSize.x = dimensions.GetWidth();
         naturalSize.y = dimensions.GetHeight();
         return;
@@ -266,7 +266,7 @@ void AnimatedImageVisual::GetNaturalSize(Vector2& naturalSize)
     }
     else if(mImageUrls && mImageUrls->size() > 0)
     {
-      mImageSize = Dali::GetClosestImageSize((*mImageUrls)[0].mUrl);
+      mImageSize = Dali::GetClosestImageSize((*mImageUrls)[0].mUrl.GetUrl());
     }
   }
 
@@ -292,7 +292,7 @@ void AnimatedImageVisual::DoCreatePropertyMap(Property::Map& map) const
     Property::Array urls;
     for(unsigned int i = 0; i < mImageUrls->size(); ++i)
     {
-      urls.Add((*mImageUrls)[i].mUrl);
+      urls.Add((*mImageUrls)[i].mUrl.GetUrl());
     }
     Property::Value value(const_cast<Property::Array&>(urls));
     map.Insert(Toolkit::ImageVisual::Property::URL, value);
@@ -307,8 +307,7 @@ void AnimatedImageVisual::DoCreatePropertyMap(Property::Map& map) const
   map.Insert(Toolkit::ImageVisual::Property::FRAME_DELAY, static_cast<int>(mFrameDelay));
   map.Insert(Toolkit::DevelImageVisual::Property::LOOP_COUNT, static_cast<int>(mLoopCount));
   map.Insert(Toolkit::DevelImageVisual::Property::CURRENT_FRAME_NUMBER, (mImageCache) ? static_cast<int32_t>(mImageCache->GetCurrentFrameIndex()) : -1);
-  map.Insert(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, (mImageCache) ? static_cast<int32_t>((mAnimatedImageLoading) ? mAnimatedImageLoading.GetImageCount() : 
-                                                                                                                                     mImageCache->GetTotalFrameCount()) : -1);
+  map.Insert(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, (mImageCache) ? static_cast<int32_t>((mAnimatedImageLoading) ? mAnimatedImageLoading.GetImageCount() : mImageCache->GetTotalFrameCount()) : -1);
 
   map.Insert(Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior);
 
@@ -358,7 +357,7 @@ void AnimatedImageVisual::OnDoAction(const Dali::Property::Index actionId, const
     {
       // STOP reset functionality will actually be done in a future change
       // Stop will be executed on next timer tick
-      mActionStatus = DevelAnimatedImageVisual::Action::STOP;
+      mActionStatus     = DevelAnimatedImageVisual::Action::STOP;
       mCurrentLoopIndex = FIRST_LOOP;
       if(IsOnScene())
       {
@@ -578,11 +577,11 @@ void AnimatedImageVisual::DoSetProperty(Property::Index        index,
       value.Get(sync);
       if(sync)
       {
-        mImpl->mFlags |= Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+        mImpl->mFlags |= Visual::Base::Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
       }
       else
       {
-        mImpl->mFlags &= ~Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+        mImpl->mFlags &= ~Visual::Base::Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
       }
       break;
     }
@@ -640,8 +639,8 @@ void AnimatedImageVisual::DoSetProperty(Property::Index        index,
 
 void AnimatedImageVisual::DoSetOnScene(Actor& actor)
 {
-  mStartFirstFrame      = true;
-  mPlacementActor       = actor;
+  mStartFirstFrame = true;
+  mPlacementActor  = actor;
   PrepareTextureSet();
 }
 
@@ -666,9 +665,9 @@ void AnimatedImageVisual::DoSetOffScene(Actor& actor)
   }
 
   mPlacementActor.Reset();
-  mStartFirstFrame = false;
+  mStartFirstFrame   = false;
   mCurrentFrameIndex = FIRST_FRAME_INDEX;
-  mCurrentLoopIndex = FIRST_LOOP;
+  mCurrentLoopIndex  = FIRST_LOOP;
 }
 
 void AnimatedImageVisual::OnSetTransform()
index 8cc69ff..97b8d35 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -31,7 +31,7 @@ namespace Internal
 {
 namespace
 {
-constexpr bool ENABLE_ORIENTATION_CORRECTION(true);
+constexpr bool     ENABLE_ORIENTATION_CORRECTION(true);
 constexpr uint32_t FIRST_FRAME_INDEX = 0u;
 } // namespace
 
@@ -112,8 +112,8 @@ void FixedImageCache::LoadBatch()
   // Once the cache is filled, no more images are loaded.
   for(unsigned int i = 0; i < mBatchSize && mReadyFlags.size() < mImageUrls.size(); ++i)
   {
-    uint32_t frameIndex = mReadyFlags.size();
-    std::string& url = mImageUrls[frameIndex].mUrl;
+    uint32_t   frameIndex = mReadyFlags.size();
+    VisualUrl& url        = mImageUrls[frameIndex].mUrl;
 
     mReadyFlags.push_back(false);
 
@@ -121,16 +121,16 @@ void FixedImageCache::LoadBatch()
     // from within this method. This means it won't yet have a texture id, so we
     // need to account for this inside the LoadComplete method using mRequestingLoad.
     mRequestingLoad = true;
-    mLoadState = TextureManager::LoadState::LOADING;
+    mLoadState      = TextureManager::LoadState::LOADING;
 
-    bool                               synchronousLoading = false;
-    bool                               atlasingStatus     = false;
-    bool                               loadingStatus      = false;
-    AtlasUploadObserver*               atlasObserver      = nullptr;
-    ImageAtlasManagerPtr               imageAtlasManager  = nullptr;
-    Vector4                            textureRect;
-    Dali::ImageDimensions              textureRectSize;
-    auto                               preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+    bool                  synchronousLoading = false;
+    bool                  atlasingStatus     = false;
+    bool                  loadingStatus      = false;
+    AtlasUploadObserver*  atlasObserver      = nullptr;
+    ImageAtlasManagerPtr  imageAtlasManager  = nullptr;
+    Vector4               textureRect;
+    Dali::ImageDimensions textureRectSize;
+    auto                  preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
     mTextureManager.LoadTexture(
       url, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, mMaskingData, synchronousLoading, mImageUrls[frameIndex].mTextureId, textureRect, textureRectSize, atlasingStatus, loadingStatus, Dali::WrapMode::Type::DEFAULT, Dali::WrapMode::Type::DEFAULT, this, atlasObserver, imageAtlasManager, ENABLE_ORIENTATION_CORRECTION, TextureManager::ReloadPolicy::CACHED, preMultiply);
@@ -181,7 +181,7 @@ void FixedImageCache::LoadComplete(bool loadSuccess, TextureInformation textureI
 {
   if(loadSuccess)
   {
-    mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+    mLoadState           = TextureManager::LoadState::LOAD_FINISHED;
     bool frontFrameReady = IsFrontReady();
     if(!mRequestingLoad)
     {
index 65f39df..d3b6b0a 100644 (file)
@@ -47,7 +47,7 @@ public:
   struct UrlStore
   {
     TextureManager::TextureId mTextureId = TextureManager::INVALID_TEXTURE_ID;
-    std::string               mUrl;
+    VisualUrl                 mUrl;
   };
 
   /**
index e5ea68e..2929d89 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -27,16 +27,16 @@ namespace
 #if defined(DEBUG_ENABLED)
 Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
 
-#define LOG_CACHE                                                                                                                 \
-  {                                                                                                                               \
-    std::ostringstream oss;                                                                                                       \
-    oss << "Size:" << mQueue.Count() << " [ ";                                                                                    \
-    for(std::size_t _i = 0; _i < mQueue.Count(); ++_i)                                                                            \
-    {                                                                                                                             \
-      oss << _i << "={ frm#: " << mQueue[_i].mFrameNumber << " tex: " << mImageUrls[mQueue[_i].mFrameNumber].mTextureId << "}, "; \
-    }                                                                                                                             \
-    oss << " ]" << std::endl;                                                                                                     \
-    DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "%s", oss.str().c_str());                                                    \
+#define LOG_CACHE                                                                                                       \
+  {                                                                                                                     \
+    std::ostringstream oss;                                                                                             \
+    oss << "Size:" << mQueue.Count() << " [ ";                                                                          \
+    for(std::size_t _i = 0; _i < mQueue.Count(); ++_i)                                                                  \
+    {                                                                                                                   \
+      oss << _i << "={ frm#: " << mQueue[_i].mFrameNumber << " tex: " << mTextureIds[mQueue[_i].mFrameNumber] << "}, "; \
+    }                                                                                                                   \
+    oss << " ]" << std::endl;                                                                                           \
+    DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "%s", oss.str().c_str());                                          \
   }
 
 #else
@@ -67,6 +67,7 @@ RollingAnimatedImageCache::RollingAnimatedImageCache(TextureManager&
                                                      uint16_t                            batchSize,
                                                      bool                                isSynchronousLoading)
 : ImageCache(textureManager, maskingData, observer, batchSize, 0u),
+  mImageUrl(animatedImageLoading.GetUrl()),
   mAnimatedImageLoading(animatedImageLoading),
   mFrameCount(SINGLE_IMAGE_COUNT),
   mFrameIndex(FIRST_FRAME_INDEX),
@@ -74,7 +75,7 @@ RollingAnimatedImageCache::RollingAnimatedImageCache(TextureManager&
   mQueue(cacheSize),
   mIsSynchronousLoading(isSynchronousLoading)
 {
-  mImageUrls.resize(mFrameCount);
+  mTextureIds.resize(mFrameCount);
   mIntervals.assign(mFrameCount, 0);
 }
 
@@ -100,13 +101,13 @@ TextureSet RollingAnimatedImageCache::Frame(uint32_t frameIndex)
   bool synchronouslyLoaded = false;
   if(mIsSynchronousLoading && mQueue.IsEmpty())
   {
-    textureSet          = RequestFrameLoading(frameIndex, frameIndex == FIRST_FRAME_INDEX, true);
-    batchFrameIndex     = (frameIndex + 1) % mFrameCount;
+    textureSet        = RequestFrameLoading(frameIndex, true);
+    batchFrameIndex   = (frameIndex + 1) % mFrameCount;
     uint32_t interval = 0u;
     if(textureSet)
     {
       synchronouslyLoaded = true;
-      interval = mAnimatedImageLoading.GetFrameInterval(mQueue.Back().mFrameNumber);
+      interval            = mAnimatedImageLoading.GetFrameInterval(mQueue.Back().mFrameNumber);
     }
     MakeFrameReady(synchronouslyLoaded, textureSet, interval);
   }
@@ -180,7 +181,7 @@ bool RollingAnimatedImageCache::IsFrontReady() const
   return (!mQueue.IsEmpty() && mQueue.Front().mReady);
 }
 
-TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, bool useCache, bool synchronousLoading)
+TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, bool synchronousLoading)
 {
   ImageFrame imageFrame;
   imageFrame.mFrameNumber = frameIndex;
@@ -191,7 +192,8 @@ TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, b
   mLoadState = TextureManager::LoadState::LOADING;
 
   TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
-  TextureSet                textureSet    = mTextureManager.LoadAnimatedImageTexture(mAnimatedImageLoading,
+  TextureSet                textureSet    = mTextureManager.LoadAnimatedImageTexture(mImageUrl,
+                                                                   mAnimatedImageLoading,
                                                                    frameIndex,
                                                                    loadTextureId,
                                                                    mMaskingData,
@@ -199,10 +201,9 @@ TextureSet RollingAnimatedImageCache::RequestFrameLoading(uint32_t frameIndex, b
                                                                    Dali::WrapMode::Type::DEFAULT,
                                                                    Dali::WrapMode::Type::DEFAULT,
                                                                    synchronousLoading,
-                                                                   useCache,
                                                                    this);
 
-  mImageUrls[frameIndex].mTextureId = loadTextureId;
+  mTextureIds[frameIndex] = loadTextureId;
 
   return textureSet;
 }
@@ -217,7 +218,7 @@ void RollingAnimatedImageCache::LoadBatch(uint32_t frameIndex)
   {
     if(mLoadState != TextureManager::LoadState::LOADING)
     {
-      RequestFrameLoading(frameIndex, frameIndex == FIRST_FRAME_INDEX, false);
+      RequestFrameLoading(frameIndex, false);
     }
     else
     {
@@ -253,14 +254,14 @@ TextureSet RollingAnimatedImageCache::GetFrontTextureSet() const
 
 TextureManager::TextureId RollingAnimatedImageCache::GetCachedTextureId(int index) const
 {
-  return mImageUrls[mQueue[index].mFrameNumber].mTextureId;
+  return mTextureIds[mQueue[index].mFrameNumber];
 }
 
 void RollingAnimatedImageCache::PopFrontCache()
 {
   ImageFrame imageFrame = mQueue.PopFront();
-  mTextureManager.Remove(mImageUrls[imageFrame.mFrameNumber].mTextureId, this);
-  mImageUrls[imageFrame.mFrameNumber].mTextureId = TextureManager::INVALID_TEXTURE_ID;
+  mTextureManager.Remove(mTextureIds[imageFrame.mFrameNumber], this);
+  mTextureIds[imageFrame.mFrameNumber] = TextureManager::INVALID_TEXTURE_ID;
 
   if(mMaskingData && mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID)
   {
@@ -297,7 +298,7 @@ void RollingAnimatedImageCache::MakeFrameReady(bool loadSuccess, TextureSet text
     if(mFrameCount != mAnimatedImageLoading.GetImageCount())
     {
       mFrameCount = mAnimatedImageLoading.GetImageCount();
-      mImageUrls.resize(mFrameCount);
+      mTextureIds.resize(mFrameCount);
       mIntervals.assign(mFrameCount, 0u);
     }
 
@@ -331,7 +332,7 @@ void RollingAnimatedImageCache::LoadComplete(bool loadSuccess, TextureInformatio
     {
       uint32_t loadingIndex = mLoadWaitingQueue.front();
       mLoadWaitingQueue.erase(mLoadWaitingQueue.begin());
-      RequestFrameLoading(loadingIndex, loadingIndex == FIRST_FRAME_INDEX, false);
+      RequestFrameLoading(loadingIndex, false);
     }
     else if(mQueue.Count() == 1u && textureInformation.frameCount > SINGLE_IMAGE_COUNT)
     {
index 1b383b5..f520907 100644 (file)
@@ -107,12 +107,11 @@ private:
    * @brief Request to Load a frame
    *
    * @param[in] frameIndex          index of frame to be loaded.
-   * @param[in] useCache            true if this frame loading uses cache.
    * @param[in] synchronousLoading  true if the frame should be loaded synchronously
    *
    * @return the texture set currently loaded.
    */
-  TextureSet RequestFrameLoading(uint32_t frameIndex, bool useCache, bool synchronousLoading);
+  TextureSet RequestFrameLoading(uint32_t frameIndex, bool synchronousLoading);
 
   /**
    * @brief Load the next batch of images
@@ -163,7 +162,6 @@ protected:
   void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
 
 private:
-
   /**
    * Secondary class to hold readiness and index into url
    */
@@ -172,12 +170,13 @@ private:
     uint32_t mFrameNumber = 0u;
     bool     mReady       = false;
   };
+  std::vector<TextureManager::TextureId> mTextureIds;
 
+  VisualUrl                  mImageUrl;
   Dali::AnimatedImageLoading mAnimatedImageLoading;
   uint32_t                   mFrameCount;
   uint32_t                   mFrameIndex;
   uint32_t                   mCacheSize;
-  std::vector<UrlStore>      mImageUrls;
   std::vector<int32_t>       mIntervals;
   std::vector<uint32_t>      mLoadWaitingQueue;
   CircularQueue<ImageFrame>  mQueue;
index c0c598a..f78d74a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -81,7 +81,7 @@ TextureSet RollingImageCache::Frame(uint32_t frameIndex)
   while(!mQueue.IsEmpty() && mQueue.Front().mUrlIndex != frameIndex)
   {
     PopFrontCache();
-    popExist                                    = true;
+    popExist = true;
   }
 
   // TODO: synchronous loading of first frame.
@@ -144,7 +144,7 @@ void RollingImageCache::LoadBatch(uint32_t frameIndex)
   {
     ImageFrame imageFrame;
 
-    std::string& url     = mImageUrls[frameIndex].mUrl;
+    VisualUrl& url       = mImageUrls[frameIndex].mUrl;
     imageFrame.mUrlIndex = frameIndex;
     imageFrame.mReady    = false;
 
@@ -154,16 +154,16 @@ void RollingImageCache::LoadBatch(uint32_t frameIndex)
     // from within this method. This means it won't yet have a texture id, so we
     // need to account for this inside the LoadComplete method using mRequestingLoad.
     mRequestingLoad = true;
-    mLoadState = TextureManager::LoadState::LOADING;
+    mLoadState      = TextureManager::LoadState::LOADING;
 
-    bool                               synchronousLoading = false;
-    bool                               atlasingStatus     = false;
-    bool                               loadingStatus      = false;
-    AtlasUploadObserver*               atlasObserver      = nullptr;
-    ImageAtlasManagerPtr               imageAtlasManager  = nullptr;
-    Vector4                            textureRect;
-    Dali::ImageDimensions              textureRectSize;
-    auto                               preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+    bool                  synchronousLoading = false;
+    bool                  atlasingStatus     = false;
+    bool                  loadingStatus      = false;
+    AtlasUploadObserver*  atlasObserver      = nullptr;
+    ImageAtlasManagerPtr  imageAtlasManager  = nullptr;
+    Vector4               textureRect;
+    Dali::ImageDimensions textureRectSize;
+    auto                  preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
     TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
     TextureSet                textureSet    = mTextureManager.LoadTexture(
@@ -220,7 +220,7 @@ void RollingImageCache::LoadComplete(bool loadSuccess, TextureInformation textur
 
   if(loadSuccess)
   {
-    mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+    mLoadState           = TextureManager::LoadState::LOAD_FINISHED;
     bool frontFrameReady = IsFrontReady();
     if(!mRequestingLoad)
     {
index a7d1f76..f4e3059 100644 (file)
@@ -99,7 +99,7 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual(VisualFactoryCache& factory
   mRedrawInScalingDown(true)
 {
   // the rasterized image is with pre-multiplied alpha format
-  mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
+  mImpl->mFlags |= Visual::Base::Impl::IS_PREMULTIPLIED_ALPHA;
 
   if(!mVectorAnimationTask->Load(mUrl.GetUrl()))
   {
index 577a433..25fff39 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -84,7 +84,7 @@ TextureSet ImageAtlasManager::Add(Vector4&             textureRect,
   }
   size = dimensions;
 
-  unsigned int i = 0;
+  uint32_t i = 0;
   for(AtlasContainer::iterator iter = mAtlasList.begin(); iter != mAtlasList.end(); ++iter)
   {
     if(GetImplementation(*iter).Upload(textureRect, url, size, fittingMode, orientationCorrection, atlasUploadObserver))
@@ -99,6 +99,34 @@ TextureSet ImageAtlasManager::Add(Vector4&             textureRect,
   return mTextureSetList.back();
 }
 
+TextureSet ImageAtlasManager::Add(Vector4&                  textureRect,
+                                  const EncodedImageBuffer& encodedImageBuffer,
+                                  const ImageDimensions&    size,
+                                  FittingMode::Type         fittingMode,
+                                  bool                      orientationCorrection,
+                                  AtlasUploadObserver*      atlasUploadObserver)
+{
+  // big image, atlasing is not applied
+  if(static_cast<uint32_t>(size.GetWidth()) * static_cast<uint32_t>(size.GetHeight()) > MAX_ITEM_AREA || size.GetWidth() > DEFAULT_ATLAS_SIZE || size.GetHeight() > DEFAULT_ATLAS_SIZE)
+  {
+    return TextureSet();
+  }
+
+  uint32_t i = 0;
+  for(AtlasContainer::iterator iter = mAtlasList.begin(); iter != mAtlasList.end(); ++iter)
+  {
+    if(GetImplementation(*iter).Upload(textureRect, encodedImageBuffer, size, fittingMode, orientationCorrection, atlasUploadObserver))
+    {
+      return mTextureSetList[i];
+    }
+    i++;
+  }
+
+  CreateNewAtlas();
+  GetImplementation(mAtlasList.back()).Upload(textureRect, encodedImageBuffer, size, fittingMode, orientationCorrection, atlasUploadObserver);
+  return mTextureSetList.back();
+}
+
 TextureSet ImageAtlasManager::Add(Vector4&  textureRect,
                                   PixelData pixelData)
 {
@@ -108,7 +136,7 @@ TextureSet ImageAtlasManager::Add(Vector4&  textureRect,
     return TextureSet();
   }
 
-  unsigned int i = 0;
+  uint32_t i = 0;
   for(AtlasContainer::iterator iter = mAtlasList.begin(); iter != mAtlasList.end(); ++iter)
   {
     if((*iter).Upload(textureRect, pixelData))
@@ -125,7 +153,7 @@ TextureSet ImageAtlasManager::Add(Vector4&  textureRect,
 
 void ImageAtlasManager::Remove(TextureSet textureSet, const Vector4& textureRect)
 {
-  unsigned int i = 0;
+  uint32_t i = 0;
   for(TextureSetContainer::iterator iter = mTextureSetList.begin(); iter != mTextureSetList.end(); ++iter)
   {
     if((*iter) == textureSet)
index d2630c1..ec7a402 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_IMAGE_ATLAS_MANAGER_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -18,6 +18,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/rendering/texture-set.h>
@@ -82,6 +83,29 @@ public:
                  FittingMode::Type    fittingMode           = FittingMode::DEFAULT,
                  bool                 orientationCorrection = true,
                  AtlasUploadObserver* atlasUploadObserver   = NULL);
+
+  /**
+   * @brief Add an image to the atlas.
+   *
+   * @note To make the atlasing efficient, an valid size should be provided.
+   *
+   * SamplingMode::BOX_THEN_LINEAR is used to sampling pixels from the input image while fitting it to desired size.
+   *
+   * @param [out] textureRect The texture area of the resource image in the atlas.
+   * @param [in] encodedImageBuffer The encoded buffer of the resource image file to use.
+   * @param [in] size The width and height to fit the loaded image to.
+   * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
+   * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+   * @param [in] atlasUploadObserver The object to observe the uploading state inside ImageAtlas.
+   * @return The texture set containing the image.
+   */
+  TextureSet Add(Vector4&                  textureRect,
+                 const EncodedImageBuffer& encodedImageBuffer,
+                 const ImageDimensions&    size,
+                 FittingMode::Type         fittingMode           = FittingMode::DEFAULT,
+                 bool                      orientationCorrection = true,
+                 AtlasUploadObserver*      atlasUploadObserver   = NULL);
+
   /**
    * @brief Add a pixel buffer to the atlas
    *
index a2e9096..e3aa797 100644 (file)
@@ -307,11 +307,11 @@ void ImageVisual::DoSetProperty(Property::Index index, const Property::Value& va
       {
         if(sync)
         {
-          mImpl->mFlags |= Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+          mImpl->mFlags |= Visual::Base::Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
         }
         else
         {
-          mImpl->mFlags &= ~Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+          mImpl->mFlags &= ~Visual::Base::Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
         }
       }
       else
@@ -471,7 +471,7 @@ void ImageVisual::GetNaturalSize(Vector2& naturalSize)
   }
   else if(mImpl->mRenderer) // Check if we have a loaded image
   {
-    if(mImpl->mFlags & Impl::IS_ATLASING_APPLIED)
+    if(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED)
     {
       naturalSize.x = mAtlasRectSize.GetWidth();
       naturalSize.y = mAtlasRectSize.GetHeight();
@@ -620,11 +620,11 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te
 
   if(atlasing) // Flag needs to be set before creating renderer
   {
-    mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
+    mImpl->mFlags |= Visual::Base::Impl::IS_ATLASING_APPLIED;
   }
   else
   {
-    mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
+    mImpl->mFlags &= ~Visual::Base::Impl::IS_ATLASING_APPLIED;
   }
 }
 
@@ -981,7 +981,7 @@ Shader ImageVisual::GenerateShader() const
     shader = mImageVisualShaderFactory.GetShader(
       mFactoryCache,
       ImageVisualShaderFeature::FeatureBuilder()
-        .EnableTextureAtlas(mImpl->mFlags & Impl::IS_ATLASING_APPLIED && !useNativeImage)
+        .EnableTextureAtlas(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED && !useNativeImage)
         .ApplyDefaultTextureWrapMode(mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE)
         .EnableRoundedCorner(IsRoundedCornerRequired())
         .EnableBorderline(IsBorderlineRequired())
index 08e416e..24f9981 100644 (file)
@@ -33,8 +33,8 @@ namespace Toolkit
 {
 namespace Internal
 {
-RasterizingTask::RasterizingTask(SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height)
-: mSvgVisual(svgRenderer),
+RasterizingTask::RasterizingTask(SvgVisual* svgVisual, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height)
+: mSvgVisual(svgVisual),
   mVectorRenderer(vectorRenderer),
   mUrl(url),
   mDpi(dpi),
@@ -50,29 +50,41 @@ RasterizingTask::~RasterizingTask()
 
 void RasterizingTask::Load()
 {
+  if(mVectorRenderer.IsLoaded())
+  {
+    // Already loaded
+    mLoadSuccess = true;
+    return;
+  }
+
+  Dali::Vector<uint8_t> buffer;
+
   if(!mUrl.IsLocalResource())
   {
-    Dali::Vector<uint8_t> remoteBuffer;
-    if(!Dali::FileLoader::DownloadFileSynchronously(mUrl.GetUrl(), remoteBuffer))
+    if(!Dali::FileLoader::DownloadFileSynchronously(mUrl.GetUrl(), buffer))
     {
-      DALI_LOG_ERROR("RasterizingTask::Load: Failed to download file! [%s]\n", mUrl.GetUrl().c_str());
+      DALI_LOG_ERROR("Failed to download file! [%s]\n", mUrl.GetUrl().c_str());
       return;
     }
-
-    remoteBuffer.PushBack('\0');
-
-    if(!mVectorRenderer.Load(remoteBuffer, mDpi))
+  }
+  else
+  {
+    if(!Dali::FileLoader::ReadFile(mUrl.GetUrl(), buffer))
     {
-      DALI_LOG_ERROR("RasterizingTask::Load:Failed to load data! [%s]\n", mUrl.GetUrl().c_str());
+      DALI_LOG_ERROR("Failed to read file! [%s]\n", mUrl.GetUrl().c_str());
       return;
     }
-
-    mLoadSuccess = true;
   }
-  else
+
+  buffer.PushBack('\0');
+
+  if(!mVectorRenderer.Load(buffer, mDpi))
   {
-    mLoadSuccess = true;
+    DALI_LOG_ERROR("Failed to load data! [%s]\n", mUrl.GetUrl().c_str());
+    return;
   }
+
+  mLoadSuccess = true;
 }
 
 void RasterizingTask::Rasterize()
@@ -87,11 +99,6 @@ void RasterizingTask::Rasterize()
   mPixelData = Devel::PixelBuffer::Convert(pixelBuffer);
 }
 
-VectorImageRenderer RasterizingTask::GetVectorRenderer() const
-{
-  return mVectorRenderer;
-}
-
 bool RasterizingTask::IsLoaded() const
 {
   return mLoadSuccess;
@@ -258,7 +265,7 @@ void SvgRasterizeThread::ApplyRasterizedSVGToSampler()
 {
   while(RasterizingTaskPtr task = NextCompletedTask())
   {
-    task->GetSvgVisual()->ApplyRasterizedImage(task->GetVectorRenderer(), task->GetPixelData(), task->IsLoaded());
+    task->GetSvgVisual()->ApplyRasterizedImage(task->GetPixelData(), task->IsLoaded());
   }
 
   UnregisterProcessor();
index 0204bef..c0cf726 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_SVG_RASTERIZE_THREAD_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -29,7 +29,6 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/images/pixel-data.h>
 #include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/rendering/texture-set.h>
 #include <memory>
 
 // INTERNAL INCLUDES
@@ -60,12 +59,14 @@ class RasterizingTask : public RefObject
 public:
   /**
    * Constructor
-   * @param[in] svgRenderer The renderer which the rasterized image to be applied.
+   * @param[in] svgVisual The visual which the rasterized image to be applied.
+   * @param[in] vectorRenderer The vector rasterizer.
    * @param[in] url The URL to svg resource to use.
+   * @param[in] dpi The DPI of the screen.
    * @param[in] width The rasterization width.
    * @param[in] height The rasterization height.
    */
-  RasterizingTask(SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height);
+  RasterizingTask(SvgVisual* svgVisual, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height);
 
   /**
    * Destructor.
@@ -73,6 +74,11 @@ public:
   ~RasterizingTask() override;
 
   /**
+   * Load svg file
+   */
+  void Load();
+
+  /**
    * Do the rasterization with the mRasterizer.
    */
   void Rasterize();
@@ -89,21 +95,11 @@ public:
   PixelData GetPixelData() const;
 
   /**
-   * Get the VectorRenderer.
-   * @return VectorRenderer.
-   */
-  VectorImageRenderer GetVectorRenderer() const;
-  /**
    * Whether the resource is loaded.
    * @return True if the resource is loaded.
    */
   bool IsLoaded() const;
 
-  /**
-   * Load svg file
-   */
-  void Load();
-
 private:
   // Undefined
   RasterizingTask(const RasterizingTask& task);
@@ -117,8 +113,8 @@ private:
   VisualUrl           mUrl;
   PixelData           mPixelData;
   float               mDpi;
-  unsigned int        mWidth;
-  unsigned int        mHeight;
+  uint32_t            mWidth;
+  uint32_t            mHeight;
   bool                mLoadSuccess;
 };
 
index 6851c75..bddb7f0 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/file-loader.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/integration-api/debug.h>
 
@@ -49,7 +48,6 @@ const Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
 SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
 {
   SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl));
-  svgVisual->Load();
   svgVisual->SetProperties(properties);
   svgVisual->Initialize();
   return svgVisual;
@@ -58,7 +56,6 @@ SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderF
 SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
 {
   SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl));
-  svgVisual->Load();
   svgVisual->Initialize();
   return svgVisual;
 }
@@ -238,34 +235,6 @@ void SvgVisual::EnablePreMultipliedAlpha(bool preMultiplied)
   }
 }
 
-void SvgVisual::Load()
-{
-  // load remote resource on svg rasterize thread.
-  if(mImageUrl.IsLocalResource())
-  {
-    Dali::Vector<uint8_t> buffer;
-    if(Dali::FileLoader::ReadFile(mImageUrl.GetUrl(), buffer))
-    {
-      buffer.PushBack('\0');
-
-      Vector2 dpi     = Stage::GetCurrent().GetDpi();
-      float   meanDpi = (dpi.height + dpi.width) * 0.5f;
-      if(!mVectorRenderer.Load(buffer, meanDpi))
-      {
-        mLoadFailed = true;
-        DALI_LOG_ERROR("SvgVisual::Load: Failed to load file! [%s]\n", mImageUrl.GetUrl().c_str());
-        return;
-      }
-      mVectorRenderer.GetDefaultSize(mDefaultWidth, mDefaultHeight);
-    }
-    else
-    {
-      mLoadFailed = true;
-      DALI_LOG_ERROR("SvgVisual::Load: Failed to read file! [%s]\n", mImageUrl.GetUrl().c_str());
-    }
-  }
-}
-
 void SvgVisual::AddRasterizationTask(const Vector2& size)
 {
   if(mImpl->mRenderer)
@@ -277,11 +246,12 @@ void SvgVisual::AddRasterizationTask(const Vector2& size)
     float   meanDpi = (dpi.height + dpi.width) * 0.5f;
 
     RasterizingTaskPtr newTask = new RasterizingTask(this, mVectorRenderer, mImageUrl, meanDpi, width, height);
+
     if(IsSynchronousLoadingRequired() && mImageUrl.IsLocalResource())
     {
       newTask->Load();
       newTask->Rasterize();
-      ApplyRasterizedImage(newTask->GetVectorRenderer(), newTask->GetPixelData(), newTask->IsLoaded());
+      ApplyRasterizedImage(newTask->GetPixelData(), newTask->IsLoaded());
     }
     else
     {
@@ -290,7 +260,7 @@ void SvgVisual::AddRasterizationTask(const Vector2& size)
   }
 }
 
-void SvgVisual::ApplyRasterizedImage(VectorImageRenderer vectorRenderer, PixelData rasterizedPixelData, bool isLoaded)
+void SvgVisual::ApplyRasterizedImage(PixelData rasterizedPixelData, bool isLoaded)
 {
   if(isLoaded && rasterizedPixelData && IsOnScene())
   {
@@ -388,8 +358,8 @@ void SvgVisual::OnSetTransform()
   {
     if(visualSize != mRasterizedSize || mDefaultWidth == 0 || mDefaultHeight == 0)
     {
-      AddRasterizationTask(visualSize);
       mRasterizedSize = visualSize;
+      AddRasterizationTask(visualSize);
     }
   }
 
index 2b1dbe1..9dd6807 100644 (file)
@@ -151,19 +151,13 @@ public:
   /**
    * @bried Apply the rasterized image to the visual.
    *
-   * @param[in] vectorImage The data of vector image.
    * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
    * @param[in] bool Whether the resource is loaded
    */
-  void ApplyRasterizedImage(VectorImageRenderer vectorImage, PixelData rasterizedPixelData, bool isLoaded);
+  void ApplyRasterizedImage(PixelData rasterizedPixelData, bool isLoaded);
 
 private:
   /**
-   * @brief Load the SVG Image from the set URL.
-   */
-  void Load();
-
-  /**
    * @bried Rasterize the svg with the given size, and add it to the visual.
    *
    * @param[in] size The target size of the SVG rasterization.
index 9b0e811..777e48f 100644 (file)
@@ -342,8 +342,6 @@ void TextVisual::DoSetOnScene(Actor& actor)
   // Renderer needs textures and to be added to control
   mRendererUpdateNeeded = true;
 
-  mRendererList.push_back(mImpl->mRenderer);
-
   UpdateRenderer();
 }
 
@@ -620,16 +618,16 @@ void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sa
     ++textureSetIndex;
   }
 
-  if(styleEnabled && info.styleBuffer)
+  if(styleEnabled && info.styleBuffer && info.overlayStyleBuffer)
   {
     PixelData styleData = ConvertToPixelData(info.styleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
     AddTexture(textureSet, styleData, sampler, textureSetIndex);
     ++textureSetIndex;
-  }
 
-  if(styleEnabled && isOverlayStyle && info.styleBuffer)
-  {
-    PixelData overlayStyleData = ConvertToPixelData(info.styleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
+    // TODO : We need to seperate whether use overlayStyle or not.
+    // Current text visual shader required both of them.
+
+    PixelData overlayStyleData = ConvertToPixelData(info.overlayStyleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
     AddTexture(textureSet, overlayStyleData, sampler, textureSetIndex);
     ++textureSetIndex;
   }
@@ -711,6 +709,14 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple
       PixelData                             styleData      = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888);
       Dali::DevelPixelData::PixelDataBuffer stylePixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(styleData);
       info.styleBuffer                                     = stylePixelData.buffer;
+
+      // TODO : We need to seperate whether use overlayStyle or not.
+      // Current text visual shader required both of them.
+
+      // Create RGBA texture for all the overlay styles
+      PixelData                             overlayStyleData      = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_OVERLAY_STYLE, false, Pixel::RGBA8888);
+      Dali::DevelPixelData::PixelDataBuffer overlayStylePixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(overlayStyleData);
+      info.overlayStyleBuffer                                     = overlayStylePixelData.buffer;
     }
 
     if(containsColorGlyph && !hasMultipleTextColors)
@@ -758,12 +764,38 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple
 
   mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
 
+  const Vector4& defaultColor = mController->GetTextModel()->GetDefaultColor();
+
   for(RendererContainer::iterator iter = mRendererList.begin(); iter != mRendererList.end(); ++iter)
   {
     Renderer renderer = (*iter);
     if(renderer)
     {
       actor.AddRenderer(renderer);
+
+      if(renderer != mImpl->mRenderer)
+      {
+        // Set constraint for text label's color for non-default renderers.
+        if(mAnimatableTextColorPropertyIndex != Property::INVALID_INDEX)
+        {
+          // Register unique property, or get property for default renderer.
+          Property::Index index = renderer.RegisterUniqueProperty("uTextColorAnimatable", defaultColor);
+
+          // Create constraint for the animatable text's color Property with uTextColorAnimatable in the renderer.
+          if(index != Property::INVALID_INDEX)
+          {
+            Constraint colorConstraint = Constraint::New<Vector4>(renderer, index, TextColorConstraint);
+            colorConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex));
+            colorConstraint.Apply();
+          }
+
+          // Make zero if the alpha value of text color is zero to skip rendering text
+          // VisualRenderer::Property::OPACITY uses same animatable property internally.
+          Constraint opacityConstraint = Constraint::New<float>(renderer, Dali::DevelRenderer::Property::OPACITY, OpacityConstraint);
+          opacityConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex));
+          opacityConstraint.Apply();
+        }
+      }
     }
   }
 }
@@ -797,6 +829,10 @@ TextureSet TextVisual::GetTextTexture(const Vector2& size, bool hasMultipleTextC
     PixelData styleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888);
     AddTexture(textureSet, styleData, sampler, textureSetIndex);
     ++textureSetIndex;
+
+    // TODO : We need to seperate whether use overlayStyle or not.
+    // Current text visual shader required both of them.
+
     // Create RGBA texture for overlay styles such as underline and strikethrough (without the text itself)
     PixelData overlayStyleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_OVERLAY_STYLE, false, Pixel::RGBA8888);
     AddTexture(textureSet, overlayStyleData, sampler, textureSetIndex);
index fa7ca4e..c79c254 100644 (file)
@@ -193,6 +193,7 @@ private:
   {
     unsigned char* textBuffer;
     unsigned char* styleBuffer;
+    unsigned char* overlayStyleBuffer;
     unsigned char* maskBuffer;
     int            width;
     int            height;
@@ -203,6 +204,7 @@ private:
     TilingInfo(int width, int height, Pixel::Format textPixelFormat)
     : textBuffer(NULL),
       styleBuffer(NULL),
+      overlayStyleBuffer(NULL),
       maskBuffer(NULL),
       width(width),
       height(height),
@@ -222,6 +224,10 @@ private:
       {
         free(styleBuffer);
       }
+      if(overlayStyleBuffer)
+      {
+        free(overlayStyleBuffer);
+      }
       if(maskBuffer)
       {
         free(maskBuffer);
index af3b04c..c43af6d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -18,6 +18,7 @@
 #include <dali-toolkit/internal/visuals/visual-url.h>
 
 // EXTERNAL HEADERS
+#include <dali/devel-api/common/hash.h>
 #include <cstring> // for toupper()
 
 namespace Dali
@@ -104,8 +105,8 @@ VisualUrl::ProtocolType ResolveLocation(const std::string& url)
 VisualUrl::Type ResolveType(const std::string& url)
 {
   // if only one char in string, can only be regular image
-  const std::size_t count = url.size();
-  VisualUrl::Type  returnType = VisualUrl::REGULAR_IMAGE;
+  const std::size_t count      = url.size();
+  VisualUrl::Type   returnType = VisualUrl::REGULAR_IMAGE;
   if(count > 0)
   {
     // parsing from the end for better chance of early outs
@@ -218,14 +219,16 @@ VisualUrl::Type ResolveType(const std::string& url)
 VisualUrl::VisualUrl()
 : mUrl(),
   mType(VisualUrl::REGULAR_IMAGE),
-  mLocation(VisualUrl::LOCAL)
+  mLocation(VisualUrl::LOCAL),
+  mUrlHash(0ull)
 {
 }
 
 VisualUrl::VisualUrl(const std::string& url)
 : mUrl(url),
   mType(VisualUrl::REGULAR_IMAGE),
-  mLocation(VisualUrl::LOCAL)
+  mLocation(VisualUrl::LOCAL),
+  mUrlHash(0ull)
 {
   if(!url.empty())
   {
@@ -241,7 +244,8 @@ VisualUrl::VisualUrl(const std::string& url)
 VisualUrl::VisualUrl(const VisualUrl& url)
 : mUrl(url.mUrl),
   mType(url.mType),
-  mLocation(url.mLocation)
+  mLocation(url.mLocation),
+  mUrlHash(url.mUrlHash)
 {
 }
 
@@ -256,6 +260,7 @@ VisualUrl& VisualUrl::operator=(const VisualUrl& url)
     mUrl      = url.mUrl;
     mType     = url.mType;
     mLocation = url.mLocation;
+    mUrlHash  = url.mUrlHash;
   }
   return *this;
 }
@@ -265,6 +270,11 @@ const std::string& VisualUrl::GetUrl() const
   return mUrl;
 }
 
+const std::uint64_t& VisualUrl::GetUrlHash() const
+{
+  return DALI_UNLIKELY(mUrlHash == 0) ? (mUrlHash = Dali::CalculateHash(mUrl)) : mUrlHash;
+}
+
 VisualUrl::Type VisualUrl::GetType() const
 {
   return mType;
index 08a276a..941d0b8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -90,6 +90,12 @@ public:
   const std::string& GetUrl() const;
 
   /**
+   * Get the hash value of full URL
+   * @return The hash value of url
+   */
+  const std::uint64_t& GetUrlHash() const;
+
+  /**
    * Get the visual type of the URL
    * @return The visual type of the URL
    */
@@ -154,6 +160,8 @@ private:
   std::string  mUrl;
   Type         mType;
   ProtocolType mLocation;
+
+  mutable std::uint64_t mUrlHash;
 };
 
 } // namespace Internal
index 9a460c0..de50efc 100644 (file)
@@ -29,7 +29,7 @@ namespace Toolkit
 {
 const unsigned int TOOLKIT_MAJOR_VERSION = 2;
 const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 22;
+const unsigned int TOOLKIT_MICRO_VERSION = 23;
 const char* const  TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index ceeba38..eb88f6b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    2.1.22
+Version:    2.1.23
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT