Merge "fix ellipsis not working issue when the given width is too narrow" into devel...
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 29 Jan 2021 17:04:16 +0000 (17:04 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 29 Jan 2021 17:04:16 +0000 (17:04 +0000)
254 files changed:
.gitignore
README.md
automated-tests/execute.sh
automated-tests/patch-coverage.pl
automated-tests/src/dali-scene-loader-internal/tct-dali-scene-loader-internal-core.cpp
automated-tests/src/dali-scene-loader/tct-dali-scene-loader-core.cpp
automated-tests/src/dali-toolkit-internal/tct-dali-toolkit-internal-core.cpp
automated-tests/src/dali-toolkit-styling/tct-dali-toolkit-styling-core.cpp
automated-tests/src/dali-toolkit-third-party/tct-dali-toolkit-third-party-core.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h [new file with mode: 0644]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp
automated-tests/src/dali-toolkit/tct-dali-toolkit-core.cpp
automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-ArcVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp
automated-tests/tcbuild [changed from symlink to file mode: 0755]
build/tizen/.gitignore
build/tizen/CMakeLists.txt
build/tizen/dali-scene-loader/CMakeLists.txt
build/tizen/docs/dali.doxy.in
build/tizen/shader-generator.sh [new file with mode: 0755]
dali-scene-loader/README.md
dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.frag [new file with mode: 0644]
dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.vert [new file with mode: 0644]
dali-scene-loader/public-api/animation-definition.cpp
dali-scene-loader/public-api/blend-shape-details.h
dali-scene-loader/public-api/camera-parameters.h
dali-scene-loader/public-api/dli-loader.cpp
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.h
dali-scene-loader/public-api/scene-definition.cpp
dali-scene-loader/public-api/skinning-details.h
dali-scene-loader/public-api/utils.cpp
dali-scene-loader/public-api/utils.h
dali-toolkit/devel-api/builder/builder.h
dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-context.cpp [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-context.h [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-settings.cpp [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-settings.h [new file with mode: 0755]
dali-toolkit/devel-api/controls/web-view/web-view.cpp [changed mode: 0644->0755]
dali-toolkit/devel-api/controls/web-view/web-view.h [changed mode: 0644->0755]
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/shader-effects/alpha-discard-effect.cpp [new file with mode: 0644]
dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h
dali-toolkit/devel-api/shader-effects/dissolve-effect.cpp [new file with mode: 0644]
dali-toolkit/devel-api/shader-effects/dissolve-effect.h
dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp [new file with mode: 0644]
dali-toolkit/devel-api/shader-effects/distance-field-effect.h
dali-toolkit/devel-api/shader-effects/image-region-effect.cpp [new file with mode: 0644]
dali-toolkit/devel-api/shader-effects/image-region-effect.h
dali-toolkit/devel-api/shader-effects/motion-blur-effect.cpp [new file with mode: 0644]
dali-toolkit/devel-api/shader-effects/motion-blur-effect.h
dali-toolkit/devel-api/shader-effects/motion-stretch-effect.cpp [new file with mode: 0644]
dali-toolkit/devel-api/shader-effects/motion-stretch-effect.h
dali-toolkit/devel-api/visuals/arc-visual-properties-devel.h
dali-toolkit/devel-api/visuals/image-visual-properties-devel.h
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp
dali-toolkit/internal/controls/bubble-effect/bubble-effect.h
dali-toolkit/internal/controls/bubble-effect/bubble-emitter-impl.cpp
dali-toolkit/internal/controls/bubble-effect/color-adjuster.h
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-renderers.cpp
dali-toolkit/internal/controls/control/control-renderers.h
dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp
dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp
dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp
dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h
dali-toolkit/internal/controls/page-turn-view/page-turn-effect.cpp
dali-toolkit/internal/controls/scene3d-view/gltf-loader.cpp
dali-toolkit/internal/controls/scene3d-view/gltf-shader.h [deleted file]
dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.cpp
dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.cpp [changed mode: 0644->0755]
dali-toolkit/internal/controls/web-view/web-view-impl.h [changed mode: 0644->0755]
dali-toolkit/internal/file.list
dali-toolkit/internal/filters/blur-two-pass-filter.cpp
dali-toolkit/internal/filters/emboss-filter.cpp
dali-toolkit/internal/filters/spread-filter.cpp
dali-toolkit/internal/graphics/shaders/alpha-discard-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/animated-gradient-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/animated-gradient-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/arc-visual-butt-cap-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/arc-visual-round-cap-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/arc-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bloom-view-composite-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bloom-view-extract-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/blur-two-images-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/blur-two-pass-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/border-visual-anti-aliasing-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/border-visual-anti-aliasing-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/border-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/border-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bouncing-effect-mesh-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bouncing-effect-mesh-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bubble-effect-color-adjuster.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bubble-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bubble-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bubble-emitter.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/bubble-emitter.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/color-visual-blur-edge-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/color-visual-blur-edge-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/color-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/color-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/control-renderers.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/control-renderers.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/cube-transition-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/cube-transition-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/dissolve-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/dissolve-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/distance-field-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/effects-view.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/effects-view.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/emboss-filter-composite-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/emboss-filter-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gaussian-blur-view.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-basecolor-texture.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-emit-texture.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-gles-version-300.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-ibl-texture.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-metallicroughness-texture.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-normal-texture.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-occulusion-texture.def [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-linear-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-radial-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-region-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-visual-atlas-clamp-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-visual-atlas-various-wrap-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-visual-no-atlas-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/image-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/mesh-visual-normal-map-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/mesh-visual-normal-map-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/mesh-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/mesh-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/mesh-visual-simple-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/mesh-visual-simple-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/model3d-view-nrmmap-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/model3d-view-nrmmap-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/model3d-view-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/model3d-view-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/model3d-view-simple-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/model3d-view-simple-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/motion-blur-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/motion-blur-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/motion-stretch-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/motion-stretch-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/npatch-visual-3x3-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/npatch-visual-mask-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/npatch-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/npatch-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/page-turn-book-spine-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/page-turn-book-spine-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/page-turn-effect.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/page-turn-effect.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/primitive-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/primitive-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/shadow-view-render-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/shadow-view-render-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/spread-filter-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/super-blur-view.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-atlas-l8-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-atlas-rgba-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-atlas-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-controller-background-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-controller-background-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-decorator-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-decorator-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-scroller-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-scroller-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-with-style-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-emoji-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-and-emoji-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/video-view-texture.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/video-view-texture.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/video-view.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/video-view.vert [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/wireframe-visual-shader.frag [new file with mode: 0644]
dali-toolkit/internal/graphics/shaders/wireframe-visual-shader.vert [new file with mode: 0644]
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-scroller.cpp
dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp
dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp
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/fixed-image-cache.h
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-image/rolling-image-cache.h
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/arc/arc-visual.cpp
dali-toolkit/internal/visuals/arc/arc-visual.h
dali-toolkit/internal/visuals/border/border-visual.cpp
dali-toolkit/internal/visuals/color/color-visual.cpp
dali-toolkit/internal/visuals/gradient/gradient-visual.cpp
dali-toolkit/internal/visuals/image-visual-shader-factory.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/mesh/mesh-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/primitive/primitive-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/texture-manager-impl.h
dali-toolkit/internal/visuals/visual-base-data-impl.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.h
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/visual-factory-cache.cpp
dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp
dali-toolkit/public-api/dali-toolkit-version.cpp
dali-toolkit/public-api/visuals/visual-properties.h
packaging/dali-toolkit.spec

index daf57d2..f31e277 100644 (file)
@@ -45,3 +45,9 @@ build/tizen/CMakeDoxygenDefaults.cmake
 /packaging/home*
 .vscode/
 core
+.clangd/
+compile_commands.json
+dali-toolkit/internal/graphics/generated/*
+dali-toolkit/internal/graphics/builtin-shader-extern-gen.h
+dali-scene-loader/internal/graphics/generated/*
+dali-scene-loader/internal/graphics/builtin-shader-extern-gen.h
index ff51191..e4cfdbc 100644 (file)
--- a/README.md
+++ b/README.md
@@ -14,6 +14,8 @@
       * [3. Building for MS Windows](#3-building-for-ms-windows)
          * Build with the Visual Studio project.
          * Build with CMake.
+      * [4. Building for MacOS](#4-building-for-macos)
+   * [DALi Scene Loader](#dali-scene-loader)
 
 # Build Instructions
 
@@ -109,3 +111,26 @@ vcpkg-script folder in the windows-dependencies repository.
     - INSTALL_CMAKE_MODULES    ---> Whether to install the CMake modules (Used by the CMake command find_package() to find previously installed libraries).
     - ENABLE_DEBUG             ---> Whether to build with debug enabled.
     - USE_DEFAULT_RESOURCE_DIR ---> Whether to use the default resource folders. Otherwise set environment variables for DALI_IMAGE_DIR, DALI_SOUND_DIR, DALI_STYLE_DIR, DALI_STYLE_IMAGE_DIR and DALI_DATA_READ_ONLY_DIR
+
+## 4. Building for MacOS
+
+It is assumed that the DALi environment has been set up & both DALi Core & Adaptor have been built accordingly.
+
+To build the repository enter the 'build/tizen' folder:
+```zsh
+% cd dali-toolkit/build/tizen
+```
+Then run the following command to set up the build:
+```zsh
+% cmake -DCMAKE_INSTALL_PREFIX=$DESKTOP_PREFIX -DCMAKE_TOOLCHAIN_FILE=$VCPKG_FOLDER/scripts/buildsystems/vcpkg.cmake -DINSTALL_CMAKE_MODULES=ON
+```
+If a Debug build is required, then add `-DCMAKE_BUILD_TYPE=Debug -DENABLE_DEBUG=ON`
+
+To build, run:
+```zsh
+% make install -j8
+```
+
+# DALi Scene Loader
+
+For information about the DALi Scene Loader library, refer to dali-scene-loader/README.md.
index add0e78..adee84b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-TEMP=`getopt -o dhsSmf --long debug,help,failnorerun,serial,tct,modules -n 'execute.sh' -- "$@"`
+TEMP=`getopt -o dhsSmfq --long debug,help,failnorerun,quiet,serial,tct,modules -n 'execute.sh' -- "$@"`
 
 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
 
@@ -9,13 +9,14 @@ eval set -- "$TEMP"
 
 function usage
 {
-    echo -e "Usage: execute.sh [-d][-s|-S|-r] [module|testcase]"
+    echo -e "Usage: execute.sh [-d][-s|-S|-r][-q] [module|testcase]"
     echo -e "       execute.sh\t\tExecute test cases from all modules in parallel"
     echo -e "       execute.sh -f \tExecute test cases from all modules in parallel without rerunning failed test cases"
     echo -e "       execute.sh -d <testcase>\tDebug testcase"
     echo -e "       execute.sh [module]\tExecute test cases from the given module in parallel"
     echo -e "       execute.sh -s [module]\t\tExecute test cases in serial using Testkit-Lite"
     echo -e "       execute.sh -S [module]\t\tExecute test cases in serial"
+    echo -e "       execute.sh -q|--quiet ...\tExecute test cases, but don't write output"
     echo -e "       execute.sh <testcase>\tFind and execute the given test case"
     exit 2
 }
@@ -25,6 +26,7 @@ opt_serial=""
 opt_modules=0
 opt_debug=0
 opt_noFailedRerun="";
+opt_quiet="";
 while true ; do
     case "$1" in
         -h|--help)     usage ;;
@@ -32,6 +34,7 @@ while true ; do
         -s|--tct)      opt_tct=1 ; shift ;;
         -f|--nofailedrerun) opt_noFailedRerun="-f" ; shift ;;
         -S|--serial)   opt_serial="-s" ; shift ;;
+        -q|--quiet)    opt_quiet="-q" ; shift ;;
         -m|--modules)  opt_modules=1 ; shift ;;
         --) shift; break;;
         *) echo "Internal error $1!" ; exit 1 ;;
@@ -67,6 +70,31 @@ function summary_end
 EOF
 }
 
+function output_start
+{
+    start=`date +"%Y-%m-%d_%H_%M_%S"`
+    cat > tct-${1}-core-tests.xml <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="./style/testresult.xsl"?>
+<test_definition>
+<environment build_id="" device_id="localhost" device_model="" device_name="N/A" host="Ubuntu" manufacturer="" resolution="N/A" screen_size="N/A"><other /></environment>
+<summary test_plan_name="Empty test_plan_name"><start_at>$start</start_at><end_at>$start</end_at></summary>
+  <suite category="Core APIs" name="tct-$1-core-tests">
+    <set name="default" set_debug_msg="automated-tests.auto.suite_1_set_1.dlog">
+EOF
+}
+
+
+function output_end
+{
+    cat >> tct-${1}-core-tests.xml <<EOF
+    </set>
+  </suite>
+</test_definition>
+EOF
+}
+
+
 if [ $opt_modules == 1 ] ; then
     modules= get_modules
     echo $modules
@@ -118,7 +146,9 @@ else
         do
             echo -e "$ASCII_BOLD"
             echo -e "Executing $mod$ASCII_RESET"
-            dbus-launch build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun
+            output_start $mod
+            dbus-launch build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun $opt_quiet
+            output_end $mod
         done
         summary_end
 
@@ -128,7 +158,9 @@ else
         summary_start
         module=$1
         shift;
-        dbus-launch build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $*
+        output_start ${module}
+        dbus-launch build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $opt_quiet $*
+        output_end ${module}
         summary_end
 
     else
index b3cf098..1f836a4 100755 (executable)
@@ -83,7 +83,7 @@ my %options = (
     "output:s"     => { "optvar"=>\$opt_output, "desc"=>"Generate html output"},
     "help"         => { "optvar"=>\$opt_help, "desc"=>""},
     "quiet"        => { "optvar"=>\$opt_quiet, "desc"=>""},
-    "verbose"      => { "optvar"=>\$opt_verbose, "desc"=>"" });
+    "verbose"      => { "optvar"=>\$opt_verbose, "desc"=>"Also output coverage" });
 
 my %longOptions = map { $_ => $options{$_}->{"optvar"} } keys(%options);
 GetOptions( %longOptions ) or pod2usage(2);
@@ -875,15 +875,14 @@ sub info(@)
     }
 }
 
-# NEW STUFF
 
-## Format per file, repeated, no linebreak
+# Format per file, repeated, no linebreak
 # <diffcmd>
 # index c1..c2 c3
 # --- a/<left-hand-side-file>
 # +++ b/<right-hand-side-file>
 # <diff hunks>
-
+#
 # Format of each diff hunk, repeated, no linebreak
 # @@ <ranges> @@ line
 # 3 lines of context
@@ -986,7 +985,7 @@ sub parse_diff
     $files{$file}->{"patch"} = [@checklines];
     $files{$file}->{"b_lines"} = {%b_lines};
 
-    my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit)?/!} (keys(%files));;
+    my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit|-scene-loader)?/!} (keys(%files));
 
     if($pd_debug)
     {
@@ -1064,6 +1063,13 @@ sub calc_patch_coverage_percentage
         my $abs_filename = File::Spec->rel2abs($file, $root);
         my $sumcountref = $info_data{$abs_filename}->{"sum"};
 
+        if($debug>1)
+        {
+            print("File:  $abs_filename\n");
+            print Dumper($info_data{$abs_filename});
+            print "\n";
+        }
+
         if( $sumcountref )
         {
             for my $patch (@$patchref)
@@ -1312,27 +1318,6 @@ EOH
 ##                                    MAIN                                    ##
 ################################################################################
 
-my $cwd = getcwd(); # expect this to be automated-tests folder
-
-# execute coverage.sh, generating build/tizen/dali.info from lib, and
-# *.dir/dali.info. Don't generate html
-print `./coverage.sh -n`;
-chdir "..";
-$root = getcwd();
-
-our %info_data; # Hash of all data from .info files
-my @info_files = split(/\n/, `find . -name dali.info`);
-my %new_info;
-
-# Read in all specified .info files
-foreach (@info_files)
-{
-    %new_info = %{read_info_file($_)};
-
-    # Combine %new_info with %info_data
-    %info_data = %{combine_info_files(\%info_data, \%new_info)};
-}
-
 
 # Generate git diff command
 my @cmd=('--no-pager','diff','--no-ext-diff','-U0','--no-color');
@@ -1362,7 +1347,7 @@ else
         }
         else
         {
-            die "Both cached & working files - cannot get correct patch from git\n";
+            die "Error: Both cached & working files - cannot get correct patch from git\nRun git add first.";
             # Would have to diff from separate clone.
         }
     }
@@ -1370,6 +1355,31 @@ else
 
 push @cmd, @ARGV;
 
+# Before executing the diff, run the coverage.sh script. This is done here so that the
+# error condition above happens straight away, rather than after spewing out lots of information.
+
+my $cwd = getcwd(); # expect this to be automated-tests folder
+# execute coverage.sh, generating build/tizen/dali.info from lib, and
+# *.dir/dali.info. Don't generate html
+printf("Running coverage.sh\n");
+my $coverage_output=`./coverage.sh -n`;
+chdir "..";
+$root = getcwd();
+
+our %info_data; # Hash of all data from .info files
+my @info_files = split(/\n/, `find . -name dali.info`);
+my %new_info;
+
+# Read in all specified .info files
+foreach (@info_files)
+{
+    %new_info = %{read_info_file($_)};
+
+    # Combine %new_info with %info_data
+    %info_data = %{combine_info_files(\%info_data, \%new_info)};
+}
+
+
 # Execute diff & coverage from root directory
 my $filesref = run_diff(@cmd);
 
@@ -1386,21 +1396,33 @@ foreach my $file (keys(%$filesref))
 }
 if( $filecount == 0 )
 {
-    print "No source files found\n";
+    print "Warning: No source files found\n";
     exit 0;    # Exit with no error.
 }
 
 #print_simplified_info() if $debug;
 #exit 0;
+if($debug > 1)
+{
+    print "Info keys:\n";
+    for my $key (keys(%info_data))
+    {
+        print "$key\n";
+    }
+    print "\n\n";
+}
 
 my $percentref = calc_patch_coverage_percentage($filesref);
 if($percentref->[0] == 0)
 {
-    print "No coverable lines found\n";
+    print "Warning: No coverable lines found\n";
     exit 0;
 }
 my $percent = $percentref->[1];
 
+printf(join("\n", grep { $_ !~ /^Remov/ } split(/\n/,$coverage_output))) if $opt_verbose;
+#printf($coverage_output) if $opt_verbose;
+
 my $color=BOLD RED;
 if($opt_output)
 {
@@ -1417,6 +1439,7 @@ elsif( ! $opt_quiet )
     print RESET;
 }
 
+printf("\n\n=========================\nPatch coverage output:\n=========================\n");
 printf("Line Coverage: %d/%d\n", $percentref->[2], $percentref->[0]);
 printf("Percentage of change covered: %5.2f%\n", $percent);
 
index 9dea347..7bfea6e 100644 (file)
@@ -1,51 +1,7 @@
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <test-harness.h>
 #include "tct-dali-scene-loader-internal-core.h"
 
 int main(int argc, char * const argv[])
 {
-  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
-  const char* optString = "sf";
-  bool optRerunFailed(true);
-  bool optRunSerially(false);
-
-  int nextOpt = 0;
-  do
-  {
-    nextOpt = getopt( argc, argv, optString );
-    switch(nextOpt)
-    {
-      case 'f':
-        optRerunFailed = false;
-        break;
-      case 's':
-        optRunSerially = true;
-        break;
-      case '?':
-        TestHarness::Usage(argv[0]);
-        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
-        break;
-    }
-  } while( nextOpt != -1 );
-
-  if( optind == argc ) // no testcase name in argument list
-  {
-    if( optRunSerially )
-    {
-      result = TestHarness::RunAll( argv[0], tc_array );
-    }
-    else
-    {
-      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
-    }
-  }
-  else
-  {
-    // optind is index of next argument - interpret as testcase name
-    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
-  }
-  return result;
+  return TestHarness::RunTests(argc, argv, tc_array);
 }
index 90b7a2c..5b79502 100644 (file)
@@ -1,51 +1,7 @@
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <test-harness.h>
 #include "tct-dali-scene-loader-core.h"
 
 int main(int argc, char * const argv[])
 {
-  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
-  const char* optString = "sf";
-  bool optRerunFailed(true);
-  bool optRunSerially(false);
-
-  int nextOpt = 0;
-  do
-  {
-    nextOpt = getopt( argc, argv, optString );
-    switch(nextOpt)
-    {
-      case 'f':
-        optRerunFailed = false;
-        break;
-      case 's':
-        optRunSerially = true;
-        break;
-      case '?':
-        TestHarness::Usage(argv[0]);
-        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
-        break;
-    }
-  } while( nextOpt != -1 );
-
-  if( optind == argc ) // no testcase name in argument list
-  {
-    if( optRunSerially )
-    {
-      result = TestHarness::RunAll( argv[0], tc_array );
-    }
-    else
-    {
-      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
-    }
-  }
-  else
-  {
-    // optind is index of next argument - interpret as testcase name
-    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
-  }
-  return result;
+  return TestHarness::RunTests(argc, argv, tc_array);
 }
index 39ed044..fe0ed63 100644 (file)
@@ -1,51 +1,7 @@
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <test-harness.h>
 #include "tct-dali-toolkit-internal-core.h"
 
 int main(int argc, char * const argv[])
 {
-  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
-  const char* optString = "sf";
-  bool optRerunFailed(true);
-  bool optRunSerially(false);
-
-  int nextOpt = 0;
-  do
-  {
-    nextOpt = getopt( argc, argv, optString );
-    switch(nextOpt)
-    {
-      case 'f':
-        optRerunFailed = false;
-        break;
-      case 's':
-        optRunSerially = true;
-        break;
-      case '?':
-        TestHarness::Usage(argv[0]);
-        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
-        break;
-    }
-  } while( nextOpt != -1 );
-
-  if( optind == argc ) // no testcase name in argument list
-  {
-    if( optRunSerially )
-    {
-      result = TestHarness::RunAll( argv[0], tc_array );
-    }
-    else
-    {
-      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
-    }
-  }
-  else
-  {
-    // optind is index of next argument - interpret as testcase name
-    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
-  }
-  return result;
+  return TestHarness::RunTests(argc, argv, tc_array);
 }
index ef04d46..16b61c2 100644 (file)
@@ -1,51 +1,7 @@
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <test-harness.h>
 #include "tct-dali-toolkit-styling-core.h"
 
 int main(int argc, char * const argv[])
 {
-  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
-  const char* optString = "sf";
-  bool optRerunFailed(true);
-  bool optRunSerially(false);
-
-  int nextOpt = 0;
-  do
-  {
-    nextOpt = getopt( argc, argv, optString );
-    switch(nextOpt)
-    {
-      case 'f':
-        optRerunFailed = false;
-        break;
-      case 's':
-        optRunSerially = true;
-        break;
-      case '?':
-        TestHarness::Usage(argv[0]);
-        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
-        break;
-    }
-  } while( nextOpt != -1 );
-
-  if( optind == argc ) // no testcase name in argument list
-  {
-    if( optRunSerially )
-    {
-      result = TestHarness::RunAll( argv[0], tc_array );
-    }
-    else
-    {
-      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
-    }
-  }
-  else
-  {
-    // optind is index of next argument - interpret as testcase name
-    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
-  }
-  return result;
+  return TestHarness::RunTests(argc, argv, tc_array);
 }
index d188f08..779e56b 100644 (file)
@@ -1,51 +1,7 @@
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <test-harness.h>
 #include "tct-dali-toolkit-third-party-core.h"
 
 int main(int argc, char * const argv[])
 {
-  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
-  const char* optString = "sf";
-  bool optRerunFailed(true);
-  bool optRunSerially(false);
-
-  int nextOpt = 0;
-  do
-  {
-    nextOpt = getopt( argc, argv, optString );
-    switch(nextOpt)
-    {
-      case 'f':
-        optRerunFailed = false;
-        break;
-      case 's':
-        optRunSerially = true;
-        break;
-      case '?':
-        TestHarness::Usage(argv[0]);
-        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
-        break;
-    }
-  } while( nextOpt != -1 );
-
-  if( optind == argc ) // no testcase name in argument list
-  {
-    if( optRunSerially )
-    {
-      result = TestHarness::RunAll( argv[0], tc_array );
-    }
-    else
-    {
-      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
-    }
-  }
-  else
-  {
-    // optind is index of next argument - interpret as testcase name
-    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
-  }
-  return result;
+  return TestHarness::RunTests(argc, argv, tc_array);
 }
index a4b45c9..c6e63e7 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_SUITE_UTILS_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -417,25 +417,25 @@ inline void DALI_TEST_PRINT_ASSERT(DaliException& e)
  * @param expressions code to execute
  * @param except the exception expected in the assert
  */
-#define DALI_TEST_THROWS(expressions, except)                                                               \
-  try                                                                                                       \
-  {                                                                                                         \
-    TestApplication::EnableLogging(false);                                                                  \
-    expressions;                                                                                            \
-    TestApplication::EnableLogging(true);                                                                   \
-    fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except);   \
-    tet_result(TET_FAIL);                                                                                   \
-    throw("TET_FAIL");                                                                                      \
-  }                                                                                                         \
-  catch(except &)                                                                                           \
-  {                                                                                                         \
-    tet_result(TET_PASS);                                                                                   \
-  }                                                                                                         \
-  catch(...)                                                                                                \
-  {                                                                                                         \
-    fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__);                             \
-    tet_result(TET_FAIL);                                                                                   \
-    throw;                                                                                                  \
+#define DALI_TEST_THROWS(expressions, except)                                                             \
+  try                                                                                                     \
+  {                                                                                                       \
+    TestApplication::EnableLogging(false);                                                                \
+    expressions;                                                                                          \
+    TestApplication::EnableLogging(true);                                                                 \
+    fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \
+    tet_result(TET_FAIL);                                                                                 \
+    throw("TET_FAIL");                                                                                    \
+  }                                                                                                       \
+  catch(except&)                                                                                          \
+  {                                                                                                       \
+    tet_result(TET_PASS);                                                                                 \
+  }                                                                                                       \
+  catch(...)                                                                                              \
+  {                                                                                                       \
+    fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__);                           \
+    tet_result(TET_FAIL);                                                                                 \
+    throw;                                                                                                \
   }
 
 // Functor to test whether an Applied signal is emitted
index 062276a..a2a1848 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -55,9 +55,7 @@ void TestApplication::CreateCore()
 
   mCore = Dali::Integration::Core::New(mRenderController,
                                        mPlatformAbstraction,
-                                       mGlAbstraction,
-                                       mGlSyncAbstraction,
-                                       mGlContextHelperAbstraction,
+                                       mGraphicsController,
                                        Integration::RenderToFrameBuffer::FALSE,
                                        Integration::DepthBufferAvailable::TRUE,
                                        Integration::StencilBufferAvailable::TRUE,
@@ -141,19 +139,24 @@ TestRenderController& TestApplication::GetRenderController()
   return mRenderController;
 }
 
+TestGraphicsController& TestApplication::GetGraphicsController()
+{
+  return mGraphicsController;
+}
+
 TestGlAbstraction& TestApplication::GetGlAbstraction()
 {
-  return mGlAbstraction;
+  return static_cast<TestGlAbstraction&>(mGraphicsController.GetGlAbstraction());
 }
 
 TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction()
 {
-  return mGlSyncAbstraction;
+  return static_cast<TestGlSyncAbstraction&>(mGraphicsController.GetGlSyncAbstraction());
 }
 
 TestGlContextHelperAbstraction& TestApplication::GetGlContextHelperAbstraction()
 {
-  return mGlContextHelperAbstraction;
+  return static_cast<TestGlContextHelperAbstraction&>(mGraphicsController.GetGlContextHelperAbstraction());
 }
 
 void TestApplication::ProcessEvent(const Integration::Event& event)
@@ -262,7 +265,7 @@ bool TestApplication::RenderOnly()
 void TestApplication::ResetContext()
 {
   mCore->ContextDestroyed();
-  mGlAbstraction.Initialize();
+  mGraphicsController.Initialize();
   mCore->ContextCreated();
 }
 
index 7362505..e7d8c76 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_APPLICATION_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
 #include <dali/integration-api/resource-policies.h>
 #include <dali/integration-api/scene.h>
 #include <dali/integration-api/trace.h>
+
 #include <dali/public-api/common/dali-common.h>
 #include <test-platform-abstraction.h>
 
-#include "test-gl-abstraction.h"
-#include "test-gl-context-helper-abstraction.h"
-#include "test-gl-sync-abstraction.h"
+#include "test-graphics-controller.h"
 #include "test-render-controller.h"
 
 namespace Dali
@@ -58,27 +57,30 @@ public:
   void CreateScene();
   void InitializeCore();
   ~TestApplication() override;
-  static void                     LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
-  static void                     LogContext(bool start, const char* tag);
-  Dali::Integration::Core&        GetCore();
-  TestPlatformAbstraction&        GetPlatform();
-  TestRenderController&           GetRenderController();
+  static void              LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
+  static void              LogContext(bool start, const char* tag);
+  Dali::Integration::Core& GetCore();
+  TestPlatformAbstraction& GetPlatform();
+  TestRenderController&    GetRenderController();
+  TestGraphicsController&  GetGraphicsController();
+
   TestGlAbstraction&              GetGlAbstraction();
   TestGlSyncAbstraction&          GetGlSyncAbstraction();
   TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
-  void                            ProcessEvent(const Integration::Event& event);
-  void                            SendNotification();
-  bool                            Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
-  bool                            PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
-  bool                            RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
-  uint32_t                        GetUpdateStatus();
-  bool                            UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
-  bool                            RenderOnly();
-  void                            ResetContext();
-  bool                            GetRenderNeedsUpdate();
-  bool                            GetRenderNeedsPostRender();
-  uint32_t                        Wait(uint32_t durationToWait);
-  static void                     EnableLogging(bool enabled)
+
+  void        ProcessEvent(const Integration::Event& event);
+  void        SendNotification();
+  bool        Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
+  bool        PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
+  bool        RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
+  uint32_t    GetUpdateStatus();
+  bool        UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
+  bool        RenderOnly();
+  void        ResetContext();
+  bool        GetRenderNeedsUpdate();
+  bool        GetRenderNeedsPostRender();
+  uint32_t    Wait(uint32_t durationToWait);
+  static void EnableLogging(bool enabled)
   {
     mLoggingEnabled = enabled;
   }
@@ -92,11 +94,9 @@ private:
   void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
 
 protected:
-  TestPlatformAbstraction        mPlatformAbstraction;
-  TestRenderController           mRenderController;
-  TestGlAbstraction              mGlAbstraction;
-  TestGlSyncAbstraction          mGlSyncAbstraction;
-  TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+  TestPlatformAbstraction mPlatformAbstraction;
+  TestRenderController    mRenderController;
+  TestGraphicsController  mGraphicsController;
 
   Integration::UpdateStatus mStatus;
   Integration::RenderStatus mRenderStatus;
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h
new file mode 100644 (file)
index 0000000..f5ab764
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef TEST_GRAPHICS_CONTROLLER_H
+#define TEST_GRAPHICS_CONTROLLER_H
+
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#include <dali/graphics-api/graphics-controller.h>
+#include "test-gl-abstraction.h"
+#include "test-gl-context-helper-abstraction.h"
+#include "test-gl-sync-abstraction.h"
+
+namespace Dali
+{
+class TestGraphicsController : public Dali::Graphics::Controller
+{
+public:
+  TestGraphicsController()          = default;
+  virtual ~TestGraphicsController() = default;
+
+  void Initialize()
+  {
+    mGlAbstraction.Initialize();
+  }
+
+  Integration::GlAbstraction& GetGlAbstraction() override
+  {
+    return mGlAbstraction;
+  }
+
+  Integration::GlSyncAbstraction& GetGlSyncAbstraction() override
+  {
+    return mGlSyncAbstraction;
+  }
+
+  Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override
+  {
+    return mGlContextHelperAbstraction;
+  }
+
+private:
+  TestGlAbstraction              mGlAbstraction;
+  TestGlSyncAbstraction          mGlSyncAbstraction;
+  TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+};
+
+} // namespace Dali
+
+#endif //TEST_GRAPHICS_CONTROLLER_H
index b53630d..587d4a5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
 #include <sys/wait.h>
 #include <testcase.h>
 
-#include <time.h>
+#include <getopt.h>
 #include <unistd.h>
-
+#include <algorithm>
 #include <chrono>
+#include <cstdlib>
 #include <cstring>
+#include <ctime>
+#include <fstream>
 #include <map>
+#include <sstream>
 #include <vector>
 
+using std::chrono::steady_clock;
+using std::chrono::system_clock;
+
 namespace TestHarness
 {
 typedef std::map<int32_t, TestCase> RunningTestCases;
@@ -48,18 +55,185 @@ const char* basename(const char* path)
   return slash;
 }
 
-void SuppressLogOutput()
+std::vector<std::string> Split(const std::string& aString, char delimiter)
 {
-  // Close stdout and stderr to suppress the log output
-  close(STDOUT_FILENO); // File descriptor number for stdout is 1
-  close(STDERR_FILENO); // File descriptor number for stderr is 2
+  std::vector<std::string> tokens;
+  std::string              token;
+  std::istringstream       tokenStream(aString);
+  while(std::getline(tokenStream, token, delimiter))
+  {
+    tokens.push_back(token);
+  }
+  return tokens;
+}
 
-  // The POSIX specification requires that /dev/null must be provided,
-  // The open function always chooses the lowest unused file descriptor
-  // It is sufficient for stdout to be writable.
-  open("/dev/null", O_WRONLY); // Redirect file descriptor number 1 (i.e. stdout) to /dev/null
-  // When stderr is opened it must be both readable and writable.
-  open("/dev/null", O_RDWR); // Redirect file descriptor number 2 (i.e. stderr) to /dev/null
+std::string Join(const std::vector<std::string>& tokens, char delimiter)
+{
+  std::ostringstream oss;
+
+  unsigned int delimiterCount = 0;
+  for(auto& token : tokens)
+  {
+    oss << token;
+    if(delimiterCount < tokens.size() - 1)
+    {
+      oss << delimiter;
+    }
+    ++delimiterCount;
+  }
+  return oss.str();
+}
+
+std::string ChildOutputFilename(int pid)
+{
+  std::ostringstream os;
+  os << "/tmp/tct-child." << pid;
+  return os.str();
+}
+
+std::string TestModuleFilename(const char* processName)
+{
+  auto pathComponents = Split(processName, '/');
+  auto aModule        = pathComponents.back();
+  aModule += "-tests.xml";
+  return aModule;
+}
+
+std::string TestModuleName(const char* processName)
+{
+  auto pathComponents   = Split(processName, '/');
+  auto aModule          = pathComponents.back();
+  auto moduleComponents = Split(aModule, '-');
+
+  moduleComponents[1][0] = std::toupper(moduleComponents[1][0]);
+  moduleComponents[2][0] = std::toupper(moduleComponents[2][0]);
+
+  std::ostringstream oss;
+  for(unsigned int i = 1; i < moduleComponents.size() - 1; ++i) // [0]=tct, [n-1]=core
+  {
+    oss << moduleComponents[i];
+
+    if(i > 1 && i < moduleComponents.size() - 2) // skip first and last delimiter
+    {
+      oss << '-';
+    }
+  }
+
+  return oss.str();
+}
+
+std::string ReadAndEscape(std::string filename)
+{
+  std::ostringstream os;
+  std::ifstream      ifs;
+  ifs.open(filename, std::ifstream::in);
+  while(ifs.good())
+  {
+    std::string line;
+    std::getline(ifs, line);
+    for(auto c : line)
+    {
+      switch(c)
+      {
+        case '<':
+          os << "&lt;";
+          break;
+        case '>':
+          os << "&gt;";
+          break;
+        case '&':
+          os << "&amp;";
+          break;
+        default:
+          os << c;
+          break;
+      }
+    }
+    os << "\\"
+       << "n";
+  }
+  ifs.close();
+  return os.str();
+}
+
+void OutputTestResult(
+  std::ofstream& ofs,
+  const char*    pathToExecutable,
+  std::string    testSuiteName,
+  TestCase&      testCase,
+  std::string    startTime,
+  std::string    endTime)
+{
+  std::string outputFilename = ChildOutputFilename(testCase.childPid);
+  std::string testOutput     = ReadAndEscape(outputFilename);
+
+  ofs << "<testcase component=\"CoreAPI/" << testSuiteName << "/default\" execution_type=\"auto\" id=\""
+      << testCase.name << "\" purpose=\"\" result=\"" << (testCase.result == 0 ? "PASS" : "FAIL") << "\">" << std::endl
+      << "<description><test_script_entry test_script_expected_result=\"0\">"
+      << pathToExecutable << testCase.name << "</test_script_entry>" << std::endl
+      << "</description>"
+      << "<result_info><actual_result>" << (testCase.result == 0 ? "PASS" : "FAIL") << "</actual_result>" << std::endl
+      << "<start>" << startTime << "</start>"
+      << "<end>" << endTime << "</end>"
+      << "<stdout><![CDATA[]]></stdout>"
+      << "<stderr><![CDATA[" << testOutput << "]]></stderr></result_info></testcase>" << std::endl;
+
+  unlink(outputFilename.c_str());
+}
+
+void OutputTestResults(const char* processName, RunningTestCases& children)
+{
+  std::ofstream ofs;
+  std::string   filename   = TestModuleFilename(processName);
+  std::string   moduleName = TestModuleName(processName);
+  ofs.open(filename, std::ofstream::out | std::ofstream::app);
+
+  // Sort completed cases by original test case id
+  std::vector<TestCase> childTestCases;
+  childTestCases.reserve(children.size());
+  for(auto& element : children) childTestCases.push_back(element.second);
+  std::sort(childTestCases.begin(), childTestCases.end(), [](const TestCase& a, const TestCase& b) {
+    return a.testCase < b.testCase;
+  });
+
+  const int BUFSIZE = 256;
+  char      buffer[BUFSIZE];
+  for(auto& testCase : childTestCases)
+  {
+    auto tt = system_clock::to_time_t(testCase.startSystemTime);
+    strftime(buffer, BUFSIZE, "%c", localtime(&tt));
+    std::string startTime(buffer);
+    OutputTestResult(ofs, processName, moduleName, testCase, startTime, startTime);
+  }
+
+  ofs.close();
+}
+
+void OutputStatistics(const char* processName, int32_t numPasses, int32_t numFailures)
+{
+  FILE* fp = fopen("summary.xml", "a");
+  if(fp != NULL)
+  {
+    fprintf(fp,
+            "  <suite name=\"%s-tests\">\n"
+            "    <total_case>%d</total_case>\n"
+            "    <pass_case>%d</pass_case>\n"
+            "    <pass_rate>%5.2f</pass_rate>\n"
+            "    <fail_case>%d</fail_case>\n"
+            "    <fail_rate>%5.2f</fail_rate>\n"
+            "    <block_case>0</block_case>\n"
+            "    <block_rate>0.00</block_rate>\n"
+            "    <na_case>0</na_case>\n"
+            "    <na_rate>0.00</na_rate>\n"
+            "  </suite>\n",
+            basename(processName),
+            numPasses + numFailures,
+            numPasses,
+            (float)numPasses * 100.0f / (numPasses + numFailures),
+            numFailures,
+            (float)numFailures * 100.0f / (numPasses + numFailures));
+    fclose(fp);
+  }
 }
 
 int32_t RunTestCase(struct ::testcase_s& testCase)
@@ -89,35 +263,55 @@ int32_t RunTestCase(struct ::testcase_s& testCase)
   return result;
 }
 
-int32_t RunTestCaseInChildProcess(struct ::testcase_s& testCase, bool suppressOutput)
+int32_t RunTestCaseRedirectOutput(TestCase& testCase, bool suppressOutput)
+{
+  // Executing in child process
+  // Close stdout and stderr to suppress the log output
+  close(STDOUT_FILENO); // File descriptor number for stdout is 1
+
+  // The POSIX specification requires that /dev/null must be provided,
+  // The open function always chooses the lowest unused file descriptor
+  // It is sufficient for stdout to be writable.
+  open("/dev/null", O_WRONLY); // Redirect file descriptor number 1 (i.e. stdout) to /dev/null
+
+  fflush(stderr);
+  close(STDERR_FILENO);
+  if(suppressOutput)
+  {
+    stderr = fopen("/dev/null", "w+"); // Redirect fd 2 to /dev/null
+  }
+  else
+  {
+    // When stderr is opened it must be both readable and writable.
+    std::string childOutputFilename = ChildOutputFilename(getpid());
+    stderr                          = fopen(childOutputFilename.c_str(), "w+");
+  }
+
+  int32_t status = RunTestCase(*testCase.tctPtr);
+
+  fflush(stderr);
+  fclose(stderr);
+
+  return status;
+}
+
+int32_t RunTestCaseInChildProcess(TestCase& testCase, bool redirect)
 {
   int32_t testResult = EXIT_STATUS_TESTCASE_FAILED;
 
   int32_t pid = fork();
   if(pid == 0) // Child process
   {
-    if(suppressOutput)
+    if(redirect)
     {
-      SuppressLogOutput();
+      int status = RunTestCaseRedirectOutput(testCase, false);
+      exit(status);
     }
     else
     {
-      printf("\n");
-      for(int32_t i = 0; i < 80; ++i) printf("#");
-      printf("\nTC: %s\n", testCase.name);
-      fflush(stdout);
+      int status = RunTestCase(*testCase.tctPtr);
+      exit(status);
     }
-
-    int32_t status = RunTestCase(testCase);
-
-    if(!suppressOutput)
-    {
-      fflush(stdout);
-      fflush(stderr);
-      fclose(stdout);
-      fclose(stderr);
-    }
-    exit(status);
   }
   else if(pid == -1)
   {
@@ -126,8 +320,9 @@ int32_t RunTestCaseInChildProcess(struct ::testcase_s& testCase, bool suppressOu
   }
   else // Parent process
   {
-    int32_t status   = 0;
-    int32_t childPid = waitpid(pid, &status, 0);
+    int32_t status    = 0;
+    int32_t childPid  = waitpid(pid, &status, 0);
+    testCase.childPid = childPid;
     if(childPid == -1)
     {
       perror("waitpid");
@@ -167,43 +362,32 @@ int32_t RunTestCaseInChildProcess(struct ::testcase_s& testCase, bool suppressOu
   return testResult;
 }
 
-void OutputStatistics(const char* processName, int32_t numPasses, int32_t numFailures)
+int32_t RunAll(const char* processName, ::testcase tc_array[], bool quiet)
 {
-  FILE* fp = fopen("summary.xml", "a");
-  if(fp != NULL)
+  int32_t       numFailures = 0;
+  int32_t       numPasses   = 0;
+  std::ofstream ofs;
+  std::string   filename   = TestModuleFilename(processName);
+  std::string   moduleName = TestModuleName(processName);
+  ofs.open(filename, std::ofstream::out | std::ofstream::app);
+  const int BUFSIZE = 256;
+  char      buffer[BUFSIZE];
+
+  // Run test cases in child process( to handle signals ), but run serially.
+  for(uint32_t i = 0; tc_array[i].name; i++)
   {
-    fprintf(fp,
-            "  <suite name=\"%s\">\n"
-            "    <total_case>%d</total_case>\n"
-            "    <pass_case>%d</pass_case>\n"
-            "    <pass_rate>%5.2f</pass_rate>\n"
-            "    <fail_case>%d</fail_case>\n"
-            "    <fail_rate>%5.2f</fail_rate>\n"
-            "    <block_case>0</block_case>\n"
-            "    <block_rate>0.00</block_rate>\n"
-            "    <na_case>0</na_case>\n"
-            "    <na_rate>0.00</na_rate>\n"
-            "  </suite>\n",
-            basename(processName),
-            numPasses + numFailures,
-            numPasses,
-            (float)numPasses / (numPasses + numFailures),
-            numFailures,
-            (float)numFailures / (numPasses + numFailures));
-    fclose(fp);
-  }
-}
+    auto tt = system_clock::to_time_t(system_clock::now());
+    strftime(buffer, BUFSIZE, "%c", localtime(&tt));
+    std::string startTime(buffer);
 
-int32_t RunAll(const char* processName, ::testcase tc_array[])
-{
-  int32_t numFailures = 0;
-  int32_t numPasses   = 0;
+    TestCase testCase(i, &tc_array[i]);
+    testCase.result = RunTestCaseInChildProcess(testCase, quiet);
 
-  // Run test cases in child process( to kill output/handle signals ), but run serially.
-  for(uint32_t i = 0; tc_array[i].name; i++)
-  {
-    int32_t result = RunTestCaseInChildProcess(tc_array[i], false);
-    if(result == 0)
+    tt = system_clock::to_time_t(system_clock::now());
+    strftime(buffer, BUFSIZE, "%c", localtime(&tt));
+    std::string endTime(buffer);
+
+    if(testCase.result == 0)
     {
       numPasses++;
     }
@@ -211,7 +395,12 @@ int32_t RunAll(const char* processName, ::testcase tc_array[])
     {
       numFailures++;
     }
+    if(!quiet)
+    {
+      OutputTestResult(ofs, processName, moduleName, testCase, startTime, endTime);
+    }
   }
+  ofs.close();
 
   OutputStatistics(processName, numPasses, numFailures);
 
@@ -219,7 +408,7 @@ int32_t RunAll(const char* processName, ::testcase tc_array[])
 }
 
 // Constantly runs up to MAX_NUM_CHILDREN processes
-int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool reRunFailed)
+int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool reRunFailed, bool quiet)
 {
   int32_t numFailures = 0;
   int32_t numPasses   = 0;
@@ -241,8 +430,9 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
       int32_t pid = fork();
       if(pid == 0) // Child process
       {
-        SuppressLogOutput();
-        exit(RunTestCase(tc_array[nextTestCase]));
+        TestCase testCase(nextTestCase, &tc_array[nextTestCase]);
+        int      status = RunTestCaseRedirectOutput(testCase, quiet);
+        exit(status);
       }
       else if(pid == -1)
       {
@@ -252,7 +442,9 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
       else // Parent process
       {
         TestCase tc(nextTestCase, tc_array[nextTestCase].name);
-        tc.startTime = std::chrono::steady_clock::now();
+        tc.startTime       = steady_clock::now();
+        tc.startSystemTime = system_clock::now();
+        tc.childPid        = pid;
 
         children[pid] = tc;
         nextTestCase++;
@@ -289,11 +481,12 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
     {
       if(WIFEXITED(status))
       {
-        int32_t testResult = WEXITSTATUS(status);
-        if(testResult)
+        auto& testCase  = children[childPid];
+        testCase.result = WEXITSTATUS(status);
+        if(testCase.result)
         {
-          printf("Test case %s failed: %d\n", children[childPid].testCaseName, testResult);
-          failedTestCases.push_back(children[childPid].testCase);
+          printf("Test case %s failed: %d\n", testCase.name, testCase.result);
+          failedTestCases.push_back(testCase.testCase);
           numFailures++;
         }
         else
@@ -310,7 +503,8 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
         RunningTestCases::iterator iter = children.find(childPid);
         if(iter != children.end())
         {
-          printf("Test case %s exited with signal %s\n", iter->second.testCaseName, strsignal(status));
+          printf("Test case %s exited with signal %s\n", iter->second.name, strsignal(status));
+          iter->second.result = 1;
           failedTestCases.push_back(iter->second.testCase);
         }
         else
@@ -324,6 +518,11 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
     }
   }
 
+  if(!quiet)
+  {
+    OutputTestResults(processName, children);
+  }
+
   OutputStatistics(processName, numPasses, numFailures);
 
   if(reRunFailed)
@@ -338,7 +537,9 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
         printf("=");
       }
       printf("\n");
-      RunTestCaseInChildProcess(tc_array[failedTestCases[i]], false);
+      int      index = failedTestCases[i];
+      TestCase testCase(index, &tc_array[index]);
+      RunTestCaseInChildProcess(testCase, false);
     }
   }
 
@@ -368,11 +569,62 @@ void Usage(const char* program)
     "   %s <testcase name>\t\t Execute a test case\n"
     "   %s \t\t Execute all test cases in parallel\n"
     "   %s -r\t\t Execute all test cases in parallel, rerunning failed test cases\n"
-    "   %s -s\t\t Execute all test cases serially\n",
+    "   %s -s\t\t Execute all test cases serially\n"
+    "   %s -q\t\t Run without output\n",
+    program,
     program,
     program,
     program,
     program);
 }
 
+int RunTests(int argc, char* const argv[], ::testcase tc_array[])
+{
+  int         result    = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
+  const char* optString = "sfq";
+  bool        optRerunFailed(true);
+  bool        optRunSerially(false);
+  bool        optQuiet(false);
+
+  int nextOpt = 0;
+  do
+  {
+    nextOpt = getopt(argc, argv, optString);
+    switch(nextOpt)
+    {
+      case 'f':
+        optRerunFailed = false;
+        break;
+      case 's':
+        optRunSerially = true;
+        break;
+      case 'q':
+        optQuiet = true;
+        break;
+      case '?':
+        TestHarness::Usage(argv[0]);
+        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
+        break;
+    }
+  } while(nextOpt != -1);
+
+  if(optind == argc) // no testcase name in argument list
+  {
+    if(optRunSerially)
+    {
+      result = TestHarness::RunAll(argv[0], tc_array, optQuiet);
+    }
+    else
+    {
+      result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed, optQuiet);
+    }
+  }
+  else
+  {
+    // optind is index of next argument - interpret as testcase name
+    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
+  }
+  return result;
+}
+
 } // namespace TestHarness
index b210918..554846f 100644 (file)
@@ -41,33 +41,63 @@ const int32_t MAX_NUM_CHILDREN(16);
 struct TestCase
 {
   int32_t                               testCase;
-  const char*                           testCaseName;
+  const char*                           name;
   std::chrono::steady_clock::time_point startTime;
+  std::chrono::system_clock::time_point startSystemTime;
+  int32_t                               result;
+  pid_t                                 childPid{0};
+  testcase*                             tctPtr;
 
+  TestCase(int32_t index, testcase* testCase)
+  : testCase(index),
+    name(testCase->name),
+    startTime(),
+    startSystemTime(),
+    result(0),
+    childPid(0),
+    tctPtr(testCase)
+  {
+  }
   TestCase()
   : testCase(0),
-    testCaseName(NULL),
-    startTime()
+    name(NULL),
+    startTime(),
+    startSystemTime(),
+    result(0),
+    childPid(0),
+    tctPtr(nullptr)
   {
   }
 
   TestCase(int32_t tc, const char* name)
   : testCase(tc),
-    testCaseName(name),
-    startTime()
+    name(name),
+    startTime(),
+    startSystemTime(),
+    result(0),
+    childPid(0),
+    tctPtr(nullptr)
   {
   }
   TestCase(const TestCase& rhs)
   : testCase(rhs.testCase),
-    testCaseName(rhs.testCaseName),
-    startTime(rhs.startTime)
+    name(rhs.name),
+    startTime(rhs.startTime),
+    startSystemTime(rhs.startSystemTime),
+    result(rhs.result),
+    childPid(rhs.childPid),
+    tctPtr(rhs.tctPtr)
   {
   }
   TestCase& operator=(const TestCase& rhs)
   {
-    testCase     = rhs.testCase;
-    testCaseName = rhs.testCaseName;
-    startTime    = rhs.startTime;
+    testCase        = rhs.testCase;
+    name            = rhs.name;
+    startTime       = rhs.startTime;
+    startSystemTime = rhs.startSystemTime;
+    result          = rhs.result;
+    childPid        = rhs.childPid;
+    tctPtr          = rhs.tctPtr;
     return *this;
   }
 };
@@ -109,6 +139,14 @@ int32_t FindAndRunTestCase(::testcase tc_array[], const char* testCaseName);
  */
 void Usage(const char* program);
 
+/**
+ * Main function.
+ * @param[in] argc Argument count
+ * @param[in] argv Argument vector
+ * @param[in] tc_array Array of test cases
+ */
+int RunTests(int argc, char* const argv[], ::testcase tc_array[]);
+
 } // namespace TestHarness
 
 #endif
index 81b03dd..d6419ff 100755 (executable)
 #include "toolkit-timer.h"
 
 #include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
+#include <dali/public-api/images/pixel-data.h>
 #include <dali/public-api/object/any.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/adaptor-framework/native-image-source.h>
@@ -58,6 +64,228 @@ static void DisconnectFromGlobalSignal( bool (*func)() )
 }
 }
 
+class MockWebEngineContext : public Dali::WebEngineContext
+{
+public:
+  MockWebEngineContext()
+    : mockModel( Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER )
+  {
+  }
+
+  Dali::WebEngineContext::CacheModel GetCacheModel() const override
+  {
+    return mockModel;
+  }
+
+  void SetCacheModel( Dali::WebEngineContext::CacheModel cacheModel ) override
+  {
+    mockModel = cacheModel;
+  }
+
+  void SetProxyUri( const std::string& uri ) override
+  {
+  }
+
+  void SetDefaultProxyAuth( const std::string& username, const std::string& password ) override
+  {
+  }
+
+  void SetCertificateFilePath( const std::string& certificatePath ) override
+  {
+  }
+
+  void DeleteWebDatabase() override
+  {
+  }
+
+  void DeleteWebStorage() override
+  {
+  }
+
+  void DeleteLocalFileSystem() override
+  {
+  }
+
+  void DisableCache( bool cacheDisabled ) override
+  {
+  }
+
+  void ClearCache() override
+  {
+  }
+
+private:
+  Dali::WebEngineContext::CacheModel mockModel;
+};
+
+class MockWebEngineCookieManager : public Dali::WebEngineCookieManager
+{
+public:
+  MockWebEngineCookieManager()
+    : mockCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY )
+  {
+  }
+
+  void SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy policy ) override
+  {
+    mockCookieAcceptPolicy = policy;
+  }
+
+  Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const override
+  {
+    return mockCookieAcceptPolicy;
+  }
+
+  void ClearCookies() override
+  {
+  }
+
+  void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ) override
+  {
+  }
+
+private:
+  Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy;
+};
+
+class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem
+{
+public:
+  MockWebEngineBackForwardListItem()
+    : mockUrl( "http://url" ),
+      mockTitle( "title" ),
+      mockOriginalUrl( "http://originalurl" )
+  {
+  }
+
+  std::string GetUrl() const override
+  {
+    return mockUrl;
+  }
+
+  std::string GetTitle() const override
+  {
+    return mockTitle;
+  }
+
+  std::string GetOriginalUrl() const override
+  {
+    return mockOriginalUrl;
+  }
+
+private:
+  std::string mockUrl;
+  std::string mockTitle;
+  std::string mockOriginalUrl;
+};
+
+class MockWebEngineBackForwardList : public Dali::WebEngineBackForwardList
+{
+public:
+  MockWebEngineBackForwardList( )
+    : mockItem(),
+      pMockItem( &mockItem )
+  {
+  }
+
+  Dali::WebEngineBackForwardListItem& GetCurrentItem() const override
+  {
+    return *pMockItem;
+  }
+
+  Dali::WebEngineBackForwardListItem& GetItemAtIndex( uint32_t index ) const override
+  {
+    return *pMockItem;
+  }
+
+  uint32_t GetItemCount() const override
+  {
+    return 1;
+  }
+
+private:
+  MockWebEngineBackForwardListItem mockItem;
+  WebEngineBackForwardListItem* pMockItem;
+};
+
+class MockWebEngineSettings : public WebEngineSettings
+{
+public:
+  MockWebEngineSettings()
+    : mockDefaultFontSize( 16 ),
+      mockJavaScriptEnabled( true ),
+      mockImageLoadedAutomatically( true ),
+      mockDefaultTextEncodingName()
+  {
+  }
+
+  uint32_t GetDefaultFontSize() const override
+  {
+    return mockDefaultFontSize;
+  }
+
+  void SetDefaultFontSize( uint32_t size ) override
+  {
+    mockDefaultFontSize = size;
+  }
+
+  bool IsJavaScriptEnabled() const override
+  {
+    return mockJavaScriptEnabled;
+  }
+
+  void EnableJavaScript( bool enabled ) override
+  {
+    mockJavaScriptEnabled = enabled;
+  }
+
+  bool AreImagesLoadedAutomatically() const override
+  {
+    return mockImageLoadedAutomatically;
+  }
+
+  void AllowImagesLoadAutomatically( bool automatic ) override
+  {
+    mockImageLoadedAutomatically = automatic;
+  }
+
+  std::string GetDefaultTextEncodingName() const override
+  {
+    return mockDefaultTextEncodingName;
+  }
+
+  void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) override
+  {
+    mockDefaultTextEncodingName = defaultTextEncodingName;
+  }
+
+  void AllowMixedContents( bool allowed ) override
+  {
+  }
+
+  void EnableSpatialNavigation( bool enabled ) override
+  {
+  }
+
+  void EnableWebSecurity( bool enabled ) override
+  {
+  }
+
+  void AllowFileAccessFromExternalUrl( bool allowed ) override
+  {
+  }
+
+  void AllowScriptsOpenWindows( bool allowed ) override
+  {
+  }
+
+private:
+  int mockDefaultFontSize;
+  bool mockJavaScriptEnabled;
+  bool mockImageLoadedAutomatically;
+  std::string mockDefaultTextEncodingName;
+};
+
 class WebEngine: public Dali::BaseObject
 {
 public:
@@ -65,17 +293,19 @@ public:
   WebEngine()
     : mUrl()
     , mCurrentPlusOnePos( 0 )
-    , mCacheModel( Dali::WebEnginePlugin::CacheModel::DOCUMENT_VIEWER )
-    , mCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy::NO_THIRD_PARTY )
     , mUserAgent()
-    , mEnableJavaScript( true )
-    , mLoadImagesAutomatically( true )
-    , mDefaultTextEncodingName()
-    , mDefaultFontSize( 16 )
     , mEvaluating( false )
+    , mScrollPosition( 0, 0 )
+    , mScrollSize( 500, 500 )
+    , mContentSize( 500, 500 )
   {
     gInstanceCount++;
     gInstance = this;
+
+    mockWebEngineSettings = new MockWebEngineSettings();
+    mockWebEngineContext = new MockWebEngineContext();
+    mockWebEngineCookieManager = new MockWebEngineCookieManager();
+    mockWebEngineBackForwardList = new MockWebEngineBackForwardList();
   }
 
   virtual ~WebEngine()
@@ -85,6 +315,31 @@ public:
     {
       gInstance = NULL;
     }
+
+    delete mockWebEngineSettings;
+    delete mockWebEngineContext;
+    delete mockWebEngineCookieManager;
+    delete mockWebEngineBackForwardList;
+  }
+
+  Dali::WebEngineSettings& GetSettings() const
+  {
+    return *mockWebEngineSettings;
+  }
+
+  Dali::WebEngineContext& GetContext() const
+  {
+    return *mockWebEngineContext;
+  }
+
+  Dali::WebEngineCookieManager& GetCookieManager() const
+  {
+    return *mockWebEngineCookieManager;
+  }
+
+  Dali::WebEngineBackForwardList& GetBackForwardList() const
+  {
+    return *mockWebEngineBackForwardList;
   }
 
   void LoadUrl( const std::string& url )
@@ -98,6 +353,37 @@ public:
     return mUrl;
   }
 
+  std::string GetTitle() const
+  {
+    return std::string("title");
+  }
+
+  Dali::PixelData GetFavicon() const
+  {
+    uint8_t* faviconData = new uint8_t[ 16 ];
+
+    faviconData[ 0 ] = 0xff;
+    faviconData[ 1 ] = 0x00;
+    faviconData[ 2 ] = 0x00;
+    faviconData[ 3 ] = 0xff;
+    faviconData[ 4 ] = 0xff;
+    faviconData[ 5 ] = 0x00;
+    faviconData[ 6 ] = 0x00;
+    faviconData[ 7 ] = 0xff;
+    faviconData[ 8 ] = 0xff;
+    faviconData[ 9 ] = 0x00;
+    faviconData[ 10 ] = 0x00;
+    faviconData[ 11 ] = 0xff;
+    faviconData[ 12 ] = 0xff;
+    faviconData[ 13 ] = 0x00;
+    faviconData[ 14 ] = 0x00;
+    faviconData[ 15 ] = 0xff;
+
+    return Dali::PixelData::New( faviconData, 16, 2, 2,
+                                 Dali::Pixel::Format::RGBA8888,
+                                 Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+  }
+
   bool CanGoForward() const
   {
     return mHistory.size() > mCurrentPlusOnePos;
@@ -135,26 +421,6 @@ public:
     ConnectToGlobalSignal( &OnClearHistory );
   }
 
-  Dali::WebEnginePlugin::CacheModel GetCacheModel() const
-  {
-    return mCacheModel;
-  }
-
-  void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
-  {
-    mCacheModel = cacheModel;
-  }
-
-  Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const
-  {
-    return mCookieAcceptPolicy;
-  }
-
-  void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
-  {
-    mCookieAcceptPolicy = policy;
-  }
-
   const std::string& GetUserAgent() const
   {
     return mUserAgent;
@@ -165,44 +431,34 @@ public:
     mUserAgent = userAgent;
   }
 
-  bool IsJavaScriptEnabled() const
-  {
-    return mEnableJavaScript;
-  }
-
-  void EnableJavaScript( bool enabled )
-  {
-    mEnableJavaScript = enabled;
-  }
-
-  bool AreImagesAutomaticallyLoaded() const
+  void ScrollBy( int dx, int dy )
   {
-    return mLoadImagesAutomatically;
-  }
-
-  void LoadImagesAutomatically( bool automatic )
-  {
-    mLoadImagesAutomatically = automatic;
+    mScrollPosition += Dali::Vector2( dx, dy );
+    if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
+    {
+      gInstance->mScrollEdgeReachedSignal.Emit( Dali::WebEnginePlugin::ScrollEdge::BOTTOM );
+    }
   }
 
-  const std::string& GetDefaultTextEncodingName() const
+  void SetScrollPosition( int x, int y )
   {
-    return mDefaultTextEncodingName;
+    mScrollPosition.x = x;
+    mScrollPosition.y = y;
   }
 
-  void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+  Dali::Vector2 GetScrollPosition() const
   {
-    mDefaultTextEncodingName = defaultTextEncodingName;
+    return mScrollPosition;
   }
 
-  int GetDefaultFontSize() const
+  Dali::Vector2 GetScrollSize() const
   {
-    return mDefaultFontSize;
+    return mScrollSize;
   }
 
-  void SetDefaultFontSize( int defaultFontSize )
+  Dali::Vector2 GetContentSize() const
   {
-    mDefaultFontSize = defaultFontSize;
+    return  mContentSize;
   }
 
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
@@ -220,21 +476,29 @@ public:
     return mPageLoadErrorSignal;
   }
 
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
+  {
+    return mScrollEdgeReachedSignal;
+  }
+
   std::string                                                mUrl;
   std::vector< std::string >                                 mHistory;
   size_t                                                     mCurrentPlusOnePos;
-  Dali::WebEnginePlugin::CacheModel                          mCacheModel;
-  Dali::WebEnginePlugin::CookieAcceptPolicy                  mCookieAcceptPolicy;
   std::string                                                mUserAgent;
-  bool                                                       mEnableJavaScript;
-  bool                                                       mLoadImagesAutomatically;
-  std::string                                                mDefaultTextEncodingName;
-  int                                                        mDefaultFontSize;
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType         mPageLoadStartedSignal;
   Dali::WebEnginePlugin::WebEnginePageLoadSignalType         mPageLoadFinishedSignal;
   Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType    mPageLoadErrorSignal;
   std::vector< std::function< void( const std::string& ) > > mResultCallbacks;
   bool                                                       mEvaluating;
+
+  Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+  Dali::Vector2                                               mScrollPosition;
+  Dali::Vector2                                               mScrollSize;
+  Dali::Vector2                                               mContentSize;
+  WebEngineBackForwardList*                                   mockWebEngineBackForwardList;
+  WebEngineContext*                                           mockWebEngineContext;
+  WebEngineCookieManager*                                     mockWebEngineCookieManager;
+  WebEngineSettings*                                          mockWebEngineSettings;
 };
 
 inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
@@ -369,15 +633,49 @@ void WebEngine::Create( int width, int height, const std::string& locale, const
 {
 }
 
+void WebEngine::Create( int width, int height, int argc, char** argv )
+{
+}
+
 void WebEngine::Destroy()
 {
 }
 
+WebEngineSettings& WebEngine::GetSettings() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetSettings();
+}
+
+WebEngineContext& WebEngine::GetContext() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetContext();
+}
+
+WebEngineCookieManager& WebEngine::GetCookieManager() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetCookieManager();
+}
+
+WebEngineBackForwardList& WebEngine::GetBackForwardList() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetBackForwardList();
+}
+
 void WebEngine::LoadUrl( const std::string& url )
 {
   return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
 }
 
+std::string WebEngine::GetTitle() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetTitle();
+}
+
+Dali::PixelData WebEngine::GetFavicon() const
+{
+  return Internal::Adaptor::GetImplementation( *this ).GetFavicon();
+}
+
 const std::string& WebEngine::GetUrl()
 {
   return Internal::Adaptor::GetImplementation( *this ).GetUrl();
@@ -390,7 +688,7 @@ NativeImageInterfacePtr WebEngine::GetNativeImageSource()
   return sourcePtr;
 }
 
-void WebEngine::LoadHTMLString( const std::string& htmlString )
+void WebEngine::LoadHtmlString( const std::string& htmlString )
 {
 }
 
@@ -439,37 +737,13 @@ void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectNam
 {
 }
 
-void WebEngine::ClearHistory()
-{
-  Internal::Adaptor::GetImplementation( *this ).ClearHistory();
-}
-
-void WebEngine::ClearCache()
+void WebEngine::ClearAllTilesResources()
 {
 }
 
-void WebEngine::ClearCookies()
-{
-}
-
-Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const
-{
-  return Internal::Adaptor::GetImplementation( *this ).GetCacheModel();
-}
-
-void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
-{
-  Internal::Adaptor::GetImplementation( *this ).SetCacheModel( cacheModel );
-}
-
-Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const
-{
-  return Internal::Adaptor::GetImplementation( *this ).GetCookieAcceptPolicy();
-}
-
-void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
+void WebEngine::ClearHistory()
 {
-  Internal::Adaptor::GetImplementation( *this ).SetCookieAcceptPolicy( policy );
+  Internal::Adaptor::GetImplementation( *this ).ClearHistory();
 }
 
 const std::string& WebEngine::GetUserAgent() const
@@ -482,44 +756,29 @@ void WebEngine::SetUserAgent( const std::string& userAgent )
   Internal::Adaptor::GetImplementation( *this ).SetUserAgent( userAgent );
 }
 
-bool WebEngine::IsJavaScriptEnabled() const
+void WebEngine::ScrollBy( int dx, int dy )
 {
-  return Internal::Adaptor::GetImplementation( *this ).IsJavaScriptEnabled();
+  Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
 }
 
-void WebEngine::EnableJavaScript( bool enabled )
+void WebEngine::SetScrollPosition( int x, int y )
 {
-  Internal::Adaptor::GetImplementation( *this ).EnableJavaScript( enabled );
+  Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
 }
 
-bool WebEngine::AreImagesAutomaticallyLoaded() const
+Dali::Vector2 WebEngine::GetScrollPosition() const
 {
-  return Internal::Adaptor::GetImplementation( *this ).AreImagesAutomaticallyLoaded();
+  return Internal::Adaptor::GetImplementation( *this ).GetScrollPosition();
 }
 
-void WebEngine::LoadImagesAutomatically( bool automatic )
+Dali::Vector2 WebEngine::GetScrollSize() const
 {
-  Internal::Adaptor::GetImplementation( *this ).LoadImagesAutomatically( automatic );
+  return Internal::Adaptor::GetImplementation( *this ).GetScrollSize();
 }
 
-const std::string& WebEngine::GetDefaultTextEncodingName() const
+Dali::Vector2 WebEngine::GetContentSize() const
 {
-  return Internal::Adaptor::GetImplementation( *this ).GetDefaultTextEncodingName();
-}
-
-void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
-{
-  Internal::Adaptor::GetImplementation( *this ).SetDefaultTextEncodingName( defaultTextEncodingName );
-}
-
-int WebEngine::GetDefaultFontSize() const
-{
-  return Internal::Adaptor::GetImplementation( *this ).GetDefaultFontSize();
-}
-
-void WebEngine::SetDefaultFontSize( int defaultFontSize )
-{
-  Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize );
+  return Internal::Adaptor::GetImplementation( *this ).GetContentSize();
 }
 
 void WebEngine::SetSize( int width, int height )
@@ -536,6 +795,10 @@ bool WebEngine::SendKeyEvent( const KeyEvent& event )
   return true;
 }
 
+void WebEngine::SetFocus( bool focused )
+{
+}
+
 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
 {
   return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
@@ -551,5 +814,10 @@ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErro
   return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal();
 }
 
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+  return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeReachedSignal();
+}
+
 } // namespace Dali;
 
index 5e64bd3..6d6077b 100644 (file)
@@ -1,51 +1,7 @@
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <test-harness.h>
 #include "tct-dali-toolkit-core.h"
 
 int main(int argc, char * const argv[])
 {
-  int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
-  const char* optString = "sf";
-  bool optRerunFailed(true);
-  bool optRunSerially(false);
-
-  int nextOpt = 0;
-  do
-  {
-    nextOpt = getopt( argc, argv, optString );
-    switch(nextOpt)
-    {
-      case 'f':
-        optRerunFailed = false;
-        break;
-      case 's':
-        optRunSerially = true;
-        break;
-      case '?':
-        TestHarness::Usage(argv[0]);
-        exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
-        break;
-    }
-  } while( nextOpt != -1 );
-
-  if( optind == argc ) // no testcase name in argument list
-  {
-    if( optRunSerially )
-    {
-      result = TestHarness::RunAll( argv[0], tc_array );
-    }
-    else
-    {
-      result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
-    }
-  }
-  else
-  {
-    // optind is index of next argument - interpret as testcase name
-    result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
-  }
-  return result;
+  return TestHarness::RunTests(argc, argv, tc_array);
 }
index 90ee00e..243a73b 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
 #include "dummy-control.h"
@@ -74,7 +75,9 @@ int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
     .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
     .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
     .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
-    .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT ));
+    .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
+    .Add( DevelVisual::Property::CORNER_RADIUS, 22.2f )
+    .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE ));
 
   Property::Map resultMap;
   animatedImageVisual.CreatePropertyMap( resultMap );
@@ -87,6 +90,14 @@ int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
 
+  value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<float>(), 22.2f, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get<int>() == Visual::Transform::Policy::ABSOLUTE );
+
   // request AnimatedImageVisual with an URL
   Visual::Base animatedImageVisual2 = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
   resultMap.Clear();
@@ -107,7 +118,76 @@ int UtcDaliAnimatedImageVisualGetPropertyMap01(void)
 int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
 {
   ToolkitTestApplication application;
-  tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image" );
+  tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image with fixed cache" );
+
+  // request AnimatedImageVisual with a property map
+  VisualFactory factory = VisualFactory::Get();
+  Property::Array urls;
+  CopyUrlsIntoArray( urls );
+
+  Visual::Base animatedImageVisual = factory.CreateVisual(
+    Property::Map()
+    .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
+    .Add( "url", urls )
+    .Add( "batchSize", 4 )
+    .Add( "cacheSize", 20 )
+    .Add( "loopCount", 10 )
+    .Add( "frameDelay", 200 )
+    .Add( "pixelArea", Vector4() )
+    .Add( "wrapModeU", WrapMode::REPEAT )
+    .Add( "wrapModeV", WrapMode::DEFAULT )
+    .Add( "cornerRadius", 50.0f )
+    .Add( "cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE ));
+
+  Property::Map resultMap;
+  animatedImageVisual.CreatePropertyMap( resultMap );
+  // check the property values from the returned map from a visual
+  Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE,  Property::INTEGER );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
+
+  value = resultMap.Find( ImageVisual::Property::URL, "url" );
+  DALI_TEST_CHECK( value );
+  Property::Array* resultUrls = value->GetArray();
+  DALI_TEST_CHECK( resultUrls );
+  DALI_TEST_EQUALS( resultUrls->Count(), urls.Count(), TEST_LOCATION );
+
+  value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
+
+  value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
+
+  value = resultMap.Find( ImageVisual::Property::FRAME_DELAY, "frameDelay" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 11, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<float>(), 50.0f, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get<int>() == Visual::Transform::Policy::RELATIVE );
+
+  END_TEST;
+}
+
+
+int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache" );
 
   // request AnimatedImageVisual with a property map
   VisualFactory factory = VisualFactory::Get();
@@ -124,7 +204,8 @@ int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
     .Add( "frameDelay", 200 )
     .Add( "pixelArea", Vector4() )
     .Add( "wrapModeU", WrapMode::REPEAT )
-    .Add( "wrapModeV", WrapMode::DEFAULT ));
+    .Add( "wrapModeV", WrapMode::DEFAULT )
+    .Add( "cornerRadius", 50.5f ));
 
   Property::Map resultMap;
   animatedImageVisual.CreatePropertyMap( resultMap );
@@ -155,10 +236,22 @@ int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
 
+  value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 11, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<float>(), 50.5f, TEST_LOCATION );
+
+  value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get<int>() == Visual::Transform::Policy::ABSOLUTE );
+
   END_TEST;
 }
 
-int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
+int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
 {
   ToolkitTestApplication application;
   tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
@@ -193,6 +286,10 @@ int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( value->Get<int>() == 2 );
 
+  value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -204,12 +301,14 @@ int UtcDaliAnimatedImageVisualSynchronousLoading(void)
 
   {
     Property::Map propertyMap;
-    propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
-    propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
-    propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
-    propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
-    propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
-    propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+    propertyMap.Insert( Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
+    propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
+    propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2 );
+    propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2 );
+    propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20 );
+    propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
+    propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 0.23f );
+    propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE );
 
     VisualFactory factory = VisualFactory::Get();
     Visual::Base visual = factory.CreateVisual( propertyMap );
@@ -1206,4 +1305,4 @@ int UtcDaliAnimatedImageVisualPlayback(void)
   }
 
   END_TEST;
-}
\ No newline at end of file
+}
index 534aeb6..42a9e91 100644 (file)
@@ -139,7 +139,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void)
   propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
              .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME  )
              .Add( DevelImageVisual::Property::LOOP_COUNT, 3  )
-             .Add( DevelImageVisual::Property::PLAY_RANGE, playRange  );
+             .Add( DevelImageVisual::Property::PLAY_RANGE, playRange  )
+             .Add( DevelVisual::Property::CORNER_RADIUS, 50.0f );
 
   Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
   DALI_TEST_CHECK( visual );
@@ -170,6 +171,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
   tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" );
 
   int startFrame = 1, endFrame = 3;
+  float cornerRadius = 50.0f;
   Property::Array playRange;
   playRange.PushBack( startFrame );
   playRange.PushBack( endFrame );
@@ -181,7 +183,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
              .Add( "playRange", playRange )
              .Add( "stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME )
              .Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE )
-             .Add( "redrawInScalingDown", false );
+             .Add( "redrawInScalingDown", false )
+             .Add( "cornerRadius", cornerRadius );
 
   Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
   DALI_TEST_CHECK( visual );
@@ -237,6 +240,14 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( value->Get< bool >() == false );
 
+  value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION );
+
+  value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::ABSOLUTE );
+
   actor.Unparent( );
   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
 
@@ -249,6 +260,7 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
   tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" );
 
   int startFrame = 1, endFrame = 3;
+  float cornerRadius = 50.0f;
   Property::Array playRange;
   playRange.PushBack( startFrame );
   playRange.PushBack( endFrame );
@@ -257,7 +269,9 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
   propertyMap.Add( Toolkit::Visual::Property::TYPE,  DevelVisual::ANIMATED_VECTOR_IMAGE )
              .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
              .Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
-             .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
+             .Add( DevelImageVisual::Property::PLAY_RANGE, playRange )
+             .Add( DevelVisual::Property::CORNER_RADIUS, cornerRadius )
+             .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE);
 
   // request AnimatedVectorImageVisual with a property map
   VisualFactory factory = VisualFactory::Get();
@@ -317,6 +331,14 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
   DALI_TEST_CHECK( value );
   DALI_TEST_CHECK( value->Get< bool >() == true );    // Check default value
 
+  value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION );
+
+  value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::RELATIVE );
+
   // request AnimatedVectorImageVisual with an URL
   Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
 
index dbc326d..0bde103 100644 (file)
@@ -198,6 +198,52 @@ int UtcDaliArcVisualGetPropertyMap01(void)
   END_TEST;
 }
 
+int UtcDaliArcVisualGetPropertyMap02(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliArcVisualGetPropertyMap02" );
+
+  float thickness = 20.0f;
+  float startAngle = 0.0f, sweepAngle = 90.0f;
+
+  Property::Map propertyMap;
+  propertyMap.Add(Visual::Property::TYPE, DevelVisual::ARC)
+             .Add(Visual::Property::MIX_COLOR, Color::RED)
+             .Add(DevelArcVisual::Property::THICKNESS, thickness )
+             .Add(DevelArcVisual::Property::START_ANGLE, startAngle )
+             .Add(DevelArcVisual::Property::SWEEP_ANGLE, sweepAngle )
+             .Add(DevelArcVisual::Property::CAP, DevelArcVisual::Cap::ROUND );
+
+  Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+  DALI_TEST_CHECK( visual );
+
+  Property::Map resultMap;
+  visual.CreatePropertyMap( resultMap );
+
+  // check the property values from the returned map from a visual
+  Property::Value* value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get< Vector4 >(), Color::RED, TEST_LOCATION );
+
+  value = resultMap.Find( DevelArcVisual::Property::THICKNESS, Property::FLOAT );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get< float >(), thickness, TEST_LOCATION );
+
+  value = resultMap.Find( DevelArcVisual::Property::START_ANGLE, Property::FLOAT );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get< float >(), startAngle, TEST_LOCATION );
+
+  value = resultMap.Find( DevelArcVisual::Property::SWEEP_ANGLE, Property::FLOAT );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_EQUALS( value->Get< float >(), sweepAngle, TEST_LOCATION );
+
+  value = resultMap.Find( DevelArcVisual::Property::CAP, Property::INTEGER );
+  DALI_TEST_CHECK( value );
+  DALI_TEST_CHECK( value->Get< int >() == DevelArcVisual::Cap::ROUND );
+
+  END_TEST;
+}
+
 int UtcDaliArcVisualUpdateProperty(void)
 {
   ToolkitTestApplication application;
index 706f8da..2ad46f4 100644 (file)
@@ -1247,6 +1247,11 @@ int UtcDaliImageVisualSetInvalidSyncImage(void)
   application.SendNotification();
   application.Render();
 
+  // Check resource status
+  Visual::ResourceStatus status = actor.GetVisualResourceStatus(Control::CONTROL_PROPERTY_END_INDEX + 1);
+  DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+  // The broken image should be shown.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
 
index c135c9f..761e88e 100644 (file)
@@ -3617,6 +3617,8 @@ int UtcDaliVisualRoundedCorner(void)
     application.Render();
 
     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+    // Default corner radius policy is absolute.
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
   }
 
   // color visual 1
@@ -3759,8 +3761,114 @@ int UtcDaliVisualRoundedCorner(void)
     application.Render();
 
     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+    // Default corner radius policy is absolute.
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+  }
+
+  // animated image visual
+  {
+    VisualFactory factory = VisualFactory::Get();
+    Property::Map properties;
+    float cornerRadius = 24.0f;
+
+    properties[Visual::Property::TYPE] = Visual::ANIMATED_IMAGE;
+    properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
+    properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius + 10.0f; // Dummy Input
+    properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+    properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE;
+
+    Visual::Base visual = factory.CreateVisual( properties );
+
+    // trigger creation through setting on stage
+    DummyControl dummy = DummyControl::New( true );
+    Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    application.GetScene().Add( dummy );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
   }
 
+  // vector image visual
+  {
+    VisualFactory factory = VisualFactory::Get();
+    Property::Map properties;
+    float cornerRadius = 27.0f;
+
+    properties[Visual::Property::TYPE] = Visual::SVG;
+    properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
+    properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+
+    Visual::Base visual = factory.CreateVisual( properties );
+
+    // trigger creation through setting on stage
+    DummyControl dummy = DummyControl::New( true );
+    Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    application.GetScene().Add( dummy );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+    // Default corner radius policy is absolute.
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+  }
+
+  // animated vector image visual
+  {
+    VisualFactory factory = VisualFactory::Get();
+    Property::Map properties;
+    float cornerRadius = 1.3f;
+
+    properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_VECTOR_IMAGE;
+    properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
+    properties["cornerRadius"] = cornerRadius;
+    properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE;
+
+    Visual::Base visual = factory.CreateVisual( properties );
+
+    // trigger creation through setting on stage
+    DummyControl dummy = DummyControl::New( true );
+    Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    application.GetScene().Add( dummy );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+    DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
+  }
+
+
   END_TEST;
 }
 
@@ -3959,6 +4067,8 @@ int UtcDaliVisualGetVisualProperty01(void)
   application.Render();
 
   Vector3 targetColor(1.0f, 1.0f, 1.0f);
+  Vector2 targetOffset(0.05f, 0.05f);
+  Vector2 targetSize(1.1f, 1.1f);
   float targetOpacity = 0.5f;
   float targetCornerRadius = 20.0f;
   float targetBlurRadius = 10.0f;
@@ -3966,6 +4076,8 @@ int UtcDaliVisualGetVisualProperty01(void)
   Animation animation = Animation::New(1.0f);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), targetColor);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::OFFSET), targetOffset);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::SIZE), targetSize);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelColorVisual::Property::BLUR_RADIUS), targetBlurRadius);
   animation.Play();
@@ -3982,6 +4094,18 @@ int UtcDaliVisualGetVisualProperty01(void)
   DALI_TEST_CHECK(colorValue);
   DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
 
+  Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+  Dali::Property::Map* transformMap = transformValue->GetMap();
+  DALI_TEST_CHECK(transformMap);
+
+  Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+  DALI_TEST_CHECK(offsetValue);
+  DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+  Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+  DALI_TEST_CHECK(sizeValue);
+  DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
   Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
   DALI_TEST_CHECK(cornerRadiusValue);
   DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
@@ -3992,6 +4116,8 @@ int UtcDaliVisualGetVisualProperty01(void)
 
   // Test uniform values
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
 
@@ -4040,6 +4166,8 @@ int UtcDaliVisualGetVisualProperty02(void)
   application.Render();
 
   Vector3 targetColor(1.0f, 1.0f, 1.0f);
+  Vector2 targetOffset(0.05f, 0.05f);
+  Vector2 targetSize(1.1f, 1.1f);
   float targetOpacity = 0.5f;
   float targetCornerRadius = 20.0f;
   float targetBlurRadius = 10.0f;
@@ -4048,6 +4176,8 @@ int UtcDaliVisualGetVisualProperty02(void)
   Animation animation = Animation::New(1.0f);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "mixColor"), targetColor);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "opacity"), targetOpacity);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "offset"), targetOffset);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "size"), targetSize);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "cornerRadius"), targetCornerRadius);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "blurRadius"), targetBlurRadius);
   animation.Play();
@@ -4064,6 +4194,18 @@ int UtcDaliVisualGetVisualProperty02(void)
   DALI_TEST_CHECK(colorValue);
   DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
 
+  Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+  Dali::Property::Map* transformMap = transformValue->GetMap();
+  DALI_TEST_CHECK(transformMap);
+
+  Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+  DALI_TEST_CHECK(offsetValue);
+  DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+  Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+  DALI_TEST_CHECK(sizeValue);
+  DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
   Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
   DALI_TEST_CHECK(cornerRadiusValue);
   DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
@@ -4074,6 +4216,8 @@ int UtcDaliVisualGetVisualProperty02(void)
 
   // Test uniform values
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
 
index adfa9f9..0d02ccf 100644 (file)
 #include <dali.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/public-api/images/pixel-data.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
 #include <dali-toolkit/devel-api/controls/web-view/web-view.h>
 
-
 using namespace Dali;
 using namespace Toolkit;
 
@@ -39,6 +45,7 @@ const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
 
 static int gPageLoadStartedCallbackCalled = 0;
 static int gPageLoadFinishedCallbackCalled = 0;
+static int gScrollEdgeReachedCallbackCalled = 0;
 static int gEvaluateJavaScriptCallbackCalled = 0;
 static bool gTouched = false;
 
@@ -66,6 +73,11 @@ static void OnPageLoadFinished( WebView view, const std::string& url )
   gPageLoadFinishedCallbackCalled++;
 }
 
+static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
+{
+  gScrollEdgeReachedCallbackCalled++;
+}
+
 static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode )
 {
 }
@@ -201,8 +213,6 @@ int UtcDaliWebViewPageNavigation(void)
   view.Reload();
   view.StopLoading();
   view.ClearHistory();
-  view.ClearCache();
-  view.ClearCookies();
   Test::EmitGlobalTimerSignal();
   DALI_TEST_CHECK( !view.CanGoBack() );
   DALI_TEST_CHECK( !view.CanGoForward() );
@@ -254,83 +264,97 @@ int UtcDaliWebViewTouchAndKeys(void)
   END_TEST;
 }
 
-int UtcDaliWebViewProperty1(void)
+int UtcDaliWebViewFocusGainedAndLost(void)
 {
-  // URL
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
-  std::string local;
-  view.SetProperty( WebView::Property::URL, TEST_URL1 );
-  Property::Value val = view.GetProperty( WebView::Property::URL );
-  DALI_TEST_CHECK( val.Get( local ) );
-  DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
+  view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+  view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+  application.GetScene().Add( view );
+  application.SendNotification();
+  application.Render();
+
+  view.SetKeyInputFocus();
+  DALI_TEST_CHECK( view.HasKeyInputFocus() );
+
+  // reset
+  view.ClearKeyInputFocus();
+  DALI_TEST_CHECK( !view.HasKeyInputFocus() );
 
   END_TEST;
 }
 
-int UtcDaliWebViewProperty2(void)
+int UtcDaliWebViewGetWebBackForwardList(void)
 {
-  // CACHE_MODEL
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
-  const std::string kDefaultValue = "DOCUMENT_VIEWER";
-  const WebView::CacheModel::Type kTestEnum = WebView::CacheModel::PRIMARY_WEB_BROWSER;
-  const std::string kTestValue = "PRIMARY_WEB_BROWSER";
+  Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+  DALI_TEST_CHECK( bfList != 0 );
 
-  // Check default value
-  std::string output;
-  Property::Value value = view.GetProperty( WebView::Property::CACHE_MODEL );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+  END_TEST;
+}
 
-  // Check Set/GetProperty
-  view.SetProperty( WebView::Property::CACHE_MODEL, kTestEnum );
-  value = view.GetProperty( WebView::Property::CACHE_MODEL );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+int UtcDaliWebViewGetWebContext(void)
+{
+  ToolkitTestApplication application;
 
-  view.SetProperty( WebView::Property::CACHE_MODEL, kTestValue );
-  value = view.GetProperty( WebView::Property::CACHE_MODEL );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebContext* context = view.GetContext();
+  DALI_TEST_CHECK( context != 0 );
 
   END_TEST;
 }
 
-int UtcDaliWebViewProperty3(void)
+int UtcDaliWebViewGetWebCookieManager(void)
 {
-  // COOKIE_ACCEPT_POLICY
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
-  const std::string kDefaultValue = "NO_THIRD_PARTY";
-  const WebView::CookieAcceptPolicy::Type kTestEnum = WebView::CookieAcceptPolicy::NEVER;
-  const std::string kTestValue = "NEVER";
+  Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+  DALI_TEST_CHECK( cookieManager != 0 );
 
-  // Check default value
-  std::string output;
-  Property::Value value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+  END_TEST;
+}
 
-  // Check Set/GetProperty
-  view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestEnum );
-  value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+int UtcDaliWebViewGetWebSettings(void)
+{
+  ToolkitTestApplication application;
 
-  view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestValue );
-  value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewProperty1(void)
+{
+  // URL
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  std::string local;
+  view.SetProperty( WebView::Property::URL, TEST_URL1 );
+  Property::Value val = view.GetProperty( WebView::Property::URL );
+  DALI_TEST_CHECK( val.Get( local ) );
+  DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
 
   END_TEST;
 }
@@ -361,140 +385,352 @@ int UtcDaliWebViewProperty4(void)
   END_TEST;
 }
 
-int UtcDaliWebViewProperty5(void)
+int UtcDaliWebViewProperty9(void)
 {
-  // ENABLE_JAVASCRIPT
+  // SCROLL_POSITION
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
-  const bool kDefaultValue = true;
-  const bool kTestValue = false;
-
   // Check default value
-  bool output;
-  Property::Value value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+  Dali::Vector2 output = Dali::Vector2::ONE;
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
 
   // Check Set/GetProperty
-  view.SetProperty( WebView::Property::ENABLE_JAVASCRIPT, kTestValue );
-  value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+  Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+  view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+  // Check default value of scroll size
+  output = Dali::Vector2::ONE;
+  view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
+  DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+  // Check default value of content size
+  output = Dali::Vector2::ONE;
+  view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
+  DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewPropertyTitleFavicon(void)
+{
+  // SCROLL_POSITION
+  ToolkitTestApplication application;
+
+  char argv[] = "--test";
+  WebView view = WebView::New( 1, (char**)&argv );
+  DALI_TEST_CHECK( view );
+
+  // reset something
+  view.ClearAllTilesResources();
+
+  // Check default value of title
+  std::string testValue("title");
+  std::string output;
+  view.GetProperty( WebView::Property::TITLE ).Get( output );
+  DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+  // Check default value of favicon
+  Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
+  DALI_TEST_CHECK( favicon );
+  Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
+  DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
 
   END_TEST;
 }
 
-int UtcDaliWebViewProperty6(void)
+int UtcDaliWebViewScrollBy(void)
 {
-  // LOAD_IMAGES_AUTOMATICALLY
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
-  const bool kDefaultValue = true;
-  const bool kTestValue = false;
+  // load url.
+  ConnectionTracker* testTracker = new ConnectionTracker();
+  view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
+  bool signal1 = false;
+  view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
+  DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
+
+  view.LoadUrl( TEST_URL1 );
+  Test::EmitGlobalTimerSignal();
+
+  // set scroll position.
+  Dali::Vector2 output = Dali::Vector2::ONE;
+  Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+  view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+  // scroll by and trigger scrollEdgeReached event.
+  view.ScrollBy( 50, 50 );
+  view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+  DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
+  DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
+  DALI_TEST_CHECK( signal1 );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewEvaluteJavaScript(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+  view.LoadHtmlString( "<body>Hello World!</body>" );
+  view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
+  view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
+  Test::EmitGlobalTimerSignal();
+
+  DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliWebViewMethodsForCoverage(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+  view.LoadHtmlString( "<body>Hello World!</body>" );
+  view.AddJavaScriptMessageHandler( "jsObject",
+    []( const std::string& arg ) {
+    }
+  );
+
+  DALI_TEST_CHECK( view );
+
+  END_TEST;
+}
+
+// test cases for web backforward list.
+
+int UtcDaliWebBackForwardListCheckItem(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+  DALI_TEST_CHECK( bfList != 0 )
+
+  unsigned int itemCount = bfList->GetItemCount();
+  DALI_TEST_CHECK( itemCount == 1 )
+
+  Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
+  DALI_TEST_CHECK( citem != 0 );
+
+  const std::string kDefaultUrl( "http://url" );
+  std::string testValue = citem->GetUrl();
+  DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
+
+  const std::string kDefaultTitle( "title" );
+  testValue = citem->GetTitle();
+  DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
+
+  const std::string kDefaultOriginalUrl( "http://originalurl" );
+  testValue = citem->GetOriginalUrl();
+  DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
+
+  Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
+  DALI_TEST_CHECK( item != 0 );
+
+  END_TEST;
+}
+
+// test cases for web context.
+
+int UtcDaliWebContextGetSetCacheModel(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
+
+  Dali::Toolkit::WebContext* context = view.GetContext();
+  DALI_TEST_CHECK( context != 0 )
+
+  std::string kDefaultValue;
+
+  // Reset something
+  context->SetProxyUri( kDefaultValue );
+  context->SetCertificateFilePath( kDefaultValue );
+  context->DisableCache( false );
+  context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
+  context->DeleteWebDatabase();
+  context->DeleteWebStorage();
+  context->DeleteLocalFileSystem();
+  context->ClearCache();
 
   // Check default value
-  bool output;
-  Property::Value value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+  Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
+  DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
 
   // Check Set/GetProperty
-  view.SetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY, kTestValue );
-  value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+  context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
+  value = context->GetCacheModel();
+  DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
 
   END_TEST;
 }
 
-int UtcDaliWebViewProperty7(void)
+// test cases for web cookie manager.
+
+int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
 {
-  // DEFAULT_TEXT_ENCODING_NAME
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
+  Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+  DALI_TEST_CHECK( cookieManager != 0 )
+
   const std::string kDefaultValue;
-  const std::string kTestValue = "UTF-8";
+
+  // Reset something
+  cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
+  cookieManager->ClearCookies();
 
   // Check default value
-  std::string output;
-  Property::Value value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+  Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
+  DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
 
   // Check Set/GetProperty
-  view.SetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME, kTestValue );
-  value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+  cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
+  value = cookieManager->GetCookieAcceptPolicy();
+  DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
 
   END_TEST;
 }
 
-int UtcDaliWebViewProperty8(void)
+// test cases for web settings.
+
+int UtcDaliWebSettingsGetSetDefaultFontSize(void)
 {
-  // DEFAULT_FONT_SIZE
   ToolkitTestApplication application;
 
   WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
-  const int kDefaultValue = 16;
-  const int kTestValue = 26;
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  // Reset something
+  settings->AllowMixedContents( false );
+  settings->EnableSpatialNavigation( false );
+  settings->EnableWebSecurity( false );
+  settings->AllowFileAccessFromExternalUrl( false );
+  settings->AllowScriptsOpenWindows( false );
 
   // Check default value
-  int output;
-  Property::Value value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+  int value = settings->GetDefaultFontSize();
+  DALI_TEST_CHECK( value == 16 );
 
   // Check Set/GetProperty
-  view.SetProperty( WebView::Property::DEFAULT_FONT_SIZE, kTestValue );
-  value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
-  DALI_TEST_CHECK( value.Get( output ) );
-  DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+  settings->SetDefaultFontSize( 20 );
+  value = settings->GetDefaultFontSize();
+  DALI_TEST_CHECK( value == 20 );
 
   END_TEST;
 }
 
-int UtcDaliWebViewEvaluteJavaScript(void)
+int UtcDaliWebSettingsCheckEnableJavaScript(void)
 {
   ToolkitTestApplication application;
 
-  WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
 
-  view.LoadHTMLString( "<body>Hello World!</body>" );
-  view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
-  view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
-  Test::EmitGlobalTimerSignal();
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
 
-  DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
+  // Reset something
+  settings->AllowMixedContents( false );
+  settings->EnableSpatialNavigation( false );
+  settings->EnableWebSecurity( false );
+  settings->AllowFileAccessFromExternalUrl( false );
+  settings->AllowScriptsOpenWindows( false );
+
+  // Check default value is true or not
+  bool value = settings->IsJavaScriptEnabled();
+  DALI_TEST_CHECK( value );
+
+  // Check Set/GetProperty
+  settings->EnableJavaScript( false );
+  value = settings->IsJavaScriptEnabled();
+  DALI_TEST_CHECK( !value );
 
   END_TEST;
 }
 
-
-int UtcDaliWebViewMethodsForCoverage(void)
+int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
 {
   ToolkitTestApplication application;
 
-  WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+  WebView view = WebView::New();
+  DALI_TEST_CHECK( view );
 
-  view.LoadHTMLString( "<body>Hello World!</body>" );
-  view.AddJavaScriptMessageHandler( "jsObject",
-    []( const std::string& arg ) {
-    }
-  );
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  // Reset something
+  settings->AllowMixedContents( false );
+  settings->EnableSpatialNavigation( false );
+  settings->EnableWebSecurity( false );
+  settings->AllowFileAccessFromExternalUrl( false );
+  settings->AllowScriptsOpenWindows( false );
 
+  // Check default value is true or not
+  bool value = settings->AreImagesLoadedAutomatically();
+  DALI_TEST_CHECK( value );
+
+  // Check Set/GetProperty
+  settings->AllowImagesLoadAutomatically( false );
+  value = settings->AreImagesLoadedAutomatically();
+  DALI_TEST_CHECK( !value );
+
+  END_TEST;
+}
+
+int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
+{
+  ToolkitTestApplication application;
+
+  WebView view = WebView::New();
   DALI_TEST_CHECK( view );
 
+  Dali::Toolkit::WebSettings* settings = view.GetSettings();
+  DALI_TEST_CHECK( settings != 0 )
+
+  const std::string kDefaultValue;
+  const std::string kTestValue = "UTF-8";
+
+  // Reset something
+  settings->AllowMixedContents( false );
+  settings->EnableSpatialNavigation( false );
+  settings->EnableWebSecurity( false );
+  settings->AllowFileAccessFromExternalUrl( false );
+  settings->AllowScriptsOpenWindows( false );
+
+  // Check default value
+  std::string value = settings->GetDefaultTextEncodingName();
+  DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
+
+  // Check Set/GetProperty
+  settings->SetDefaultTextEncodingName( kTestValue );
+  value = settings->GetDefaultTextEncodingName();
+  DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
+
   END_TEST;
 }
+
deleted file mode 120000 (symlink)
index 89c2de70cd166068877a43402f6f48217687e409..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-scripts/tcbuild.sh
\ No newline at end of file
new file mode 100755 (executable)
index 0000000000000000000000000000000000000000..b60467501b00694f25867da76af3e0e797eea37f
--- /dev/null
@@ -0,0 +1,215 @@
+#!/bin/bash
+
+#---------- DEBUG_BEGIN ----------
+#ARG="-d" # debug-on flag, might be set as $1
+# keyprompt "introductory message" -- wait until any key pressed
+function keyprompt { echo -ne "\n\e[1;31m$1 -- " && read -n 1 && echo -e "\n\e[0m"; }
+# d_bp -- breakpoint at which user need to press any key to proceed
+function d_bp { if [[ "$ARG" == "-d" ]]; then keyprompt "d >> Press any key"; fi }
+# d_showVar VARNAME -- print bash variable name
+function d_showVar { if [ "$ARG" == "-d" -a -n "$1" ]; then echo "d >> ${1} = ${!1}"; fi }
+# d_print "message" -- print a debug message
+function d_print { if [ "$ARG" == "-d" -a -n "$1" ]; then echo -e "d >> $1"; fi }
+#----------  DEBUG_END  ----------
+
+PROJECT_DIR="$(cd "$(dirname $0)" && pwd)"
+d_showVar PROJECT_DIR
+
+function gbs_profile {
+perl -e "
+use Config::Tiny;
+my \$Config = Config::Tiny->read( \"\$ENV{HOME}/.gbs.conf\" );
+my \$profile = \$Config->{general}->{profile};
+\$profile =~ s/profile.//;
+print \$profile;"
+}
+
+PROFILE=`gbs_profile`
+RPM_DIR="$HOME/GBS-ROOT/local/repos/$PROFILE/armv7l/RPMS"
+d_showVar RPM_DIR
+
+function add_module {
+    # argument check
+    if [ -z "$1" ]; then echo "Usage: `basename $0` addmod <module_name> [module_lib_name]"; exit 1; fi
+
+    MODULE_NAME=$1
+    d_showVar MODULE_NAME
+    MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/')
+    d_showVar MODULE_NAME_C
+    MODULE_NAME_U=$(echo $MODULE_NAME | sed -e 's/-/_/')
+    d_showVar MODULE_NAME_U
+#    MODULE_LIBNAME=${2:-capi-$MODULE_NAME}
+    MODULE_LIBNAME=$1
+    d_showVar MODULE_LIBNAME
+
+    echo "Adding $MODULE_NAME module to project..."
+    d_bp
+    cd $PROJECT_DIR
+    # prepare .spec file
+    echo "-- Generating packaging/core-$MODULE_NAME-tests.spec file"
+    if [ ! -d packaging ]; then mkdir packaging; fi
+    sed -e "s:\[MODULE_NAME\]:$MODULE_NAME:g" -e "s:\[MODULE_LIBNAME\]:$MODULE_LIBNAME:g" \
+        templates/core-\[module_name\]-tests.spec > packaging/core-$MODULE_NAME-tests.spec
+    # prepare src directory
+    mkdir src/$MODULE_NAME
+    echo "-- Generating src/$MODULE_NAME/CMakeLists.txt file"
+    sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" -e "s:%{MODULE_LIBNAME}:$MODULE_LIBNAME:g" \
+        templates/src-directory/CMakeLists.txt > src/$MODULE_NAME/CMakeLists.txt
+    echo "-- Generating src/$MODULE_NAME/tct-$MODULE_NAME-core.c file"
+    sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" \
+        templates/src-directory/tct-\[module_name\]-core.c > src/$MODULE_NAME/tct-$MODULE_NAME-core.c
+    echo "-- Generating src/$MODULE_NAME/utc-$MODULE_NAME.c file"
+    sed -e "s:%{MODULE_NAME_U}:$MODULE_NAME_U:g" -e "s:%{MODULE_NAME_C}:$MODULE_NAME_C:g" \
+        templates/src-directory/utc-\[module_name\].c > src/$MODULE_NAME/utc-$MODULE_NAME.c
+    echo "Task finished successfully"
+}
+
+function rm_module {
+    # argument check
+    if [ -z "$1" ]; then echo "Usage: `basename $0` rmmod <module_name>"; exit 1; fi
+
+    MODULE_NAME=$1
+    d_showVar MODULE_NAME
+
+    echo "Removing $MODULE_NAME module from project..."
+    d_bp
+    echo "---- Updating /opt/tct/packages/package_list.xml"
+    scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/packages/package_list.xml 1
+    if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+   # echo "---- Updating test plans"
+   # scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/manager/plan/*.xml 1
+   # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+
+    cd $PROJECT_DIR
+    echo "-- Removing packaging/core-$MODULE_NAME-tests.spec file"
+    rm packaging/core-$MODULE_NAME-tests.spec
+    echo "-- Removing src/$MODULE_NAME directory"
+    rm -r src/$MODULE_NAME
+    echo "Task finished successfully"
+}
+
+function build {
+    if [ -n "$1" ]; then
+        (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
+        if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+        cp packaging/core-$1-tests.spec ../packaging
+        cp .gitignore-without-autogenerated-files .gitignore
+        gbs build -A armv7l --spec core-$1-tests.spec --include-all --keep-packs | \
+            tee build.log | stdbuf -o0 sed -e 's/error:/\x1b[1;91m&\x1b[0m/' \
+                                           -e 's/warning:/\x1b[93m&\x1b[0m/'
+        rm ../packaging/core-$1-tests.spec
+        cp .gitignore-with-autogenerated-files .gitignore
+    else
+        echo "Build requires a module name"
+        exit 1
+    fi
+}
+
+function inst {
+    if [ -z "$1" ]
+    then
+        for mod in `ls -1 src/ | grep -v CMakeLists`
+        do
+
+       if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
+
+            PKG_NAME="core-$mod-tests"
+            d_showVar PKG_NAME
+            VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
+            d_showVar VER
+            PKG_VNAME="$PKG_NAME-$VER"
+            d_showVar PKG_VNAME
+            PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
+            d_showVar PKG_FNAME
+
+            if [ -f "$RPM_DIR/$PKG_FNAME" ]
+            then
+                inst $mod
+                echo ""
+            fi
+       fi
+        done
+    else
+        cd $PROJECT_DIR
+        # setting variables
+        MOD_NAME="$1"
+        d_showVar MOD_NAME
+        PKG_NAME="core-$MOD_NAME-tests"
+        d_showVar PKG_NAME
+        VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
+        d_showVar VER
+        PKG_VNAME="$PKG_NAME-$VER"
+        d_showVar PKG_VNAME
+        PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
+        d_showVar PKG_FNAME
+        TCT_DIR="opt/tct-$MOD_NAME-core-tests"
+        d_showVar TCT_DIR
+
+        echo "Deploying $MOD_NAME suite to tct-mgr..."
+        d_bp
+        # prepare tct directory and files
+        echo "-- Preparing suite .zip file..."
+        echo "---- Creating /tmp/$TCT_DIR directory"
+        rm -r /tmp/opt > /dev/null 2>&1
+        mkdir -p /tmp/$TCT_DIR
+        # README
+        echo "---- Copying /tmp/$TCT_DIR"
+        cp templates/tct-package/README /tmp/$TCT_DIR
+        # rpm
+        echo "---- Copying /tmp/$TCT_DIR package"
+        cp $RPM_DIR/$PKG_FNAME /tmp/$TCT_DIR
+        if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+        # inst.sh
+        echo "---- Generating /tmp/$TCT_DIR/inst.sh file"
+        sed -e "s:%{PKG_NAME}:\"$PKG_NAME\":g" -e "s:%{PKG_FULLNAME}:\"$PKG_FNAME\":g" \
+            -e "s:%{PKG_DIR}:\"/opt/usr/media/tct/$TCT_DIR\":g" \
+            templates/tct-package/inst.sh > /tmp/$TCT_DIR/inst.sh
+        chmod a+x /tmp/$TCT_DIR/inst.sh
+        # tests.xml
+        echo "---- Generating /tmp/$TCT_DIR"
+        scripts/tctestsgen.sh $MOD_NAME /tmp/$TCT_DIR target
+        if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+        # zip
+        echo "---- Preparing /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip file"
+        # clear old zips
+        rm -r /tmp/tct/packages > /dev/null 2>&1
+        mkdir -p /tmp/tct/packages
+        # create new zip
+        ( cd /tmp; zip -r /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip opt > /dev/null 2>&1; )
+        # deployment
+        echo "-- Suite deployment..."
+        echo "---- Copying /opt/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip"
+        cp /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip /opt/tct/packages/
+        echo "---- Updating /opt/tct/packages/package_list.xml"
+        scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/packages/package_list.xml 0
+        if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+       # echo "---- Updating test plans"
+       # for file in `grep -r tct-$MOD_NAME-core-tests /opt/tct/manager/plan/ | cut -d: -f1 | uniq`
+       # do
+       #     scripts/tcpackageslistsgen.sh $MOD_NAME $file
+       # done
+       # scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/manager/plan/Full_test.xml
+       # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+        echo "Task finished successfully"
+    fi
+}
+
+if [ -z "$1" ]; then
+    # usage note
+    echo "Usage: `basename $0` <addmod|rmmod|build|install> <module_name> [module_lib_name]"
+    exit 1
+elif [ "addmod" == "$1" ]; then
+    # add new module
+    add_module $2 $3
+elif [ "rmmod" == "$1" ]; then
+    # remove module
+    rm_module $2
+elif [ "build" == "$1" ]; then
+    # build the binary
+    build $2
+elif [ "install" == "$1" ]; then
+    # install
+    inst $2
+else
+    echo "Invalid subcommand: $1"
+fi
index f52387f..e59a17f 100644 (file)
@@ -1,2 +1,5 @@
 build
 dali.info
+*.dylib
+dali2-*-config.cmake
+libdali2-scene-loader.so*
\ No newline at end of file
index 657446c..840ff92 100644 (file)
@@ -53,6 +53,11 @@ IF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc.
   FIND_PACKAGE( dali2-adaptor REQUIRED)
 ENDIF()
 
+IF ( APPLE )
+  FIND_PACKAGE( dali2-core REQUIRED)
+  FIND_PACKAGE( dali2-adaptor REQUIRED)
+ENDIF()
+
 SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
 
 # Define non-boolean options to CMake
@@ -208,16 +213,24 @@ IF( WIN32 )
   ADD_COMPILE_OPTIONS( /vmg )                           # Avoids a 'reinterpret_cast' compile error while compiling signals and callbacks.
   ADD_COMPILE_OPTIONS( /wd4251 )                        # Ignores warning C4251: "'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'"
 ELSE()
+  INCLUDE(CheckCXXCompilerFlag)
+
   # Set up compiler flags and warnings
   ADD_COMPILE_OPTIONS( -Wno-ignored-qualifiers )
 
   # TODO: Clang is a lot more strict with warnings, we should address
   # those issues at some point.
-  IF( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
+  # Matches "Clang" or "AppleClang"
+  IF( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
     ADD_COMPILE_OPTIONS( -Werror )
   ENDIF()
 
-  ADD_COMPILE_OPTIONS( -Wall -Wno-unused-parameter -Wno-float-equal -Wno-class-memaccess )
+  ADD_COMPILE_OPTIONS( -Wall -Wno-unused-parameter -Wno-float-equal )
+  ADD_COMPILE_OPTIONS( -Wall -Wno-unused-parameter -Wno-float-equal )
+  CHECK_CXX_COMPILER_FLAG(-Wno-class-memaccess HAVE_NO_CLASS_MEMACCESS)
+  IF (HAVE_NO_CLASS_MEMACCESS)
+    ADD_COMPILE_OPTIONS( -Wno-class-memaccess )
+  ENDIF()
 
   IF( ENABLE_COVERAGE OR "$ENV{CXXFLAGS}" MATCHES --coverage )
     ADD_COMPILE_OPTIONS( --coverage )
@@ -270,12 +283,21 @@ IF(DEFINED STATIC)
   SET(LIBTYPE STATIC)
 ENDIF()
 
-IF( WIN32 )
+# Generate source files for shaders
+SET(SHADER_SOURCE_DIR "${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/shaders/")
+SET(SHADER_GENERATED_DIR "${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/generated")
+EXECUTE_PROCESS( COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/shader-generator.sh ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}" )
+
+SET(GENERATED_SHADER_DIR ${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/)
+SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+             "${GENERATED_SHADER_DIR}/generated/"
+             "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
+
+IF( WIN32 OR APPLE )
   SET( DALICORE_LDFLAGS
         "${DALICORE_LDFLAGS}"
         dali2-core::dali2-core )
 
-  FIND_PACKAGE( pthreads REQUIRED )
   FIND_PACKAGE( curl REQUIRED )
   FIND_LIBRARY( GETOPT_LIBRARY NAMES getopt )
   FIND_LIBRARY( EXIF_LIBRARY NAMES libexif )
@@ -285,14 +307,17 @@ IF( WIN32 )
   FIND_PACKAGE( jpeg REQUIRED )
   FIND_LIBRARY( TURBO_JPEG_LIBRARY NAMES turbojpeg )
 
-  FIND_PACKAGE( unofficial-fontconfig REQUIRED )
   FIND_PACKAGE( freetype REQUIRED )
   FIND_PACKAGE( harfbuzz REQUIRED )
   FIND_LIBRARY( FRIBIDI_LIBRARY NAMES fribidi )
 
   FIND_PACKAGE( unofficial-angle REQUIRED )
-  FIND_PACKAGE( unofficial-cairo REQUIRED )
 
+  IF(WIN32)
+    FIND_PACKAGE( unofficial-fontconfig REQUIRED )
+  ENDIF()
+
+  FIND_PACKAGE( unofficial-cairo REQUIRED )
   FIND_PACKAGE( WebP REQUIRED )
 
   SET( DALIADAPTOR_LDFLAGS
@@ -300,6 +325,9 @@ IF( WIN32 )
        dali2-adaptor::dali2-adaptor )
 ENDIF()
 
+IF ( WIN32 )
+  FIND_PACKAGE( pthreads REQUIRED )
+ENDIF()
 
 ADD_LIBRARY( ${name} ${LIBTYPE} ${SOURCES} )
 TARGET_LINK_LIBRARIES( ${name}
@@ -348,7 +376,7 @@ IF( INSTALL_CMAKE_MODULES )
   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake DESTINATION share/${name})
 
   # Install the pdb file.
-  IF( ENABLE_DEBUG )
+  IF( ENABLE_DEBUG AND WIN32 )
     install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/${name}.pdb DESTINATION ${BIN_DIR} )
   ENDIF()
 ELSE()
@@ -399,7 +427,7 @@ INSTALL_HEADERS_WITH_DIRECTORY(PACKAGE_DOXY_HEADERS ${PACKAGE_DOXY_SRC_DIR} "dal
 INSTALL( FILES ${ROOT_SRC_DIR}/dali-toolkit/dali-toolkit.h DESTINATION ${INCLUDE_DIR}/dali-toolkit )
 
 # package doxygen file (contains doxygen grouping information)
-INSTALL( FILES ${package_doxy_files} DESTINATION ${DEV_INCLUDE_PATH}/dali-toolkit/doc )
+INSTALL( FILES ${package_doxy_files} DESTINATION ${INCLUDE_DIR}/dali-toolkit/doc )
 
 # On some platforms we want to install the data files to different location compare to
 # the data location used runtime. For example, on Android we want the toolkit library to load
index 887b2a5..d3ebe7d 100644 (file)
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.8.2)
 set(name "dali2-scene-loader")
 
 project(${name} CXX)
@@ -144,7 +144,59 @@ if( ANDROID )
        target_link_libraries(${name} log)
 endif()
 
-install(TARGETS ${name} DESTINATION ${prefix}/lib)
+# Generate source files for shaders
+SET(SHADER_SOURCE_DIR "${scene_loader_dir}/internal/graphics/shaders/")
+SET(SHADER_GENERATED_DIR "${scene_loader_dir}/internal/graphics/generated")
+EXECUTE_PROCESS( COMMAND bash -c "${repo_root_dir}/build/tizen/shader-generator.sh ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}" )
+
+SET(GENERATED_SHADER_DIR ${scene_loader_dir}/internal/graphics/)
+SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+             "${GENERATED_SHADER_DIR}/generated/"
+             "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
+
+IF( INSTALL_CMAKE_MODULES )
+       SET_TARGET_PROPERTIES( ${name}
+               PROPERTIES
+               VERSION ${DALI_SCENE_LOADER_VERSION}
+               SOVERSION ${${name}_VERSION_MAJOR}
+               CLEAN_DIRECT_OUPUT 1
+       )
+
+       IF( ENABLE_DEBUG )
+               SET( BIN_DIR "${BIN_DIR}/debug" )
+               SET( LIB_DIR "${LIB_DIR}/debug" )
+       ENDIF()
+
+       # Install the library files.
+       INSTALL( TARGETS ${name}
+               EXPORT ${name}-targets
+               LIBRARY DESTINATION ${LIB_DIR}
+               ARCHIVE DESTINATION ${LIB_DIR}
+               RUNTIME DESTINATION ${BIN_DIR}
+       )
+
+       # Install the cmake modules.
+       INSTALL(
+               EXPORT ${name}-targets
+               NAMESPACE ${name}::
+               FILE ${name}-targets.cmake
+               DESTINATION share/${name}
+       )
+
+       FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake "
+               include(CMakeFindDependencyMacro)
+               include(\${CMAKE_CURRENT_LIST_DIR}/${name}-targets.cmake)
+       ")
+       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake DESTINATION share/${name})
+
+       # Install the pdb file.
+       IF( ENABLE_DEBUG AND WIN32 )
+               install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/${name}.pdb DESTINATION ${BIN_DIR} )
+       ENDIF()
+ELSE()
+       # Install the library so file and symlinks
+       INSTALL( TARGETS ${name} DESTINATION ${LIB_DIR} )
+ENDIF()
 
 file(GLOB scene_loader_include_files ${scene_loader_public_api_dir})
 install(DIRECTORY ${scene_loader_include_files}
index 75cece0..0a9d553 100644 (file)
@@ -995,6 +995,7 @@ INPUT                  = @DOXYGEN_DOCS_DIR@/content \
                          @prefix@/include/dali/devel-api \
                          ../../../dali-toolkit/public-api \
                          ../../../dali-toolkit/devel-api \
+                         ../../../dali-scene-loader/public-api \
                          ../../../automated-tests/README.md
 
 # This tag can be used to specify the character encoding of the source files
@@ -2266,7 +2267,10 @@ INCLUDE_FILE_PATTERNS  =
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED             = DALI_TOOLKIT_API \
+PREDEFINED             = DALI_CORE_API \
+                         DALI_ADAPTOR_API \
+                         DALI_TOOLKIT_API \
+                         DALI_SCENE_LOADER_API \
                          DALI_INTERNAL \
                          __attribute__ \
                          ((visibility \
diff --git a/build/tizen/shader-generator.sh b/build/tizen/shader-generator.sh
new file mode 100755 (executable)
index 0000000..7b6b2fc
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+indir=$1
+outdir=$2
+
+mkdir -p $outdir
+
+if [ ! -e $indir ] ; then
+    echo "Error! "$indir" not found!"
+    exit 0
+fi
+
+cd $indir
+all_shaders=$(ls -1 *.{vert,frag,def})
+cd $OLDPWD
+
+# Generate one header file per shader which is defined as a const std::string_view
+for name in $all_shaders ; do
+  echo "Generating header files for $name..."
+  varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
+
+  newname=$(echo ${name} | sed -e 's/\./-/;')".h"
+  echo Writing $newname
+
+  shader_fullpath=$(echo ${indir})$name
+
+  header_name="${varname}_GEN_H"
+  echo "const std::string_view" "$varname""{" > $outdir/$newname
+  cat $shader_fullpath | sed -e 's/^..*$/"&\\n"/' >> $outdir/$newname
+  echo "};" >> $outdir/$newname
+done
+
+# Generate one cpp file that includes all the previously generated string_views for shaders
+echo "Generating cpp file..."
+echo -e "#include \"../builtin-shader-extern-gen.h\"\n" > $outdir/builtin-shader-gen.cpp
+
+varnames=
+for name in $all_shaders ; do
+    varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
+    newname=$(echo ${name} | sed -e 's/\./-/;')".h"
+    varnames="${varnames} $varname"
+    echo "#include \"$newname\"" >> $outdir/builtin-shader-gen.cpp
+done
+
+# Generate one header file that defines all the shader string_views as extern variables
+echo "Generating extern header file ( for external use )..."
+echo "#ifndef GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H" > $outdir/../builtin-shader-extern-gen.h
+echo -e "#define GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H\n" >> $outdir/../builtin-shader-extern-gen.h
+
+echo "#include <string_view>" >> $outdir/../builtin-shader-extern-gen.h
+echo "" >> $outdir/../builtin-shader-extern-gen.h
+
+for name in $all_shaders ; do
+    varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
+    newname=$(echo ${name} | sed -e 's/\./-/;')".h"
+    echo "extern const std::string_view $varname;" >> $outdir/../builtin-shader-extern-gen.h
+done
+cat >> $outdir/../builtin-shader-extern-gen.h << EOF
+
+#endif // GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H
+EOF
+
index 2f88dbe..b29c463 100644 (file)
-# dali-sceen-loader
+# Table of contents
+   * [Overview](#overview)
+   * [`scenes`](#scenes)
+   * [`nodes`](#nodes)
+      * [Transformations](#transformations)
+      * [Size](#size)
+      * [Visibility](#visibility)
+      * [`children`](#children)
+      * [`customization`](#customization)
+      * [Renderables](#renderables)
+         * [`model`](#model)
+         * [`arc`](#arc)
+      * [`inverseBindPoseMatrix`](#inversebindposematrix)
+   * [`materials`](#materials)
+   * [`meshes`](#meshes)
+   * [`shaders`](#shaders)
+      * [`rendererState`](#rendererState)
+      * [`defines`](#defines)
+      * [`hints`](#hints)
+      * [Uniforms](#uniforms)
+   * [`skeletons`](#skeletons)
+   * [`cameras`](#cameras)
+      * [Perspective cameras](#perspective-cameras)
+      * [Orthographic cameras](#orthographic-cameras)
+   * [`lights`](#lights)
+   * [`animations`](#animations)
+      * [`properties`](#properties)
+         * [`keyFramesBin`](#keyframesbin)
+         * [`keyFrames`](#keyFrames)
+         * [`value`](#value)
+   * [`animationGroups`](#animationGroups)
 
-Provides functionality for loading scenes created in the JSON-based DLI format. DLI is most similar to glTF, but less verbose / granular, and it has a few extra features:
+# Overview
+DLI is a JSON based format for representing 3D scenes.
+   * Like glTF, the DLI document defines a set of scenes, which in turn define a hierarchical structure of nodes, and the additional data required to render them - meshes, geometry.
+   * Unlike glTF, it allows definitions of shaders, environment maps, and lighting parameters as well;
+   * Unlike glTF, DLI does not concern itself with buffers, buffer views and accessors;
+   * It supports customizations, which allow replacing parts of the scene based on customization tags and options, without reloading the whole scene.
+   * It supports the processing of custom categories, which can be scheduled to take place prior to or after the processing of the scene data, as well as custom node and animation processors.
 
-- customizations: switch between alternative definitions of parts of the scene;
-- environment maps;
-- text, arc, and image elements;
-- etc. (TODO)
+# `scenes`
+The "scenes" element is an array of JSON objects, each of which must define a `nodes` array with the index of the definition of the root node.
 
-Please refer to [dli-exporter](http://github.com/dalihub/dli-exporter) for converting 3D models to DLI.
+:warning: The array must not be empty. Only the first element is used.
+An optional `scene` element with an integer value may be defined to specify the index of the first scene to be created.
+The rest of the scenes are created in the order of their definition (from index 0 to the highest, skipping the default - already created - scene).
+```js
+{
+    "scene": 0,
+    "scenes": [ { "nodes": [ 0 ] } ],
+    "nodes": [ {
+        "name": "some_unique_name"
+    } ]
+}
+```
 
-## Prequisites
+# `nodes`
+The 3D scene is built using a hierarchy of nodes, which are used to position the objects to render.
 
-- Windows:
+:warning: Each node must have a `name` string that 1, is not an empty string and 2, is unique within the DLI document. The use of alpha-numeric characters and underscore only is highly recommeneded.
 
-  - Microsoft Visual Studio 2017 (or later, with 2017 build tools);
-  - [windows-dependencies](https://github.com/dalihub/windows-dependencies ) - please follow the steps in its README.md *as well as* its vcpkg-script/ReadMe.md, to install VCPKG and all dependencies;
-- Linux:
+## Transformations
+There are two ways to define the local transform of each nodes. Both are optional, defaulting to a position at the origin, a scale of one and no rotation.
+   * A `matrix` array of 16 numerical values defining a column-major 4x4 matrix;
+   * A `position` array of 3 numerical values defining a 3D vector and an `angle` array of 3 numerical values defining euler angles of rotation along the 3 axes.
 
-  - GCC v9.3+;
-  - CMake v3.14+;
-  - [dali-core](https://github.com/dalihub/dali-core );
-  - [dali-adaptor](https://github.com/dalihub/dali-adaptor );
-  - [dali-toolkit](https://github.com/dalihub/dali-toolkit );
-  - configure DALi environment by following the instructions in README.md, in dali-core;
+## Size
+The size of the bounding box of a node may be specified using either of the optional `size` or `bounds` properties, as arrays of 2 or 3 numerical values. Its default value is the unit vector.
 
-## Build instructions
+## Visibility
+The `visible` optional boolean property defines whether a node and its children are rendered (`true`) or not (`false`).
 
-1, build the DALi libraries;
+## `children`
+An array of 0 or more indices into the top level `nodes` array, which shall inherit the transform and visibility of their parent node.
 
-2,
+:warning: Nodes are processed in the order they are encountered during the depth-first traversal of the hierarchy.
+```js
+  "nodes": [ {
+    "name": "hip",
+    "children": [ 3, 1, 2 ]
+  }, {
+    "name": "spine"
+  }, {
+    "name": "left leg"
+  }, {
+    "name": "right leg"
+  } ]
+```
 
-  - Windows: refer to the VS2017 solution in the windows-dependencies repository;
-  - Linux: run the ../build/tizen/dali-scene-loader/build.sh;
-  - Tizen:
+## `customization`
+Customizations may allow creating a different sub-tree of each node that define them, based on application specific configuration settings known at the time of creating the scene.
+The definition of a `customization` is a single string tag: 
+```js
+  "nodes": [ {
+    "name": "Soup du jour",
+    "customization": "flavor", // this one
+    "children": [ 1, 2, 3 ]
+  }, {
+    "name": "Broccoli and Stilton",
+  }, {
+    "name": "Butternut Squash",
+  }, {
+    "name": "Strawberry and Cream",
+  } ]
+```
+:warning: Customizations and renderables are mutually exclusive on the same node.
 
-    $ gbs build -A ${target_arch}
+## Renderables
+There is support for two types of nodes that define renderable content.
+The definition of these renderables come in sub-objects.
+All of them support a `color` property, which is an array of 3 or 4 numerical values for RGB or RGBA components. For the alpha value to take effect, alpha blending must be enabled; this is controlled by the [material](#materiaL).
 
-    - for debug, add: --define "%enable_debug 1"
-    - for SMACK-enabled targets, add: --define "%enable_dali_smack_rules 1"
+:warning: Customizations and renderables are mutually exclusive on the same node.
+
+### `model`
+Provides definition for a 3D object, which requires a `mesh`, `shader` and `material`.
+Each of these are provided in form of an integer index into the related top-level array of the DLI document.
+
+:warning: `mesh` must be provided; the rest are optional and default to 0.
+```js
+  "nodes": [ {
+    "name": "Sphere",
+    "model": {
+      "mesh": 0, // required
+      "shader": 0, // optional, defaults to 0
+      "material": 1 // optional, defaults to 0
+    }
+  } ]
+```
+
+### `arc`
+Arc is a specialisation of a model that allows the rendering of circular progress bars. As such, it also must provide a `mesh` ID.
+```js
+  "nodes": [ {
+    "name": "Any Name",
+    "arc": {
+      "mesh": 0, // required
+      "shader": 0, // optional, defaults to 0
+      "material": 1 // optional, defaults to 0
+      "antiAliasing": true,
+      "radius": -0.928,
+      "startAngle": -81.0,
+      "endAngle": 261
+    }
+  } ]
+```
+   * `startAngle` and `endAngle` are the angular positions where the arc starts and ends, in degrees.
+   * `radius` is the inner radius of the arc, the outer radius being defined by the [`size`](#size) of the node.
+   * `antiAliasing` defines whether the edges of the arc should be smoothed.
+   
+## `inverseBindPoseMatrix`
+Nodes that serve as joints of a [skeleton](#skeleton) must define this property as an array of 16 numerical values for a column major 4x4 matrix.
+```js
+  "nodes": [ {
+    "name" : "l_shoulder_JNT",
+    "inverseBindPoseMatrix" : [ 0.996081, -0.0407448, 0.0785079, 0.0, 0.0273643, 0.985992, 0.164531, 0.0, -0.0841121, -0.161738, 0.983242, 0.0, -0.0637747, -1.16091, -0.161038, 1.0 ]
+  } ]
+```
+
+# `environment`
+An array of environment map definitions, which have the following format:
+```js
+  "environment": [{
+    "cubeSpecular": "Studio_001/Radiance.ktx",
+    "cubeDiffuse": "Studio_001/Irradiance.ktx",
+    "cubeInitialOrientation": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] 
+  } ]
+```
+`cubeSpecular` and `cubeDiffuse` are the names of the respective cube map files that will be attempted to be located from the _environment_ path, which is up to the application. A 1x1x1 white RGB888 cubemap is created in place of either that was omitted.
+`cubeInitialOrientation` may be used to inform the (PBR) shader of a matrix which describes the initial orientation of the cube map. Defaults to the identity matrix.
+
+# `materials`
+Defines configurations of textures (and their samplers) that form materials. These can be created from single values or image files (in the formats that DALi supports).
+```js
+  "materials": [ {
+    "environment": 0,
+    "albedoMap": "A.png",
+    "normal": "N.png",
+    "metallicRoughnessMap": "MR.png",
+    "color": [ 1.0, 0.8, 0.7, 0.5 ]
+  } ]
+```
+   * `environment`: The index of the [environment map](#environments) to use. Single integer, defaults to `0`.
+   * `mipmap`: A boolean to speficy if the creation and sampling of mipmaps should be enabled. Off by default.
+   * `color`: Base color, which the color of the node gets multiplied by. Defaults to white.
+   * `metallic` and `roughness`: Properties for PBR materials; both are expected to be a single numerical value and default to `1.0`.
+
+## Texture maps
+`albedoMap` / `albedoMetallicMap` / `normalMap` / `normalRoughnessMap` / `metallicRoughnessMap` / `subsurfaceMap`: define various texture semantics, i.e. the role of the texture, which shall be loaded from an image _inside the materials path_, which is up to the application. All of them are optional.
+
+:warning: Semantics shall not overlap within the same material, e.g. multiple albedo definitions, or albedo and albedoMetallic.
+
+# `meshes`
+Defines an array of meshes which are used to access geometry data stored in a binary file. The `uri` property is used to locate each file _inside the mesh path_, which is up to the application; alternatively it can be set to `"quad"`, resulting in the creation of a unit quad.
+Those models loaded from a file may provide an accessor, and flag its presence in the `attributes` bitmask property. The following are supported:
+|Attribute Name|Bit|Decimal value|Type|Remarks|
+|-|-|-|-|-|
+|`indices`  |0|  1|unsigned short||
+|`positions`|1|  2|Vector3||
+|`normals`  |2|  4|Vector3||
+|`textures` |3|  8|Vector2|UVs|
+|`tangents` |4| 16|Vector3||
+|           |5| 32||Ignored, but reserved for bitangents|
+|`joints0`  |6| 64|Vector4|Joint IDs for skinned meshes|
+|`weights0` |7|128|Vector4|Joint weights for skinned meshes|
+
+E.g. if positions, normals and tangents are provided, the `attributes` property must have a value of 2 + 4 + 16 = 22.
+Each attribute must provide a `byteOffset` and `byteLength` property, which must be correctly sized for the type of the given attribute.
+Finally, to specify what primitives should the geometry be rendered as, a `primitive` property may be provided with one of the following values: `TRIANGLES` (default), `LINES`, `POINTS`.
+
+## Skinned meshes
+DLI supports meshes that allow deformation by skeletal animation. These must define a few additional properties:
+   * `joints0` and `weights0` attributes, as above.
+   * A [`skeleton`](#skeletons) ID, to specify which (joint) nodes' transformations affect the mesh.
+
+:warning: The maximum number of bones supported by DALi Scene Loader is `64`.
+
+## Blend shapes
+Blend shapes provide alternate configurations of vertex `positions`, `normals` and/or `tangents` that may be blended with the same attributes of the base mesh, controlled by an animatable `weight`.
+```js
+  "meshes": [ {
+      "uri": "example.bin",
+      "attributes": 2,
+      "positions": {
+          "byteOffset": 0,
+          "byteLength": 12000
+      },
+      "blendShapesHeader": {
+          "version": "2.0",
+          "byteOffset": 12000,
+          "byteLEngth": 4
+      },
+      "blendShapes": [ {
+          "weight": 0.0,
+          "positions": {
+              byteOffset: 12004,
+              byteLength: 12000
+          }
+      } ]
+  } ]
+```
+A `blendShapesHeader`, if present, must define:
+   * the `version` of the blend shapes; supported values are `1.0` and `2.0`. The difference between the versions is that v1.0 requires a per-blend shape definition of an un-normalization factor.
+   * the `byteOffset` and `byteLength` of a buffer in the binary which defines the width (2 bytes) and height (2 bytes) of the texture that dali-scene-loader creates for blend shape data.
+
+The `blendShapes` array then defines the shapes that are available to blend between, comprising of:
+   * An initial `weight` numerical, the default is 0;
+   * `position` / `normals` / `tangents` attributes, which must be also present in the base mesh and are the same format (`byteOffset` / `byteLength`);
+
+:warning: The size of the attributes of the blend shape must match that of the base mesh (and each other) - i.e. they must define the same number of vertices.
+
+# `shaders`
+Provides an array of shader programs that renderables may use for rendering.
+For each shader, `vertex` and `fragment` are required string properties pointing to the shader files _inside the shader path_, which is up to the application.
+   * `rendererState`: This string defines the options for configuring the settings of the renderer. Refer to public-api/renderer-state.h for details.
+   * `defines`: An optional array of strings which will be used to create #defines into the vertex and fragment shaders.
+   * `hints`: An optional array of strings that map to `Dali::Shader::Hint` values. Therefore two values are supported - `MODIFIES_GEOMETRY` and `OUTPUT_IS_TRANSPARENT`.
+
+## Uniforms
+Every property that is not one of the reserved keys above, will be attempted to be registered as a uniform of the same name.
+
+:warning: Boolean values will be converted to floating point 1.0 (for `true`) or 0.0 (for `false`).
+
+:warning: Integer values will be converted to floating point.
+
+:warning: Arrays of numerical values will be treated as one of the vec2 / vec3 / vec4 / mat3 / mat4 types, depending on what do they define sufficient components for.
+```js
+  "shaders": [ {
+    "vertex": "dli_pbr.vsh",
+    "fragment": "dli_pbr.fsh",
+    "defines": [ "HIGHP", SKINNING" ],
+    "rendererState": "DEPTH_WRITE|DEPTH_TEST|CULL_BACK",
+    "hints": 
+    "uMaxLOD": 6
+  } ]
+```
+
+# `skeletons`
+Skeletons in DLI simply define the name of a `node` that shall serve as the _root joint_ of the given skeleton.
+```js
+  "skeletons": [ {
+    "node": "hipJoint"
+  } ]
+```
+The Joint IDs in skinned mesh data relate to the descendants of the [node](#nodes) identified as the root joint that are joints, i.e. define [`inverseBindPoseMatrix`](#inversebindposematrix), in depth-first traversal order.
+
+# `cameras`
+Define the transformation of viewers and the projection used by them.
+All cameras may define:
+   * `matrix`: an array of 16 numerical values for the transform matrix
+   * `near` and `far` values for the position of the respective clipping planes. These default to `0.1` and `1000.0`, respectively.
+
+## Perspective cameras
+This projection type - and a vertical field of view of `60` degrees - is the default.
+The (V)FOV can be specified in the `fov` property, as a single numerical value.
+
+## Orthographic cameras
+If the `orthographic` is defined with an array of four numerical values for the left, right, bottom and top clipping planes (in this order), then orthographic projection is used, and `fov` is ignored.
+
+# `lights`
+Define parameters for a single light source - the implementation is up to the application. The following properties are supported.
+   * `transform`: matrix of 16 numerical values for the positioning / directing of the light;
+   * `color`: array of 3 components for RGB;
+   * `intensity`: single float;
+   * `shadowIntensity`: single float;
+   * `shadowMapSize`: unsigned integer size (same width & height) of shadow map.
+   * `orthographicSize`: single float to define the size (same width & height) of orthographic position.
+
+# `animations`
+Animations provide a way to change properties of nodes (and those of their renderables) over time.
+```js
+  "animations": [ {
+     "name": "Idle",
+     "loopCount": 0,
+     "duration": 4.0,
+     "endAction": "DISCARD",
+     "disconnectAction": "DISCARD",
+     "properties": []
+  } ]
+```
+   * `name`: the identifier to look the animation up by;
+   * `loopCount`: the number of times that the animation should be played. The default is `1`; `0` signifies infinity repetitions.
+   * `duration`: the duration of the animation in seconds. If not provided, it will be calculated from the properties.
+   * `endAction` and `disconnectAction`: the supported values, defaults and their meaning are described in the `Dali::Animation::EndAction` enum;
+
+## `properties`
+An array of animation property definitions.
+   * `node`: the name of the node whose property shall be animated;
+   * `property`: the name that the property was registered under.
+   * `alphaFunction`: the name of an alpha function which shall be used in animating a value, or between key frames;
+   * `timePeriod`: `delay` (defaults to `0.0`) and `duration` (defaults to the `duration` of the animation) of the property animation, in sceonds;
+
+The property may be animated using one of the following methods. They are listed in priority order; if e.g. a property defines `keyFramesBin` and `keyFrames`, then only `keyFramesBin` is used. 
+
+### `keyFramesBin`
+JSON object that defines a keyframe animation in a binary buffer, with the following properties:
+   * `url` the path to the file containing the buffer;
+   * `numKeys`: the number of keys.
+   * `byteOffset`: offset to the start of the buffer
+
+The size of the buffer depends on the property being animated, where  the property value for each frame follows a 4 byte floating point value determining progress (between 0 and 1).
+
+:warning: Only `position` (3D vector of floats, 12 bytes), `rotation` (Quaternion, 12 bytes), and `scale` (3D vector, 12 bytes) properties are supported.
+
+### `keyFrames`
+JSON array of keyframe objects defined with the following properties:
+   * `progress`: a scalar between `0` and `1` to apply to the duration to get the time stamp of the frame;
+   * `value`: array of 3 or 4 numerical values depending on which property is being animated;
+
+:warning: Only `position`, `rotation`, and `scale` properties are supported.
+
+### `value`
+Value animations animate a property using a single value that may be absolute or relative.
+The properties it supports are the following:
+   * `value`: the value to animate to (if absolute) or by (if `relative`);
+   * `relative`: whether `value` is a target, or an offset;
+
+# `animationGroups`
+Animation groups simply group animations together by name, under another name, which may be used to trigger them at the same time.
+```js
+  "animationGroups": [ {
+    "name": "Idle",
+    "animations": [ "IdleBody", "IdleFace" ]
+  } ]
+```
diff --git a/dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.frag b/dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.frag
new file mode 100644 (file)
index 0000000..a1153c9
--- /dev/null
@@ -0,0 +1,11 @@
+#version 300 es
+
+precision mediump float;
+flat in float vColor;
+out vec4 FragColor;
+
+void main()
+{
+  vec3 rgb = vec3(fract(vColor), fract(vColor * 0.00390625), fract(vColor * 0.00390625 * 0.00390625));
+  FragColor = vec4(rgb, 1.);
+}
\ No newline at end of file
diff --git a/dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.vert b/dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.vert
new file mode 100644 (file)
index 0000000..98b6086
--- /dev/null
@@ -0,0 +1,13 @@
+#version 300 es
+
+precision mediump float;
+uniform mat4 uMvpMatrix;
+in vec3 aPosition;
+in float aColor;
+flat out float vColor;
+
+void main()
+{
+  vColor = aColor;
+  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+}
\ No newline at end of file
index b41b8d5..ee2b519 100644 (file)
@@ -32,11 +32,10 @@ Animation::EndAction AnimationDefinition::StopForModification(Animation& anim)
   return endAction;
 }
 
-AnimationDefinition::AnimationDefinition()
-{}
+AnimationDefinition::AnimationDefinition() = default;
 
 AnimationDefinition::AnimationDefinition(AnimationDefinition&& other)
-:  mName(std::move(other.mName)),
+: mName(std::move(other.mName)),
   mDuration(other.mDuration),
   mLoopCount(other.mLoopCount),
   mDisconnectAction(other.mDisconnectAction),
index 7ea6d3f..67283a8 100644 (file)
@@ -68,6 +68,8 @@ struct DALI_SCENE_LOADER_API BlendShapes
    *  on the given @a shader and @a actor.
    */
   static void ConfigureProperties(const std::pair<MeshDefinition, MeshGeometry>& mesh, Shader shader, Actor actor);
+
+  BlendShapes() = delete;
 };
 
 }
index 20b3ee3..044c7f4 100644 (file)
@@ -35,23 +35,12 @@ namespace SceneLoader
 
 struct DALI_SCENE_LOADER_API CameraParameters
 {
-  CameraParameters()
-  : matrix(Matrix::IDENTITY),
-    orthographicSize(-1.f, 1.f, 1.f, -1.f),
-    yFov(60.f),
-    zNear(0.1f),
-    zFar(1000.f),
-    isPerspective(true)
-  {}
-
-  ~CameraParameters() = default;
-
-  Matrix matrix;
-  Vector4 orthographicSize;
-  float yFov;
-  float zNear;
-  float zFar;
-  bool isPerspective;
+  Matrix matrix = Matrix::IDENTITY;
+  Vector4 orthographicSize = Vector4{ -1.f, 1.f, 1.f, -1.f };
+  float yFov = 60.f;
+  float zNear = 0.1f;
+  float zFar = 1000.f;
+  bool isPerspective = true;
 
   /**
    * @return The view-projection matrix of the camera.
index 06268eb..11dc036 100644 (file)
@@ -159,9 +159,9 @@ void ReadArcField(const TreeNode* eArc, ArcNode& arc)
   ReadFloat(eArc->GetChild("endAngle"), arc.mEndAngleDegrees);
 }
 
-const TreeNode *Tidx(const TreeNode *node, int index)
+const TreeNode *GetNthChild(const TreeNode *node, uint32_t index)
 {
-  int i = 0;
+  uint32_t i = 0;
   for (TreeNode::ConstIterator it = (*node).CBegin(); it != (*node).CEnd(); ++it, ++i)
   {
     if (i == index)
@@ -463,8 +463,8 @@ void DliLoader::Impl::ParseScene(LoadParams& params)
 void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* tnScenes,
   const Toolkit::TreeNode* tnNodes, LoadParams& params)
 {
-  auto getSceneRootIdx = [&](Index iScene) {
-    auto tn = Tidx(tnScenes, iScene);  // now a "scene" object
+  auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) {
+    auto tn = GetNthChild(tnScenes, iScene);  // now a "scene" object
     if (!tn)
     {
       ExceptionFlinger(ASSERT_LOCATION) << iScene << " is out of bounds access into " << SCENES << ".";
@@ -483,7 +483,7 @@ void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode*
         " must define a node id.";
     }
 
-    tn = Tidx(tn, 0);  // now the first element of the array
+    tn = GetNthChild(tn, 0);  // now the first element of the array
     Index iRootNode;
     if (!ReadIndex(tn, iRootNode))
     {
@@ -496,7 +496,7 @@ void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode*
       ExceptionFlinger(ASSERT_LOCATION) << "Root node index << " << iRootNode << " of scene " << iScene << " is out of bounds.";
     }
 
-    tn = Tidx(tnNodes, iRootNode);  // now a "node" object
+    tn = GetNthChild(tnNodes, iRootNode);  // now a "node" object
     if (tn->GetType() != TreeNode::OBJECT)
     {
       ExceptionFlinger(ASSERT_LOCATION) << "Root node of scene " << iScene << " is of invalid JSON type; object required";
@@ -1095,7 +1095,7 @@ void DliLoader::Impl::ParseNodesInternal(const TreeNode* const nodes, Index inde
   std::vector<IndexProperty> resourceIds;
   resourceIds.reserve(4);
 
-  if (auto node = Tidx(nodes, index))
+  if (auto node = GetNthChild(nodes, index))
   {
     NodeDefinition nodeDef;
     nodeDef.mParentIdx = inOutParentStack.empty() ? INVALID_INDEX : inOutParentStack.back();
index ed08a41..451060b 100644 (file)
@@ -903,13 +903,15 @@ float LoadBlendShapeKeyFrames(const std::string& path, const gt::Animation::Chan
   const float duration = LoadDataFromAccessors<float>(path, input, output, inputDataBuffer, outputDataBuffer);
 
   char weightNameBuffer[32];
-  char* const pWeightName = weightNameBuffer + sprintf(weightNameBuffer, "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str());
+  auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str());
+  char* const pWeightName = weightNameBuffer + prefixSize;
+  const auto remainingSize = sizeof(weightNameBuffer) - prefixSize;
   for (uint32_t weightIndex = 0u, endWeightIndex = channel.mSampler->mOutput->mCount / channel.mSampler->mInput->mCount; weightIndex < endWeightIndex; ++weightIndex)
   {
     AnimatedProperty& animatedProperty = properties[propertyIndex++];
 
     animatedProperty.mNodeName = nodeName;
-    sprintf(pWeightName, "%d]", weightIndex);
+    snprintf(pWeightName, remainingSize, "%d]", weightIndex);
     animatedProperty.mPropertyName = std::string(weightNameBuffer);
 
     animatedProperty.mKeyFrames = KeyFrames::New();
index ca1244b..952a824 100644 (file)
@@ -100,6 +100,11 @@ Sampler SamplerFlags::MakeSampler(Type flags)
   return sampler;
 }
 
+TextureDefinition::TextureDefinition(const std::string& imageUri, SamplerFlags::Type samplerFlags)
+: mImageUri(imageUri),
+  mSamplerFlags(samplerFlags)
+{}
+
 MaterialDefinition::RawData
   MaterialDefinition::LoadRaw(const std::string& imagesPath) const
 {
index 619e849..d360c88 100644 (file)
@@ -116,10 +116,7 @@ struct DALI_SCENE_LOADER_API TextureDefinition
   std::string mImageUri;
   SamplerFlags::Type mSamplerFlags;
 
-  TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT)
-  :  mImageUri(imageUri),
-    mSamplerFlags(samplerFlags)
-  {}
+  TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT);
 };
 
 /**
index 19d4544..2cea908 100644 (file)
@@ -64,7 +64,7 @@ private:
 };
 
 
-const std::string QUAD_STRING("quad");
+const std::string QUAD("quad");
 
 ///@brief Reads a blob from the given stream @a source into @a target, which must have
 /// at least @a descriptor.length bytes.
@@ -290,10 +290,10 @@ void CalculateTextureSize(uint32_t totalTextureSize, uint32_t& textureWidth, uin
 {
   DALI_ASSERT_DEBUG(0u != totalTextureSize && "totalTextureSize is zero.")
 
-    // Calculate the dimensions of the texture.
-    // The total size of the texture is the length of the blend shapes blob.
+  // Calculate the dimensions of the texture.
+  // The total size of the texture is the length of the blend shapes blob.
 
-    textureWidth = 0u;
+  textureWidth = 0u;
   textureHeight = 0u;
 
   if (0u == totalTextureSize)
@@ -443,21 +443,21 @@ void CalculateGltf2BlendShapes(uint8_t* geometryBuffer, std::ifstream& binFile,
 }
 
 MeshDefinition::SparseBlob::SparseBlob(const Blob& indices, const Blob& values, uint32_t count)
-:  mIndices{indices},
+: mIndices{indices},
   mValues{values},
   mCount{count}
 {}
 
 MeshDefinition::Accessor::Accessor(const MeshDefinition::Blob& blob,
   const MeshDefinition::SparseBlob& sparse)
-:  mBlob{blob},
+: mBlob{blob},
   mSparse{(sparse.mIndices.IsDefined() && sparse.mValues.IsDefined()) ? new SparseBlob{sparse} : nullptr}
 {}
 
 void MeshDefinition::Blob::ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max,
   uint32_t count, float* values)
 {
-  DALI_ASSERT_DEBUG(max.empty() || max.size() == min.size());
+  DALI_ASSERT_DEBUG(max.size() == min.size() || max.size() * min.size() == 0);
   const auto numComponents = std::max(min.size(), max.size());
 
   using ClampFn = void(*)(const float*, const float*, uint32_t, float&);
@@ -489,6 +489,15 @@ void MeshDefinition::Blob::ApplyMinMax(const std::vector<float>& min, const std:
   }
 }
 
+MeshDefinition::Blob::Blob(uint32_t offset, uint32_t length, uint16_t stride, uint16_t elementSizeHint, const std::vector<float>& min, const std::vector<float>& max)
+: mOffset(offset),
+  mLength(length),
+  mStride(stride),
+  mElementSizeHint(elementSizeHint),
+  mMin(min),
+  mMax(max)
+{}
+
 uint32_t MeshDefinition::Blob::GetBufferSize() const
 {
   return IsConsecutive() ? mLength : (mLength * mElementSizeHint / mStride);
@@ -511,7 +520,7 @@ void MeshDefinition::RawData::Attrib::AttachBuffer(Geometry& g) const
 
 bool MeshDefinition::IsQuad() const
 {
-  return CaseInsensitiveStringCompare("quad", mUri);
+  return CaseInsensitiveStringCompare(QUAD, mUri);
 }
 
 bool MeshDefinition::IsSkinned() const
index 6a1eaa6..057aad7 100644 (file)
@@ -81,14 +81,7 @@ struct DALI_SCENE_LOADER_API MeshDefinition
     Blob() = default;
 
     Blob(uint32_t offset, uint32_t length, uint16_t stride = 0, uint16_t elementSizeHint = 0,
-      const std::vector<float>& min = {}, const std::vector<float>& max = {})
-      : mOffset(offset),
-      mLength(length),
-      mStride(stride),
-      mElementSizeHint(elementSizeHint),
-      mMin(min),
-      mMax(max)
-    {}
+      const std::vector<float>& min = {}, const std::vector<float>& max = {});
 
     /**
      * @brief Calculates the size of a tightly-packed buffer for the elements from the blob.
index 994ec18..3dec499 100644 (file)
@@ -44,8 +44,7 @@ class ViewProjection;
 class DALI_SCENE_LOADER_API IResourceReceiver
 {
 public:
-  virtual ~IResourceReceiver()
-  {}
+  virtual ~IResourceReceiver() = default;
 
   virtual void Register(ResourceType::Value type, Index id) = 0;
 };
@@ -58,8 +57,7 @@ public:
 class DALI_SCENE_LOADER_API IResourceReflector
 {
 public:
-  virtual ~IResourceReflector()
-  {}
+  virtual ~IResourceReflector() = default;
 
   virtual void Reflect(ResourceType::Value type, Index& id) = 0;
 };
@@ -163,7 +161,7 @@ public:  // TYPES
     Index mShaderIdx = INVALID_INDEX;
 
   public: // METHODS
-    virtual ~Renderable() {}
+    virtual ~Renderable() = default;
 
     virtual void RegisterResources(IResourceReceiver& receiver) const;
     virtual void ReflectResources(IResourceReflector& reflector);
@@ -189,7 +187,7 @@ public:  // TYPES
     virtual void Finish(NodeDefinition& n) = 0;
 
   protected:
-    ~IVisitor() {}
+    ~IVisitor() = default; // deliberately non-virtual these are transient objects and we don't want to pay for the vtable.
   };
 
   class IConstVisitor
@@ -199,7 +197,7 @@ public:  // TYPES
     virtual void Finish(const NodeDefinition& n) = 0;
 
   protected:
-    ~IConstVisitor() {}
+    ~IConstVisitor() = default; // deliberately non-virtual these are transient objects and we don't want to pay for the vtable.
   };
 
   struct Extra
index 0bafc3b..54aa0c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -24,6 +24,7 @@
 #include "dali-scene-loader/public-api/blend-shape-details.h"
 #include "dali-scene-loader/public-api/utils.h"
 #include "dali-scene-loader/public-api/skinning-details.h"
+#include "dali-scene-loader/internal/graphics/builtin-shader-extern-gen.h"
 
 //#define DEBUG_SCENE_DEFINITION
 //#define DEBUG_JOINTS
@@ -133,27 +134,6 @@ struct ResourceReflector : IResourceReflector
 
 
 #ifdef DEBUG_JOINTS
-const char* JOINT_DEBUG_VSH = "#version 300 es\n"
-DALI_COMPOSE_SHADER(
-  precision mediump float;
-  uniform mat4 uMvpMatrix;
-  in vec3 aPosition;
-  in float aColor;
-  flat out float vColor;
-  void main() {
-    vColor = aColor;
-    gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
-  });
-
-const char* JOINT_DEBUG_FSH = "#version 300 es\n"
-DALI_COMPOSE_SHADER(
-  precision mediump float;
-  flat in float vColor;
-  out vec4 FragColor;
-  void main() {
-    vec3 rgb = vec3(fract(vColor), fract(vColor * 0.00390625), fract(vColor * 0.00390625 * 0.00390625));
-    FragColor = vec4(rgb, 1.);
-  });
 
 Shader sJointDebugShader;
 int sNumScenes = 0;
@@ -162,7 +142,7 @@ void EnsureJointDebugShaderCreated()
 {
   if (0 == sNumScenes)
   {
-    sJointDebugShader = Shader::New(JOINT_DEBUG_VSH, JOINT_DEBUG_FSH);
+    sJointDebugShader = Shader::New(SHADER_SCENE_LOADER_JOINT_DEBUG_VERT, SHADER_SCENE_LOADER_JOINT_DEBUG_FRAG);
   }
   ++sNumScenes;
 }
@@ -206,7 +186,7 @@ class ActorCreatorVisitor : public NodeDefinition::IConstVisitor
 {
 public:
   ActorCreatorVisitor(NodeDefinition::CreateParams& params)
-  :  mCreationContext(params)
+  : mCreationContext(params)
   {}
 
   void Start(const NodeDefinition& n)
@@ -400,7 +380,7 @@ SceneDefinition::SceneDefinition()
 }
 
 SceneDefinition::SceneDefinition(SceneDefinition&& other)
-:  mNodes(std::move(other.mNodes)),
+: mNodes(std::move(other.mNodes)),
   mRootNodeIds(std::move(other.mRootNodeIds))
 {
 #ifdef DEBUG_JOINTS
index 38dd628..415d25a 100644 (file)
@@ -39,6 +39,8 @@ struct DALI_SCENE_LOADER_API Skinning
    * @brief Name of bone matrix uniform (array).
    */
   static const std::string BONE_UNIFORM_NAME;
+
+  Skinning() = delete;
 };
 
 }
index 773bf17..8b8132e 100644 (file)
@@ -35,7 +35,28 @@ namespace
 thread_local char sExceptionFlingerMessageBuffer[ExceptionFlinger::MESSAGE_BUFFER_SIZE]{};
 }
 
-char* ExceptionFlinger::GetMessageBuffer()
+StreamBuffer::StreamBuffer(char* buffer, size_t size) noexcept(true)
+{
+  setp(buffer, buffer + size);
+}
+
+ExceptionFlinger::Impl::~Impl() noexcept(false)
+{
+  throw DaliException(mLocation, GetMessageBuffer());
+}
+
+ExceptionFlinger::ExceptionFlinger(const char* location) noexcept(true)
+: mImpl{ location },
+  mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1),
+  mStream(&mStreamBuffer)
+{}
+
+ExceptionFlinger::~ExceptionFlinger() noexcept(false)
+{
+  operator<<('\0');
+}
+
+char* ExceptionFlinger::GetMessageBuffer() noexcept(true)
 {
   return sExceptionFlingerMessageBuffer;
 }
index 09c30e1..1aace35 100644 (file)
@@ -41,10 +41,7 @@ namespace SceneLoader
 class DALI_SCENE_LOADER_API StreamBuffer : public std::basic_streambuf<char>
 {
 public:
-  StreamBuffer(char* buffer, size_t size)
-  {
-    setp(buffer, buffer + size);
-  }
+  StreamBuffer(char* buffer, size_t size) noexcept(true);
 };
 
 /*
@@ -57,29 +54,30 @@ class DALI_SCENE_LOADER_API ExceptionFlinger
 public:
   enum { MESSAGE_BUFFER_SIZE = 512 };
 
-  ExceptionFlinger(const char* location)
-  : mLocation(location),
-    mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1),
-    mStream(&mStreamBuffer)
-  {}
+  ExceptionFlinger(const char* location) noexcept(true);
 
-  ~ExceptionFlinger() noexcept(false)
-  {
-    operator<<('\0');
-    throw DaliException(mLocation, GetMessageBuffer());
-  }
+  [[noreturn]]
+  ~ExceptionFlinger() noexcept(false);
 
   template <typename T>
-  ExceptionFlinger& operator<<(const T& rhs)
+  ExceptionFlinger& operator<<(const T& rhs) noexcept(true)
   {
     mStream << rhs;
     return *this;
   }
 
 private:
-  static char* GetMessageBuffer();
+  struct Impl
+  {
+    const char* mLocation;
+
+    [[noreturn]]
+    ~Impl() noexcept(false);
+  };
+
+  static char* GetMessageBuffer() noexcept(true);
 
-  const char* mLocation;
+  Impl mImpl;
   StreamBuffer mStreamBuffer;
   std::ostream mStream;
 };
index f10f037..b255c11 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_UIBUILDER_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -163,9 +163,23 @@ public:
    * @brief Adds user defined constants to all future style template or animation expansions
    *
    * e.g.
-   *   Property::Map map;
-   *   map["IMAGE_DIRECTORY"] = "/usr/share/images";
-   *   builder.AddConstants( map );
+   * @code
+   * Property::Map map;
+   * map["IMAGE_DIRECTORY"] = "/usr/share/images";
+   * builder.AddConstants( map );
+   * @endcode
+   *
+   * The following shows a list of constants available by default:
+   *
+   *  Constant                     | Description
+   * ----------------------------- | ----------------------------------------------------------------------------------------------------
+   *   DALI_IMAGE_DIR              | The Image Directory used by Toolkit.
+   *   DALI_SOUND_DIR              | The Sound Directory used by Toolkit.
+   *   DALI_STYLE_DIR              | The Style directory that the Toolkit uses.
+   *   DALI_STYLE_IMAGE_DIR        | The directory that stores all the images used by Toolkit's style.
+   *   DALI_SHADER_VERSION_PREFIX  | For use in custom shaders to prepend the shader version in use. @ref Shader::GetShaderVersionPrefix
+   *   DALI_VERTEX_SHADER_PREFIX   | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetVertexShaderPrefix
+   *   DALI_FRAGMENT_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetFragmentShaderPrefix()
    *
    * @pre The Builder has been initialized.
    * @param map The user defined constants used in template expansions.
@@ -180,6 +194,8 @@ public:
    * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
    * @endcode
    *
+   * @see AddConstants(const Property::Map&) for builder pre-defined default constants.
+   *
    * @pre The Builder has been initialized.
    * @param key The constant name to add or update
    * @param value The new value for the constant.
diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.cpp
new file mode 100755 (executable)
index 0000000..c8f9aeb
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+const std::string EMPTY_STRING;
+
+WebBackForwardListItem::WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item )
+: mWebEngineBackForwardListItem( item )
+{
+}
+
+WebBackForwardListItem::~WebBackForwardListItem()
+{
+}
+
+std::string WebBackForwardListItem::GetUrl() const
+{
+  return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetUrl() : EMPTY_STRING;
+}
+
+std::string WebBackForwardListItem::GetTitle() const
+{
+  return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetTitle() : EMPTY_STRING;
+}
+
+std::string WebBackForwardListItem::GetOriginalUrl() const
+{
+  return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetOriginalUrl() : EMPTY_STRING;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h
new file mode 100755 (executable)
index 0000000..44a3bc1
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
+#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
+
+/*
+ * Copyright (c) 2021 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+class WebEngineBackForwardListItem;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebBackForwardListItem is a class for back-forward list item of WebView.
+ *
+ *
+ * For working WebBackForwardListItem, a Dali::WebBackForwardListItem should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebBackForwardListItem
+{
+public:
+  /**
+   * @brief Creates a WebBackForwardListItem.
+   */
+  WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item );
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebBackForwardListItem() final;
+
+  /**
+   * @brief Returns the URL of the item.
+   *
+   * @details The returned URL may differ from the original URL (For example,
+   *          if the page is redirected).
+   *
+   * @return The URL of the @a item, otherwise "" in case of an error
+   */
+  std::string GetUrl() const;
+
+  /**
+   * @brief Returns the title of the item.
+   *
+   * @return The title of the @a item, otherwise "" in case of an error
+   */
+  std::string GetTitle() const;
+
+  /**
+   * @brief Returns the original URL of the item.
+   *
+   * @return The original URL of the @a item, otherwise "" in case of an error
+   */
+  std::string GetOriginalUrl() const;
+
+private:
+
+  const Dali::WebEngineBackForwardListItem* mWebEngineBackForwardListItem;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp
new file mode 100755 (executable)
index 0000000..fe4e33b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebBackForwardList::WebBackForwardList( const Dali::WebEngineBackForwardList& list )
+: mWebEngineBackForwardList( list )
+, mWebBackForwardListItem( 0 )
+{
+}
+
+WebBackForwardList::~WebBackForwardList()
+{
+}
+
+WebBackForwardListItem* WebBackForwardList::GetCurrentItem()
+{
+  mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetCurrentItem() );
+  return &mWebBackForwardListItem;
+}
+
+WebBackForwardListItem* WebBackForwardList::GetItemAtIndex( uint32_t index )
+{
+  mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetItemAtIndex( index ) );
+  return &mWebBackForwardListItem;
+}
+
+uint32_t WebBackForwardList::GetItemCount() const
+{
+  return mWebEngineBackForwardList.GetItemCount();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h
new file mode 100755 (executable)
index 0000000..144c02b
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
+#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
+
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+class WebEngineBackForwardList;
+
+namespace Toolkit
+{
+class WebBackForwardListItem;
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebBackForwardList is a class for back-forward list item of WebView.
+ *
+ *
+ * For working WebBackForwardList, a Dali::WebBackForwardList should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebBackForwardList
+{
+public:
+  /**
+   * @brief Creates a WebBackForwardList.
+   */
+  WebBackForwardList( const Dali::WebEngineBackForwardList& list );
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebBackForwardList() final;
+
+  /**
+   * @brief Returns the current item in the @a list.
+   * @return The current item in list.
+   */
+  WebBackForwardListItem* GetCurrentItem();
+
+  /**
+   * @brief Returns the item at a given @a index relative to the current item.
+   * @param[in] index The index of the item
+   * @return The current item in list.
+   */
+  WebBackForwardListItem* GetItemAtIndex(uint32_t index);
+
+  /**
+   * @brief Returns the length of the back-forward list including the current
+   *        item.
+   * @return The length of the back-forward list including the current item,
+   *         otherwise 0 in case of an error
+   */
+  uint32_t GetItemCount() const;
+
+private:
+  const Dali::WebEngineBackForwardList&  mWebEngineBackForwardList;
+  Dali::Toolkit::WebBackForwardListItem mWebBackForwardListItem;
+
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.cpp b/dali-toolkit/devel-api/controls/web-view/web-context.cpp
new file mode 100755 (executable)
index 0000000..1e0cbbd
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebContext::WebContext( Dali::WebEngineContext& context)
+: mWebEngineContext( context )
+{
+}
+
+WebContext::~WebContext()
+{
+}
+
+Dali::WebEngineContext::CacheModel WebContext::GetCacheModel() const
+{
+  return mWebEngineContext.GetCacheModel();
+}
+
+void WebContext::SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel )
+{
+  mWebEngineContext.SetCacheModel( cacheModel );
+}
+
+void WebContext::SetProxyUri( const std::string& uri )
+{
+  mWebEngineContext.SetProxyUri( uri );
+}
+
+void WebContext::SetCertificateFilePath( const std::string& certificatePath )
+{
+  mWebEngineContext.SetCertificateFilePath( certificatePath );
+}
+
+void WebContext::DisableCache( bool cacheDisabled )
+{
+  mWebEngineContext.DisableCache( cacheDisabled );
+}
+
+void WebContext::SetDefaultProxyAuth( const std::string& username, const std::string& password )
+{
+  mWebEngineContext.SetDefaultProxyAuth( username, password );
+}
+
+void WebContext::DeleteWebDatabase()
+{
+  mWebEngineContext.DeleteWebDatabase();
+}
+
+void WebContext::DeleteWebStorage()
+{
+  mWebEngineContext.DeleteWebStorage();
+}
+
+void WebContext::DeleteLocalFileSystem()
+{
+  mWebEngineContext.DeleteLocalFileSystem();
+}
+
+void WebContext::ClearCache()
+{
+  mWebEngineContext.ClearCache();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.h b/dali-toolkit/devel-api/controls/web-view/web-context.h
new file mode 100755 (executable)
index 0000000..1640c70
--- /dev/null
@@ -0,0 +1,148 @@
+#ifndef DALI_TOOLKIT_WEB_CONTEXT_H
+#define DALI_TOOLKIT_WEB_CONTEXT_H
+
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebContext is a control for settings of WebView.
+ *
+ * For working WebContext, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebContext
+{
+public:
+
+  /**
+   * @brief Creates a WebContext.
+   *
+   * @param[in] context The context of web engine.
+   */
+  WebContext( Dali::WebEngineContext& context );
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebContext() final;
+
+  /**
+   * @brief Returns the cache model type.
+   *
+   * @return #Dali::WebEngineContext::CacheModel
+   */
+  Dali::WebEngineContext::CacheModel GetCacheModel() const;
+
+  /**
+   * @brief Requests to set the cache model.
+   *
+   * @param[in] cacheModel The cache model
+   */
+  void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel );
+
+  /**
+   * @brief Sets the given proxy URI to network backend of specific context.
+   *
+   * @param[in] uri The proxy URI to set
+   */
+  void SetProxyUri( const std::string& uri );
+
+  /**
+   * Adds CA certificates to persistent NSS certificate database
+   *
+   * Function accepts a path to a CA certificate file, a path to a directory
+   * containing CA certificate files, or a colon-seprarated list of those.
+   * Certificate files should have *.crt extension.
+   * Directories are traversed recursively.
+   *
+   * @param[in] certificatePath path to a CA certificate file(s), see above for details
+   */
+  void SetCertificateFilePath( const std::string& certificatePath );
+
+  /**
+   * Toggles the cache to be enabled or disabled
+   *
+   * Function works asynchronously.
+   * By default the cache is disabled resulting in not storing network data on disk.
+   *
+   * @param[in] cacheDisabled enable or disable cache
+   */
+  void DisableCache( bool cacheDisabled );
+
+  /**
+   * @brief Sets a proxy auth credential to network backend of specific context.
+   *
+   * @param[in] username username to set
+   * @param[in] password password to set
+   */
+  void SetDefaultProxyAuth( const std::string& username, const std::string& password );
+
+  /**
+   * Requests for deleting all web databases.
+   */
+  void DeleteWebDatabase();
+
+  /**
+   * @brief Deletes web storage.
+   *
+   * @details This function does not ensure that all data will be removed.
+   *          Should be used to extend free physical memory.
+   */
+  void DeleteWebStorage();
+
+  /**
+   * @brief Requests for deleting all local file systems.
+   */
+  void DeleteLocalFileSystem();
+
+  /**
+   * @brief Requests to clear cache
+   */
+  void ClearCache();
+
+private:
+
+  Dali::WebEngineContext&  mWebEngineContext;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_CONTEXT_H
diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp
new file mode 100755 (executable)
index 0000000..ef6bd64
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebCookieManager::WebCookieManager( Dali::WebEngineCookieManager& manager )
+: mWebEngineCookieManager( manager )
+{
+}
+
+WebCookieManager::~WebCookieManager()
+{
+}
+
+void WebCookieManager::SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy cookieAcceptPolicy )
+{
+  mWebEngineCookieManager.SetCookieAcceptPolicy( cookieAcceptPolicy );
+}
+
+Dali::WebEngineCookieManager::CookieAcceptPolicy WebCookieManager::GetCookieAcceptPolicy() const
+{
+  return mWebEngineCookieManager.GetCookieAcceptPolicy();
+}
+
+void WebCookieManager::ClearCookies()
+{
+  mWebEngineCookieManager.ClearCookies();
+}
+
+void WebCookieManager::SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage )
+{
+  mWebEngineCookieManager.SetPersistentStorage( path, storage );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h
new file mode 100755 (executable)
index 0000000..adb8481
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
+#define DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
+
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineCookieManager;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebCookieManager is a control for settings of WebView.
+ *
+ *
+ * For working WebCookieManager, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebCookieManager
+{
+public:
+
+  /**
+   * @brief Creates a WebCookieManager.
+   * @param[in] manager A #Dali::WebEngineCookieManager
+   */
+  WebCookieManager( Dali::WebEngineCookieManager& manager );
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebCookieManager() final;
+
+  /**
+   * @brief Sets @a policy as the cookie acceptance policy for @a manager.
+   *
+   * @details By default, only cookies set by the main document loaded are
+   *          accepted.
+   *
+   * @param[in] policy A #Dali::WebEngineCookieManager::CookieAcceptPolicy
+   */
+  void SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy policy );
+
+  /**
+   * @brief Gets the cookie acceptance policy. The default is Toolkit::WebCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY.
+   * @see Dali::WebEngineCookieManager::CookieAcceptPolicy
+   */
+  Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const;
+
+  /**
+   * @brief Deletes all the cookies of @a manager.
+   */
+  void ClearCookies();
+
+  /**
+   * @brief Sets the @a path where non-session cookies are stored persistently using
+   *        @a storage as the format to read/write the cookies.
+   *
+   * @details Cookies are initially read from @a path/Cookies to create an initial
+   *          set of cookies. Then, non-session cookies will be written to @a path/Cookies.
+   *          By default, @a manager doesn't store the cookies persistently, so you need to
+   *          call this method to keep cookies saved across sessions.
+   *          If @a path does not exist it will be created.
+   *
+   * @param[in] path The path where to read/write Cookies
+   * @param[in] storage The type of storage
+   */
+  void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage );
+
+private:
+
+  Dali::WebEngineCookieManager&  mWebEngineCookieManager;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
diff --git a/dali-toolkit/devel-api/controls/web-view/web-settings.cpp b/dali-toolkit/devel-api/controls/web-view/web-settings.cpp
new file mode 100755 (executable)
index 0000000..7b6dc13
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebSettings::WebSettings( Dali::WebEngineSettings& settings )
+: mWebEngineSettings( settings )
+{
+}
+
+WebSettings::~WebSettings()
+{
+}
+
+void WebSettings::AllowMixedContents( bool allowed )
+{
+  mWebEngineSettings.AllowMixedContents( allowed );
+}
+
+void WebSettings::EnableSpatialNavigation( bool enabled )
+{
+  mWebEngineSettings.AllowMixedContents( enabled );
+}
+
+int WebSettings::GetDefaultFontSize() const
+{
+  return mWebEngineSettings.GetDefaultFontSize();
+}
+
+void WebSettings::SetDefaultFontSize( int defaultFontSize )
+{
+  mWebEngineSettings.SetDefaultFontSize( defaultFontSize );
+}
+
+void WebSettings::EnableWebSecurity( bool enabled )
+{
+  mWebEngineSettings.EnableWebSecurity( enabled );
+}
+
+void WebSettings::AllowFileAccessFromExternalUrl( bool allowed )
+{
+  mWebEngineSettings.AllowFileAccessFromExternalUrl( allowed );
+}
+
+bool WebSettings::IsJavaScriptEnabled() const
+{
+  return mWebEngineSettings.IsJavaScriptEnabled();
+}
+
+void WebSettings::EnableJavaScript( bool enabled )
+{
+  mWebEngineSettings.EnableJavaScript( enabled );
+}
+
+void WebSettings::AllowScriptsOpenWindows( bool allowed )
+{
+  mWebEngineSettings.AllowScriptsOpenWindows( allowed );
+}
+
+bool WebSettings::AreImagesLoadedAutomatically() const
+{
+  return mWebEngineSettings.AreImagesLoadedAutomatically();
+}
+
+void WebSettings::AllowImagesLoadAutomatically( bool automatic )
+{
+  mWebEngineSettings.AllowImagesLoadAutomatically( automatic );
+}
+
+std::string WebSettings::GetDefaultTextEncodingName() const
+{
+  return mWebEngineSettings.GetDefaultTextEncodingName();
+}
+
+void WebSettings::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+{
+  mWebEngineSettings.SetDefaultTextEncodingName( defaultTextEncodingName );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/web-view/web-settings.h b/dali-toolkit/devel-api/controls/web-view/web-settings.h
new file mode 100755 (executable)
index 0000000..dc46e7c
--- /dev/null
@@ -0,0 +1,169 @@
+#ifndef DALI_TOOLKIT_WEB_SETTINGS_H
+#define DALI_TOOLKIT_WEB_SETTINGS_H
+
+/*
+ * Copyright (c) 2020 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineSettings;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebEngineSettings is a control for settings of WebView.
+ *
+ *
+ * For working WebEngineSettings, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebSettings
+{
+public:
+  /**
+   * @brief Creates a WebEngineSettings.
+   *
+   * @param[in] settings A settings of web engine.
+   */
+  WebSettings( Dali::WebEngineSettings& settings );
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~WebSettings() final;
+
+  /**
+   *@brief Allow running mixed contents or not.
+   *
+   * @param[in] allowed if true, allow to run mixed contents,
+   *      otherwise not allow
+   */
+  void AllowMixedContents( bool allowed );
+
+  /**
+   * @brief Enable the spatial navigation or not.
+   *
+   * @param[in] enabled if true, use spatial navigation,
+   *       otherwise to disable
+   */
+  void EnableSpatialNavigation( bool enabled );
+
+  /**
+   * @brief Returns the default font size in pixel. The default value is 16.
+   *
+   * @return The default font size
+   */
+  int GetDefaultFontSize() const;
+
+  /**
+   * @brief Sets the default font size in pixel. The default value is 16.
+   *
+   * @param[in] defaultFontSize A new default font size to set
+   */
+  void SetDefaultFontSize( int defaultFontSize );
+
+  /**
+   * @brief Enables/disables web security.
+   *
+   * @param[in] enabled if true, to enable the web security
+   *       otherwise to disable
+   */
+  void EnableWebSecurity( bool enabled );
+
+  /**
+   * @brief Allow/Disallow file access from external url
+   *
+   * @param[in] allowed if true, to allow file access from external url
+   *       otherwise to disallow
+   */
+  void AllowFileAccessFromExternalUrl( bool allowed );
+
+  /**
+   * @brief Returns whether JavaScript can be executable. The default is true.
+   *
+   * @return true if JavaScript executing is enabled, false otherwise
+   */
+  bool IsJavaScriptEnabled() const;
+
+  /**
+   * @brief Enables/disables JavaScript executing. The default is enabled.
+   *
+   * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+   */
+  void EnableJavaScript( bool enabled );
+
+  /**
+   * @brief Allow if the scripts can open new windows.
+   *
+   * @param[in] allowed if true, the scripts can open new windows,
+   *       otherwise not
+   */
+  void AllowScriptsOpenWindows( bool allowed );
+
+  /**
+   * @brief Returns whether images can be loaded automatically. The default is true.
+   *
+   * @return true if images are loaded automatically, false otherwise
+   */
+  bool AreImagesLoadedAutomatically() const;
+
+  /**
+   * @brief Enables/disables auto loading of images. The default is enabled.
+   *
+   * @param[in] automatic True if images are loaded automatically, false otherwise
+   */
+  void AllowImagesLoadAutomatically( bool automatic );
+
+  /**
+   * @brief Gets the default text encoding name (e.g. UTF-8).
+   *
+   * @return The default text encoding name
+   */
+  std::string GetDefaultTextEncodingName() const;
+
+  /**
+   * @brief Sets the default text encoding name (e.g. UTF-8).
+   *
+   * @param[in] defaultTextEncodingName The default text encoding name
+   */
+  void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+
+private:
+  Dali::WebEngineSettings& mWebEngineSettings;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_SETTINGS_H
old mode 100644 (file)
new mode 100755 (executable)
index 7758f7b..a0672ae
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/web-view/web-view-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 
 namespace Dali
 {
@@ -58,19 +59,49 @@ WebView WebView::New(const std::string& locale, const std::string& timezoneId)
   return Internal::WebView::New(locale, timezoneId);
 }
 
+WebView WebView::New( int argc, char** argv )
+{
+  return Internal::WebView::New( argc, argv );
+}
+
 WebView WebView::DownCast(BaseHandle handle)
 {
   return Control::DownCast<WebView, Internal::WebView>(handle);
 }
 
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
+{
+  return Dali::Toolkit::GetImpl( *this ).GetSettings();
+}
+
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+  return Dali::Toolkit::GetImpl( *this ).GetContext();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+  return Dali::Toolkit::GetImpl( *this ).GetCookieManager();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+  return Dali::Toolkit::GetImpl( *this ).GetBackForwardList();
+}
+
+Dali::Toolkit::ImageView& WebView::GetFavicon()
+{
+  return Dali::Toolkit::GetImpl( *this ).GetFavicon();
+}
+
 void WebView::LoadUrl(const std::string& url)
 {
   Dali::Toolkit::GetImpl(*this).LoadUrl(url);
 }
 
-void WebView::LoadHTMLString(const std::string& htmlString)
+void WebView::LoadHtmlString(const std::string& htmlString)
 {
-  Dali::Toolkit::GetImpl(*this).LoadHTMLString(htmlString);
+  Dali::Toolkit::GetImpl(*this).LoadHtmlString(htmlString);
 }
 
 void WebView::Reload()
@@ -93,6 +124,11 @@ void WebView::Resume()
   Dali::Toolkit::GetImpl(*this).Resume();
 }
 
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+  Dali::Toolkit::GetImpl( *this ).ScrollBy( deltaX, deltaY );
+}
+
 bool WebView::CanGoForward()
 {
   return Dali::Toolkit::GetImpl(*this).CanGoForward();
@@ -128,19 +164,14 @@ void WebView::AddJavaScriptMessageHandler(const std::string& exposedObjectName,
   Dali::Toolkit::GetImpl(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
 }
 
-void WebView::ClearHistory()
+void WebView::ClearAllTilesResources()
 {
-  Dali::Toolkit::GetImpl(*this).ClearHistory();
+  Dali::Toolkit::GetImpl( *this ).ClearAllTilesResources();
 }
 
-void WebView::ClearCache()
-{
-  Dali::Toolkit::GetImpl(*this).ClearCache();
-}
-
-void WebView::ClearCookies()
+void WebView::ClearHistory()
 {
-  Dali::Toolkit::GetImpl(*this).ClearCookies();
+  Dali::Toolkit::GetImpl(*this).ClearHistory();
 }
 
 WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
@@ -158,6 +189,11 @@ WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
   return Dali::Toolkit::GetImpl(*this).PageLoadErrorSignal();
 }
 
+WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+  return Dali::Toolkit::GetImpl( *this ).ScrollEdgeReachedSignal();
+}
+
 WebView::WebView(Internal::WebView& implementation)
 : Control(implementation)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 83b5ebd..0380c26
 #include <functional>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
 #include <dali-toolkit/public-api/controls/control.h>
 
 namespace Dali
 {
 namespace Toolkit
 {
+class ImageView;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
+
 namespace Internal DALI_INTERNAL
 {
 class WebView;
@@ -49,59 +56,6 @@ class WebView;
 class DALI_TOOLKIT_API WebView : public Control
 {
 public:
-  /**
-   * @brief A structure used to contain the cache model enumeration.
-   */
-  struct CacheModel
-  {
-    /**
-     * @brief Enumeration for cache model options.
-     */
-    enum Type
-    {
-      /**
-       * @brief Use the smallest cache capacity.
-       */
-      DOCUMENT_VIEWER,
-
-      /**
-       * @brief Use the bigger cache capacity than DocumentBrowser.
-       */
-      DOCUMENT_BROWSER,
-
-      /**
-       * @brief Use the biggest cache capacity.
-       */
-      PRIMARY_WEB_BROWSER
-    };
-  };
-
-  /**
-   * @brief A structure used to contain the cookie acceptance policy enumeration.
-   */
-  struct CookieAcceptPolicy
-  {
-    /**
-     * @brief Enumeration for the cookies accept policies.
-     */
-    enum Type
-    {
-      /**
-       * @brief Accepts every cookie sent from any page.
-       */
-      ALWAYS,
-
-      /**
-       * @brief Rejects all the cookies.
-       */
-      NEVER,
-
-      /**
-       * @brief Accepts only cookies set by the main document that is loaded.
-       */
-      NO_THIRD_PARTY
-    };
-  };
 
   /**
    * @brief Enumeration for the start and end property ranges for this control.
@@ -126,54 +80,35 @@ public:
       URL = PROPERTY_START_INDEX,
 
       /**
-       * @brief The cache model.
-       * @details Name "cacheModel", type WebView::CacheModel::Type (Property::INTEGER) or Property::STRING.
-       * @note Default is WebView::CacheModel::DOCUMENT_VIEWER.
-       * @see WebView::CacheModel::Type
-       */
-      CACHE_MODEL,
-
-      /**
-       * @brief The cookie acceptance policy.
-       * @details Name "cookieAcceptPolicy", type WebView::CookieAcceptPolicy::Type (Property::INTEGER) or Property::STRING.
-       * @note Default is WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
-       * @see WebView::CookieAcceptPolicy::Type
-       */
-      COOKIE_ACCEPT_POLICY,
-
-      /**
        * @brief The user agent string.
        * @details Name "userAgent", type Property::STRING.
        */
       USER_AGENT,
 
       /**
-       * @brief Whether JavaScript is enabled.
-       * @details Name "enableJavaScript", type Property::BOOLEAN.
-       * @note Default is true.
+       * @brief The current position of scroll.
+       * @details Name "scrollPosition", type Property::VECTOR2.
        */
-      ENABLE_JAVASCRIPT,
+      SCROLL_POSITION,
 
       /**
-       * @brief Whether images can be loaded automatically.
-       * @details Name "loadImagesAutomatically", type Property::BOOLEAN.
-       * @note Default is true.
+       * @brief The current position of scroll.
+       * @details Name "scrollSize", type Property::VECTOR2. Read-only.
        */
-      LOAD_IMAGES_AUTOMATICALLY,
+      SCROLL_SIZE,
 
       /**
-       * @brief The default text encoding name.
-       * @details Name "defaultTextEncodingName", type Property::STRING.
-       * @note If the value is not set, the web engine detects web page's text encoding.
+       * @brief The current position of scroll.
+       * @details Name "contentSize", type Property::VECTOR2. Read-only.
        */
-      DEFAULT_TEXT_ENCODING_NAME,
+      CONTENT_SIZE,
 
       /**
-       * @brief The default font size in pixel.
-       * @details Name "defaultFontSize", type Property::INT.
-       * @note Default is 16.
+       * @brief The title of web page.
+       * @details Name "title", type Property::STRING.
+       * @note The value is read-only.
        */
-      DEFAULT_FONT_SIZE
+      TITLE,
     };
   };
 
@@ -261,12 +196,17 @@ public:
   /**
    * @brief WebView signal type related with page loading.
    */
-  typedef Signal<void(WebView, const std::string&)> WebViewPageLoadSignalType;
+  using WebViewPageLoadSignalType = Signal< void( WebView, const std::string& ) >;
 
   /**
    * @brief WebView signal type related with page loading error.
    */
-  typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
+  using WebViewPageLoadErrorSignalType = Signal< void( WebView, const std::string&, LoadErrorCode ) >;
+
+  /**
+   * @brief WebView signal type related with scroll edge reached.
+   */
+  using WebViewScrollEdgeReachedSignalType = Signal< void( WebView, Dali::WebEnginePlugin::ScrollEdge ) >;
 
 public:
   /**
@@ -286,6 +226,14 @@ public:
   static WebView New(const std::string& locale, const std::string& timezoneId);
 
   /**
+   * @brief Creates an initialized WebView.
+   *
+   * @param [in] argc The count of arguments of Applications
+   * @param [in] argv The string array of arguments of Applications
+   */
+  static WebView New( int argc, char** argv );
+
+  /**
    * @brief Creates an uninitialized WebView.
    */
   WebView();
@@ -324,6 +272,33 @@ public:
   static WebView DownCast(BaseHandle handle);
 
   /**
+   * @brief Get WebSettings of WebEngine.
+   */
+  Dali::Toolkit::WebSettings* GetSettings() const;
+
+  /**
+   * @brief Get WebContext of WebEngine.
+   */
+  Dali::Toolkit::WebContext* GetContext() const;
+
+  /**
+   * @brief Get CookieManager of WebEngine.
+   */
+  Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+  /**
+   * @brief Get WebBackForwardList of WebEngine.
+   */
+  Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+  /**
+   * @brief Get Favicon of web page.
+   *
+   * @return Handle to a fav icon
+   */
+  Dali::Toolkit::ImageView& GetFavicon();
+
+  /**
    * @brief Loads a web page based on a given URL.
    *
    * @param [in] url The URL of the resource to load
@@ -335,7 +310,7 @@ public:
    *
    * @param [in] htmlString The string to use as the contents of the web page
    */
-  void LoadHTMLString(const std::string& htmlString);
+  void LoadHtmlString(const std::string& htmlString);
 
   /**
    * @brief Reloads the Web.
@@ -358,6 +333,13 @@ public:
   void Resume();
 
   /**
+   * @brief Scrolls the webpage of view by deltaX and deltaY.
+   * @param[in] deltaX The delta x of scroll
+   * @param[in] deltaY The delta y of scroll
+   */
+  void ScrollBy( int deltaX, int deltaY );
+
+  /**
    * @brief Returns whether forward is possible.
    *
    * @return True if forward is possible, false otherwise
@@ -423,19 +405,14 @@ public:
   void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
 
   /**
-   * @brief Clears the history of Web.
+   * @brief Clears all tiles resources of Web.
    */
-  void ClearHistory();
+  void ClearAllTilesResources();
 
   /**
-   * @brief Clears the cache of Web.
-   */
-  void ClearCache();
-
-  /**
-   * @brief Clears all the cookies of Web.
+   * @brief Clears the history of Web.
    */
-  void ClearCookies();
+  void ClearHistory();
 
   /**
    * @brief Connects to this signal to be notified when page loading is started.
@@ -458,6 +435,13 @@ public:
    */
   WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
 
+  /**
+   * @brief Connects to this signal to be notified when scroll edge is reached.
+   *
+   * @return A signal object to connect with.
+   */
+  WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
 public: // Not intended for application developers
   /// @cond internal
   /**
index 7315172..f43ca09 100755 (executable)
@@ -36,6 +36,11 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/controls/text-controls/text-selection-toolbar.cpp
   ${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp
   ${devel_api_src_dir}/controls/video-view/video-view-devel.cpp
+  ${devel_api_src_dir}/controls/web-view/web-back-forward-list.cpp
+  ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.cpp
+  ${devel_api_src_dir}/controls/web-view/web-context.cpp
+  ${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp
+  ${devel_api_src_dir}/controls/web-view/web-settings.cpp
   ${devel_api_src_dir}/controls/web-view/web-view.cpp
   ${devel_api_src_dir}/focus-manager/keyinput-focus-manager.cpp
   ${devel_api_src_dir}/focus-manager/keyboard-focus-manager-devel.cpp
@@ -44,6 +49,12 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/image-loader/image-atlas.cpp
   ${devel_api_src_dir}/image-loader/texture-manager.cpp
   ${devel_api_src_dir}/layouting/flex-node.cpp
+  ${devel_api_src_dir}/shader-effects/alpha-discard-effect.cpp
+  ${devel_api_src_dir}/shader-effects/dissolve-effect.cpp
+  ${devel_api_src_dir}/shader-effects/distance-field-effect.cpp
+  ${devel_api_src_dir}/shader-effects/image-region-effect.cpp
+  ${devel_api_src_dir}/shader-effects/motion-blur-effect.cpp
+  ${devel_api_src_dir}/shader-effects/motion-stretch-effect.cpp
   ${devel_api_src_dir}/styling/style-manager-devel.cpp
   ${devel_api_src_dir}/text/bitmap-font.cpp
   ${devel_api_src_dir}/text/text-utils-devel.cpp
@@ -239,6 +250,11 @@ SET( devel_api_video_view_header_files
 )
 
 SET( devel_api_web_view_header_files
+  ${devel_api_src_dir}/controls/web-view/web-back-forward-list.h
+  ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.h
+  ${devel_api_src_dir}/controls/web-view/web-context.h
+  ${devel_api_src_dir}/controls/web-view/web-cookie-manager.h
+  ${devel_api_src_dir}/controls/web-view/web-settings.h
   ${devel_api_src_dir}/controls/web-view/web-view.h
 )
 
diff --git a/dali-toolkit/devel-api/shader-effects/alpha-discard-effect.cpp b/dali-toolkit/devel-api/shader-effects/alpha-discard-effect.cpp
new file mode 100644 (file)
index 0000000..2e049f1
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+Property::Map CreateAlphaDiscardEffect()
+{
+  Property::Map map;
+
+  Property::Map customShader;
+  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_ALPHA_DISCARD_EFFECT_FRAG.data();
+
+  map[Toolkit::Visual::Property::SHADER] = customShader;
+  return map;
+}
+
+} // namespace Toolkit
+} // namespace Dali
index fafd889..e782f78 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_ALPHA_DISCARD_EFFECT_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -22,7 +22,7 @@
 #include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -42,31 +42,7 @@ namespace Toolkit
  *
  * @return A property map of the required shaders.
  */
-inline Property::Map CreateAlphaDiscardEffect()
-{
-  const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE =
-    "varying mediump vec2 vTexCoord;                                \n"
-    "                                                               \n"
-    "uniform sampler2D sTexture;                                    \n"
-    "uniform lowp vec4 uColor;                                      \n"
-    "void main()                                                    \n"
-    "{                                                              \n"
-    "  mediump vec4 color = texture2D( sTexture, vTexCoord );       \n"
-    "  if(color.a <= 0.0001)                                        \n"
-    "  {                                                            \n"
-    "    discard;                                                   \n"
-    "  }                                                            \n"
-    "  gl_FragColor = color * uColor;                               \n"
-    "}                                                              \n";
-
-  Property::Map map;
-
-  Property::Map customShader;
-  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE;
-
-  map[Toolkit::Visual::Property::SHADER] = customShader;
-  return map;
-}
+DALI_TOOLKIT_API Property::Map CreateAlphaDiscardEffect();
 
 } // namespace Toolkit
 
diff --git a/dali-toolkit/devel-api/shader-effects/dissolve-effect.cpp b/dali-toolkit/devel-api/shader-effects/dissolve-effect.cpp
new file mode 100644 (file)
index 0000000..e8c1b7e
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/dissolve-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+void DissolveEffectSetCentralLine( Actor& actor, const Vector2& position, const Vector2& displacement, float initialProgress )
+{
+  // the line passes through 'position' and has the direction of 'displacement'
+  float coefA, coefB, coefC; //line equation: Ax+By+C=0;
+  coefA = displacement.y;
+  coefB = -displacement.x;
+  coefC = -displacement.y * position.x + displacement.x * position.y;
+
+  float inversedAABB     = 1.f / (coefA * coefA + coefB * coefB);
+  float inversedSqrtAABB = sqrtf(inversedAABB);
+  float saddleA;
+
+  //saddle surface(Hyperbolic paraboloid)function, used to calculate the dissolve starting time
+  //z = y*y/a/a - x*x/b/b
+  //with our selection of parameters(a and b), this value for any texture coordinate is between -1.0 and 1.0
+
+  Vector3 saddleParam; // [0]: a*a, [1]: b*b, [2] b
+  Vector2 translation;
+  Vector2 rotation;
+  float   toNext = -1.f;
+  if(displacement.x > 0.f || (EqualsZero(displacement.x) && displacement.y > 0.f))
+  {
+    toNext = 1.f;
+  }
+
+  if((displacement.y * displacement.x < 0.0f))
+  {
+    //distance from (0,0) to the line
+    float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
+    //distance from (1, 1 ) to the line
+    float distanceBottomRight = fabsf(coefA + coefB + coefC) * inversedSqrtAABB;
+    saddleA                   = std::max(distanceTopLeft, distanceBottomRight);
+
+    //foot of a perpendicular: (1,0) to the line
+    float footX1 = (coefB * coefB - coefA * coefC) * inversedAABB;
+    float footY1 = (-coefA * coefB - coefB * coefC) * inversedAABB;
+    //foot of a perpendicular: (0,1) to the line
+    float footX2   = (-coefA * coefB - coefA * coefC) * inversedAABB;
+    float footY2   = (coefA * coefA - coefB * coefC) * inversedAABB;
+    saddleParam[1] = (footX1 - footX2) * (footX1 - footX2) + (footY1 - footY2) * (footY1 - footY2);
+    translation    = Vector2(-footX2, -footY2);
+  }
+  else
+  {
+    //distance from(1,0) to the line
+    float distanceTopRight = fabsf(coefA + coefC) * inversedSqrtAABB;
+    //distance from(0,1) to the line
+    float distanceBottomLeft = fabsf(coefB + coefC) * inversedSqrtAABB;
+    saddleA                  = std::max(distanceTopRight, distanceBottomLeft);
+    //foot of a perpendicular: (0,0) to the line
+    float footX3 = (-coefA * coefC) * inversedAABB;
+    float footY3 = (-coefB * coefC) * inversedAABB;
+    //foot of a perpendicular: (1.0,1.0) to the line
+    float footX4   = (coefB * coefB - coefA * coefB - coefA * coefC) * inversedAABB;
+    float footY4   = (-coefA * coefB + coefA * coefA - coefB * coefC) * inversedAABB;
+    saddleParam[1] = (footX3 - footX4) * (footX3 - footX4) + (footY3 - footY4) * (footY3 - footY4);
+    translation    = Vector2(-footX3, -footY3);
+  }
+
+  saddleParam[2] = sqrtf(saddleParam[1]);
+  saddleParam[0] = saddleA * saddleA;
+  rotation       = Vector2(-displacement.x, displacement.y);
+  rotation.Normalize();
+
+  actor.RegisterProperty("uSaddleParam", saddleParam);
+  actor.RegisterProperty("uTranslation", translation);
+  actor.RegisterProperty("uRotation", rotation);
+  actor.RegisterProperty("uToNext", toNext);
+  actor.RegisterProperty("uPercentage", initialProgress, Dali::Property::ANIMATABLE);
+}
+
+Property::Map CreateDissolveEffect( bool useHighPrecision )
+{
+  const char* prefixHighPrecision("precision highp float;\n");
+  const char* prefixMediumPrecision("precision mediump float;\n");
+
+  const char* vertexShader = SHADER_DISSOLVE_EFFECT_VERT.data();
+  const char* fragmentShader = SHADER_DISSOLVE_EFFECT_FRAG.data();
+
+  Property::Map map;
+
+  Property::Map customShader;
+
+  std::string vertexShaderString;
+  std::string fragmentShaderString;
+  if(useHighPrecision)
+  {
+    vertexShaderString.reserve(strlen(prefixHighPrecision) + strlen(vertexShader));
+    vertexShaderString.append(prefixHighPrecision);
+
+    fragmentShaderString.reserve(strlen(prefixHighPrecision) + strlen(fragmentShader));
+    fragmentShaderString.append(prefixHighPrecision);
+  }
+  else
+  {
+    vertexShaderString.reserve(strlen(prefixMediumPrecision) + strlen(vertexShader));
+    vertexShaderString.append(prefixMediumPrecision);
+
+    fragmentShaderString.reserve(strlen(prefixMediumPrecision) + strlen(fragmentShader));
+    fragmentShaderString.append(prefixMediumPrecision);
+  }
+
+  vertexShaderString.append(vertexShader);
+  fragmentShaderString.append(fragmentShader);
+
+  customShader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShaderString;
+  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
+
+  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 20;
+  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 20;
+
+  customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+  map[Toolkit::Visual::Property::SHADER] = customShader;
+  return map;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
index ba7cb1c..47c171f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_SHADER_EFFECT_DISSOLVE_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/rendering/shader.h>
 #include <string.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 
 namespace Dali
@@ -41,76 +44,8 @@ namespace Toolkit
  * @param[in] displacement The direction of the central line
  * @param[in] initialProgress The normalised initial progress of the shader
  */
-inline void DissolveEffectSetCentralLine(Actor& actor, const Vector2& position, const Vector2& displacement, float initialProgress)
-{
-  // the line passes through 'position' and has the direction of 'displacement'
-  float coefA, coefB, coefC; //line equation: Ax+By+C=0;
-  coefA = displacement.y;
-  coefB = -displacement.x;
-  coefC = -displacement.y * position.x + displacement.x * position.y;
-
-  float inversedAABB     = 1.f / (coefA * coefA + coefB * coefB);
-  float inversedSqrtAABB = sqrtf(inversedAABB);
-  float saddleA;
-
-  //saddle surface(Hyperbolic paraboloid)function, used to calculate the dissolve starting time
-  //z = y*y/a/a - x*x/b/b
-  //with our selection of parameters(a and b), this value for any texture coordinate is between -1.0 and 1.0
-
-  Vector3 saddleParam; // [0]: a*a, [1]: b*b, [2] b
-  Vector2 translation;
-  Vector2 rotation;
-  float   toNext = -1.f;
-  if(displacement.x > 0.f || (EqualsZero(displacement.x) && displacement.y > 0.f))
-  {
-    toNext = 1.f;
-  }
-
-  if((displacement.y * displacement.x < 0.0f))
-  {
-    //distance from (0,0) to the line
-    float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
-    //distance from (1, 1 ) to the line
-    float distanceBottomRight = fabsf(coefA + coefB + coefC) * inversedSqrtAABB;
-    saddleA                   = std::max(distanceTopLeft, distanceBottomRight);
+DALI_TOOLKIT_API void DissolveEffectSetCentralLine( Actor& actor, const Vector2& position, const Vector2& displacement, float initialProgress );
 
-    //foot of a perpendicular: (1,0) to the line
-    float footX1 = (coefB * coefB - coefA * coefC) * inversedAABB;
-    float footY1 = (-coefA * coefB - coefB * coefC) * inversedAABB;
-    //foot of a perpendicular: (0,1) to the line
-    float footX2   = (-coefA * coefB - coefA * coefC) * inversedAABB;
-    float footY2   = (coefA * coefA - coefB * coefC) * inversedAABB;
-    saddleParam[1] = (footX1 - footX2) * (footX1 - footX2) + (footY1 - footY2) * (footY1 - footY2);
-    translation    = Vector2(-footX2, -footY2);
-  }
-  else
-  {
-    //distance from(1,0) to the line
-    float distanceTopRight = fabsf(coefA + coefC) * inversedSqrtAABB;
-    //distance from(0,1) to the line
-    float distanceBottomLeft = fabsf(coefB + coefC) * inversedSqrtAABB;
-    saddleA                  = std::max(distanceTopRight, distanceBottomLeft);
-    //foot of a perpendicular: (0,0) to the line
-    float footX3 = (-coefA * coefC) * inversedAABB;
-    float footY3 = (-coefB * coefC) * inversedAABB;
-    //foot of a perpendicular: (1.0,1.0) to the line
-    float footX4   = (coefB * coefB - coefA * coefB - coefA * coefC) * inversedAABB;
-    float footY4   = (-coefA * coefB + coefA * coefA - coefB * coefC) * inversedAABB;
-    saddleParam[1] = (footX3 - footX4) * (footX3 - footX4) + (footY3 - footY4) * (footY3 - footY4);
-    translation    = Vector2(-footX3, -footY3);
-  }
-
-  saddleParam[2] = sqrtf(saddleParam[1]);
-  saddleParam[0] = saddleA * saddleA;
-  rotation       = Vector2(-displacement.x, displacement.y);
-  rotation.Normalize();
-
-  actor.RegisterProperty("uSaddleParam", saddleParam);
-  actor.RegisterProperty("uTranslation", translation);
-  actor.RegisterProperty("uRotation", rotation);
-  actor.RegisterProperty("uToNext", toNext);
-  actor.RegisterProperty("uPercentage", initialProgress, Dali::Property::ANIMATABLE);
-}
 /**
  * @brief Create a new Dissolve effect
  *
@@ -123,105 +58,7 @@ inline void DissolveEffectSetCentralLine(Actor& actor, const Vector2& position,
  *  @return The newly created Property::Map with the dissolve effect
  */
 
-inline Property::Map CreateDissolveEffect(bool useHighPrecision = true)
-{
-  const char* prefixHighPrecision("precision highp float;\n");
-  const char* prefixMediumPrecision("precision mediump float;\n");
-
-  const char* vertexShader(
-    "attribute mediump vec2 aPosition;\n"
-    "\n"
-    "uniform mediump mat4   uMvpMatrix;\n"
-    "uniform vec3           uSize;\n"
-    "uniform vec4           uTextureRect;"
-    "\n"
-    "uniform float          uPercentage;\n"
-    "uniform vec3           uSaddleParam;\n"
-    "uniform vec2           uTranslation;\n"
-    "uniform vec2           uRotation; \n"
-    "uniform float          uToNext;\n"
-    "\n"
-    "varying float          vPercentage;\n"
-    "varying vec2           vTexCoord;\n"
-    "\n"
-    "void main()\n"
-    "{\n"
-    "  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
-    "  vertexPosition.xyz *= uSize;\n"
-    "  vertexPosition = uMvpMatrix * vertexPosition;\n"
-    "  gl_Position = vertexPosition;\n"
-    "\n"
-    "  vec2 texCoord = aPosition + vec2(0.5);\n"
-    "  vTexCoord = texCoord;\n"
-    "\n"
-    "  //Calculate the distortion value given the dissolve central line\n"
-    "  vec2 value = texCoord + uTranslation;\n"
-    "  mat2 rotateMatrix = mat2(uRotation.s, uRotation.t, -uRotation.t, uRotation.s);\n"
-    "  value = rotateMatrix * value;\n"
-    "  if(uToNext == 1.0)\n"
-    "    value.s = uSaddleParam[2] + value.s;\n"
-    "  float delay = value.t * value.t / uSaddleParam[0] - value.s * value.s / uSaddleParam[1];\n"
-    "  vPercentage = clamp(uPercentage * 2.0 - 0.5 * sin(delay * 1.571) - 0.5, 0.0, 1.0);\n"
-    "}\n");
-
-  const char* fragmentShader(
-    "varying float           vPercentage;\n"
-    "varying mediump vec2  vTexCoord;\n"
-    "\n"
-    "uniform sampler2D   sTexture;\n"
-    "uniform lowp vec4 uColor;\n"
-    "uniform vec4 uTextureRect;\n"
-    "float rand(vec2 co)\n"
-    "{\n"
-    "  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n"
-    "}\n"
-    "void main()\n"
-    "{\n"
-    "  //Calculate the randomness\n"
-    "  float  offsetS = rand(vTexCoord * vPercentage) - vTexCoord.s;\n"
-    "  float offsetT = rand(vec2(vTexCoord.t * vPercentage, vTexCoord.s * vPercentage)) - vTexCoord.t;\n"
-    "  vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage;\n"
-    "  gl_FragColor = texture2D(sTexture, lookupCoord) * uColor;\n"
-    "  gl_FragColor.a *= 1.0 - vPercentage;\n"
-    "}\n");
-
-  Property::Map map;
-
-  Property::Map customShader;
-
-  std::string vertexShaderString;
-  std::string fragmentShaderString;
-  if(useHighPrecision)
-  {
-    vertexShaderString.reserve(strlen(prefixHighPrecision) + strlen(vertexShader));
-    vertexShaderString.append(prefixHighPrecision);
-
-    fragmentShaderString.reserve(strlen(prefixHighPrecision) + strlen(fragmentShader));
-    fragmentShaderString.append(prefixHighPrecision);
-  }
-  else
-  {
-    vertexShaderString.reserve(strlen(prefixMediumPrecision) + strlen(vertexShader));
-    vertexShaderString.append(prefixMediumPrecision);
-
-    fragmentShaderString.reserve(strlen(prefixMediumPrecision) + strlen(fragmentShader));
-    fragmentShaderString.append(prefixMediumPrecision);
-  }
-
-  vertexShaderString.append(vertexShader);
-  fragmentShaderString.append(fragmentShader);
-
-  customShader[Visual::Shader::Property::VERTEX_SHADER]   = vertexShaderString;
-  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
-
-  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 20;
-  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 20;
-
-  customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
-  map[Toolkit::Visual::Property::SHADER] = customShader;
-  return map;
-}
+DALI_TOOLKIT_API Property::Map CreateDissolveEffect( bool useHighPrecision = true);
 
 } // namespace Toolkit
 
diff --git a/dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp b/dali-toolkit/devel-api/shader-effects/distance-field-effect.cpp
new file mode 100644 (file)
index 0000000..597dc7c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
+
+// EXTERNAL INCLUDES
+#include <string.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+Dali::Property::Map CreateDistanceFieldEffect()
+{
+  const char* fragmentShaderPrefix("#extension GL_OES_standard_derivatives : enable\n");
+
+  const char* fragmentShader = SHADER_DISTANCE_FIELD_EFFECT_FRAG.data();
+
+  Property::Map map;
+
+  Property::Map customShader;
+
+  std::string fragmentShaderString;
+  fragmentShaderString.reserve(strlen(fragmentShaderPrefix) + strlen(fragmentShader));
+  fragmentShaderString.append(fragmentShaderPrefix);
+  fragmentShaderString.append(fragmentShader);
+
+  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
+  customShader[Visual::Shader::Property::HINTS]           = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+  map[Toolkit::Visual::Property::SHADER] = customShader;
+  return map;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
index b963693..2a233f3 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_SHADER_EFFECT_DISTANCEFIELD_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  *
  */
 
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/property-map.h>
-#include <string.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
 
 namespace Dali
 {
@@ -52,125 +51,7 @@ namespace Toolkit
  *
  *  @return The newly created Property::Map with the distance field effect
  */
-inline Dali::Property::Map CreateDistanceFieldEffect()
-{
-  const char* fragmentShaderPrefix("#extension GL_OES_standard_derivatives : enable\n");
-
-  const char* fragmentShader(
-    "varying mediump vec2 vTexCoord;\n"
-    "\n"
-    "uniform mediump float uGlowBoundary;\n"
-    "uniform mediump vec2  uOutlineParams;\n"
-    "uniform lowp    vec4  uOutlineColor;\n"
-    "uniform lowp    vec4  uShadowColor;\n"
-    "uniform mediump vec2  uShadowOffset;\n"
-    "uniform lowp    vec4  uGlowColor;\n"
-    "uniform lowp    float uDoOutline;\n"
-    "uniform lowp    float uDoShadow;\n"
-    "uniform lowp    float uDoGlow;\n"
-    "\n"
-    "uniform sampler2D sTexture;\n"
-    "uniform lowp vec4 uColor;\n"
-    "\n"
-    "void main()\n"
-    "{\n"
-    "  // sample distance field\n"
-    "  mediump float smoothing = 0.5;\n"
-    "  \n"
-    "  mediump float distance = texture2D(sTexture, vTexCoord).a;\n"
-    "  mediump float smoothWidth = fwidth(distance);\n"
-    "  mediump float alphaFactor = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);\n"
-    "  lowp    vec4  color;\n"
-    "  if (uDoShadow == 0.0)\n"
-    "  {\n"
-    "    mediump float alpha = uColor.a * alphaFactor;\n"
-    "    lowp    vec4  rgb = uColor;\n"
-    "\n"
-    "    if (uDoOutline > 0.0)\n"
-    "    {\n"
-    "      mediump float outlineWidth = uOutlineParams[1] + smoothWidth;\n"
-    "      mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);\n"
-    "      alpha = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);\n"
-    "      rgb = mix(uOutlineColor, uColor, outlineBlend);\n"
-    "    }\n"
-    "\n"
-    "    if (uDoGlow > 0.0)\n"
-    "    {\n"
-    "      rgb = mix(uGlowColor, rgb, alphaFactor);\n"
-    "      alpha = smoothstep(uGlowBoundary, smoothing, distance);\n"
-    "    }\n"
-    "\n"
-    "    // set fragment color\n"
-    "    color = vec4(rgb.rgb, alpha);\n"
-    "  }\n"
-    "\n"
-    "  else // (uDoShadow > 0.0)\n"
-    "  {\n"
-    "    mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
-    "    mediump float inText = alphaFactor;\n"
-    "    mediump float inShadow = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, shadowDistance);\n"
-    "\n"
-    "    // inside object, outside shadow\n"
-    "    if (inText == 1.0)\n"
-    "    {\n"
-    "      color = uColor;\n"
-    "    }\n"
-    "    // inside object, outside shadow\n"
-    "    else if ((inText != 0.0) && (inShadow == 0.0))\n"
-    "    {\n"
-    "      color = uColor;\n"
-    "      color.a *= inText;\n"
-    "    }\n"
-    "    // outside object, completely inside shadow\n"
-    "    else if ((inText == 0.0) && (inShadow == 1.0))\n"
-    "    {\n"
-    "      color = uShadowColor;\n"
-    "    }\n"
-    "    // inside object, completely inside shadow\n"
-    "    else if ((inText != 0.0) && (inShadow == 1.0))\n"
-    "    {\n"
-    "      color = mix(uShadowColor, uColor, inText);\n"
-    "      color.a = uShadowColor.a;\n"
-    "    }\n"
-    "    // inside object, inside shadow's border\n"
-    "    else if ((inText != 0.0) && (inShadow != 0.0))\n"
-    "    {\n"
-    "      color = mix(uShadowColor, uColor, inText);\n"
-    "      color.a *= max(inText, inShadow);\n"
-    "    }\n"
-    "    // inside shadow's border\n"
-    "    else if (inShadow != 0.0)\n"
-    "    {\n"
-    "      color = uShadowColor;\n"
-    "      color.a *= inShadow;\n"
-    "    }\n"
-    "    // outside shadow and object\n"
-    "    else \n"
-    "    {\n"
-    "      color.a = 0.0;\n"
-    "    }\n"
-    "\n"
-    "  }\n"
-    "\n"
-    "  gl_FragColor = color;\n"
-    "\n"
-    "}\n");
-
-  Property::Map map;
-
-  Property::Map customShader;
-
-  std::string fragmentShaderString;
-  fragmentShaderString.reserve(strlen(fragmentShaderPrefix) + strlen(fragmentShader));
-  fragmentShaderString.append(fragmentShaderPrefix);
-  fragmentShaderString.append(fragmentShader);
-
-  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
-  customShader[Visual::Shader::Property::HINTS]           = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
-  map[Toolkit::Visual::Property::SHADER] = customShader;
-  return map;
-}
+DALI_TOOLKIT_API Dali::Property::Map CreateDistanceFieldEffect();
 
 } // namespace Toolkit
 
diff --git a/dali-toolkit/devel-api/shader-effects/image-region-effect.cpp b/dali-toolkit/devel-api/shader-effects/image-region-effect.cpp
new file mode 100644 (file)
index 0000000..bab97f2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+Property::Map CreateImageRegionEffect()
+{
+  Property::Map map;
+
+  Property::Map customShader;
+  customShader[Visual::Shader::Property::VERTEX_SHADER] = SHADER_IMAGE_REGION_EFFECT_VERT.data();
+
+  map[Toolkit::Visual::Property::SHADER] = customShader;
+  return map;
+}
+
+} // Toolkit
+
+} // Dali
index 30d5f4e..65504c1 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_IMAGE_REGION_EFFECT_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -22,7 +22,7 @@
 #include <dali/public-api/object/property-map.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -41,43 +41,7 @@ namespace Toolkit
  *
  * @return A property map of the required shader
  */
-inline Property::Map CreateImageRegionEffect()
-{
-  std::string vertexShader(
-    "attribute mediump vec2 aPosition;\n"
-    "\n"
-    "uniform mediump mat4 uMvpMatrix;\n"
-    "uniform vec3 uSize;\n"
-    "uniform vec4 uTextureRect;"
-    "\n"
-    "varying vec2 vTexCoord;\n"
-
-    "uniform mediump vec2 uTopLeft;\n"
-    "uniform mediump vec2 uBottomRight;\n"
-    "void main()\n"
-    "{\n"
-    "  mediump vec4 position = vec4(aPosition, 0.0, 1.0);\n"
-    "  position.xyz *= uSize;\n"
-    "  gl_Position = uMvpMatrix * position;\n"
-    // The line below is doing the same as the following commented lines:
-    //"  vec2 imageSize = uTextureRect.zw - uTextureRect.xy;\n"
-    //"  vec2 topLeft = uTextureRect.xy + uTopLeft * imageSize;\n"
-    //"  vec2 bottomRight = uTextureRect.xy + uBottomRight * imageSize;\n"
-    //"  vec2 texCoord = (aTexCoord - uTextureRect.xy) / imageSize;\n"
-    //"  vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );\n"
-
-    "  vec2 texCoord = aPosition + vec2(0.5);\n"
-    "  vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );\n"
-    "}\n");
-
-  Property::Map map;
-
-  Property::Map customShader;
-  customShader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
-
-  map[Toolkit::Visual::Property::SHADER] = customShader;
-  return map;
-}
+DALI_TOOLKIT_API Property::Map CreateImageRegionEffect();
 
 } // namespace Toolkit
 
diff --git a/dali-toolkit/devel-api/shader-effects/motion-blur-effect.cpp b/dali-toolkit/devel-api/shader-effects/motion-blur-effect.cpp
new file mode 100644 (file)
index 0000000..430832e
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/motion-blur-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+void SetMotionBlurProperties( Actor& actor, unsigned int numBlurSamples )
+{
+  actor.RegisterProperty("uBlurTexCoordScale", 0.125f);
+  actor.RegisterProperty("uGeometryStretchFactor", 0.05f);
+  actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
+  actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
+  actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
+  actor.RegisterProperty("uAlphaScale", 0.75f);
+  actor.RegisterProperty("uNumSamples", static_cast<float>(numBlurSamples));
+  actor.RegisterProperty("uRecipNumSamples", 1.0f / static_cast<float>(numBlurSamples));
+  actor.RegisterProperty("uRecipNumSamplesMinusOne", 1.0f / static_cast<float>(numBlurSamples - 1.0f));
+  Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
+
+  Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
+  constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
+  constraint.Apply();
+}
+
+
+Property::Map CreateMotionBlurEffect()
+{
+  Property::Map map;
+
+  Property::Map customShader;
+  customShader[Visual::Shader::Property::VERTEX_SHADER]   = SHADER_MOTION_BLUR_EFFECT_VERT.data();
+  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_MOTION_BLUR_EFFECT_FRAG.data();
+
+  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
+  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
+
+  customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+  map[Toolkit::Visual::Property::SHADER] = customShader;
+  return map;
+}
+
+} // Toolkit
+} // Dali
index b800943..8201976 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_SHADER_EFFECT_MOTION_BLUR_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/actors/actor.h>
-#include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/object/property-map.h>
-#include <dali/public-api/rendering/shader.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -37,23 +35,7 @@ namespace Toolkit
  * @param[in] actor The actor that registers the uniform properties
  * @param[in] numBlurSamples Number of samples used by the shader
  */
-inline void SetMotionBlurProperties(Actor& actor, unsigned int numBlurSamples = 8)
-{
-  actor.RegisterProperty("uBlurTexCoordScale", 0.125f);
-  actor.RegisterProperty("uGeometryStretchFactor", 0.05f);
-  actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
-  actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
-  actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
-  actor.RegisterProperty("uAlphaScale", 0.75f);
-  actor.RegisterProperty("uNumSamples", static_cast<float>(numBlurSamples));
-  actor.RegisterProperty("uRecipNumSamples", 1.0f / static_cast<float>(numBlurSamples));
-  actor.RegisterProperty("uRecipNumSamplesMinusOne", 1.0f / static_cast<float>(numBlurSamples - 1.0f));
-  Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
-
-  Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
-  constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
-  constraint.Apply();
-}
+DALI_TOOLKIT_API void SetMotionBlurProperties( Actor& actor, unsigned int numBlurSamples = 8 );
 
 /**
  * @brief Create a new MotionBlurEffect
@@ -95,147 +77,7 @@ inline void SetMotionBlurProperties(Actor& actor, unsigned int numBlurSamples =
  *
  * @return The newly created Property::Map with the motion blur effect
  */
-inline Property::Map CreateMotionBlurEffect()
-{
-  std::string vertexSource;
-  vertexSource =
-    "precision mediump float;\n"
-
-    "attribute vec2 aPosition;\n"
-
-    "uniform mat4 uMvpMatrix;\n"
-    "uniform mat4 uModelView;\n"
-    "uniform mat4 uViewMatrix;\n"
-    "uniform mat4 uProjection;\n"
-    "uniform vec3 uSize;\n"
-
-    "uniform mat4 uModelLastFrame;\n"
-    "float timeDelta = 0.0167;\n"
-
-    "uniform float uGeometryStretchFactor;\n"
-    "uniform float uSpeedScalingFactor;\n"
-
-    // outputs
-    "varying vec2 vModelSpaceCenterToPos;\n"
-    "varying vec2 vScreenSpaceVelocityVector;\n"
-    "varying float vSpeed;\n"
-    "varying vec2 vTexCoord;\n"
-
-    "void main()\n"
-    "{\n"
-    // get view space position of vertex this frame and last frame
-    " vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
-    " vertexPosition.xyz *= uSize;\n"
-
-    " vec4 viewSpaceVertex = uModelView * vertexPosition;\n"
-    " vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertexPosition;\n"
-    " float reciprocalTimeDelta = 1.0 / timeDelta;\n"
-
-    // work out vertex's last movement in view space
-    " vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
-
-    // get clip space position of vertex this frame and last frame
-    " vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;\n"
-    " vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;\n"
-
-    // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
-    // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
-    " float t = 0.0;\n"
-    " float posDeltaLength = length(viewSpacePosDelta);\n"
-    " if(posDeltaLength > 0.001)\n" // avoid div by 0 if object has barely moved
-    " {\n"
-    "   vec4 viewSpaceCenterToPos = uModelView * vec4(vertexPosition.xy, 0.0, 0.0);\n"
-    "   float centerToVertexDist = length(viewSpaceCenterToPos);\n"
-    "   if(centerToVertexDist > 0.001)\n" // avoid div by 0 if object has vertex at model space origin
-    "   {\n"
-    "     vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;\n"
-    "     vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;\n"
-    "     t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5;\n" // scale and bias from [-1..1] to [0..1]
-    "   }\n"
-    " }\n"
-    // output vertex position lerped with its last position, based on how much it is trailing,
-    // this stretches the geom back along where it has just been, giving a warping effect
-    // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
-    " gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * uGeometryStretchFactor * reciprocalTimeDelta);\n"
-
-    // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
-    " vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;\n"
-    " vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;\n"
-    // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
-    " vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);\n"
-    " vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y;\n" // TODO negated due to y being inverted in our coordinate system?
-    // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
-    " vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;\n"
-    " vSpeed = clamp(vSpeed, 0.0, 1.0);\n"
-
-    // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
-    " vModelSpaceCenterToPos = viewSpaceVertex.xy;\n"
-
-    " vec2 texCoord = aPosition + vec2(0.5);"
-    " vTexCoord = texCoord;\n"
-    "}\n";
-
-  std::string fragmentSource;
-  fragmentSource =
-    "precision mediump float;\n"
-
-    "uniform sampler2D sTexture;\n"
-    "uniform vec4 uColor;\n"
-
-    "uniform vec2 uObjectFadeStart;\n"
-    "uniform vec2 uObjectFadeEnd;\n"
-    "uniform float uAlphaScale;\n"
-    "uniform float uBlurTexCoordScale;\n"
-    "uniform float uNumSamples;\n"
-    "uniform float uRecipNumSamples;\n"
-    "uniform float uRecipNumSamplesMinusOne;\n"
-    // inputs
-    "varying vec2 vModelSpaceCenterToPos;\n"
-    "varying vec2 vScreenSpaceVelocityVector;\n"
-    "varying float vSpeed;\n"
-    "varying vec2 vTexCoord;\n"
-
-    "void main()\n"
-    "{\n"
-    // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
-    // the blurred object and the unblurred background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
-    " vec2 centerToPixel = abs(vModelSpaceCenterToPos);\n"
-    " vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));\n"
-    " float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale;\n" // apply global scaler
-    " fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);\n"                // fade proportional to speed, so opaque when at rest
-
-    // scale velocity vector by user requirements
-    " vec2 velocity = vScreenSpaceVelocityVector * uBlurTexCoordScale;\n"
-
-    // standard actor texel
-    " vec4 colActor = texture2D(sTexture, vTexCoord);\n"
-
-    // blurred actor - gather texture samples from the actor texture in the direction of motion
-    " vec4 col = colActor * uRecipNumSamples;\n"
-    " for(float i = 1.0; i < uNumSamples; i += 1.0)\n"
-    " {\n"
-    "   float t = i * uRecipNumSamplesMinusOne;\n"
-    "   col += texture2D(sTexture, vTexCoord + (velocity * t)) * uRecipNumSamples;\n"
-    " }\n"
-    " gl_FragColor = mix(colActor, col, vSpeed);\n"                         // lerp blurred and non-blurred actor based on speed of motion
-    " gl_FragColor.a = fadeToEdgesScale;//colActor.a * fadeToEdgesScale;\n" // fade blurred actor to its edges based on speed of motion
-    " gl_FragColor *= uColor;\n"
-    "}\n";
-
-  Property::Map map;
-
-  Property::Map customShader;
-  customShader[Visual::Shader::Property::VERTEX_SHADER]   = vertexSource;
-  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentSource;
-
-  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
-  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
-
-  customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
-  map[Toolkit::Visual::Property::SHADER] = customShader;
-  return map;
-}
+DALI_TOOLKIT_API Property::Map CreateMotionBlurEffect();
 
 } // namespace Toolkit
 
diff --git a/dali-toolkit/devel-api/shader-effects/motion-stretch-effect.cpp b/dali-toolkit/devel-api/shader-effects/motion-stretch-effect.cpp
new file mode 100644 (file)
index 0000000..bdd21f7
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/motion-stretch-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+void SetMotionStretchProperties( Actor& actor )
+{
+  actor.RegisterProperty("uGeometryStretchFactor", 0.5f);
+  actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
+  actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
+  actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
+  actor.RegisterProperty("uAlphaScale", 0.75f);
+  Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
+
+  Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
+  constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
+  constraint.Apply();
+}
+
+Property::Map CreateMotionStretchEffect()
+{
+  Property::Map map;
+
+  Property::Map customShader;
+  customShader[Visual::Shader::Property::VERTEX_SHADER]   = SHADER_MOTION_STRETCH_EFFECT_VERT.data();
+  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_MOTION_STRETCH_EFFECT_FRAG.data();
+
+  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
+  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
+
+  customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+  map[Toolkit::Visual::Property::SHADER] = customShader;
+  return map;
+}
+
+
+} // Toolkit
+} // Dali
index 8ad4c48..5f4976d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/actors/actor.h>
-#include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/object/property-map.h>
-#include <dali/public-api/rendering/shader.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -34,19 +32,7 @@ namespace Toolkit
 /**
  * @brief Set the properties for the motion stretch
  */
-inline void SetMotionStretchProperties(Actor& actor)
-{
-  actor.RegisterProperty("uGeometryStretchFactor", 0.5f);
-  actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
-  actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
-  actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
-  actor.RegisterProperty("uAlphaScale", 0.75f);
-  Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
-
-  Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
-  constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
-  constraint.Apply();
-}
+DALI_TOOLKIT_API void SetMotionStretchProperties( Actor& actor );
 
 /**
  * @brief Creates a new MotionStretchEffect
@@ -74,134 +60,7 @@ inline void SetMotionStretchProperties(Actor& actor)
  *
  * @return The newly created Property::Map with the motion stretch effect
  */
-inline Property::Map CreateMotionStretchEffect()
-{
-  std::string vertexSource;
-  vertexSource =
-    "precision mediump float;\n"
-
-    "attribute vec2 aPosition;\n"
-
-    "uniform mat4 uMvpMatrix;\n"
-    "uniform mat4 uModelView;\n"
-    "uniform mat4 uViewMatrix;\n"
-    "uniform mat4 uProjection;\n"
-    "uniform vec3 uSize;\n"
-
-    "uniform mat4  uModelLastFrame;\n"
-    "float timeDelta = 0.0167;\n"
-
-    "uniform float uGeometryStretchFactor;\n"
-    "uniform float uSpeedScalingFactor;\n"
-
-    // outputs
-    "varying vec2 vModelSpaceCenterToPos;\n"
-    "varying vec2 vScreenSpaceVelocityVector;\n"
-    "varying float vSpeed;\n"
-    "varying vec2 vTexCoord;\n"
-
-    "void main()\n"
-    "{\n"
-    // get view space position of vertex this frame and last frame
-    " vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
-    " vertexPosition.xyz *= uSize;\n"
-
-    " vec4 viewSpaceVertex = uModelView * vertexPosition;\n"
-    " vec4 viewSpaceVertexLastFrame = uViewMatrix * uModelLastFrame * vertexPosition;\n"
-
-    // work out vertex's last movement in view space
-    " vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
-    " float reciprocalTimeDelta = 1.0 / timeDelta;\n"
-
-    // get clip space position of vertex this frame and last frame
-    " vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;\n"
-    " vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;\n"
-
-    // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
-    // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
-    " float t = 0.0;\n"
-    " float posDeltaLength = length(viewSpacePosDelta);\n"
-    " if(posDeltaLength > 0.001)\n" // avoid div by 0 if object has barely moved
-    " {\n"
-    "   vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0, 0.0);\n"
-    "   float centerToVertexDist = length(viewSpaceCenterToPos);\n"
-    "   if(centerToVertexDist > 0.001)\n" // avoid div by 0 if object has vertex at model space origin
-    "   {\n"
-    "     vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;\n"
-    "     vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;\n"
-    "     t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5;\n" // scale and bias from [-1..1] to [0..1]
-    "   }\n"
-    " }\n"
-    // output vertex position lerped with its last position, based on how much it is trailing,
-    // this stretches the geom back along where it has just been, giving a warping effect
-    // We raise t to a power in order that non-trailing vertices are effected much more than trailing ones
-    // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
-    " gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * t * t * uGeometryStretchFactor * reciprocalTimeDelta);\n"
-
-    // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
-    " vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;\n"
-    " vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;\n"
-    // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
-    " vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);\n"
-    " vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y;\n" // TODO negated due to y being inverted in our coordinate system?
-    // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
-    " vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;\n"
-    " vSpeed = clamp(vSpeed, 0.0, 1.0);\n"
-
-    // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
-    " vModelSpaceCenterToPos = viewSpaceVertex.xy;\n"
-
-    " vec2 texCoord = aPosition + vec2(0.5);"
-    " vTexCoord = texCoord;\n"
-    "}\n";
-
-  std::string fragmentSource;
-  fragmentSource =
-    "precision mediump float;\n"
-
-    "uniform sampler2D sTexture;\n"
-    "uniform vec4 uColor;\n"
-
-    "uniform vec2 uObjectFadeStart;\n"
-    "uniform vec2 uObjectFadeEnd;\n"
-    "uniform float uAlphaScale;\n"
-
-    // inputs
-    "varying vec2 vModelSpaceCenterToPos;\n"
-    "varying vec2 vScreenSpaceVelocityVector;\n"
-    "varying float vSpeed;\n"
-    "varying vec2 vTexCoord;\n"
-
-    "void main()\n"
-    "{\n"
-    // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
-    // the stretched object and the background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
-    " vec2 centerToPixel = abs( vModelSpaceCenterToPos );\n"
-    " vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));\n"
-    " float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale;\n" // apply global scaler
-    " fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);\n"                // fade proportional to speed, so opaque when at rest
-
-    // standard actor texel
-    " vec4 colActor = texture2D(sTexture, vTexCoord);\n"
-    " gl_FragColor = colActor;\n"
-    " gl_FragColor.a *= fadeToEdgesScale;\n" // fade actor to its edges based on speed of motion
-    " gl_FragColor *= uColor;\n"
-    "}";
-
-  Property::Map map;
-
-  Property::Map customShader;
-  customShader[Visual::Shader::Property::VERTEX_SHADER]   = vertexSource;
-  customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentSource;
-
-  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
-  customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
-
-  customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
-  map[Toolkit::Visual::Property::SHADER] = customShader;
-  return map;
-}
+DALI_TOOLKIT_API Property::Map CreateMotionStretchEffect();
 
 } // namespace Toolkit
 
index e03515b..8be5a94 100644 (file)
@@ -39,21 +39,21 @@ enum
 {
   /**
    * @brief The thickness of the arc.
-   * @details Name "thickness", type Property::FLOAT.
+   * @details Name "thickness", type Property::FLOAT, animatable.
    * @note Mandatory.
    */
   THICKNESS = VISUAL_PROPERTY_START_INDEX,
 
   /**
    * @brief The start angle where the arc begins in degrees.
-   * @details Name "startAngle", type Property::FLOAT.
+   * @details Name "startAngle", type Property::FLOAT, animatable.
    * @note Optional. If not specified, the default is 0.
    */
   START_ANGLE,
 
   /**
    * @brief The sweep angle of the arc in degrees.
-   * @details Name "sweepAngle", type Property::FLOAT.
+   * @details Name "sweepAngle", type Property::FLOAT, animatable.
    * The arc starts at a specified start angle and sweeps clockwise, drawing slices of pie.
    * @note Optional. If not specified, the default is 360.
    */
index a10a3f8..413b556 100644 (file)
@@ -104,14 +104,14 @@ enum Type
   PLAY_STATE = ORIENTATION_CORRECTION + 5,
 
   /**
-   * @brief The current frame number the AnimatedVectorImageVisual will use.
+   * @brief The current frame number the AnimatedImageVisual and AnimatedVectorImageVisual will use.
    * @details Name "currentFrameNumber", Type Property::INTEGER, between [0, the maximum frame number] or between the play range if specified
    * @note This property is read-only.
    */
   CURRENT_FRAME_NUMBER = ORIENTATION_CORRECTION + 6,
 
   /**
-   * @brief The total frame number the AnimatedVectorImageVisual will use.
+   * @brief The total frame number the AnimatedImageVisual and AnimatedVectorImageVisual will use.
    * @details Name "totalFrameNumber", Type Property::INTEGER.
    * @note This property is read-only.
    */
index 8bcdff1..88c51b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -28,6 +28,7 @@
 #include <dali/public-api/object/type-info.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/rendering/shader.h>
 #include <dali/public-api/signals/functor-delegate.h>
 #include <dali/devel-api/common/stage.h>
 #include <dali/devel-api/scripting/scripting.h>
@@ -156,13 +157,16 @@ Builder::Builder()
 {
   mParser = Dali::Toolkit::JsonParser::New();
 
-  Property::Map defaultDirs;
-  defaultDirs[TOKEN_STRING(DALI_IMAGE_DIR)]       = AssetManager::GetDaliImagePath();
-  defaultDirs[TOKEN_STRING(DALI_SOUND_DIR)]       = AssetManager::GetDaliSoundPath();
-  defaultDirs[TOKEN_STRING(DALI_STYLE_DIR)]       = AssetManager::GetDaliStylePath();
-  defaultDirs[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath();
+  Property::Map defaultConstants;
+  defaultConstants[TOKEN_STRING(DALI_IMAGE_DIR)]              = AssetManager::GetDaliImagePath();
+  defaultConstants[TOKEN_STRING(DALI_SOUND_DIR)]              = AssetManager::GetDaliSoundPath();
+  defaultConstants[TOKEN_STRING(DALI_STYLE_DIR)]              = AssetManager::GetDaliStylePath();
+  defaultConstants[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)]        = AssetManager::GetDaliStyleImagePath();
+  defaultConstants[TOKEN_STRING(DALI_SHADER_VERSION_PREFIX)]  = Shader::GetShaderVersionPrefix();
+  defaultConstants[TOKEN_STRING(DALI_VERTEX_SHADER_PREFIX)]   = Shader::GetVertexShaderPrefix();
+  defaultConstants[TOKEN_STRING(DALI_FRAGMENT_SHADER_PREFIX)] = Shader::GetFragmentShaderPrefix();
 
-  AddConstants( defaultDirs );
+  AddConstants(defaultConstants);
 }
 
 void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
index ed35267..d54dcd3 100644 (file)
@@ -33,6 +33,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
 #include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h>
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
@@ -85,54 +86,6 @@ const char* const BLOOM_SATURATION_PROPERTY_NAME = "uBloomSaturation";
 const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
 const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
 
-///////////////////////////////////////////////////////
-//
-// Bloom shaders
-//
-
-const char* const BLOOM_EXTRACT_FRAGMENT_SOURCE =
-  "varying mediump vec2 vTexCoord;\n"
-  "uniform sampler2D sTexture;\n"
-  "uniform lowp vec4 uColor;\n"
-  "uniform mediump float uBloomThreshold;\n"
-  "uniform mediump float uRecipOneMinusBloomThreshold;\n"
-  "void main()\n"
-  "{\n"
-  "  mediump vec4 col;\n"
-  "  col = texture2D(sTexture, vTexCoord);\n"
-  "  col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold;\n" // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
-  "  gl_FragColor = clamp(col, 0.0, 1.0);\n"
-  "}\n";
-
-const char* const COMPOSITE_FRAGMENT_SOURCE =
-  "precision mediump float;\n"
-  "varying mediump vec2 vTexCoord;\n"
-  "uniform sampler2D sTexture;\n"
-  "uniform sampler2D sEffect;\n"
-  "uniform lowp vec4 uColor;\n"
-  "uniform float uBloomIntensity;\n"
-  "uniform float uImageIntensity;\n"
-  "uniform float uBloomSaturation;\n"
-  "uniform float uImageSaturation;\n"
-
-  "vec4 ChangeSaturation(vec4 col, float sat)\n"
-  "{\n"
-  "  float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));\n"
-  "  return mix(vec4(grey, grey, grey, 1.0), col, sat);\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  mediump vec4 image;\n"
-  "  mediump vec4 bloom;\n"
-  "  image = texture2D(sTexture, vTexCoord);\n"
-  "  bloom = texture2D(sEffect, vTexCoord);\n"
-  "  image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;\n"
-  "  bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;\n"
-  "  image *= 1.0 - clamp(bloom, 0.0, 1.0);\n" // darken base where bloom is strong, to prevent excessive burn-out of result
-  "  gl_FragColor = image + bloom;\n"
-  "}\n";
-
 } // namespace
 
 
@@ -386,7 +339,7 @@ void BloomView::AllocateResources()
     //////////////////////////////////////////////////////
     // Point actors and render tasks at new render targets
 
-    Renderer bloomRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, BLOOM_EXTRACT_FRAGMENT_SOURCE );
+    Renderer bloomRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLOOM_VIEW_EXTRACT_SHADER_FRAG );
     SetRendererTexture( bloomRenderer, mRenderTargetForRenderingChildren );
     mBloomExtractActor.AddRenderer( bloomRenderer );
     mBloomExtractActor.SetProperty( Actor::Property::SIZE, Vector2( mDownsampledWidth, mDownsampledHeight ) ); // size needs to match render target
@@ -395,7 +348,7 @@ void BloomView::AllocateResources()
     mGaussianBlurView.SetUserImageAndOutputRenderTarget( mBloomExtractTarget.GetColorTexture(), blurExtractTarget );
 
     // use the completed blur in the first buffer and composite with the original child actors render
-    Renderer compositeRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, COMPOSITE_FRAGMENT_SOURCE );
+    Renderer compositeRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLOOM_VIEW_COMPOSITE_SHADER_FRAG );
     SetRendererTexture( compositeRenderer, mRenderTargetForRenderingChildren );
     TextureSet textureSet = compositeRenderer.GetTextures();
     textureSet.SetTexture( 0u, mRenderTargetForRenderingChildren.GetColorTexture() );
index 65b485f..4f4a3e5 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <sstream>
 #include <dali/public-api/rendering/shader.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -38,87 +39,10 @@ namespace Internal
  */
 inline Shader CreateBubbleShader( unsigned int numBubble )
 {
-  const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump float   aIndex;\n
-  attribute mediump vec2    aPosition;\n
-  attribute highp   vec2    aTexCoord;\n
-  varying   mediump vec2    vTexCoord;\n
-  uniform   mediump mat4    uMvpMatrix;\n
-  // the gravity applied to the y direction
-  uniform mediump float uGravity;\n
-  // xy: the emit position of the bubble; zw: the destination of the bubble.
-  // The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
-  uniform vec4 uStartEndPosition[NUMBER_OF_BUBBLE];\n
-  // The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
-  uniform float uPercentage[NUMBER_OF_BUBBLE];\n
-  uniform vec2 uInvertedMovementArea;\n
-  // The bubble number is restricted by the available uniform num.
-  // To increase the displayed bubble, every uStartEndPosition and uPercentage uniform is applied to a small bunch of bubbles (9 here)
-  // The offset defines the random offset between bubbles within the bunch.
-  uniform vec2 uOffset[9];\n
-  // This uniform is used to change the bubble size during running time
-  uniform float uDynamicScale;\n
-  varying float vPercentage;\n
-  varying vec2  vEffectTexCoord;\n
-  void main()\n
-  {\n
-    vec4 position = vec4( aPosition, 0.0, 1.0 );\n
-    // The Z coordinate is used to record the bubble index within current mesh actor
-    int index = int(aIndex); \n
-    //for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
-    int groupIdx = index / NUMBER_OF_BUBBLE;\n
-    // The bubbles within the same bunch applies the same uniforms uStartEndPosition[idx] & uPercentage[idx]
-    int idx = index - groupIdx*NUMBER_OF_BUBBLE;\n
-    float percentage = uPercentage[idx];
-    // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
-    if( percentage <= 0.0 || percentage >= 1.0 )\n
-    {\n
-      gl_Position = vec4(0.0);\n
-      return;\n
-    }\n
-    vec4 startAndEnd = uStartEndPosition[idx];\n
-    // The final position is added up different offset for bubbles
-    startAndEnd.zw += uOffset[groupIdx];\n
-    \n
-    // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
-    // the new xy value containes both the new scale and new bubble position
-    position.xy *= uDynamicScale*min(percentage*5.0, 1.0);\n
-    position.xy += mix(startAndEnd.xy, startAndEnd.zw, percentage);\n
-    // The gravity is g*t*t on the y direction
-    position.y += uGravity * pow(percentage, 2.0);\n
-    gl_Position = uMvpMatrix * position;\n
-    \n
-    // Add multiple bubble shapes in the effect
-    vTexCoord = aTexCoord;\n
-    vPercentage = percentage;\n
-    // Use the emit position color for the bubble
-    vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea + vec2(0.5);\n
-  }\n
-  );
-
-  const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  varying mediump vec2  vTexCoord;\n
-  uniform lowp    vec4  uColor;\n
-  uniform sampler2D     sBackground;\n
-  uniform sampler2D     sBubbleShape;\n
-  varying mediump float vPercentage;\n
-  varying mediump vec2  vEffectTexCoord;\n
-  \n
-  void main()\n
-  {\n
-    // Get the emit pisition color, and Mix with the actor color
-    mediump vec4 fragColor = texture2D(sBackground, vEffectTexCoord)*uColor;\n
-    // Apply the shape defined by the texture contained sBubbleShape
-    // And make the opacity being 0.7, and animate from 0.7 to 0 during the last 1/3 of movement
-    fragColor.a  *= texture2D(sBubbleShape, vTexCoord).a * ( 2.1 - max( vPercentage*2.1, 1.4 ) );\n
-    gl_FragColor = fragColor;\n
-  }\n
-  );
-
   std::ostringstream vertexShaderStringStream;
   vertexShaderStringStream << "#define NUMBER_OF_BUBBLE "<< numBubble << "\n"
-                           << VERTEX_SHADER;
-  Shader shader = Shader::New( vertexShaderStringStream.str(), FRAGMENT_SHADER );
+                           << SHADER_BUBBLE_EFFECT_VERT;
+  Shader shader = Shader::New( vertexShaderStringStream.str(), SHADER_BUBBLE_EFFECT_FRAG );
 
   return shader;
 }
index 5ee9047..b1e28e7 100644 (file)
@@ -27,6 +27,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/bubble-effect/bubble-effect.h>
 #include <dali-toolkit/internal/controls/bubble-effect/bubble-renderer.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace
 {
@@ -59,60 +60,6 @@ float RandomRange(float f0, float f1, unsigned int& seed)
   return f0 + (rand_r( &seed ) & 0xfff) * (f1-f0) * (1.0f/4095.0f);
 }
 
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  attribute mediump vec2 aTexCoord;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  varying mediump vec2 vTexCoord;\n
-  \n
-
-  void main()\n
-  {\n
-    gl_Position = uMvpMatrix * vec4(aPosition*uSize.xy,0.0,1.0);
-    vTexCoord = aTexCoord;\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-    precision highp float;\n
-    uniform vec3 uHSVDelta;\n
-    varying mediump vec2 vTexCoord;\n
-    uniform sampler2D sTexture;\n
-    float rand(vec2 co) \n
-    {\n
-      return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
-    \n
-    vec3 rgb2hsv(vec3 c)\n
-    {\n
-      vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
-      vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n
-      vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n
-      \n
-      float d = q.x - min(q.w, q.y);\n
-      float e = 1.0e-10;\n
-      return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n
-    }\n
-    vec3 hsv2rgb(vec3 c)\n
-    {\n
-      vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
-      vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n
-      return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n
-    }\n
-    void main() {\n
-      vec4 color = texture2D(sTexture, vTexCoord); \n
-      vec3 hsvColor = rgb2hsv( color.rgb );\n
-      // modify the hsv Value
-      hsvColor += uHSVDelta * rand(vTexCoord); \n
-      // if the new vale exceeds one, then decrease it
-      hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n
-      // if the new vale drops below zero, then increase it
-      hsvColor -= min(hsvColor*2.0, 0.0);\n
-      color = vec4( hsv2rgb( hsvColor ), 1.0 ); \n
-      gl_FragColor = color; \n
-    }\n
-  );
-
 Dali::Geometry CreateTexturedQuad()
 {
   struct Vertex
@@ -265,7 +212,7 @@ void BubbleEmitter::SetBackground( Texture bgTexture, const Vector3& hsvDelta )
 
   //Create renderer
   Dali::Geometry geometry = CreateTexturedQuad();
-  Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+  Shader shader = Shader::New( SHADER_BUBBLE_EMITTER_VERT, SHADER_BUBBLE_EMITTER_FRAG );
   Renderer renderer = Renderer::New( geometry, shader );
   TextureSet textureSet = TextureSet::New();
   textureSet.SetTexture(0u, bgTexture );
index bbf81a9..ffcce3a 100644 (file)
@@ -24,8 +24,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
-
-#define DALI_COMPOSE_SHADER(STR) #STR
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -51,50 +50,8 @@ inline void SetColorAdjusterProperties( Actor& actor, const Vector3& hsvDelta, b
 */
 inline Property::Map CreateColorAdjuster()
 {
-  std::string fragmentShader = DALI_COMPOSE_SHADER(
-    precision highp float;\n
-    uniform vec3 uHSVDelta;\n
-    uniform float uIgnoreAlpha;\n
-    varying mediump vec2 vTexCoord;\n
-    uniform sampler2D sTexture;\n
-    float rand(vec2 co) \n
-    {\n
-      return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
-    \n
-    vec3 rgb2hsv(vec3 c)\n
-    {\n
-      vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
-      vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n
-      vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n
-      \n
-      float d = q.x - min(q.w, q.y);\n
-      float e = 1.0e-10;\n
-      return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n
-    }\n
-    vec3 hsv2rgb(vec3 c)\n
-    {\n
-      vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
-      vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n
-      return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n
-    }\n
-    void main() {\n
-      vec4 color = texture2D(sTexture, vTexCoord); \n
-      vec3 hsvColor = rgb2hsv( color.rgb );\n
-      // modify the hsv Value
-      hsvColor += uHSVDelta * rand(vTexCoord); \n
-      // if the new vale exceeds one, then decrease it
-      hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n
-      // if the new vale drops below zero, then increase it
-      hsvColor -= min(hsvColor*2.0, 0.0);\n
-      color.rgb = hsv2rgb( hsvColor ); \n
-      // uIgnoreAlpha decide the result alpha will be 1.0 or source's alpha
-      color.a += uIgnoreAlpha;\n
-      gl_FragColor = color; \n
-    }\n
-  );
-
   Property::Map customShader;
-  customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
+  customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_BUBBLE_EFFECT_COLOR_ADJUSTER_FRAG.data();
 
   Property::Map map;
   map[ Toolkit::Visual::Property::SHADER ] = customShader;
index 4e12efb..b10842b 100755 (executable)
@@ -47,6 +47,7 @@
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
 
 namespace
 {
@@ -2132,14 +2133,13 @@ bool Control::Impl::AccessibleImpl::GrabFocus()
   return Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( self );
 }
 
-const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png";
-
 static Dali::Actor CreateHighlightIndicatorActor()
 {
+  std::string focusBorderImagePath(AssetManager::GetDaliImagePath());
+  focusBorderImagePath += "/keyboard_focus.9.png";
   // Create the default if it hasn't been set and one that's shared by all the
-  // keyboard focusable actors const char* const FOCUS_BORDER_IMAGE_PATH =
-  // DALI_IMAGE_DIR "keyboard_focus.9.png";
-  auto actor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH );
+  // keyboard focusable actors
+  auto actor = Toolkit::ImageView::New( focusBorderImagePath );
   actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
   DevelControl::AppendAccessibilityAttribute( actor, "highlight", "" );
   actor.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED, true);
index ea6e2e4..e864690 100644 (file)
@@ -24,36 +24,6 @@ namespace Toolkit
 namespace Internal
 {
 
-#define DALI_COMPOSE_SHADER(STR) #STR
-
-const char * const BASIC_VERTEX_SOURCE = DALI_COMPOSE_SHADER(
-  precision mediump float;\n
-  attribute mediump vec2 aPosition;\n
-  varying mediump vec2 vTexCoord;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump vec3 uSize;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition * uSize.xy, 0.0, 1.0);\n
-    vTexCoord = aPosition + vec2(0.5);
-    gl_Position = uMvpMatrix * vertexPosition;\n
-  }\n
-);
-
-const char * const BASIC_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
-  precision mediump float;\n
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform vec4 uColor;\n
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D(sTexture, vTexCoord);\n
-    gl_FragColor *= uColor;
-  }\n
-);
-
 Geometry CreateGridGeometry( Uint16Pair gridSize )
 {
   uint16_t gridWidth = gridSize.GetWidth();
@@ -118,7 +88,7 @@ Geometry CreateGridGeometry( Uint16Pair gridSize )
   return geometry;
 }
 
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc )
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc )
 {
   Dali::Shader shader = Dali::Shader::New( vertexSrc, fragmentSrc );
 
@@ -153,7 +123,7 @@ Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc )
   return renderer;
 }
 
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc, Dali::Shader::Hint::Value hints, Uint16Pair gridSize )
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc, Dali::Shader::Hint::Value hints, Uint16Pair gridSize )
 {
   Dali::Shader shader = Dali::Shader::New( vertexSrc, fragmentSrc, hints );
 
index 320528c..de14bb6 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <dali/dali.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -26,9 +27,8 @@ namespace Toolkit
 namespace Internal
 {
 
-extern const char* const BASIC_VERTEX_SOURCE;
-
-extern const char* const BASIC_FRAGMENT_SOURCE;
+#define BASIC_VERTEX_SOURCE SHADER_CONTROL_RENDERERS_VERT
+#define BASIC_FRAGMENT_SOURCE SHADER_CONTROL_RENDERERS_FRAG
 
 /**
  * Helper method for rendering an image with custom shader.
@@ -36,7 +36,7 @@ extern const char* const BASIC_FRAGMENT_SOURCE;
  * @param[in] fragmentSrc The custom fragment shader.
  * @return A newly created renderer.
  */
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc );
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc );
 
 /**
  * Helper method for rendering an image with custom shader.
@@ -45,7 +45,7 @@ Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc );
  * @param[in] gridSize The number of grid sub-divisions required.
  * @return A newly created renderer.
  */
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc, Dali::Shader::Hint::Value hints, Dali::Uint16Pair gridSize );
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc, Dali::Shader::Hint::Value hints, Dali::Uint16Pair gridSize );
 
 /**
  * Helper method for setting the first texture passed to a renderer.
index f23d985..bd12e33 100644 (file)
@@ -32,6 +32,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
 #include <dali-toolkit/internal/filters/emboss-filter.h>
 #include <dali-toolkit/internal/filters/spread-filter.h>
@@ -66,39 +67,6 @@ const float         ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
 const Vector4       EFFECTS_VIEW_DEFAULT_BACKGROUND_COLOR( 0.0f, 0.0f, 0.0f, 0.0 );
 const bool          EFFECTS_VIEW_REFRESH_ON_DEMAND(false);
 
-#define DALI_COMPOSE_SHADER(STR) #STR
-
-const char* EFFECTS_VIEW_VERTEX_SOURCE = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  varying mediump vec2 vTexCoord;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump vec3 effectOffset;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vertexPosition.xyz *= uSize;\n
-    vertexPosition.xyz += effectOffset;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-    \n
-    vTexCoord = aPosition + vec2(0.5);\n
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-const char* EFFECTS_VIEW_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 effectColor;\n
-  \n
-  void main()\n
-  {\n
-     gl_FragColor = effectColor;\n
-     gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;\n
-  }\n
-);
-
 const float BLUR_KERNEL0[] = { 12.0f/16.0f,
                                2.0f/16.0f, 2.0f/16.0f };
 
@@ -299,7 +267,8 @@ void EffectsView::OnSceneConnection( int depth )
   Actor self( Self() );
 
   // Create renderers
-  mRendererPostFilter = CreateRenderer( EFFECTS_VIEW_VERTEX_SOURCE, EFFECTS_VIEW_FRAGMENT_SOURCE );
+  mRendererPostFilter = CreateRenderer( SHADER_EFFECTS_VIEW_VERT,
+                                        SHADER_EFFECTS_VIEW_FRAG );
   mRendererPostFilter.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT );
   self.AddRenderer( mRendererPostFilter );
 
index 93fb35b..304c799 100644 (file)
@@ -37,6 +37,7 @@
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 // TODO:
 // pixel format / size - set from JSON
@@ -102,24 +103,6 @@ const float GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
 
 const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
 
-const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
-    varying mediump vec2 vTexCoord;\n
-    uniform sampler2D sTexture;\n
-    uniform lowp vec4 uColor;\n
-    uniform mediump vec2 uSampleOffsets[NUM_SAMPLES];\n
-    uniform mediump float uSampleWeights[NUM_SAMPLES];\n
-
-    void main()\n
-    {\n
-       mediump vec4 col = texture2D(sTexture, vTexCoord + uSampleOffsets[0]) * uSampleWeights[0];\n
-       for (int i=1; i<NUM_SAMPLES; ++i)\n
-       {\n
-         col += texture2D(sTexture, vTexCoord + uSampleOffsets[i]) * uSampleWeights[i];\n
-       }\n
-       gl_FragColor = col;\n
-    }\n
-);
-
 } // namespace
 
 
@@ -255,7 +238,7 @@ void GaussianBlurView::OnInitialize()
 
   std::ostringstream fragmentStringStream;
   fragmentStringStream << "#define NUM_SAMPLES " << mNumSamples << "\n";
-  fragmentStringStream << GAUSSIAN_BLUR_FRAGMENT_SOURCE;
+  fragmentStringStream << SHADER_GAUSSIAN_BLUR_VIEW_FRAG;
   std::string fragmentSource(fragmentStringStream.str());
 
   //////////////////////////////////////////////////////
@@ -264,6 +247,7 @@ void GaussianBlurView::OnInitialize()
   // Create an actor for performing a horizontal blur on the texture
   mHorizBlurActor = Actor::New();
   mHorizBlurActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER );
+
   Renderer renderer = CreateRenderer( BASIC_VERTEX_SOURCE, fragmentSource.c_str() );
   mHorizBlurActor.AddRenderer( renderer );
 
index 5b49909..1665905 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
@@ -93,185 +94,6 @@ DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Model3dView, "lightPosition",  V
 
 DALI_TYPE_REGISTRATION_END()
 
-
-#define MAKE_SHADER(A)#A
-
-//  Diffuse illumination shader
-
-const char* SIMPLE_VERTEX_SHADER = MAKE_SHADER(
-  attribute highp vec3 aPosition;\n
-  attribute highp vec2 aTexCoord;\n
-  attribute highp vec3 aNormal;\n
-  varying mediump vec3 vIllumination;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump mat4 uModelView;\n
-  uniform mediump mat3 uNormalMatrix;
-  uniform mediump mat4 uObjectMatrix;\n
-  uniform mediump vec3 uLightPosition;\n
-
-  void main()\n
-  {\n
-    vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
-    vertexPosition = uObjectMatrix * vertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-    //Illumination in Model-View space - Transform attributes and uniforms\n
-    vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
-    vec3 normal = uNormalMatrix * aNormal;\n
-    vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
-    vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
-
-    float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );\n
-    vIllumination = vec3(lightDiffuse * 0.5 + 0.5);\n
-
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-const char* SIMPLE_FRAGMENT_SHADER = MAKE_SHADER(
-  precision mediump float;\n
-  varying mediump vec3 vIllumination;\n
-  uniform lowp vec4 uColor;\n
-
-  void main()\n
-  {\n
-    gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a);\n
-  }\n
-);
-
-//  Diffuse and specular illumination shader with albedo texture
-
-const char* VERTEX_SHADER = MAKE_SHADER(
-  attribute highp vec3 aPosition;\n
-  attribute highp vec2 aTexCoord;\n
-  attribute highp vec3 aNormal;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vIllumination;\n
-  varying mediump float vSpecular;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump mat4 uModelView;
-  uniform mediump mat3 uNormalMatrix;
-  uniform mediump mat4 uObjectMatrix;\n
-  uniform mediump vec3 uLightPosition;\n
-
-  void main()
-  {\n
-    vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
-    vertexPosition = uObjectMatrix * vertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-    //Illumination in Model-View space - Transform attributes and uniforms\n
-    vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
-    vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
-    vec3 normal = normalize(uNormalMatrix * aNormal);\n
-
-    vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
-    vec3 viewDir = normalize(-vertPos.xyz);
-
-    vec3 halfVector = normalize(viewDir + vecToLight);
-
-    float lightDiffuse = dot( vecToLight, normal );\n
-    lightDiffuse = max(0.0,lightDiffuse);\n
-    vIllumination = vec3(lightDiffuse * 0.5 + 0.5);\n
-
-    vec3 reflectDir = reflect(-vecToLight, normal);
-    vSpecular = pow( max(dot(reflectDir, viewDir), 0.0), 4.0 );
-
-    vTexCoord = aTexCoord;\n
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
-  precision mediump float;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vIllumination;\n
-  varying mediump float vSpecular;\n
-  uniform sampler2D sDiffuse;\n
-  uniform lowp vec4 uColor;\n
-
-  void main()\n
-  {\n
-    vec4 texture = texture2D( sDiffuse, vTexCoord );\n
-    gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb + vSpecular * 0.3, texture.a * uColor.a);\n
-  }\n
-);
-
-//  Diffuse and specular illumination shader with albedo texture, normal map and gloss map shader
-
-const char* NRMMAP_VERTEX_SHADER = MAKE_SHADER(
-  attribute highp vec3 aPosition;\n
-  attribute highp vec2 aTexCoord;\n
-  attribute highp vec3 aNormal;\n
-  attribute highp vec3 aTangent;\n
-  attribute highp vec3 aBiNormal;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vLightDirection;\n
-  varying mediump vec3 vHalfVector;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump mat4 uModelView;
-  uniform mediump mat3 uNormalMatrix;
-  uniform mediump mat4 uObjectMatrix;\n
-  uniform mediump vec3 uLightPosition;\n
-
-  void main()
-  {\n
-    vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
-    vertexPosition = uObjectMatrix * vertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-    vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
-    vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
-
-    vec3 tangent = normalize(uNormalMatrix * aTangent);
-    vec3 binormal = normalize(uNormalMatrix * aBiNormal);
-    vec3 normal = normalize(uNormalMatrix * aNormal);
-
-    vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
-    vLightDirection.x = dot(vecToLight, tangent);
-    vLightDirection.y = dot(vecToLight, binormal);
-    vLightDirection.z = dot(vecToLight, normal);
-
-    vec3 viewDir = normalize(-vertPos.xyz);
-    vec3 halfVector = normalize(viewDir + vecToLight);
-    vHalfVector.x = dot(halfVector, tangent);
-    vHalfVector.y = dot(halfVector, binormal);
-    vHalfVector.z = dot(halfVector, normal);
-
-    vTexCoord = aTexCoord;\n
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-const char* NRMMAP_FRAGMENT_SHADER = MAKE_SHADER(
-  precision mediump float;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vLightDirection;\n
-  varying mediump vec3 vHalfVector;\n
-  uniform sampler2D sDiffuse;\n
-  uniform sampler2D sNormal;\n
-  uniform sampler2D sGloss;\n
-  uniform lowp vec4 uColor;\n
-
-  void main()\n
-  {\n
-    vec4 texture = texture2D( sDiffuse, vTexCoord );\n
-    vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n
-    vec4 glossMap = texture2D( sGloss, vTexCoord );\n
-
-    float lightDiffuse = max( 0.0, dot( normal, normalize(vLightDirection) ) );\n
-    lightDiffuse = lightDiffuse * 0.5 + 0.5;\n
-
-    float shininess = pow (max (dot (normalize( vHalfVector ), normal), 0.0), 16.0)  ;
-
-    gl_FragColor = vec4( texture.rgb * uColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a);\n
-  }\n
-);
-
-
 } // anonymous namespace
 
 using namespace Dali;
@@ -459,7 +281,7 @@ void Model3dView::OnInitialize()
 {
   //Create empty versions of the geometry and material so we always have a Renderer
   Geometry mesh = Geometry::New();
-  Shader shader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+  Shader shader = Shader::New( SHADER_MODEL3D_VIEW_SIMPLE_SHADER_VERT, SHADER_MODEL3D_VIEW_SIMPLE_SHADER_FRAG );
   mRenderer = Renderer::New( mesh, shader );
 
   DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
@@ -572,21 +394,21 @@ void Model3dView::CreateMaterial()
   {
     if( (mTexture2Url != "") && (mTexture1Url != "") && (mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP) )
     {
-      mShader = Shader::New( NRMMAP_VERTEX_SHADER, NRMMAP_FRAGMENT_SHADER );
+      mShader = Shader::New( SHADER_MODEL3D_VIEW_NRMMAP_SHADER_VERT, SHADER_MODEL3D_VIEW_NRMMAP_SHADER_FRAG );
     }
     else if( mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_TEXTURE ||
              mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
     {
-      mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+      mShader = Shader::New( SHADER_MODEL3D_VIEW_SHADER_VERT, SHADER_MODEL3D_VIEW_SHADER_FRAG );
     }
     else
     {
-      mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+      mShader = Shader::New( SHADER_MODEL3D_VIEW_SIMPLE_SHADER_VERT, SHADER_MODEL3D_VIEW_SIMPLE_SHADER_FRAG );
     }
   }
   else
   {
-    mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+    mShader = Shader::New( SHADER_MODEL3D_VIEW_SIMPLE_SHADER_VERT, SHADER_MODEL3D_VIEW_SIMPLE_SHADER_FRAG );
   }
 
   mTextureSet = TextureSet::New();
index 100c2c8..023e527 100644 (file)
@@ -20,8 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
-
-#define DALI_COMPOSE_SHADER(STR) #STR
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -52,57 +51,12 @@ namespace Internal
  **/
 inline Property::Map CreatePageTurnBookSpineEffect()
 {
-  const char* vertexSource = DALI_COMPOSE_SHADER(
-      precision mediump float;\n
-      attribute mediump vec2 aPosition;\n
-      uniform mediump mat4 uMvpMatrix;\n
-      uniform vec3 uSize;\n
-      uniform float uTextureWidth;\n
-      varying vec2 vTexCoord;\n
-      void main()\n
-      {\n
-        mediump vec4 vertexPosition = vec4(aPosition*uSize.xy, 0.0, 1.0);\n
-        gl_Position = uMvpMatrix * vertexPosition;\n
-        vTexCoord = aPosition + vec2(0.5);\n
-        vTexCoord.x /= uTextureWidth;
-      }\n);
-
-  // the simplified version of the fragment shader of page turn effect
-  const char* fragmentSource = DALI_COMPOSE_SHADER(
-      precision mediump float;\n
-      varying mediump vec2 vTexCoord;\n
-      uniform vec3 uSize;\n
-      uniform vec2 uSpineShadowParameter;\n
-      uniform sampler2D sTexture;\n
-      uniform lowp vec4 uColor;\n
-
-      void main()\n
-      {\n
-        if( gl_FrontFacing )\n // display front side
-        {\n
-          gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
-        }\n
-        else\n // display back side, flip the image horizontally by changing the x component of the texture coordinate
-        {\n
-          gl_FragColor = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) ) * uColor;\n
-        }\n
-        // display book spine, a stripe of shadowed texture
-        float pixelPos = vTexCoord.x * uSize.x;\n
-        if( pixelPos < uSpineShadowParameter.x )\n
-        {\n
-          float x = pixelPos - uSpineShadowParameter.x;\n
-          float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );\n
-          vec2 spineNormal = normalize(vec2(uSpineShadowParameter.y*x/uSpineShadowParameter.x, y));\n
-          gl_FragColor.rgb *= spineNormal.y; \n
-        }\n
-      } );
-
   Property::Map map;
 
   Property::Map customShader;
 
-  customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexSource;
-  customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource;
+  customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = SHADER_PAGE_TURN_BOOK_SPINE_EFFECT_VERT.data();
+  customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_PAGE_TURN_BOOK_SPINE_EFFECT_FRAG.data();
 
   map[ Toolkit::Visual::Property::SHADER ] = customShader;
   return map;
index 15a48da..175d6d2 100644 (file)
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
 
 namespace
 {
-#define DALI_COMPOSE_SHADER(STR) #STR
 const char * const PROPERTY_COMMON_PARAMETERS( "uCommonParameters" );
 const char * const PROPERTY_ORIGINAL_CENTER( "originalCenter" );
 const char * const PROPERTY_CURRENT_CENTER( "currentCenter" );
@@ -124,216 +124,12 @@ void Dali::Toolkit::Internal::PageTurnApplyInternalConstraint( Actor& actor, flo
 
 Property::Map Dali::Toolkit::Internal::CreatePageTurnEffect()
 {
-  const char* vertexShader = DALI_COMPOSE_SHADER(
-      /*
-       * The common parameters for all the vertices, calculate in CPU then pass into the shader as uniforms
-       *
-       *  first part of the page, (outside the the line passing through original center and vertical to curve direction)
-       * no Z change, only 2D rotation and translation
-       * ([0][0],[0][1],[1][0],[1][1]) mat2 rotateMatrix
-       * ([2][0],[2][1]) vec2 translationVector
-       *
-       * ([0][2],[0][3]) vec2 originalCenter: Typically the press down position of the Pan Gesture
-       * ([1][2],[1][3]) vec2 currentCenter: Typically the current position of the Pan Gesture
-       * ([3][0],[3][1]) vec2 curveDirection: The normalized vector pointing from original center to current center
-       * ([2][2]) float vanishingPointY: The Y coordinate of the intersection of the spine
-       *                                 and the line which goes through the original center and is vertical to the curveDirection
-       * ([2][3]) float curveEndY: The Y coordinate of intersection of the spine and the line through both original and current center
-       * ([3][2]) float curveHeight: The height of the interpolated hermite curve.
-       * ([3][3]) float currentLength: The length from the current center to the curveEnd.
-       */
-      precision mediump float;\n
-      \n
-      attribute mediump vec2 aPosition;\n
-      \n
-      uniform mediump mat4 uMvpMatrix;\n
-      uniform mediump mat3 uNormalMatrix;\n
-      uniform mediump mat4 uModelView;\n
-      \n
-      uniform mat4 uCommonParameters;\n
-      \n
-      uniform vec3 uSize;\n
-      uniform float uIsTurningBack;\n
-      uniform float uTextureWidth;\n
-      varying vec3 vNormal;\n
-      varying vec4 vPosition;\n
-      varying mediump vec2 vTexCoord;\n
-      \n
-      void main()\n
-      {\n
-        vec4 position = vec4( aPosition*uSize.xy, 0.0, 1.0);\n
-        vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);\n
-        vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);\n
-        vec3 normal = vec3(0.0,0.0,1.0);\n
-        \n
-        if(currentCenter.x < originalCenter.x)\n
-        {\n
-          // change the coordinate origin from the center of the page to its top-left
-          position.xy += uSize.xy * 0.5;\n
-          vec2 curveDirection = vec2( uCommonParameters[3]);\n
-          vec3 vanishingPoint = vec3(0.0, uCommonParameters[2][2], 0.0);\n
-          // first part of the page, (outside the the line passing through original center and vertical to curve direction)
-          //no Z change, only 2D rotation and translation
-          if( dot(curveDirection, position.xy - originalCenter) < 0.0 )
-          {\n
-            position.y -= vanishingPoint.y;\n
-            position.xy = mat2(uCommonParameters)*position.xy + vec2( uCommonParameters[2]);\n
-          }\n
-          // second part of the page, bent as a ruled surface
-          else\n
-          {\n
-            // calculate on the flat plane, between
-            // the first line passing through current vertex and vanishing point
-            // the second line passing through original center and current center
-            vec2 curveEnd = vec2( 0.0, uCommonParameters[2][3] );\n
-            vec2 curFlatDirection = vec2(0.0,1.0);\n
-            float lengthFromCurve = position.y - originalCenter.y;\n
-            float lengthOnCurve = position.x;\n
-            if(currentCenter.y != originalCenter.y)\n
-            {\n
-              curFlatDirection = normalize(position.xy - vanishingPoint.xy);\n
-              lengthFromCurve = (curveEnd.x*curveDirection.y-curveEnd.y*curveDirection.x-position.x*curveDirection.y+position.y*curveDirection.x)
-              / (curFlatDirection.x*curveDirection.y-curFlatDirection.y*curveDirection.x);\n
-              lengthOnCurve = length(position.xy+lengthFromCurve*curFlatDirection-curveEnd);\n
-            }\n
-            \n
-            // define the control points of hermite curve, composed with two segments
-            // calculation is carried out on the 2D plane which is passing through both current and original center and vertical to the image plane
-            float currentLength = uCommonParameters[3][3];\n
-            float originalLength =  abs(originalCenter.x/curveDirection.x);\n
-            float height = uCommonParameters[3][2];\n
-            float percentage = currentLength/originalLength;\n
-            //vec2 SegmentOneControlPoint0 = vec2(0.0, 0.0);
-            vec2 SegmentOneControlPoint1 = vec2((0.65*percentage - 0.15)*originalLength, (0.8 + 0.2 * percentage)*height); \n
-            vec2 SegmentTwoControlPoint0 = SegmentOneControlPoint1;\n
-            vec2 SegmentTwoControlPoint1 = vec2(currentLength, 0.0); \n
-            vec2 SegmentOneTangentVector0 = SegmentOneControlPoint1;\n
-            vec2 SegmentOneTangentVector1 = vec2(0.5*originalLength,0.0);\n
-            vec2 SegmentTwoTangentVector0 = SegmentOneTangentVector1;\n
-            vec2 SegmentTwoTangentVector1 = SegmentOneTangentVector1;\n
-            \n
-            // calculate the corresponding curve point position and its tangent vector
-            // it is a linear mapping onto nonlinear curves, might cause some unwanted deformation
-            // but as there are no analytical method to calculate the curve length on arbitrary segment
-            // no efficient way to solve this nonlinear mapping, Numerical approximation would cost too much computation in shader
-            vec2 curvePoint2D;\n
-            vec2 tangent;\n
-            float t0 = lengthOnCurve / originalLength;\n
-            if(t0<=0.5)\n
-            {\n
-              float t = 2.0*t0;\n
-              float t_2 = t*t;\n
-              float t_3 = t*t_2;\n
-              curvePoint2D = (-2.0*t_3+3.0*t_2)*SegmentOneControlPoint1
-              + (t_3-2.0*t_2+t)*SegmentOneTangentVector0 + (t_3-t_2)*SegmentOneTangentVector1;\n
-              tangent = (-6.0*t_2+6.0*t)*SegmentOneControlPoint1
-              + (3.0*t_2-4.0*t+1.0)*SegmentOneTangentVector0 + (3.0*t_2-2.0*t)*SegmentOneTangentVector1;\n
-            }\n
-            else\n
-            {\n
-              float t = 2.0*t0-1.0;\n
-              float t_2 = t*t;\n
-              float t_3 = t*t_2;\n
-              curvePoint2D = (2.0*t_3-3.0*t_2+1.0)*SegmentTwoControlPoint0 + (-2.0*t_3+3.0*t_2)*SegmentTwoControlPoint1
-              + (t_3-2.0*t_2+t)*SegmentTwoTangentVector0 + (t_3-t_2)*SegmentTwoTangentVector1;\n
-              tangent = (6.0*t_2-6.0*t)*SegmentTwoControlPoint0 + (-6.0*t_2+6.0*t)*SegmentTwoControlPoint1
-              + (3.0*t_2-4.0*t+1.0)*SegmentTwoTangentVector0 + (3.0*t_2-2.0*t)*SegmentTwoTangentVector1;\n
-              // a trick to eliminate some optical illusion caused by the gradient matter of normal in per-fragment shading
-              // which is caused by linear interpolation of normal vs. nonlinear lighting
-              // will notice some artifact in the areas with dramatically normal changes, so compress the normal differences here
-              tangent.y *=  min(1.0, length(position.xyz - vanishingPoint) / uSize.y ); \n
-            }\n
-            vec3 curvePoint = vec3(curveEnd - curvePoint2D.x*curveDirection,max(0.0,curvePoint2D.y));\n
-            vec3 tangentVector = vec3(-tangent.x*curveDirection,tangent.y);\n
-            \n
-            // locate the new vertex position on the line passing through both vanishing point and the calculated curve point position
-            vec3 curLiftDirection = vec3(0.0,-1.0,0.0);\n
-            if(currentCenter.y != originalCenter.y)\n
-            {\n
-              curLiftDirection = normalize(curvePoint - vanishingPoint);\n
-              tangentVector *= (curveDirection.y > 0.0) ? -1.0 : 1.0;\n
-              // an heuristic adjustment here, to compensate the linear parameter mapping onto the nonlinear curve
-              float Y0 = position.y - curveDirection.y * (position.x/curveDirection.x); \n
-              float proportion;
-              float refLength;\n
-              if(abs(Y0-vanishingPoint.y) > abs(curveEnd.y-vanishingPoint.y)) \n
-              {\n
-                proportion = abs(curveEnd.y - Y0) / (abs(curveEnd.y-Y0)+abs(curveEnd.y - vanishingPoint.y)); \n
-                refLength = proportion*length(originalCenter-vanishingPoint.xy) / (proportion-1.0); \n
-              }\n
-              else\n
-              {\n
-                proportion = abs(curveEnd.y - Y0) / abs(curveEnd.y - vanishingPoint.y);\n
-                refLength = proportion*length(originalCenter-vanishingPoint.xy); \n
-              }\n
-              float Y1 = currentCenter.y - (normalize(currentCenter-vanishingPoint.xy)).y * refLength; \n
-              position.y = mix(Y0, Y1, t0); \n
-            }\n
-            position.xz = curvePoint.xz - lengthFromCurve*curLiftDirection.xz;\n
-            // calculate the normal vector, will be used for lighting
-            normal = cross(curLiftDirection, normalize(tangentVector));\n
-            // the signature of Z is decided by the page turning direction:
-            // from left to right(negative); from right to left (positive)
-            position.z *= -uIsTurningBack;\n
-            normal.xy *= -uIsTurningBack;\n
-          }\n
-          // change the coordinate origin from the top-left of the page to its center
-          position.xy -= uSize.xy * 0.5; \n
-        }\n
-        vNormal =  uNormalMatrix * normal;\n
-        gl_Position = uMvpMatrix * position;
-        // varying parameters for fragment shader
-        vTexCoord = aPosition + vec2(0.5);\n
-        vTexCoord.x /= uTextureWidth;
-        vPosition = uModelView * position;\n
-      }\n
-  );
-
-  const char* fragmentShader = DALI_COMPOSE_SHADER(
-      precision mediump float;\n
-      \n
-      varying mediump vec2 vTexCoord;\n
-      \n
-      uniform sampler2D sTexture;\n
-      uniform lowp vec4 uColor;\n
-      uniform vec3 uSize;\n
-      uniform vec2 uSpineShadowParameter;\n
-      varying vec3 vNormal;\n
-      varying vec4 vPosition;\n
-      \n
-      void main()\n
-      {\n
-        // need to re-normalize the interpolated normal
-        vec3 normal = normalize( vNormal );\n
-        // display page content
-        vec4 texel;
-        // display back image of the page, flip the texture
-        if(  dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) );\n
-        // display front image of the page
-        else texel = texture2D( sTexture, vTexCoord );\n
-
-        // display book spine, a stripe of shadowed texture
-        float pixelPos = vTexCoord.x * uSize.x; \n
-        float spineShadowCoef = 1.0; \n
-        if( pixelPos < uSpineShadowParameter.x ) \n
-        {\n
-          float x = pixelPos - uSpineShadowParameter.x;\n
-          float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );\n
-          spineShadowCoef = normalize( vec2( uSpineShadowParameter.y*x/uSpineShadowParameter.x, y ) ).y;\n
-        }\n
-        // calculate the lighting
-        // set the ambient color as vec3(0.4);
-        float lightColor = abs( normal.z ) * 0.6 + 0.4;\n
-        gl_FragColor = vec4( ( spineShadowCoef * lightColor ) * texel.rgb , texel.a ) * uColor;\n
-      }
-  );
-
   Property::Map map;
 
   Property::Map customShader;
 
-  customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexShader;
-  customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
+  customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = SHADER_PAGE_TURN_EFFECT_VERT.data();
+  customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_PAGE_TURN_EFFECT_FRAG.data();
   customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
   customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
 
index 52dc236..959a39f 100644 (file)
 
 // CLASS HEADER
 #include <dali-toolkit/internal/controls/scene3d-view/gltf-loader.h>
-#include <dali-toolkit/internal/controls/scene3d-view/gltf-shader.h>
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali/devel-api/adaptor-framework/file-stream.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -1503,35 +1503,35 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
     bool isEmissiveTexture = false;
 
     std::string VERTEX_SHADER, FRAGMENT_SHADER;
-    VERTEX_SHADER = GLES_VERSION_300;
-    VERTEX_SHADER += PHYSICALLY_BASED_VERTEX_SHADER;
-    FRAGMENT_SHADER = GLES_VERSION_300;
+    VERTEX_SHADER = SHADER_GLTF_GLES_VERSION_300_DEF.data();
+    VERTEX_SHADER += SHADER_GLTF_PHYSICALLY_BASED_SHADER_VERT.data();
+    FRAGMENT_SHADER = SHADER_GLTF_GLES_VERSION_300_DEF.data();
 
     bool useIBL = ( scene3dView.GetLightType() >= Toolkit::Scene3dView::LightType::IMAGE_BASED_LIGHT );
     if( isMaterial )
     {
       MaterialInfo materialInfo = mMaterialArray[meshInfo.materialsIdx];
-      if( SetTextureAndSampler( textureSet, materialInfo.baseColorTexture.index, FRAGMENT_SHADER, DEFINE_BASECOLOR_TEXTURE, addIdx ) )
+      if( SetTextureAndSampler( textureSet, materialInfo.baseColorTexture.index, FRAGMENT_SHADER, SHADER_GLTF_BASECOLOR_TEXTURE_DEF.data(), addIdx ) )
       {
         shaderTypeIndex += static_cast<int32_t>( ShaderType::BASECOLOR_SHADER );
         isBaseColorTexture = true;
       }
-      if( SetTextureAndSampler( textureSet, materialInfo.metallicRoughnessTexture.index, FRAGMENT_SHADER, DEFINE_METALLICROUGHNESS_TEXTURE, addIdx ) )
+      if( SetTextureAndSampler( textureSet, materialInfo.metallicRoughnessTexture.index, FRAGMENT_SHADER, SHADER_GLTF_METALLICROUGHNESS_TEXTURE_DEF.data(), addIdx ) )
       {
         shaderTypeIndex += static_cast<int32_t>( ShaderType::METALLICROUGHNESS_SHADER );
         isMetallicRoughnessTexture = true;
       }
-      if( SetTextureAndSampler( textureSet, materialInfo.normalTexture.index, FRAGMENT_SHADER, DEFINE_NORMAL_TEXTURE, addIdx ) )
+      if( SetTextureAndSampler( textureSet, materialInfo.normalTexture.index, FRAGMENT_SHADER, SHADER_GLTF_NORMAL_TEXTURE_DEF.data(), addIdx ) )
       {
         shaderTypeIndex += static_cast<int32_t>( ShaderType::NORMAL_SHADER );
         isNormalTexture = true;
       }
-      if( SetTextureAndSampler( textureSet, materialInfo.occlusionTexture.index, FRAGMENT_SHADER, DEFINE_OCCLUSION_TEXTURE, addIdx ) )
+      if( SetTextureAndSampler( textureSet, materialInfo.occlusionTexture.index, FRAGMENT_SHADER, SHADER_GLTF_OCCULUSION_TEXTURE_DEF.data(), addIdx ) )
       {
         shaderTypeIndex += static_cast<int32_t>( ShaderType::OCCLUSION_SHADER );
         isOcclusionTexture = true;
       }
-      if( SetTextureAndSampler( textureSet, materialInfo.emissiveTexture.index, FRAGMENT_SHADER, DEFINE_EMIT_TEXTURE, addIdx ) )
+      if( SetTextureAndSampler( textureSet, materialInfo.emissiveTexture.index, FRAGMENT_SHADER, SHADER_GLTF_EMIT_TEXTURE_DEF.data(), addIdx ) )
       {
         shaderTypeIndex += static_cast<int32_t>( ShaderType::EMIT_SHADER );
         isEmissiveTexture = true;
@@ -1540,7 +1540,7 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
       if( useIBL )
       {
         shaderTypeIndex += static_cast<int32_t>( ShaderType::IBL_SHADER );
-        FRAGMENT_SHADER += DEFINE_IBL_TEXTURE;
+        FRAGMENT_SHADER += SHADER_GLTF_IBL_TEXTURE_DEF.data();
 
         Sampler sampler = Sampler::New();
         sampler.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
@@ -1567,7 +1567,7 @@ Actor Loader::AddNode( Scene3dView& scene3dView, uint32_t index )
       }
     }
 
-    FRAGMENT_SHADER += PHYSICALLY_BASED_FRAGMENT_SHADER;
+    FRAGMENT_SHADER += SHADER_GLTF_PHYSICALLY_BASED_SHADER_FRAG.data();
     if( !mShaderCache[shaderTypeIndex] )
     {
       mShaderCache[shaderTypeIndex] = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
diff --git a/dali-toolkit/internal/controls/scene3d-view/gltf-shader.h b/dali-toolkit/internal/controls/scene3d-view/gltf-shader.h
deleted file mode 100644 (file)
index e51b77c..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-#ifndef DALI_TOOLKIT_INTERNAL_GLTF_SHADER_H
-#define DALI_TOOLKIT_INTERNAL_GLTF_SHADER_H
-
-/*
- * Belows Vertex Shader and Fragment Shader code are based off glTF WebGL PBR.
- * https://github.com/KhronosGroup/glTF-WebGL-PBR/
- *
- * Copyright (c) 2016-2017 Mohamad Moneimne and Contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-const char* GLES_VERSION_300 = {
-  "#version 300 es\n\n"
-  "precision highp float;\n\n"
-};
-
-const char* DEFINE_BASECOLOR_TEXTURE = {
-  "#define TEXTURE_BASECOLOR\n\n"
-  "uniform sampler2D uBaseColorSampler;\n"
-  "uniform int uBaseColorTexCoordIndex;\n\n"
-};
-
-const char* DEFINE_METALLICROUGHNESS_TEXTURE = {
-  "#define TEXTURE_METALLICROUGHNESS\n\n"
-  "uniform sampler2D uMetallicRoughnessSampler;\n"
-  "uniform int uMetallicRoughnessTexCoordIndex;\n\n"
-};
-
-const char* DEFINE_NORMAL_TEXTURE = {
-  "#define TEXTURE_NORMAL\n\n"
-  "uniform sampler2D uNormalSampler;\n"
-  "uniform float uNormalScale;\n"
-  "uniform int uNormalTexCoordIndex;\n\n"
-};
-
-const char* DEFINE_OCCLUSION_TEXTURE = {
-  "#define TEXTURE_OCCLUSION\n\n"
-  "uniform sampler2D uOcclusionSampler;\n"
-  "uniform int uOcclusionTexCoordIndex;\n"
-  "uniform float uOcclusionStrength;\n\n"
-};
-
-const char* DEFINE_EMIT_TEXTURE = {
-  "#define TEXTURE_EMIT\n\n"
-  "uniform sampler2D uEmissiveSampler;\n"
-  "uniform int uEmissiveTexCoordIndex;\n"
-  "uniform vec3 uEmissiveFactor;\n\n"
-};
-
-const char* DEFINE_IBL_TEXTURE = {
-  "#define TEXTURE_IBL\n\n"
-  "uniform sampler2D ubrdfLUT;\n"
-  "uniform samplerCube uDiffuseEnvSampler;\n"
-  "uniform samplerCube uSpecularEnvSampler;\n"
-  "uniform vec4 uScaleIBLAmbient;\n"
-  "uniform highp float uMipmapLevel;\n"
-};
-
-const char* PHYSICALLY_BASED_VERTEX_SHADER = {
-  "in highp vec3 aPosition;\n"
-  "in mediump vec2 aTexCoord0;\n"
-  "in mediump vec2 aTexCoord1;\n"
-  "in lowp vec3 aNormal;\n"
-  "in lowp vec4 aTangent;\n"
-  "in lowp vec4 aVertexColor;\n"
-
-  "uniform mediump vec3 uSize;\n"
-  "uniform mediump mat4 uModelMatrix;\n"
-  "uniform mediump mat4 uViewMatrix;\n"
-  "uniform mediump mat4 uProjection;\n"
-  "uniform lowp int uLightType;\n"
-  "uniform mediump vec3 uLightVector;\n"
-  "uniform lowp int uIsColor;\n"
-
-  "out lowp vec2 vUV[2];\n"
-  "out lowp mat3 vTBN;\n"
-  "out lowp vec4 vColor;\n"
-  "flat out int visLight;\n"
-  "out highp vec3 vLightDirection;\n"
-  "out highp vec3 vPositionToCamera;\n"
-
-  "void main()\n"
-  "{\n"
-  "  highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);\n"
-  "  highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 );\n"
-  "  highp vec4 positionV = uViewMatrix * ( invY * positionW );\n"
-
-  "  vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) );\n"
-  "  vPositionToCamera *= invY.xyz;\n"
-
-  "  lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;\n"
-  "  vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal);\n"
-
-  "  vUV[0] = aTexCoord0;\n"
-  "  vUV[1] = aTexCoord1;\n"
-
-  "  visLight = 1;\n"
-  "  if( uLightType == 1 )\n"
-  "  {\n"
-  "    vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w );\n"
-  "  }\n"
-  "  else if( uLightType == 2 )\n"
-  "  {\n"
-  "    vLightDirection = -( invY.xyz * uLightVector );\n"
-  "  }\n"
-  "  else\n"
-  "  {\n"
-  "    visLight = 0;\n"
-  "  }\n"
-
-  "  vColor = vec4( 1.0 );\n"
-  "  if( uIsColor == 1 )\n"
-  "  {\n"
-  "    vColor = aVertexColor;\n"
-  "  }\n"
-
-  "  gl_Position = uProjection * positionV;\n" // needs w for proper perspective correction
-  "  gl_Position = gl_Position/gl_Position.w;\n"
-  "}\n"
-};
-
-const char* PHYSICALLY_BASED_FRAGMENT_SHADER = {
-  "uniform lowp vec3 uLightColor;\n"
-  "uniform lowp vec4 uBaseColorFactor;\n"
-  "uniform lowp vec2 uMetallicRoughnessFactors;\n"
-  "uniform lowp int alphaMode;\n"
-  "uniform lowp float alphaCutoff;\n"
-
-  "in lowp vec2 vUV[2];\n"
-  "in lowp mat3 vTBN;\n"
-  "in lowp vec4 vColor;\n"
-  "flat in int visLight;\n"
-  "in highp vec3 vLightDirection;\n"
-  "in highp vec3 vPositionToCamera;\n"
-
-  "out vec4 FragColor;"
-
-  "struct PBRInfo\n"
-  "{\n"
-  "  mediump float NdotL;\n"                  // cos angle between normal and light direction
-  "  mediump float NdotV;\n"                  // cos angle between normal and view direction
-  "  mediump float NdotH;\n"                  // cos angle between normal and half vector
-  "  mediump float VdotH;\n"                  // cos angle between view direction and half vector
-  "  mediump vec3 reflectance0;\n"            // full reflectance color (normal incidence angle)
-  "  mediump vec3 reflectance90;\n"           // reflectance color at grazing angle
-  "  lowp float alphaRoughness;\n"         // roughness mapped to a more linear change in the roughness (proposed by [2])
-  "};\n"
-
-  "const float M_PI = 3.141592653589793;\n"
-  "const float c_MinRoughness = 0.04;\n"
-
-  "vec3 getNormal()\n"
-  "{\n"
-  "#ifdef TEXTURE_NORMAL\n"
-  "  lowp vec3 n = texture( uNormalSampler, vUV[uNormalTexCoordIndex] ).rgb;\n"
-  "  n = normalize( vTBN * ( ( 2.0 * n - 1.0 ) * vec3( uNormalScale, uNormalScale, 1.0 ) ) );\n"
-  "#else\n"
-  "  lowp vec3 n = normalize( vTBN[2].xyz );\n"
-  "#endif\n"
-  "  return n;\n"
-  "}\n"
-
-  "vec3 specularReflection( PBRInfo pbrInputs )\n"
-  "{\n"
-  "  return pbrInputs.reflectance0 + ( pbrInputs.reflectance90 - pbrInputs.reflectance0 ) * pow( clamp( 1.0 - pbrInputs.VdotH, 0.0, 1.0 ), 5.0 );\n"
-  "}\n"
-
-  "float geometricOcclusion( PBRInfo pbrInputs )\n"
-  "{\n"
-  "  mediump float NdotL = pbrInputs.NdotL;\n"
-  "  mediump float NdotV = pbrInputs.NdotV;\n"
-  "  lowp float r = pbrInputs.alphaRoughness;\n"
-
-  "  lowp float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n"
-  "  lowp float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n"
-  "  return attenuationL * attenuationV;\n"
-  "}\n"
-
-  "float microfacetDistribution(PBRInfo pbrInputs)\n"
-  "{\n"
-  "  mediump float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n"
-  "  lowp float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n"
-  "  return roughnessSq / (M_PI * f * f);\n"
-  "}\n"
-
-  "vec3 linear( vec3 color )\n"
-  "{\n"
-  "  return pow(color,vec3(2.2));\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  // 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
-  "  lowp float metallic = uMetallicRoughnessFactors.x;\n"
-  "  lowp float perceptualRoughness = uMetallicRoughnessFactors.y;\n"
-
-  // 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
-  "#ifdef TEXTURE_METALLICROUGHNESS\n"
-  "  lowp vec4 metrou = texture(uMetallicRoughnessSampler, vUV[uMetallicRoughnessTexCoordIndex]);\n"
-  "  metallic = metrou.b * metallic;\n"
-  "  perceptualRoughness = metrou.g * perceptualRoughness;\n"
-  "#endif\n"
-
-  "  metallic = clamp(metallic, 0.0, 1.0);\n"
-  "  perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n"
-  // Roughness is authored as perceptual roughness; as is convention,
-  // convert to material roughness by squaring the perceptual roughness [2].
-  "  lowp float alphaRoughness = perceptualRoughness * perceptualRoughness;\n"
-
-  "#ifdef TEXTURE_BASECOLOR\n"
-  // The albedo may be defined from a base texture or a flat color
-  "  lowp vec4 baseColor = texture(uBaseColorSampler, vUV[uBaseColorTexCoordIndex]) * uBaseColorFactor;\n"
-  "  baseColor = vec4(linear(baseColor.rgb), baseColor.w);\n"
-  "#else\n"
-  "  lowp vec4 baseColor = vColor * uBaseColorFactor;\n"
-  "#endif\n"
-
-  "  if( alphaMode == 0 )\n"
-  "  {\n"
-  "    baseColor.w = 1.0;\n"
-  "  }\n"
-  "  else if( alphaMode == 1 )\n"
-  "  {\n"
-  "    if( baseColor.w >= alphaCutoff )"
-  "    {\n"
-  "      baseColor.w = 1.0;\n"
-  "    }\n"
-  "    else\n"
-  "    {\n"
-  "      baseColor.w = 0.0;\n"
-  "    }\n"
-  "  }\n"
-
-  "  lowp vec3 f0 = vec3(0.04);\n"
-  "  lowp vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n"
-  "  diffuseColor *= ( 1.0 - metallic );\n"
-  "  lowp vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n"
-
-  // Compute reflectance.
-  "  lowp float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n"
-
-  // 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);\n"
-  "  lowp vec3 specularEnvironmentR0 = specularColor.rgb;\n"
-  "  lowp vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n"
-
-  "  mediump vec3 n = getNormal();\n"                            // normal at surface point
-  "  mediump vec3 v = normalize(vPositionToCamera);\n"           // Vector from surface point to camera
-  "  mediump vec3 l = normalize(vLightDirection);\n"             // Vector from light to surface point
-  "  mediump vec3 h = normalize(l+v);\n"                         // Half vector between both l and v
-  "  mediump vec3 reflection = -normalize(reflect(v, n));\n"
-
-  "  mediump float NdotL = clamp(dot(n, l), 0.001, 1.0);\n"
-  "  mediump float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n"
-  "  mediump float NdotH = dot(n, h);\n"
-  "  mediump float LdotH = dot(l, h);\n"
-  "  mediump float VdotH = dot(v, h);\n"
-
-  "  PBRInfo pbrInputs = PBRInfo(\n"
-  "    NdotL,\n"
-  "    NdotV,\n"
-  "    NdotH,\n"
-  "    VdotH,\n"
-  "    specularEnvironmentR0,\n"
-  "    specularEnvironmentR90,\n"
-  "    alphaRoughness\n"
-  "  );\n"
-
-  // Calculate the shading terms for the microfacet specular shading model
-  "  lowp vec3 color = vec3(0.0);\n"
-  "  if( visLight == 1 )\n"
-  "  {\n"
-  "    lowp vec3 F = specularReflection( pbrInputs );\n"
-  "    lowp float G = geometricOcclusion( pbrInputs );\n"
-  "    lowp float D = microfacetDistribution( pbrInputs );\n"
-
-  // Calculation of analytical lighting contribution
-  "    lowp vec3 diffuseContrib = ( 1.0 - F ) * ( diffuseColor / M_PI );\n"
-  "    lowp vec3 specContrib = F * G * D / ( 4.0 * NdotL * NdotV );\n"
-  // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
-  "    color = NdotL * uLightColor * (diffuseContrib + specContrib);\n"
-  "  }\n"
-
-  "#ifdef TEXTURE_IBL\n"
-  "  lowp float lod = ( perceptualRoughness * uMipmapLevel );\n"
-  // retrieve a scale and bias to F0. See [1], Figure 3
-  "  lowp vec3 brdf = linear( texture( ubrdfLUT, vec2( NdotV, 1.0 - perceptualRoughness ) ).rgb );\n"
-  "  lowp vec3 diffuseLight = linear( texture( uDiffuseEnvSampler, n ).rgb );\n"
-  "  lowp vec3 specularLight = linear( textureLod( uSpecularEnvSampler, reflection, lod ).rgb );\n"
-
-  "  lowp vec3 diffuse = diffuseLight * diffuseColor * uScaleIBLAmbient.x;\n"
-  "  lowp vec3 specular = specularLight * ( specularColor * brdf.x + brdf.y ) * uScaleIBLAmbient.y;\n"
-  "  color += ( diffuse + specular );\n"
-  "#endif\n"
-
-  "#ifdef TEXTURE_OCCLUSION\n"
-  "  lowp float ao = texture( uOcclusionSampler, vUV[uOcclusionTexCoordIndex] ).r;\n"
-  "  color = mix( color, color * ao, uOcclusionStrength );\n"
-  "#endif\n"
-
-  "#ifdef TEXTURE_EMIT\n"
-  "  lowp vec3 emissive = linear( texture( uEmissiveSampler, vUV[uEmissiveTexCoordIndex] ).rgb ) * uEmissiveFactor;\n"
-  "  color += emissive;\n"
-  "#endif\n"
-
-  "  FragColor = vec4( pow( color,vec3( 1.0 / 2.2 ) ), baseColor.a );\n"
-  "}\n"
-};
-
-} // namespace internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_INTERNAL_GLTF_SHADER_H
\ No newline at end of file
index a7db0d2..be63772 100644 (file)
@@ -26,6 +26,9 @@
 #include <dali/public-api/rendering/shader.h>
 #include <dali/public-api/rendering/texture-set.h>
 
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
 namespace Dali
 {
 
@@ -47,31 +50,6 @@ const float LAYER_HEIGHTS[5] =
   26.f / 130.f
 };
 
-#define MAKE_SHADER(A)#A
-
-// Modify the vertex position according to the bounce coefficient;
-const char* MESH_VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec3    aPosition1;\n
-attribute mediump vec3    aPosition2;\n
-uniform   mediump mat4    uMvpMatrix;\n
-uniform   mediump vec3    uSize;
-uniform   mediump float   uBounceCoefficient;\n
-\n
-void main()\n
-{\n
-  gl_Position = uMvpMatrix * vec4(mix( aPosition1, aPosition2, abs(uBounceCoefficient) )*uSize, 1.0);\n
-}
-);
-
-// use the actor color to paint every layer
-const char* MESH_FRAGMENT_SHADER = MAKE_SHADER(
-uniform lowp  vec4    uColor;\n
-void main()\n
-{\n
-  gl_FragColor = uColor;\n
-}\n
-);
-
 } // namespace Anon
 
 Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
@@ -123,7 +101,7 @@ Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
   meshGeometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
 
   // Create the shader
-  Shader shader = Shader::New( MESH_VERTEX_SHADER, MESH_FRAGMENT_SHADER );
+  Shader shader = Shader::New( SHADER_BOUNCING_EFFECT_MESH_SHADER_VERT, SHADER_BOUNCING_EFFECT_MESH_SHADER_FRAG );
 
   // Create renderer
   Renderer renderer = Renderer::New( meshGeometry, shader );
index 37f7f53..3a86588 100644 (file)
@@ -31,6 +31,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
 #include <dali-toolkit/internal/controls/shadow-view/shadow-view-impl.h>
 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
@@ -88,38 +89,6 @@ const char* const SHADER_SHADOW_COLOR_PROPERTY_NAME = "uShadowColor";
 const char* const BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty";
 const char* const SHADOW_COLOR_PROPERTY_NAME = "ShadowColorProperty";
 
-const char* const RENDER_SHADOW_VERTEX_SOURCE =
-
-  " attribute mediump vec2 aPosition;\n"
-  " uniform mediump mat4 uMvpMatrix;\n"
-  " uniform mediump mat4 uModelMatrix;\n"
-  " uniform vec3 uSize;\n"
-  " varying vec2 vTexCoord;\n"
-
-  " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
-  " uniform mediump mat4 uLightCameraViewMatrix;\n"
-  "\n"
-  "void main()\n"
-  "{\n"
-    "  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
-    "  vertexPosition.xyz *= uSize;\n"
-    "  gl_Position = uMvpMatrix * vertexPosition;\n"
-    "  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vertexPosition;\n"
-    "  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
-  "}\n";
-
-const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
-  "varying mediump vec2 vTexCoord;\n"
-  "uniform lowp vec4 uShadowColor;\n"
-  "uniform sampler2D sTexture;\n"
-
-  "void main()\n"
-  "{\n"
-  "  lowp float alpha;\n"
-  "  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
-  "  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
-  "}\n";
-
 } // namespace
 
 ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale )
@@ -159,7 +128,9 @@ void ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
   mShadowPlane.SetProperty( Actor::Property::NAME, "SHADOW_PLANE" );
   mShadowPlane.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
   mShadowPlane.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
-  Renderer shadowRenderer = CreateRenderer( RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE, Shader::Hint::OUTPUT_IS_TRANSPARENT, Uint16Pair(20,20) );
+  Renderer shadowRenderer = CreateRenderer( SHADER_SHADOW_VIEW_RENDER_SHADER_VERT, SHADER_SHADOW_VIEW_RENDER_SHADER_FRAG,
+                                            Shader::Hint::OUTPUT_IS_TRANSPARENT,
+                                            Uint16Pair(20,20) );
   TextureSet textureSet = shadowRenderer.GetTextures();
   textureSet.SetTexture( 0u, mOutputFrameBuffer.GetColorTexture() );
   mShadowPlane.AddRenderer( shadowRenderer );
index 769a7fc..4cd42a4 100644 (file)
@@ -32,6 +32,7 @@
 // INTERNAL_INCLUDES
 #include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
@@ -52,18 +53,6 @@ const float GAUSSIAN_BLUR_DOWNSAMPLE_WIDTH_SCALE = 0.5f;
 const float GAUSSIAN_BLUR_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
 
 const char* ALPHA_UNIFORM_NAME( "uAlpha" );
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp float uAlpha;\n
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
-    gl_FragColor.a *= uAlpha;
-  }\n
-);
 
 /**
  * The constraint is used to blend the group of blurred images continuously with a unified blur strength property value which ranges from zero to one.
@@ -314,7 +303,7 @@ void SuperBlurView::OnSceneConnection( int depth )
 
   for(unsigned int i=0; i<mBlurLevels+1;i++)
   {
-    mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, FRAGMENT_SHADER );
+    mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SUPER_BLUR_VIEW_FRAG );
     mRenderers[i].SetProperty( Dali::Renderer::Property::DEPTH_INDEX, (int)i );
     self.AddRenderer( mRenderers[i] );
 
index 23799c3..7e64b6e 100644 (file)
@@ -1514,6 +1514,9 @@ void TextEditor::OnKeyInputFocusGained()
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() );
   if ( mInputMethodContext  && IsEditable() )
   {
+    // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
+    mInputMethodContext.NotifyTextInputMultiLine( true );
+
     mInputMethodContext.StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged );
 
     mInputMethodContext.EventReceivedSignal().Connect( this, &TextEditor::OnInputMethodContextEvent );
index fc09fd8..e87ba2f 100644 (file)
@@ -1519,7 +1519,9 @@ void TextField::OnKeyInputFocusGained()
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
   if ( mInputMethodContext && IsEditable() )
   {
+    // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
     mInputMethodContext.ApplyOptions( mInputMethodOptions );
+    mInputMethodContext.NotifyTextInputMultiLine( false );
 
     mInputMethodContext.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
 
index 6956cb2..8052be2 100755 (executable)
@@ -34,6 +34,7 @@
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -86,50 +87,6 @@ const char* const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
 const char* const DEFAULT_SAMPLER_TYPE_NAME( "sampler2D" );
 const char* const CUSTOM_SAMPLER_TYPE_NAME( "samplerExternalOES" );
 
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vertexPosition.xyz *= uSize;\n
-    gl_Position = uMvpMatrix * vertexPosition;\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = vec4(0.0);\n
-  }\n
-);
-
-const char* VERTEX_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  varying mediump vec2 vTexCoord;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  varying mediump vec2 sTexCoordRect;\n
-  void main()\n
-  {\n
-    gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);\n
-    vTexCoord = aPosition + vec2(0.5);\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
-  uniform lowp vec4 uColor;\n
-  varying mediump vec2 vTexCoord;\n
-  uniform samplerExternalOES sTexture;\n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
-  }\n
-);
-
 } // anonymous namepsace
 
 VideoView::VideoView( Dali::VideoSyncMode syncMode )
@@ -652,7 +609,7 @@ void VideoView::SetWindowSurfaceTarget()
   {
     // For underlay rendering mode, video display area have to be transparent.
     Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
-    Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+    Shader shader = Shader::New( SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG );
     mOverlayRenderer = Renderer::New( geometry, shader );
     mOverlayRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
   }
@@ -856,7 +813,7 @@ Dali::Shader VideoView::CreateShader()
 
     if( !vertexShaderValue || !checkShader )
     {
-      vertexShader = VERTEX_SHADER_TEXTURE;
+      vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
     }
 
     Property::Value* fragmentShaderValue = mEffectPropertyMap.Find( CUSTOM_FRAGMENT_SHADER );
@@ -872,13 +829,13 @@ Dali::Shader VideoView::CreateShader()
 
     if( !fragmentShaderValue || !checkShader )
     {
-      fragmentShader += FRAGMENT_SHADER_TEXTURE;
+      fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
     }
   }
   else
   {
-    vertexShader = VERTEX_SHADER_TEXTURE;
-    fragmentShader += FRAGMENT_SHADER_TEXTURE;
+    vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
+    fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
   }
 
   return Dali::Shader::New( vertexShader, fragmentShader );
old mode 100644 (file)
new mode 100755 (executable)
index c79e74a..0cf97a4
 
 // EXTERNAL INCLUDES
 #include <cstring>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
 #include <dali/devel-api/scripting/enum-helper.h>
 #include <dali/devel-api/scripting/scripting.h>
 #include <dali/devel-api/common/stage.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/public-api/image-loader/image.h>
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 
 namespace Dali
@@ -50,32 +59,19 @@ BaseHandle Create()
   return Toolkit::WebView::New();
 }
 
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER )
-DALI_ENUM_TO_STRING_TABLE_END( CacheModel )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY )
-DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy )
-
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create )
 
 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url",                     STRING,  URL                        )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel",              STRING,  CACHE_MODEL                )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy",      STRING,  COOKIE_ACCEPT_POLICY       )
 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent",               STRING,  USER_AGENT                 )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript",        BOOLEAN, ENABLE_JAVASCRIPT          )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY  )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING,  DEFAULT_TEXT_ENCODING_NAME )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize",         INTEGER, DEFAULT_FONT_SIZE          )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition",          VECTOR2, SCROLL_POSITION            )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize",              VECTOR2, SCROLL_SIZE                )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize",             VECTOR2, CONTENT_SIZE               )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "title",                   STRING,  TITLE                      )
 
 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadStarted",         PAGE_LOAD_STARTED_SIGNAL            )
 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadFinished",        PAGE_LOAD_FINISHED_SIGNAL           )
 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadError",           PAGE_LOAD_ERROR_SIGNAL              )
+DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "scrollEdgeReached",       SCROLL_EDGE_REACHED_SIGNAL          )
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -108,6 +104,25 @@ WebView::WebView( const std::string& locale, const std::string& timezoneId )
   }
 }
 
+WebView::WebView( int argc, char** argv )
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+  mUrl(),
+  mVisual(),
+  mWebViewSize( Stage::GetCurrent().GetSize() ),
+  mWebEngine(),
+  mPageLoadStartedSignal(),
+  mPageLoadFinishedSignal(),
+  mPageLoadErrorSignal()
+{
+  mWebEngine = Dali::WebEngine::New();
+
+  // WebEngine is empty when it is not properly initialized.
+  if ( mWebEngine )
+  {
+    mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, argc, argv );
+  }
+}
+
 WebView::WebView()
 : WebView( "", "" )
 {
@@ -135,6 +150,15 @@ Toolkit::WebView WebView::New( const std::string& locale, const std::string& tim
   return handle;
 }
 
+Toolkit::WebView WebView::New( int argc, char** argv )
+{
+  WebView* impl = new WebView( argc, argv );
+  Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+  impl->Initialize();
+  return handle;
+}
+
 void WebView::OnInitialize()
 {
   Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
@@ -145,7 +169,46 @@ void WebView::OnInitialize()
     mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
     mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
     mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
+    mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
+
+    mWebContext = std::unique_ptr<Dali::Toolkit::WebContext>( new WebContext( mWebEngine.GetContext() ) );
+    mWebCookieManager = std::unique_ptr<Dali::Toolkit::WebCookieManager>( new WebCookieManager( mWebEngine.GetCookieManager() ) );
+    mWebSettings = std::unique_ptr<Dali::Toolkit::WebSettings>( new WebSettings( mWebEngine.GetSettings() ) );
+    mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>( new WebBackForwardList( mWebEngine.GetBackForwardList() ) );
+  }
+}
+
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
+{
+  return mWebSettings.get();
+}
+
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+  return mWebContext.get();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+  return mWebCookieManager.get();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+  return mWebBackForwardList.get();
+}
+
+Dali::Toolkit::ImageView& WebView::GetFavicon()
+{
+  if ( mWebEngine )
+  {
+    Dali::PixelData pixelData = mWebEngine.GetFavicon();
+    std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData );
+    mFaviconView = Dali::Toolkit::ImageView::New( url );
+    mFaviconView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+    mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) );
   }
+  return mFaviconView;
 }
 
 void WebView::LoadUrl( const std::string& url )
@@ -168,7 +231,7 @@ void WebView::LoadUrl( const std::string& url )
   }
 }
 
-void WebView::LoadHTMLString( const std::string& htmlString )
+void WebView::LoadHtmlString( const std::string& htmlString )
 {
   if( mWebEngine )
   {
@@ -181,7 +244,7 @@ void WebView::LoadHTMLString( const std::string& htmlString )
     if( mVisual )
     {
       DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
-      mWebEngine.LoadHTMLString( htmlString );
+      mWebEngine.LoadHtmlString( htmlString );
     }
   }
 }
@@ -218,6 +281,14 @@ void WebView::Resume()
   }
 }
 
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+  if ( mWebEngine )
+  {
+    mWebEngine.ScrollBy( deltaX, deltaY );
+  }
+}
+
 bool WebView::CanGoForward()
 {
   return mWebEngine ? mWebEngine.CanGoForward() : false;
@@ -260,27 +331,19 @@ void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName,
   }
 }
 
-void WebView::ClearHistory()
+void WebView::ClearAllTilesResources()
 {
   if( mWebEngine )
   {
-    mWebEngine.ClearHistory();
+    mWebEngine.ClearAllTilesResources();
   }
 }
 
-void WebView::ClearCache()
-{
-  if( mWebEngine )
-  {
-    mWebEngine.ClearCache();
-  }
-}
-
-void WebView::ClearCookies()
+void WebView::ClearHistory()
 {
   if( mWebEngine )
   {
-    mWebEngine.ClearCookies();
+    mWebEngine.ClearHistory();
   }
 }
 
@@ -299,6 +362,11 @@ Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSi
   return mPageLoadErrorSignal;
 }
 
+Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+  return mScrollEdgeReachedSignal;
+}
+
 void WebView::OnPageLoadStarted( const std::string& url )
 {
   if( !mPageLoadStartedSignal.Empty() )
@@ -326,6 +394,15 @@ void WebView::OnPageLoadError( const std::string& url, int errorCode )
   }
 }
 
+void WebView::OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge )
+{
+  if( !mScrollEdgeReachedSignal.Empty() )
+  {
+    Dali::Toolkit::WebView handle( GetOwner() );
+    mScrollEdgeReachedSignal.Emit( handle, edge );
+  }
+}
+
 bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   Dali::BaseHandle handle( object );
@@ -348,6 +425,11 @@ bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* t
     webView.PageLoadErrorSignal().Connect( tracker, functor );
     connected = true;
   }
+  else if( 0 == strcmp( signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL ) )
+  {
+    webView.ScrollEdgeReachedSignal().Connect( tracker, functor );
+    connected = true;
+  }
 
   return connected;
 }
@@ -397,20 +479,6 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
         }
         break;
       }
-      case Toolkit::WebView::Property::CACHE_MODEL:
-      {
-        Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel();
-        GET_ENUM_VALUE( CacheModel, value, output );
-        impl.SetCacheModel( output );
-        break;
-      }
-      case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
-      {
-        Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy();
-        GET_ENUM_VALUE( CookieAcceptPolicy, value, output );
-        impl.SetCookieAcceptPolicy( output );
-        break;
-      }
       case Toolkit::WebView::Property::USER_AGENT:
       {
         std::string input;
@@ -420,39 +488,12 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop
         }
         break;
       }
-      case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
-      {
-        bool input;
-        if( value.Get( input ) )
-        {
-          impl.EnableJavaScript( input );
-        }
-        break;
-      }
-      case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
+      case Toolkit::WebView::Property::SCROLL_POSITION:
       {
-        bool input;
-        if( value.Get( input ) )
+        Vector2 input;
+        if ( value.Get( input ) )
         {
-          impl.LoadImagesAutomatically( input );
-        }
-        break;
-      }
-      case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
-      {
-        std::string input;
-        if( value.Get( input ) )
-        {
-          impl.SetDefaultTextEncodingName( input );
-        }
-        break;
-      }
-      case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
-      {
-        int input;
-        if( value.Get( input ) )
-        {
-          impl.SetDefaultFontSize( input );
+          impl.SetScrollPosition( input.x, input.y );
         }
         break;
       }
@@ -476,39 +517,29 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper
         value = impl.mUrl;
         break;
       }
-      case Toolkit::WebView::Property::CACHE_MODEL:
-      {
-        value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() );
-        break;
-      }
-      case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
-      {
-        value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() );
-        break;
-      }
       case Toolkit::WebView::Property::USER_AGENT:
       {
         value = impl.GetUserAgent();
         break;
       }
-      case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
+      case Toolkit::WebView::Property::SCROLL_POSITION:
       {
-        value = impl.IsJavaScriptEnabled();
+        value = impl.GetScrollPosition();
         break;
       }
-      case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
+      case Toolkit::WebView::Property::SCROLL_SIZE:
       {
-        value = impl.AreImagesAutomaticallyLoaded();
+        value = impl.GetScrollSize();
         break;
       }
-      case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
+      case Toolkit::WebView::Property::CONTENT_SIZE:
       {
-        value = impl.GetDefaultTextEncodingName();
+        value = impl.GetContentSize();
         break;
       }
-      case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
+      case Toolkit::WebView::Property::TITLE:
       {
-        value = impl.GetDefaultFontSize();
+        value = impl.GetTitle();
         break;
       }
       default:
@@ -541,94 +572,64 @@ bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
   return result;
 }
 
-Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
-{
-  return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
-}
-
-void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel )
+void WebView::OnKeyInputFocusGained()
 {
   if( mWebEngine )
   {
-    mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) );
+    mWebEngine.SetFocus( true );
   }
-}
 
-Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const
-{
-  return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY;
+  EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
 }
 
-void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy )
+void WebView::OnKeyInputFocusLost()
 {
   if( mWebEngine )
   {
-    mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) );
+    mWebEngine.SetFocus( false );
   }
-}
 
-const std::string& WebView::GetUserAgent() const
-{
-  return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
+  EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
 }
 
-void WebView::SetUserAgent( const std::string& userAgent )
+void WebView::SetScrollPosition( int x, int y )
 {
   if( mWebEngine )
   {
-    mWebEngine.SetUserAgent( userAgent );
+    mWebEngine.SetScrollPosition( x, y );
   }
 }
 
-bool WebView::IsJavaScriptEnabled() const
+Dali::Vector2 WebView::GetScrollPosition() const
 {
-  return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true;
+  return mWebEngine ? mWebEngine.GetScrollPosition() : Dali::Vector2::ZERO;
 }
 
-void WebView::EnableJavaScript( bool enabled )
+Dali::Vector2 WebView::GetScrollSize() const
 {
-  if( mWebEngine )
-  {
-    mWebEngine.EnableJavaScript( enabled );
-  }
+  return mWebEngine ? mWebEngine.GetScrollSize() : Dali::Vector2::ZERO;
 }
 
-bool WebView::AreImagesAutomaticallyLoaded() const
+Dali::Vector2 WebView::GetContentSize() const
 {
-  return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true;
+  return mWebEngine ? mWebEngine.GetContentSize() : Dali::Vector2::ZERO;
 }
 
-void WebView::LoadImagesAutomatically( bool automatic )
+std::string WebView::GetTitle() const
 {
-  if( mWebEngine )
-  {
-    mWebEngine.LoadImagesAutomatically( automatic );
-  }
-}
-
-const std::string& WebView::GetDefaultTextEncodingName() const
-{
-  return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString;
-}
-
-void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
-{
-  if( mWebEngine )
-  {
-    mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName );
-  }
+  return mWebEngine ?  mWebEngine.GetTitle() : kEmptyString;
 }
 
-int WebView::GetDefaultFontSize() const
+const std::string& WebView::GetUserAgent() const
 {
-  return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0;
+  return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
 }
 
-void WebView::SetDefaultFontSize( int defaultFontSize )
+void WebView::SetUserAgent( const std::string& userAgent )
 {
   if( mWebEngine )
   {
-    mWebEngine.SetDefaultFontSize( defaultFontSize );
+    mWebEngine.SetUserAgent( userAgent );
   }
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index c41be87..14fb0b5
  */
 
 // EXTERNAL INCLUDES
+#include <memory>
 #include <dali/devel-api/adaptor-framework/web-engine.h>
 #include <dali/public-api/images/image-operations.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 
 namespace Dali
 {
@@ -35,6 +37,10 @@ namespace Toolkit
 
 class KeyEvent;
 class TouchEvent;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
 class WebView;
 
 namespace Internal
@@ -48,6 +54,8 @@ protected:
 
   WebView( const std::string& locale, const std::string& timezoneId );
 
+  WebView( int argc, char** argv );
+
   virtual ~WebView();
 
 public:
@@ -63,6 +71,38 @@ public:
   static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
 
   /**
+   * @brief Get settings of WebEngine.
+   */
+  Dali::Toolkit::WebSettings* GetSettings() const;
+
+  /**
+   * @brief Get context of WebEngine.
+   */
+  Dali::Toolkit::WebContext* GetContext() const;
+
+  /**
+   * @brief Get cookie manager of WebEngine.
+   */
+  Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+  /**
+   * @brief Get WebBackForwardList of WebEngine.
+   */
+  Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+  /**
+   * @copydoc Dali::Toolkit::WebView::New( int, char** )
+   */
+  static Toolkit::WebView New( int argc, char** argv );
+
+  /**
+   * @brief Get Favicon of web page.
+   *
+   * @return Handle to a fav icon
+   */
+  Dali::Toolkit::ImageView& GetFavicon();
+
+  /**
    * @copydoc Dali::Toolkit::WebView::LoadUrl()
    */
   void LoadUrl( const std::string& url );
@@ -70,7 +110,7 @@ public:
   /**
    * @copydoc Dali::WebEngine::LoadHTMLString()
    */
-  void LoadHTMLString( const std::string& htmlString );
+  void LoadHtmlString( const std::string& htmlString );
 
   /**
    * @copydoc Dali::Toolkit::WebView::Reload()
@@ -93,6 +133,11 @@ public:
   void Resume();
 
   /**
+   * @copydoc Dali::Toolkit::WebView::ScrollBy()
+   */
+  void ScrollBy( int deltaX, int deltaY );
+
+  /**
    * @copydoc Dali::Toolkit::WebView::CanGoForward()
    */
   bool CanGoForward();
@@ -123,19 +168,14 @@ public:
   void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler );
 
   /**
-   * @copydoc Dali::Toolkit::WebView::ClearHistory()
-   */
-  void ClearHistory();
-
-  /**
-   * @copydoc Dali::Toolkit::WebView::ClearCache()
+   * @brief Clears all tiles resources of Web.
    */
-  void ClearCache();
+  void ClearAllTilesResources();
 
   /**
-   * @copydoc Dali::Toolkit::WebView::ClearCookies()
+   * @copydoc Dali::Toolkit::WebView::ClearHistory()
    */
-  void ClearCookies();
+  void ClearHistory();
 
   /**
    * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
@@ -152,6 +192,11 @@ public:
    */
   Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
 
+  /**
+   * @copydoc Dali::Toolkit::WebView::ScrollEdgeReachedSignal()
+   */
+  Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
 public: // Properties
 
   /**
@@ -213,106 +258,69 @@ private: // From Control
    */
   bool OnKeyEvent( const Dali::KeyEvent& event ) override;
 
-private:
-
-  // Undefined
-  WebView( const WebView& webView );
-
-  WebView& operator=( const WebView& webView );
-
-  /**
-   * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
-   * @see Toolkit::WebView::CacheModel::Type
-   */
-  Toolkit::WebView::CacheModel::Type GetCacheModel() const;
-
-  /**
-   * @brief Set cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
-   * @param[in] cacheModel The cache model option
-   * @see Toolkit::WebView::CacheModel::Type
-   */
-  void SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel );
-
   /**
-   * @brief Gets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
-   * @see Toolkit::WebView::CookieAcceptPolicy::Type
+   * @copydoc Toolkit::Control::OnKeyInputFocusGained()
    */
-  Toolkit::WebView::CookieAcceptPolicy::Type GetCookieAcceptPolicy() const;
+  void OnKeyInputFocusGained() override;
 
   /**
-   * @brief Sets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
-   * @param[in] policy The cookie acceptance policy
-   * @see Toolkit::WebView::CookieAcceptPolicy::Type
+   * @copydoc Toolkit::Control::OnKeyInputFocusLost()
    */
-  void SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy );
+  void OnKeyInputFocusLost() override;
 
-  /**
-   * @brief Get user agent string.
-   * @return The string value of user agent
-   */
-  const std::string& GetUserAgent() const;
+private:
 
-  /**
-   * @brief Set user agent string.
-   * @param[in] userAgent The string value of user agent
-   */
-  void SetUserAgent( const std::string& userAgent );
+  // Undefined
+  WebView( const WebView& webView );
 
-  /**
-   * @brief Returns whether JavaScript can be executable. The default is true.
-   *
-   * @return true if JavaScript executing is enabled, false otherwise
-   */
-  bool IsJavaScriptEnabled() const;
+  WebView& operator=( const WebView& webView );
 
   /**
-   * @brief Enables/disables JavaScript executing. The default is enabled.
-   *
-   * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+   * @brief Sets an absolute scroll of the given view.
+   * @param[in] x The coordinate x of scroll
+   * @param[in] y The coordinate y of scroll
    */
-  void EnableJavaScript( bool enabled );
+  void SetScrollPosition( int x, int y );
 
   /**
-   * @brief Returns whether images can be loaded automatically. The default is true.
-   *
-   * @return true if images are loaded automatically, false otherwise
+   * @brief Gets the current scroll position of the given view.
+   * @param[out] x The coordinate x of scroll
+   * @param[out] y The coordinate y of scroll
    */
-  bool AreImagesAutomaticallyLoaded() const;
+  Dali::Vector2 GetScrollPosition() const;
 
   /**
-   * @brief Enables/disables auto loading of images. The default is enabled.
-   *
-   * @param[in] automatic True if images are loaded automatically, false otherwise
+   * @brief Gets the possible scroll size of the given view.
+   * @param[out] width The width of scroll size
+   * @param[out] height The height of scroll size
    */
-  void LoadImagesAutomatically( bool automatic );
+  Dali::Vector2 GetScrollSize() const;
 
   /**
-   * @brief Gets the default text encoding name (e.g. UTF-8).
-   *
-   * @return The default text encoding name
+   * @brief Gets the last known content's size.
+   * @param[out] width The width of content's size
+   * @param[out] height The height of content's size
    */
-  const std::string& GetDefaultTextEncodingName() const;
+  Dali::Vector2 GetContentSize() const;
 
   /**
-   * @brief Sets the default text encoding name (e.g. UTF-8).
+   * @brief Returns the title of the Web.
    *
-   * @param[in] defaultTextEncodingName The default text encoding name
+   * @return The title of web page
    */
-  void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+  std::string GetTitle() const;
 
   /**
-   * @brief Returns the default font size in pixel. The default value is 16.
-   *
-   * @return The default font size
+   * @brief Get user agent string.
+   * @return The string value of user agent
    */
-  int GetDefaultFontSize() const;
+  const std::string& GetUserAgent() const;
 
   /**
-   * @brief Sets the default font size in pixel. The default value is 16.
-   *
-   * @param[in] defaultFontSize A new default font size to set
+   * @brief Set user agent string.
+   * @param[in] userAgent The string value of user agent
    */
-  void SetDefaultFontSize( int defaultFontSize );
+  void SetUserAgent( const std::string& userAgent );
 
   /**
    * @brief Callback function to be called when page load started.
@@ -333,6 +341,12 @@ private:
    */
   void OnPageLoadError( const std::string& url, int errorCode );
 
+  /**
+   * @brief Callback function to be called when scroll edge is reached.
+   * @param[in] e The scroll edge reached.
+   */
+  void OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge );
+
 private:
 
   std::string                                            mUrl;
@@ -343,6 +357,13 @@ private:
   Dali::Toolkit::WebView::WebViewPageLoadSignalType      mPageLoadStartedSignal;
   Dali::Toolkit::WebView::WebViewPageLoadSignalType      mPageLoadFinishedSignal;
   Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal;
+  Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+
+  std::unique_ptr<Dali::Toolkit::WebContext>             mWebContext;
+  std::unique_ptr<Dali::Toolkit::WebCookieManager>       mWebCookieManager;
+  std::unique_ptr<Dali::Toolkit::WebSettings>            mWebSettings;
+  std::unique_ptr<Dali::Toolkit::WebBackForwardList>     mWebBackForwardList;
+  Dali::Toolkit::ImageView mFaviconView;
 };
 
 } // namespace Internal
index 8cc93bc..c26fc7c 100644 (file)
@@ -179,6 +179,7 @@ SET( toolkit_src_files
    ${toolkit_src_dir}/transition-effects/cube-transition-wave-effect-impl.cpp
    ${toolkit_src_dir}/text/xhtml-entities.cpp
    ${toolkit_src_dir}/drag-drop-detector/drag-and-drop-detector-impl.cpp
+   ${toolkit_src_dir}/graphics/generated/builtin-shader-gen.cpp
 )
 
 SET( SOURCES ${SOURCES}
index e870650..f86ffd4 100644 (file)
@@ -28,6 +28,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -58,24 +59,6 @@ const float DEFAULT_KERNEL4[] = { 2.0f/16.0f, 1.5f/16.0f, 1.5f/16.0f, 1.5f/16.0f
                                   1.0f/16.0f, 1.0f/16.0f, 1.0f/16.0f, 0.5f/16.0f,
                                   0.5f/16.0f, 0.5f/16.0f, 0.5f/16.0f };
 
-const char* BLUR_TWO_PASS_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform vec2 uSampleOffsets[NUM_SAMPLES];\n"
- "uniform float uSampleWeights[NUM_SAMPLES];\n"
- "void main()\n"
- "{\n"
- "  vec4 color = vec4(0.0);\n"
- "  for( int i = 0; i < NUM_SAMPLES; ++i )\n"
- "  {\n"
- "    color += texture2D( sTexture, vTexCoord + uSampleOffsets[i] ) * uSampleWeights[i];\n"
- "  }\n"
- "  gl_FragColor = color;\n"
- "}\n"
-};
-
 std::string GetOffsetUniformName( int index )
 {
   std::ostringstream oss;
@@ -90,20 +73,6 @@ std::string GetWeightUniformName( int index )
   return oss.str();
 }
 
-const char* BLEND_TWO_IMAGES_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "uniform float uBlurStrength;\n "
- "uniform sampler2D sTexture;\n"
- "uniform sampler2D sEffect;\n"
- "varying mediump vec2 vTexCoord;\n"
- "void main()\n"
- "{\n"
- "  gl_FragColor = texture2D( sTexture, vTexCoord ) * uBlurStrength"
- "               + texture2D( sEffect, vTexCoord )*(1.0-uBlurStrength); \n"
- "}\n"
-};
-
 const char* const BLUR_STRENGTH_UNIFORM_NAME( "uBlurStrength"  );
 const char* const EFFECT_IMAGE_NAME( "sEffect" );
 
@@ -135,7 +104,7 @@ void BlurTwoPassFilter::Enable()
   // Set up blur-two-pass custom shader
   std::ostringstream sstream;
   sstream << "#define NUM_SAMPLES " << kernelSize << "\n";
-  sstream << BLUR_TWO_PASS_FRAGMENT_SOURCE;
+  sstream << SHADER_BLUR_TWO_PASS_SHADER_FRAG;
   std::string fragmentSource( sstream.str() );
 
   // create actor to render input with applied emboss effect
@@ -165,7 +134,7 @@ void BlurTwoPassFilter::Enable()
   mBlurredFrameBuffer.AttachColorTexture( blurredTexture );
 
   // create an actor to blend the blurred image and the input image with the given blur strength
-  Renderer rendererForBlending = CreateRenderer( BASIC_VERTEX_SOURCE, BLEND_TWO_IMAGES_FRAGMENT_SOURCE );
+  Renderer rendererForBlending = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLUR_TWO_IMAGES_SHADER_FRAG );
   TextureSet textureSetForBlending = rendererForBlending.GetTextures();
   textureSetForBlending.SetTexture( 0u, blurredTexture );
   textureSetForBlending.SetTexture( 1u, mInputTexture );
index b1bd177..7ea7fe1 100644 (file)
@@ -28,6 +28,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -41,35 +42,6 @@ namespace Internal
 namespace
 {
 
-const char* EMBOSS_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform vec2 uTexScale;\n"
- "uniform vec3 uCoefficient;\n"
- "\n"
- "void main()\n"
- "{\n"
- "  vec4 color  = uCoefficient.x * texture2D( sTexture, vTexCoord + vec2(0.0, -uTexScale.y) );\n"
- "  color += uCoefficient.y * texture2D( sTexture, vTexCoord );\n"
- "  color += uCoefficient.z * texture2D( sTexture, vTexCoord + vec2(0.0, uTexScale.y) );\n"
- "  gl_FragColor = color;\n"
- "}\n"
-};
-
-const char* const COMPOSITE_FRAGMENT_SOURCE =
-{
-  "varying mediump vec2 vTexCoord;\n"
-  "uniform sampler2D sTexture;\n"
-  "uniform lowp vec4 uEffectColor;\n"
-  "void main()\n"
-  "{\n"
-  "  gl_FragColor = uEffectColor;\n"
-  "  gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;\n"
-  "}\n"
-};
-
 const char* const TEX_SCALE_UNIFORM_NAME( "uTexScale" );
 const char* const COEFFICIENT_UNIFORM_NAME( "uCoefficient" );
 const char* const COLOR_UNIFORM_NAME( "uEffectColor" );
@@ -103,7 +75,7 @@ void EmbossFilter::Enable()
   mActorForInput1.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
   mActorForInput1.RegisterProperty( COEFFICIENT_UNIFORM_NAME, Vector3( 2.f, -1.f, -1.f ) );
   // set EMBOSS custom shader
-  Renderer renderer1 = CreateRenderer( BASIC_VERTEX_SOURCE, EMBOSS_FRAGMENT_SOURCE );
+  Renderer renderer1 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_SHADER_FRAG );
   SetRendererTexture( renderer1, mInputTexture );
   mActorForInput1.AddRenderer( renderer1 );
   mRootActor.Add( mActorForInput1 );
@@ -114,7 +86,7 @@ void EmbossFilter::Enable()
   mActorForInput2.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
   mActorForInput2.RegisterProperty( COEFFICIENT_UNIFORM_NAME, Vector3( -1.f, -1.f, 2.f ) );
   // set EMBOSS custom shader
-  Renderer renderer2 = CreateRenderer( BASIC_VERTEX_SOURCE, EMBOSS_FRAGMENT_SOURCE );
+  Renderer renderer2 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_SHADER_FRAG );
   SetRendererTexture( renderer2, mInputTexture );
   mActorForInput2.AddRenderer( renderer2 );
   mRootActor.Add( mActorForInput2 );
@@ -126,12 +98,12 @@ void EmbossFilter::Enable()
 
   mRootActor.Add( mActorForComposite );
 
-  mRendererForEmboss1 = CreateRenderer( BASIC_VERTEX_SOURCE, COMPOSITE_FRAGMENT_SOURCE );
+  mRendererForEmboss1 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_COMPOSITE_SHADER_FRAG );
   SetRendererTexture( mRendererForEmboss1, mFrameBufferForEmboss1 );
   mRendererForEmboss1.RegisterProperty( COLOR_UNIFORM_NAME, Color::BLACK );
   mActorForComposite.AddRenderer( mRendererForEmboss1 );
 
-  mRendererForEmboss2 = CreateRenderer( BASIC_VERTEX_SOURCE, COMPOSITE_FRAGMENT_SOURCE );
+  mRendererForEmboss2 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_COMPOSITE_SHADER_FRAG );
   SetRendererTexture( mRendererForEmboss2, mFrameBufferForEmboss2 );
   mRendererForEmboss2.RegisterProperty( COLOR_UNIFORM_NAME, Color::WHITE );
   mActorForComposite.AddRenderer( mRendererForEmboss2 );
index 5eb8a82..55b060b 100644 (file)
@@ -26,6 +26,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/control/control-renderers.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -39,26 +40,6 @@ namespace Internal
 namespace
 {
 
-const char* const SPREAD_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform int uSpread;\n"
- "uniform vec2 uTexScale;\n"
- "void main()\n"
- "{\n"
- "  vec4 color = texture2D( sTexture, vTexCoord);\n"
- "  for( int i = 1; i <= uSpread; ++i )\n"
- "  {\n"
- "    vec2 offset = uTexScale * float(i);\n"
- "    color = max( texture2D( sTexture, vTexCoord + offset), color );\n"
- "    color = max( texture2D( sTexture, vTexCoord - offset), color );\n"
- "  }\n"
- "  gl_FragColor = color;\n"
- "}\n"
-};
-
 const char* const SPREAD_UNIFORM_NAME( "uSpread" );
 const char* const TEX_SCALE_UNIFORM_NAME( "uTexScale" );
 
@@ -90,7 +71,7 @@ void SpreadFilter::Enable()
   mActorForInput.RegisterProperty( SPREAD_UNIFORM_NAME, mSpread );
   mActorForInput.RegisterProperty( TEX_SCALE_UNIFORM_NAME, Vector2( 1.0f / mTargetSize.width, 0.0f ) );
 
-  Renderer rendererForInput = CreateRenderer( BASIC_VERTEX_SOURCE, SPREAD_FRAGMENT_SOURCE );
+  Renderer rendererForInput = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SPREAD_FILTER_SHADER_FRAG );
   SetRendererTexture( rendererForInput, mInputTexture );
   mActorForInput.AddRenderer( rendererForInput );
 
@@ -106,7 +87,7 @@ void SpreadFilter::Enable()
   // register properties as shader uniforms
   mActorForHorz.RegisterProperty( SPREAD_UNIFORM_NAME, mSpread );
   mActorForHorz.RegisterProperty( TEX_SCALE_UNIFORM_NAME, Vector2( 0.0f, 1.0f / mTargetSize.height ) );
-  Renderer rendererForHorz = CreateRenderer( BASIC_VERTEX_SOURCE, SPREAD_FRAGMENT_SOURCE );
+  Renderer rendererForHorz = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SPREAD_FILTER_SHADER_FRAG );
   SetRendererTexture( rendererForHorz, textureForHorz );
   mActorForHorz.AddRenderer( rendererForHorz );
 
diff --git a/dali-toolkit/internal/graphics/shaders/alpha-discard-effect.frag b/dali-toolkit/internal/graphics/shaders/alpha-discard-effect.frag
new file mode 100644 (file)
index 0000000..d9b3d5a
--- /dev/null
@@ -0,0 +1,14 @@
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+  mediump vec4 color = texture2D( sTexture, vTexCoord );
+  if(color.a <= 0.0001)
+  {
+    discard;
+  }
+  gl_FragColor = color * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/animated-gradient-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/animated-gradient-visual-shader.frag
new file mode 100644 (file)
index 0000000..7855bf0
--- /dev/null
@@ -0,0 +1,51 @@
+precision mediump float;
+
+uniform mediump vec4 start_color;
+uniform mediump vec4 end_color;
+uniform mediump float gradient_offset;
+
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vStart;
+varying mediump vec2 vEnd;
+
+float get_position(vec2 x, vec2 s, vec2 e)
+{
+  vec2 df = e - s;
+  vec2 dx = x - s;
+
+#ifdef GRADIENT_TYPE_LINEAR
+  return dot(dx,df)/dot(df,df);
+#endif
+/* GradientType::LINEAR */
+
+#ifdef GRADIENT_TYPE_RADIAL
+  return sqrt(dot(dx,dx)/dot(df,df));
+#endif
+/* GradientType::RADIAL */
+}
+
+float recalculate(float r)
+{
+#ifdef SPREAD_TYPE_REFLECT
+  return 1.0 - abs(mod(r, 2.0) - 1.0);
+#endif
+/* SpreadType::REFLECT */
+
+#ifdef SPREAD_TYPE_REPEAT
+  return fract(r);
+#endif
+/* SpreadType::REPEAT*/
+
+#ifdef SPREAD_TYPE_CLAMP
+  return clamp(r, 0.0, 1.0);
+#endif
+/* SpreadType::CLAMP */
+}
+
+void main()
+{
+  float r = get_position( vTexCoord, vStart, vEnd );
+  r = recalculate( r + gradient_offset );
+  vec4 color = mix( start_color, end_color, r );
+  gl_FragColor = color;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/animated-gradient-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/animated-gradient-visual-shader.vert
new file mode 100644 (file)
index 0000000..e5cbaa7
--- /dev/null
@@ -0,0 +1,59 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+uniform mediump vec2 start_point;
+uniform mediump vec2 end_point;
+uniform mediump vec2 rotate_center;
+uniform mediump float rotate_angle;
+
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vStart;
+varying mediump vec2 vEnd;
+
+vec2 rotate(vec2 x, vec2 c, float a)
+{
+  vec2 d = x - c;
+  vec2 r = vec2(d.x * cos(a) - d.y * sin(a), d.x * sin(a) + d.y * cos(a));
+
+#ifdef UNIT_TYPE_BOUNDING_BOX
+  return r + c;
+#endif
+
+  /* UnitType::OBJECT_BOUNDING_BOX */
+#ifdef UNIT_TYPE_USER
+  return (r + c) / uSize.x;
+#endif
+  /* UnitType::USER_SPACE*/
+}
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix( uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  vStart = rotate( start_point, rotate_center, rotate_angle );
+  vEnd = rotate( end_point, rotate_center, rotate_angle );
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+#ifdef UNIT_TYPE_BOUNDING_BOX
+  vTexCoord = vec2(aPosition.x, -aPosition.y);
+#endif
+/* UnitType::OBJECT_BOUNDING_BOX */
+
+#ifdef UNIT_TYPE_USER
+  vTexCoord = vec2(aPosition.x, -aPosition.y * uSize.y / uSize.x);
+#endif
+/* UnitType::USER_SPACE*/
+}
diff --git a/dali-toolkit/internal/graphics/shaders/arc-visual-butt-cap-shader.frag b/dali-toolkit/internal/graphics/shaders/arc-visual-butt-cap-shader.frag
new file mode 100644 (file)
index 0000000..c191b88
--- /dev/null
@@ -0,0 +1,35 @@
+INPUT mediump vec2 vPosition;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform mediump float thickness;
+uniform mediump float radius;
+uniform mediump float startAngle;
+uniform mediump float sweepAngle;
+
+const mediump float M_PI_OVER_2 = 1.57079632679;
+const mediump float M_PI = 3.14159265359;
+const mediump float M_PI_2 = 6.28318530718;
+
+mediump float GetOpacity()
+{
+  mediump float start = radians( mod( startAngle, 360.0 ) );
+  mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );
+  mediump float dist = length( vPosition );
+  if( angle <= radians( sweepAngle ) )
+  {
+    return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );
+  }
+  mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );
+  mediump vec2 q0 = vec2( dist * cos( start - M_PI_OVER_2 ), dist * sin( start - M_PI_OVER_2 ) );
+  mediump vec2 q1 = vec2( dist * cos( end - M_PI_OVER_2 ), dist * sin( end - M_PI_OVER_2 ) );
+  mediump float opacity = 1.0 - smoothstep( 0.0, 2.0, min( length( vPosition - q0 ), length( vPosition - q1 ) ) );
+  opacity *= step( 0.0, thickness / 2.0 - abs( dist - radius ) );
+  return opacity;
+}
+
+void main()
+{
+  OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;
+  OUT_COLOR.a *= GetOpacity();
+}
diff --git a/dali-toolkit/internal/graphics/shaders/arc-visual-round-cap-shader.frag b/dali-toolkit/internal/graphics/shaders/arc-visual-round-cap-shader.frag
new file mode 100644 (file)
index 0000000..8439290
--- /dev/null
@@ -0,0 +1,32 @@
+INPUT mediump vec2 vPosition;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform mediump float thickness;
+uniform mediump float radius;
+uniform mediump float startAngle;
+uniform mediump float sweepAngle;
+
+const mediump float M_PI_OVER_2 = 1.57079632679;
+const mediump float M_PI_2 = 6.28318530718;
+
+mediump float GetOpacity()
+{
+  mediump float start = radians( mod( startAngle, 360.0 ) );
+  mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );
+  mediump float dist = length( vPosition );
+  if( angle <= radians( sweepAngle ) )
+  {
+    return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );
+  }
+  mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );
+  mediump vec2 q0 = vec2( radius * cos( start - M_PI_OVER_2 ), radius * sin( start - M_PI_OVER_2 ) );
+  mediump vec2 q1 = vec2( radius * cos( end - M_PI_OVER_2 ), radius * sin( end - M_PI_OVER_2 ) );
+  return smoothstep( -1.0, 1.0, thickness / 2.0 - min( length( vPosition - q0 ), length( vPosition - q1 ) ) );
+}
+
+void main()
+{
+  OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;
+  OUT_COLOR.a *= GetOpacity();
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/arc-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/arc-visual-shader.vert
new file mode 100644 (file)
index 0000000..e063d81
--- /dev/null
@@ -0,0 +1,25 @@
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vPosition;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  vPosition = aPosition* visualSize;
+  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/bloom-view-composite-shader.frag b/dali-toolkit/internal/graphics/shaders/bloom-view-composite-shader.frag
new file mode 100644 (file)
index 0000000..ff5778b
--- /dev/null
@@ -0,0 +1,27 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sEffect;
+uniform lowp vec4 uColor;
+uniform float uBloomIntensity;
+uniform float uImageIntensity;
+uniform float uBloomSaturation;
+uniform float uImageSaturation;
+
+vec4 ChangeSaturation(vec4 col, float sat)
+{
+  float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));
+  return mix(vec4(grey, grey, grey, 1.0), col, sat);
+}
+
+void main()
+{
+  mediump vec4 image;
+  mediump vec4 bloom;
+  image = texture2D(sTexture, vTexCoord);
+  bloom = texture2D(sEffect, vTexCoord);
+  image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;
+  bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;
+  image *= 1.0 - clamp(bloom, 0.0, 1.0); // darken base where bloom is strong, to prevent excessive burn-out of result
+  gl_FragColor = image + bloom;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/bloom-view-extract-shader.frag b/dali-toolkit/internal/graphics/shaders/bloom-view-extract-shader.frag
new file mode 100644 (file)
index 0000000..98439ed
--- /dev/null
@@ -0,0 +1,13 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform mediump float uBloomThreshold;
+uniform mediump float uRecipOneMinusBloomThreshold;
+
+void main()
+{
+  mediump vec4 col;
+  col = texture2D(sTexture, vTexCoord);
+  col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold; // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
+  gl_FragColor = clamp(col, 0.0, 1.0);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/blur-two-images-shader.frag b/dali-toolkit/internal/graphics/shaders/blur-two-images-shader.frag
new file mode 100644 (file)
index 0000000..7572a28
--- /dev/null
@@ -0,0 +1,11 @@
+precision highp float;
+uniform float uBlurStrength;
+uniform sampler2D sTexture;
+uniform sampler2D sEffect;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vTexCoord ) * uBlurStrength
+               + texture2D( sEffect, vTexCoord )*(1.0-uBlurStrength);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/blur-two-pass-shader.frag b/dali-toolkit/internal/graphics/shaders/blur-two-pass-shader.frag
new file mode 100644 (file)
index 0000000..0017e28
--- /dev/null
@@ -0,0 +1,15 @@
+precision highp float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform vec2 uSampleOffsets[NUM_SAMPLES];
+uniform float uSampleWeights[NUM_SAMPLES];
+
+void main()
+{
+  vec4 color = vec4(0.0);
+  for( int i = 0; i < NUM_SAMPLES; ++i )
+  {
+    color += texture2D( sTexture, vTexCoord + uSampleOffsets[i] ) * uSampleWeights[i];
+  }
+  gl_FragColor = color;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/border-visual-anti-aliasing-shader.frag b/dali-toolkit/internal/graphics/shaders/border-visual-anti-aliasing-shader.frag
new file mode 100644 (file)
index 0000000..8853321
--- /dev/null
@@ -0,0 +1,12 @@
+INPUT mediump float vAlpha;
+
+uniform lowp vec4 uColor;
+uniform lowp vec4 borderColor;
+uniform lowp vec3 mixColor;
+uniform mediump float borderSize;
+
+void main()
+{
+  OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;
+  OUT_COLOR.a *= smoothstep(0.0, 1.5, vAlpha) * smoothstep( borderSize + 1.5, borderSize, vAlpha );
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/border-visual-anti-aliasing-shader.vert b/dali-toolkit/internal/graphics/shaders/border-visual-anti-aliasing-shader.vert
new file mode 100644 (file)
index 0000000..e573f37
--- /dev/null
@@ -0,0 +1,14 @@
+INPUT mediump vec2 aPosition;
+INPUT mediump vec2 aDrift;
+OUTPUT mediump float vAlpha;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump float borderSize;
+
+void main()
+{
+  vec2 position = aPosition*(uSize.xy+vec2(0.75)) + aDrift*(borderSize+1.5);
+  gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);
+  vAlpha = min( abs(aDrift.x), abs(aDrift.y) )*(borderSize+1.5);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/border-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/border-visual-shader.frag
new file mode 100644 (file)
index 0000000..9718445
--- /dev/null
@@ -0,0 +1,8 @@
+uniform lowp vec4 uColor;
+uniform lowp vec4 borderColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/border-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/border-visual-shader.vert
new file mode 100644 (file)
index 0000000..6dc0721
--- /dev/null
@@ -0,0 +1,26 @@
+INPUT mediump vec2 aPosition;
+INPUT mediump vec2 aDrift;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump float borderSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec2 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy;
+}
+
+void main()
+{
+  vec2 position = ComputeVertexPosition() + aDrift*borderSize;
+  gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/bouncing-effect-mesh-shader.frag b/dali-toolkit/internal/graphics/shaders/bouncing-effect-mesh-shader.frag
new file mode 100644 (file)
index 0000000..b62f151
--- /dev/null
@@ -0,0 +1,7 @@
+// Use the actor color to paint every layer
+uniform lowp vec4 uColor;
+
+void main()
+{
+  gl_FragColor = uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/bouncing-effect-mesh-shader.vert b/dali-toolkit/internal/graphics/shaders/bouncing-effect-mesh-shader.vert
new file mode 100644 (file)
index 0000000..da69332
--- /dev/null
@@ -0,0 +1,11 @@
+// Modify the vertex position according to the bounce coefficient
+attribute mediump vec3    aPosition1;
+attribute mediump vec3    aPosition2;
+uniform   mediump mat4    uMvpMatrix;
+uniform   mediump vec3    uSize;
+uniform   mediump float   uBounceCoefficient;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(mix( aPosition1, aPosition2, abs(uBounceCoefficient) )*uSize, 1.0);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/bubble-effect-color-adjuster.frag b/dali-toolkit/internal/graphics/shaders/bubble-effect-color-adjuster.frag
new file mode 100644 (file)
index 0000000..69ff187
--- /dev/null
@@ -0,0 +1,44 @@
+precision highp float;
+uniform vec3 uHSVDelta;
+uniform float uIgnoreAlpha;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+
+float rand(vec2 co)
+{
+  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
+}
+
+vec3 rgb2hsv(vec3 c)
+{
+  vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+  vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
+  vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
+
+  float d = q.x - min(q.w, q.y);
+  float e = 1.0e-10;
+  return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+
+vec3 hsv2rgb(vec3 c)
+{
+  vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+
+void main()
+{
+  vec4 color = texture2D(sTexture, vTexCoord);
+  vec3 hsvColor = rgb2hsv( color.rgb );
+  // modify the hsv Value
+  hsvColor += uHSVDelta * rand(vTexCoord);
+  // if the new vale exceeds one, then decrease it
+  hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);
+  // if the new vale drops below zero, then increase it
+  hsvColor -= min(hsvColor*2.0, 0.0);
+  color.rgb = hsv2rgb( hsvColor );
+  // uIgnoreAlpha decide the result alpha will be 1.0 or source's alpha
+  color.a += uIgnoreAlpha;
+  gl_FragColor = color;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/bubble-effect.frag b/dali-toolkit/internal/graphics/shaders/bubble-effect.frag
new file mode 100644 (file)
index 0000000..fa06063
--- /dev/null
@@ -0,0 +1,18 @@
+varying mediump vec2 vTexCoord;
+uniform lowp vec4 uColor;
+uniform sampler2D sBackground;
+uniform sampler2D sBubbleShape;
+varying mediump float vPercentage;
+varying mediump vec2 vEffectTexCoord;
+
+void main()
+{
+  // Get the emit pisition color, and Mix with the actor color
+  mediump vec4 fragColor = texture2D(sBackground, vEffectTexCoord)*uColor;
+
+  // Apply the shape defined by the texture contained sBubbleShape
+  // And make the opacity being 0.7, and animate from 0.7 to 0 during the last 1/3 of movement
+  fragColor.a*= texture2D(sBubbleShape, vTexCoord).a * ( 2.1 - max( vPercentage*2.1, 1.4 ) );
+
+  gl_FragColor = fragColor;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/bubble-effect.vert b/dali-toolkit/internal/graphics/shaders/bubble-effect.vert
new file mode 100644 (file)
index 0000000..538d282
--- /dev/null
@@ -0,0 +1,56 @@
+attribute mediump float aIndex;
+attribute mediump vec2  aPosition;
+attribute highp   vec2  aTexCoord;
+varying   mediump vec2  vTexCoord;
+uniform   mediump mat4  uMvpMatrix;
+// the gravity applied to the y direction
+uniform mediump float uGravity;
+// xy: the emit position of the bubble; zw: the destination of the bubble.
+// The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
+uniform vec4 uStartEndPosition[NUMBER_OF_BUBBLE];
+// The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
+uniform float uPercentage[NUMBER_OF_BUBBLE];
+uniform vec2 uInvertedMovementArea;
+// The bubble number is restricted by the available uniform num.
+// To increase the displayed bubble, every uStartEndPosition and uPercentage uniform is applied to a small bunch of bubbles (9 here)
+// The offset defines the random offset between bubbles within the bunch.
+uniform vec2 uOffset[9];
+// This uniform is used to change the bubble size during running time
+uniform float uDynamicScale;
+varying float vPercentage;
+varying vec2  vEffectTexCoord;
+
+void main()
+{
+  vec4 position = vec4( aPosition, 0.0, 1.0 );
+  // The Z coordinate is used to record the bubble index within current mesh actor
+  int index = int(aIndex);
+  //for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
+  int groupIdx = index / NUMBER_OF_BUBBLE;
+  // The bubbles within the same bunch applies the same uniforms uStartEndPosition[idx] & uPercentage[idx]
+  int idx = index - groupIdx*NUMBER_OF_BUBBLE;
+  float percentage = uPercentage[idx];
+  // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
+  if( percentage <= 0.0 || percentage >= 1.0 )
+  {
+    gl_Position = vec4(0.0);
+    return;
+  }
+  vec4 startAndEnd = uStartEndPosition[idx];
+  // The final position is added up different offset for bubbles
+  startAndEnd.zw += uOffset[groupIdx];
+
+  // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
+  // the new xy value containes both the new scale and new bubble position
+  position.xy *= uDynamicScale*min(percentage*5.0, 1.0);
+  position.xy += mix(startAndEnd.xy, startAndEnd.zw, percentage);
+  // The gravity is g*t*t on the y direction
+  position.y += uGravity * pow(percentage, 2.0);
+  gl_Position = uMvpMatrix * position;
+
+  // Add multiple bubble shapes in the effect
+  vTexCoord = aTexCoord;
+  vPercentage = percentage;
+  // Use the emit position color for the bubble
+  vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea + vec2(0.5);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/bubble-emitter.frag b/dali-toolkit/internal/graphics/shaders/bubble-emitter.frag
new file mode 100644 (file)
index 0000000..06690f8
--- /dev/null
@@ -0,0 +1,41 @@
+precision highp float;
+uniform vec3 uHSVDelta;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+
+float rand(vec2 co)
+{
+  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
+}
+
+vec3 rgb2hsv(vec3 c)
+{
+  vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+  vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
+  vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
+
+  float d = q.x - min(q.w, q.y);
+  float e = 1.0e-10;
+  return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+
+vec3 hsv2rgb(vec3 c)
+{
+  vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+
+void main()
+{
+  vec4 color = texture2D(sTexture, vTexCoord);
+  vec3 hsvColor = rgb2hsv( color.rgb );
+  // modify the hsv Value
+  hsvColor += uHSVDelta * rand(vTexCoord);
+  // if the new vale exceeds one, then decrease it
+  hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);
+  // if the new vale drops below zero, then increase it
+  hsvColor -= min(hsvColor*2.0, 0.0);
+  color = vec4( hsv2rgb( hsvColor ), 1.0 );
+  gl_FragColor = color;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/bubble-emitter.vert b/dali-toolkit/internal/graphics/shaders/bubble-emitter.vert
new file mode 100644 (file)
index 0000000..f7bd577
--- /dev/null
@@ -0,0 +1,11 @@
+attribute mediump vec2 aPosition;
+attribute mediump vec2 aTexCoord;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition*uSize.xy,0.0,1.0);
+  vTexCoord = aTexCoord;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-blur-edge-shader.frag b/dali-toolkit/internal/graphics/shaders/color-visual-blur-edge-shader.frag
new file mode 100644 (file)
index 0000000..f2025a7
--- /dev/null
@@ -0,0 +1,13 @@
+INPUT mediump vec2 vPosition;
+INPUT mediump vec2 vRectSize;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform mediump float blurRadius;
+
+void main()
+{
+  mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );
+  OUT_COLOR = vec4(mixColor, 1.0) * uColor;
+  OUT_COLOR.a *= blur.x * blur.y;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-blur-edge-shader.vert b/dali-toolkit/internal/graphics/shaders/color-visual-blur-edge-shader.vert
new file mode 100644 (file)
index 0000000..65849eb
--- /dev/null
@@ -0,0 +1,29 @@
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vPosition;
+OUTPUT mediump vec2 vRectSize;
+
+uniform highp   mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec2 extraSize;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float blurRadius;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize + blurRadius * 2.0;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  vRectSize = visualSize / 2.0;
+  vPosition = aPosition* visualSize;
+  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.frag
new file mode 100644 (file)
index 0000000..4654ab4
--- /dev/null
@@ -0,0 +1,25 @@
+INPUT mediump vec2 vPosition;
+INPUT mediump vec2 vRectSize;
+INPUT mediump float vCornerRadius;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  OUT_COLOR = vec4(mixColor, 1.0) * uColor;
+  mediump vec2 diff = abs( vPosition ) - vRectSize;
+  mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+  if( dist > 1.0 )
+  {
+    OUT_COLOR.a = 0.0;
+  }
+  else if( dist > -1.0 )
+  {
+    if( min( diff.x, diff.y ) < 0.0)
+    {
+      dist += min( diff.x, diff.y ) / vCornerRadius;
+    }
+    OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist );
+  }
+}
diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/color-visual-rounded-corner-shader.vert
new file mode 100644 (file)
index 0000000..33216e5
--- /dev/null
@@ -0,0 +1,35 @@
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vPosition;
+OUTPUT mediump vec2 vRectSize;
+OUTPUT mediump float vCornerRadius;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec2 extraSize;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  mediump float minSize = min( visualSize.x, visualSize.y );
+  vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+  vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+  vRectSize = visualSize / 2.0 - vCornerRadius;
+  vCornerRadius = max( vCornerRadius, 1.0 );
+  vPosition = aPosition* visualSize;
+  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/color-visual-shader.frag
new file mode 100644 (file)
index 0000000..fef045b
--- /dev/null
@@ -0,0 +1,7 @@
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  OUT_COLOR = vec4(mixColor, 1.0) * uColor;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/color-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/color-visual-shader.vert
new file mode 100644 (file)
index 0000000..993d9d4
--- /dev/null
@@ -0,0 +1,24 @@
+INPUT mediump vec2 aPosition;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/control-renderers.frag b/dali-toolkit/internal/graphics/shaders/control-renderers.frag
new file mode 100644 (file)
index 0000000..e29e6a1
--- /dev/null
@@ -0,0 +1,10 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform vec4 uColor;
+
+void main()
+{
+  gl_FragColor = texture2D(sTexture, vTexCoord);
+  gl_FragColor *= uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/control-renderers.vert b/dali-toolkit/internal/graphics/shaders/control-renderers.vert
new file mode 100644 (file)
index 0000000..e7e930f
--- /dev/null
@@ -0,0 +1,12 @@
+precision mediump float;
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition * uSize.xy, 0.0, 1.0);
+  vTexCoord = aPosition + vec2(0.5);
+  gl_Position = uMvpMatrix * vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/cube-transition-effect.frag b/dali-toolkit/internal/graphics/shaders/cube-transition-effect.frag
new file mode 100644 (file)
index 0000000..b8b19ac
--- /dev/null
@@ -0,0 +1,9 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec4 uSamplerRect;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/cube-transition-effect.vert b/dali-toolkit/internal/graphics/shaders/cube-transition-effect.vert
new file mode 100644 (file)
index 0000000..fccd035
--- /dev/null
@@ -0,0 +1,17 @@
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+uniform mediump vec4 uTextureRect;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  vTexCoord = aPosition + vec2(0.5);
+  vTexCoord = mix(uTextureRect.xy, uTextureRect.zw, vTexCoord);
+
+  gl_Position = vertexPosition;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/dissolve-effect.frag b/dali-toolkit/internal/graphics/shaders/dissolve-effect.frag
new file mode 100644 (file)
index 0000000..e28a074
--- /dev/null
@@ -0,0 +1,21 @@
+varying float        vPercentage;
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform vec4 uTextureRect;
+
+float rand(vec2 co)
+{
+  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
+}
+
+void main()
+{
+  //Calculate the randomness
+  float  offsetS = rand(vTexCoord * vPercentage) - vTexCoord.s;
+  float offsetT = rand(vec2(vTexCoord.t * vPercentage, vTexCoord.s * vPercentage)) - vTexCoord.t;
+  vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage;
+  gl_FragColor = texture2D(sTexture, lookupCoord) * uColor;
+  gl_FragColor.a *= 1.0 - vPercentage;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/dissolve-effect.vert b/dali-toolkit/internal/graphics/shaders/dissolve-effect.vert
new file mode 100644 (file)
index 0000000..be8c3df
--- /dev/null
@@ -0,0 +1,34 @@
+attribute mediump vec2 aPosition;
+
+uniform mediump mat4   uMvpMatrix;
+uniform vec3           uSize;
+uniform vec4           uTextureRect;
+
+uniform float          uPercentage;
+uniform vec3           uSaddleParam;
+uniform vec2           uTranslation;
+uniform vec2           uRotation;
+uniform float          uToNext;
+
+varying float          vPercentage;
+varying vec2           vTexCoord;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  vertexPosition = uMvpMatrix * vertexPosition;
+  gl_Position = vertexPosition;
+
+  vec2 texCoord = aPosition + vec2(0.5);
+  vTexCoord = texCoord;
+
+  //Calculate the distortion value given the dissolve central line
+  vec2 value = texCoord + uTranslation;
+  mat2 rotateMatrix = mat2(uRotation.s, uRotation.t, -uRotation.t, uRotation.s);
+  value = rotateMatrix * value;
+  if(uToNext == 1.0)
+    value.s = uSaddleParam[2] + value.s;
+  float delay = value.t * value.t / uSaddleParam[0] - value.s * value.s / uSaddleParam[1];
+  vPercentage = clamp(uPercentage * 2.0 - 0.5 * sin(delay * 1.571) - 0.5, 0.0, 1.0);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/distance-field-effect.frag b/dali-toolkit/internal/graphics/shaders/distance-field-effect.frag
new file mode 100644 (file)
index 0000000..82c294d
--- /dev/null
@@ -0,0 +1,97 @@
+varying mediump vec2 vTexCoord;
+
+uniform mediump float uGlowBoundary;
+uniform mediump vec2  uOutlineParams;
+uniform lowp    vec4  uOutlineColor;
+uniform lowp    vec4  uShadowColor;
+uniform mediump vec2  uShadowOffset;
+uniform lowp    vec4  uGlowColor;
+uniform lowp    float uDoOutline;
+uniform lowp    float uDoShadow;
+uniform lowp    float uDoGlow;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+  // sample distance field
+  mediump float smoothing = 0.5;
+
+  mediump float distance = texture2D(sTexture, vTexCoord).a;
+  mediump float smoothWidth = fwidth(distance);
+  mediump float alphaFactor = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);
+  lowp    vec4  color;
+
+  if (uDoShadow == 0.0)
+  {
+    mediump float alpha = uColor.a * alphaFactor;
+    lowp    vec4  rgb = uColor;
+
+    if (uDoOutline > 0.0)
+    {
+      mediump float outlineWidth = uOutlineParams[1] + smoothWidth;
+      mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);
+      alpha = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);
+      rgb = mix(uOutlineColor, uColor, outlineBlend);
+    }
+
+    if (uDoGlow > 0.0)
+    {
+      rgb = mix(uGlowColor, rgb, alphaFactor);
+      alpha = smoothstep(uGlowBoundary, smoothing, distance);
+    }
+
+    // set fragment color
+    color = vec4(rgb.rgb, alpha);
+  }
+
+  else // (uDoShadow > 0.0)
+  {
+    mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;
+    mediump float inText = alphaFactor;
+    mediump float inShadow = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, shadowDistance);
+
+    // inside object, outside shadow
+    if (inText == 1.0)
+    {
+      color = uColor;
+    }
+    // inside object, outside shadow
+    else if ((inText != 0.0) && (inShadow == 0.0))
+    {
+      color = uColor;
+      color.a *= inText;
+    }
+    // outside object, completely inside shadow
+    else if ((inText == 0.0) && (inShadow == 1.0))
+    {
+      color = uShadowColor;
+    }
+    // inside object, completely inside shadow
+    else if ((inText != 0.0) && (inShadow == 1.0))
+    {
+      color = mix(uShadowColor, uColor, inText);
+      color.a = uShadowColor.a;
+    }
+    // inside object, inside shadow's border
+    else if ((inText != 0.0) && (inShadow != 0.0))
+    {
+      color = mix(uShadowColor, uColor, inText);
+      color.a *= max(inText, inShadow);
+    }
+    // inside shadow's border
+    else if (inShadow != 0.0)
+    {
+      color = uShadowColor;
+      color.a *= inShadow;
+    }
+    // outside shadow and object
+    else
+    {
+      color.a = 0.0;
+    }
+  }
+
+  gl_FragColor = color;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/effects-view.frag b/dali-toolkit/internal/graphics/shaders/effects-view.frag
new file mode 100644 (file)
index 0000000..9c66b3b
--- /dev/null
@@ -0,0 +1,9 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 effectColor;
+
+void main()
+{
+  gl_FragColor = effectColor;
+  gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/effects-view.vert b/dali-toolkit/internal/graphics/shaders/effects-view.vert
new file mode 100644 (file)
index 0000000..e8b7984
--- /dev/null
@@ -0,0 +1,16 @@
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+uniform mediump vec3 effectOffset;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  vertexPosition.xyz += effectOffset;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  vTexCoord = aPosition + vec2(0.5);
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/emboss-filter-composite-shader.frag b/dali-toolkit/internal/graphics/shaders/emboss-filter-composite-shader.frag
new file mode 100644 (file)
index 0000000..1ef9fc1
--- /dev/null
@@ -0,0 +1,9 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uEffectColor;
+
+void main()
+{
+  gl_FragColor = uEffectColor;
+  gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/emboss-filter-shader.frag b/dali-toolkit/internal/graphics/shaders/emboss-filter-shader.frag
new file mode 100644 (file)
index 0000000..2a6761a
--- /dev/null
@@ -0,0 +1,13 @@
+precision highp float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform vec2 uTexScale;
+uniform vec3 uCoefficient;
+
+void main()
+{
+  vec4 color  = uCoefficient.x * texture2D( sTexture, vTexCoord + vec2(0.0, -uTexScale.y) );
+  color += uCoefficient.y * texture2D( sTexture, vTexCoord );
+  color += uCoefficient.z * texture2D( sTexture, vTexCoord + vec2(0.0, uTexScale.y) );
+  gl_FragColor = color;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/gaussian-blur-view.frag b/dali-toolkit/internal/graphics/shaders/gaussian-blur-view.frag
new file mode 100644 (file)
index 0000000..6613b0f
--- /dev/null
@@ -0,0 +1,15 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform mediump vec2 uSampleOffsets[NUM_SAMPLES];
+uniform mediump float uSampleWeights[NUM_SAMPLES];
+
+void main()
+{
+  mediump vec4 col = texture2D(sTexture, vTexCoord + uSampleOffsets[0]) * uSampleWeights[0];
+  for (int i=1; i<NUM_SAMPLES; ++i)
+  {
+    col += texture2D(sTexture, vTexCoord + uSampleOffsets[i]) * uSampleWeights[i];
+  }
+  gl_FragColor = col;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-basecolor-texture.def b/dali-toolkit/internal/graphics/shaders/gltf-basecolor-texture.def
new file mode 100644 (file)
index 0000000..b5d47f8
--- /dev/null
@@ -0,0 +1,4 @@
+#define TEXTURE_BASECOLOR
+
+uniform sampler2D uBaseColorSampler;
+uniform int uBaseColorTexCoordIndex;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-emit-texture.def b/dali-toolkit/internal/graphics/shaders/gltf-emit-texture.def
new file mode 100644 (file)
index 0000000..8cfce19
--- /dev/null
@@ -0,0 +1,5 @@
+#define TEXTURE_EMIT
+
+uniform sampler2D uEmissiveSampler;
+uniform int uEmissiveTexCoordIndex;
+uniform vec3 uEmissiveFactor;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-gles-version-300.def b/dali-toolkit/internal/graphics/shaders/gltf-gles-version-300.def
new file mode 100644 (file)
index 0000000..c6e148b
--- /dev/null
@@ -0,0 +1,2 @@
+#version 300 es
+precision highp float;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-ibl-texture.def b/dali-toolkit/internal/graphics/shaders/gltf-ibl-texture.def
new file mode 100644 (file)
index 0000000..c6a6302
--- /dev/null
@@ -0,0 +1,7 @@
+#define TEXTURE_IBL
+
+uniform sampler2D ubrdfLUT;
+uniform samplerCube uDiffuseEnvSampler;
+uniform samplerCube uSpecularEnvSampler;
+uniform vec4 uScaleIBLAmbient;
+uniform highp float uMipmapLevel;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-metallicroughness-texture.def b/dali-toolkit/internal/graphics/shaders/gltf-metallicroughness-texture.def
new file mode 100644 (file)
index 0000000..7c065db
--- /dev/null
@@ -0,0 +1,4 @@
+#define TEXTURE_METALLICROUGHNESS
+
+uniform sampler2D uMetallicRoughnessSampler;
+uniform int uMetallicRoughnessTexCoordIndex;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-normal-texture.def b/dali-toolkit/internal/graphics/shaders/gltf-normal-texture.def
new file mode 100644 (file)
index 0000000..16c851a
--- /dev/null
@@ -0,0 +1,5 @@
+#define TEXTURE_NORMAL
+
+uniform sampler2D uNormalSampler;
+uniform float uNormalScale;
+uniform int uNormalTexCoordIndex;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-occulusion-texture.def b/dali-toolkit/internal/graphics/shaders/gltf-occulusion-texture.def
new file mode 100644 (file)
index 0000000..2003d47
--- /dev/null
@@ -0,0 +1,5 @@
+#define TEXTURE_OCCLUSION
+
+uniform sampler2D uOcclusionSampler;
+uniform int uOcclusionTexCoordIndex;
+uniform float uOcclusionStrength;
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.frag b/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.frag
new file mode 100644 (file)
index 0000000..cefd19e
--- /dev/null
@@ -0,0 +1,189 @@
+uniform lowp vec3 uLightColor;
+uniform lowp vec4 uBaseColorFactor;
+uniform lowp vec2 uMetallicRoughnessFactors;
+uniform lowp int alphaMode;
+uniform lowp float alphaCutoff;
+
+in lowp vec2 vUV[2];
+in lowp mat3 vTBN;
+in lowp vec4 vColor;
+flat in int visLight;
+in highp vec3 vLightDirection;
+in highp vec3 vPositionToCamera;
+
+out vec4 FragColor;
+
+struct PBRInfo
+{
+  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 getNormal()
+{
+#ifdef TEXTURE_NORMAL
+  lowp vec3 n = texture( uNormalSampler, vUV[uNormalTexCoordIndex] ).rgb;
+  n = normalize( vTBN * ( ( 2.0 * n - 1.0 ) * vec3( uNormalScale, uNormalScale, 1.0 ) ) );
+#else
+  lowp vec3 n = normalize( vTBN[2].xyz );
+#endif
+  return n;
+}
+
+vec3 specularReflection( PBRInfo pbrInputs )
+{
+  return pbrInputs.reflectance0 + ( pbrInputs.reflectance90 - pbrInputs.reflectance0 ) * pow( clamp( 1.0 - pbrInputs.VdotH, 0.0, 1.0 ), 5.0 );
+}
+
+float geometricOcclusion( PBRInfo pbrInputs )
+{
+  mediump float NdotL = pbrInputs.NdotL;
+  mediump float NdotV = pbrInputs.NdotV;
+  lowp float r = pbrInputs.alphaRoughness;
+
+  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;
+}
+
+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);
+}
+
+vec3 linear( vec3 color )
+{
+  return pow(color,vec3(2.2));
+}
+
+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
+  lowp float metallic = uMetallicRoughnessFactors.x;
+  lowp float perceptualRoughness = uMetallicRoughnessFactors.y;
+
+  // 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
+#ifdef TEXTURE_METALLICROUGHNESS
+  lowp vec4 metrou = texture(uMetallicRoughnessSampler, vUV[uMetallicRoughnessTexCoordIndex]);
+  metallic = metrou.b * metallic;
+  perceptualRoughness = metrou.g * perceptualRoughness;
+#endif
+
+  metallic = clamp(metallic, 0.0, 1.0);
+  perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
+  // Roughness is authored as perceptual roughness; as is convention,
+  // convert to material roughness by squaring the perceptual roughness [2].
+  lowp float alphaRoughness = perceptualRoughness * perceptualRoughness;
+
+#ifdef TEXTURE_BASECOLOR
+  // The albedo may be defined from a base texture or a flat color
+  lowp vec4 baseColor = texture(uBaseColorSampler, vUV[uBaseColorTexCoordIndex]) * uBaseColorFactor;
+  baseColor = vec4(linear(baseColor.rgb), baseColor.w);
+#else
+  lowp vec4 baseColor = vColor * uBaseColorFactor;
+#endif
+
+  if( alphaMode == 0 )
+  {
+    baseColor.w = 1.0;
+  }
+  else if( alphaMode == 1 )
+  {
+    if( baseColor.w >= alphaCutoff )
+    {
+      baseColor.w = 1.0;
+    }
+    else
+    {
+      baseColor.w = 0.0;
+    }
+  }
+
+  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 n = getNormal();                            // normal at surface point
+  mediump vec3 v = normalize(vPositionToCamera);           // Vector from surface point to camera
+  mediump vec3 l = normalize(vLightDirection);             // Vector from light to surface point
+  mediump vec3 h = normalize(l+v);                         // Half vector between both l and v
+  mediump vec3 reflection = -normalize(reflect(v, n));
+
+  mediump float NdotL = clamp(dot(n, l), 0.001, 1.0);
+  mediump float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
+  mediump float NdotH = dot(n, h);
+  mediump float LdotH = dot(l, h);
+  mediump float VdotH = dot(v, h);
+
+  PBRInfo pbrInputs = PBRInfo(
+    NdotL,
+    NdotV,
+    NdotH,
+    VdotH,
+    specularEnvironmentR0,
+    specularEnvironmentR90,
+    alphaRoughness
+  );
+
+  // Calculate the shading terms for the microfacet specular shading model
+  lowp vec3 color = vec3(0.0);
+  if( visLight == 1 )
+  {
+    lowp vec3 F = specularReflection( pbrInputs );
+    lowp float G = geometricOcclusion( pbrInputs );
+    lowp float D = microfacetDistribution( pbrInputs );
+
+  // Calculation of analytical lighting contribution
+    lowp vec3 diffuseContrib = ( 1.0 - F ) * ( diffuseColor / M_PI );
+    lowp vec3 specContrib = F * G * D / ( 4.0 * NdotL * NdotV );
+  // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
+    color = NdotL * uLightColor * (diffuseContrib + specContrib);
+  }
+
+#ifdef TEXTURE_IBL
+  lowp float lod = ( perceptualRoughness * uMipmapLevel );
+  // retrieve a scale and bias to F0. See [1], Figure 3
+  lowp vec3 brdf = linear( texture( ubrdfLUT, vec2( NdotV, 1.0 - perceptualRoughness ) ).rgb );
+  lowp vec3 diffuseLight = linear( texture( uDiffuseEnvSampler, n ).rgb );
+  lowp vec3 specularLight = linear( textureLod( uSpecularEnvSampler, reflection, lod ).rgb );
+
+  lowp vec3 diffuse = diffuseLight * diffuseColor * uScaleIBLAmbient.x;
+  lowp vec3 specular = specularLight * ( specularColor * brdf.x + brdf.y ) * uScaleIBLAmbient.y;
+  color += ( diffuse + specular );
+#endif
+
+#ifdef TEXTURE_OCCLUSION
+  lowp float ao = texture( uOcclusionSampler, vUV[uOcclusionTexCoordIndex] ).r;
+  color = mix( color, color * ao, uOcclusionStrength );
+#endif
+
+#ifdef TEXTURE_EMIT
+  lowp vec3 emissive = linear( texture( uEmissiveSampler, vUV[uEmissiveTexCoordIndex] ).rgb ) * uEmissiveFactor;
+  color += emissive;
+#endif
+
+  FragColor = vec4( pow( color,vec3( 1.0 / 2.2 ) ), baseColor.a );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert b/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert
new file mode 100644 (file)
index 0000000..6628865
--- /dev/null
@@ -0,0 +1,60 @@
+in highp vec3 aPosition;
+in mediump vec2 aTexCoord0;
+in mediump vec2 aTexCoord1;
+in lowp vec3 aNormal;
+in lowp vec4 aTangent;
+in lowp vec4 aVertexColor;
+
+uniform mediump vec3 uSize;
+uniform mediump mat4 uModelMatrix;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat4 uProjection;
+uniform lowp int uLightType;
+uniform mediump vec3 uLightVector;
+uniform lowp int uIsColor;
+
+out lowp vec2 vUV[2];
+out lowp mat3 vTBN;
+out lowp vec4 vColor;
+flat out int visLight;
+out highp vec3 vLightDirection;
+out highp vec3 vPositionToCamera;
+
+void main()
+{
+  highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);
+  highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 );
+  highp vec4 positionV = uViewMatrix * ( invY * positionW );
+
+  vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) );
+  vPositionToCamera *= invY.xyz;
+
+  lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;
+  vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal);
+
+  vUV[0] = aTexCoord0;
+  vUV[1] = aTexCoord1;
+
+  visLight = 1;
+  if( uLightType == 1 )
+  {
+    vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w );
+  }
+  else if( uLightType == 2 )
+  {
+    vLightDirection = -( invY.xyz * uLightVector );
+  }
+  else
+  {
+    visLight = 0;
+  }
+
+  vColor = vec4( 1.0 );
+  if( uIsColor == 1 )
+  {
+    vColor = aVertexColor;
+  }
+
+  gl_Position = uProjection * positionV; // needs w for proper perspective correction
+  gl_Position = gl_Position/gl_Position.w;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-rounded-corner-shader.vert
new file mode 100644 (file)
index 0000000..144fa81
--- /dev/null
@@ -0,0 +1,38 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  mediump float minSize = min( visualSize.x, visualSize.y );
+  vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+  vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+  vRectSize = visualSize * 0.5 - vCornerRadius;
+  vCornerRadius = max( vCornerRadius, 1.0 );
+  vPosition = aPosition * visualSize;
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-shader.vert b/dali-toolkit/internal/graphics/shaders/gradient-visual-bounding-box-shader.vert
new file mode 100644 (file)
index 0000000..018e260
--- /dev/null
@@ -0,0 +1,27 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-rounded-corner-shader.frag
new file mode 100644 (file)
index 0000000..548367c
--- /dev/null
@@ -0,0 +1,26 @@
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+  mediump vec2 diff = abs( vPosition ) - vRectSize;
+  mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+  if( dist > 1.0 )
+  {
+    gl_FragColor = vec4( 0.0 );
+  }
+  else if( dist > -1.0 )
+  {
+    if( min( diff.x, diff.y ) < 0.0 )
+    {
+      dist += min( diff.x, diff.y ) / vCornerRadius;
+    }
+    gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );
+  }
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-linear-shader.frag
new file mode 100644 (file)
index 0000000..1ec04b2
--- /dev/null
@@ -0,0 +1,9 @@
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-rounded-corner-shader.frag
new file mode 100644 (file)
index 0000000..10bf0fe
--- /dev/null
@@ -0,0 +1,26 @@
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+  mediump vec2 diff = abs( vPosition ) - vRectSize;
+  mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+  if( dist > 1.0 )
+  {
+    gl_FragColor = vec4( 0.0 );
+  }
+  else if( dist > -1.0 )
+  {
+    if( min( diff.x, diff.y ) < 0.0)
+    {
+      dist += min( diff.x, diff.y ) / vCornerRadius;
+    }
+    gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );
+  }
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-radial-shader.frag
new file mode 100644 (file)
index 0000000..8d37383
--- /dev/null
@@ -0,0 +1,9 @@
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-rounded-corner-shader.vert
new file mode 100644 (file)
index 0000000..f383185
--- /dev/null
@@ -0,0 +1,39 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  mediump float minSize = min( visualSize.x, visualSize.y );
+  vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+  vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+  vRectSize = visualSize * 0.5 - vCornerRadius;
+  vCornerRadius = max( vCornerRadius, 1.0 );
+  vPosition = aPosition * visualSize;
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+  vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-shader.vert b/dali-toolkit/internal/graphics/shaders/gradient-visual-user-space-shader.vert
new file mode 100644 (file)
index 0000000..ca1eab6
--- /dev/null
@@ -0,0 +1,28 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+  vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/image-region-effect.vert b/dali-toolkit/internal/graphics/shaders/image-region-effect.vert
new file mode 100644 (file)
index 0000000..5997336
--- /dev/null
@@ -0,0 +1,28 @@
+attribute mediump vec2 aPosition;
+
+uniform mediump mat4 uMvpMatrix;
+uniform vec3 uSize;
+uniform vec4 uTextureRect;
+
+varying vec2 vTexCoord;
+
+uniform mediump vec2 uTopLeft;
+uniform mediump vec2 uBottomRight;
+
+void main()
+{
+  mediump vec4 position = vec4(aPosition, 0.0, 1.0);
+  position.xyz *= uSize;
+  gl_Position = uMvpMatrix * position;
+
+    // The line below is doing the same as the following commented lines:
+    //
+    // vec2 imageSize = uTextureRect.zw - uTextureRect.xy;
+    // vec2 topLeft = uTextureRect.xy + uTopLeft * imageSize;
+    // vec2 bottomRight = uTextureRect.xy + uBottomRight * imageSize;
+    // vec2 texCoord = (aTexCoord - uTextureRect.xy) / imageSize;
+    // vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );
+
+  vec2 texCoord = aPosition + vec2(0.5);
+  vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-atlas-clamp-shader.frag b/dali-toolkit/internal/graphics/shaders/image-visual-atlas-clamp-shader.frag
new file mode 100644 (file)
index 0000000..0d87f9d
--- /dev/null
@@ -0,0 +1,13 @@
+INPUT mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform mediump vec4 uAtlasRect;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );
+  OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-atlas-various-wrap-shader.frag b/dali-toolkit/internal/graphics/shaders/image-visual-atlas-various-wrap-shader.frag
new file mode 100644 (file)
index 0000000..eeb8a0c
--- /dev/null
@@ -0,0 +1,28 @@
+INPUT mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform mediump vec4 uAtlasRect;
+
+// WrapMode -- 0: CLAMP; 1: REPEAT; 2: REFLECT;
+uniform lowp vec2 wrapMode;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )
+
+{
+  mediump float coord;
+  if( wrap > 1.5 )\n // REFLECT
+    coord = 1.0-abs(fract(coordinate*0.5)*2.0 - 1.0);
+  else \n// warp == 0 or 1
+    coord = mix(coordinate, fract( coordinate ), wrap);
+  return clamp( mix(range.x, range.y, coord), range.x, range.y );
+}
+
+void main()
+{
+  mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),
+                                wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );
+  OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-no-atlas-shader.frag b/dali-toolkit/internal/graphics/shaders/image-visual-no-atlas-shader.frag
new file mode 100644 (file)
index 0000000..ffc960c
--- /dev/null
@@ -0,0 +1,11 @@
+INPUT mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag b/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.frag
new file mode 100644 (file)
index 0000000..0e2c1d8
--- /dev/null
@@ -0,0 +1,32 @@
+INPUT mediump vec2 vTexCoord;
+INPUT mediump vec2 vPosition;
+INPUT mediump vec2 vRectSize;
+INPUT mediump float vCornerRadius;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  mediump vec2 diff = abs( vPosition ) - vRectSize;
+  mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+  mediump float opacity = 1.0;
+  if( dist > 1.0 )
+  {
+    opacity = 0.0;
+  }
+  else if( dist > -1.0 )
+  {
+    if( min( diff.x, diff.y ) < 0.0 )
+    {
+      dist += min( diff.x, diff.y ) / vCornerRadius;
+    }
+    opacity = 1.0 - smoothstep( -1.0, 1.0, dist );
+  }
+
+  OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+  OUT_COLOR.a *= opacity;
+  OUT_COLOR.rgb *= mix( 1.0, opacity, preMultipliedAlpha );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert b/dali-toolkit/internal/graphics/shaders/image-visual-rounded-corner-shader.vert
new file mode 100644 (file)
index 0000000..0bd3530
--- /dev/null
@@ -0,0 +1,38 @@
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vTexCoord;
+OUTPUT mediump vec2 vPosition;
+OUTPUT mediump vec2 vRectSize;
+OUTPUT mediump float vCornerRadius;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec4 pixelArea;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+uniform mediump vec2 extraSize;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  mediump float minSize = min( visualSize.x, visualSize.y );
+  vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+  vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+  vRectSize = visualSize * 0.5 - vCornerRadius;
+  vCornerRadius = max( vCornerRadius, 1.0 );
+  vPosition = aPosition* visualSize;
+  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+  vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/image-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/image-visual-shader.vert
new file mode 100644 (file)
index 0000000..fe0c35c
--- /dev/null
@@ -0,0 +1,27 @@
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vTexCoord;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec4 pixelArea;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+  vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/mesh-visual-normal-map-shader.frag b/dali-toolkit/internal/graphics/shaders/mesh-visual-normal-map-shader.frag
new file mode 100644 (file)
index 0000000..8c355ec
--- /dev/null
@@ -0,0 +1,25 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform sampler2D sDiffuse;
+uniform sampler2D sNormal;
+uniform sampler2D sGloss;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  vec4 texture = texture2D( sDiffuse, vTexCoord );
+  vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );
+  vec4 glossMap = texture2D( sGloss, vTexCoord );
+  vec4 visualMixColor = vec4( mixColor, 1.0 );
+
+  float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );
+  lightDiffuse = lightDiffuse * 0.5 + 0.5;
+
+  float shininess = pow ( max ( dot ( normalize( vHalfVector ), normal ), 0.0 ), 16.0 );
+
+  gl_FragColor = vec4( texture.rgb * uColor.rgb * visualMixColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a * visualMixColor.a );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/mesh-visual-normal-map-shader.vert b/dali-toolkit/internal/graphics/shaders/mesh-visual-normal-map-shader.vert
new file mode 100644 (file)
index 0000000..c25a1bb
--- /dev/null
@@ -0,0 +1,62 @@
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+attribute highp vec3 aTangent;
+attribute highp vec3 aBiNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  float scaleFactor = min( visualSize.x, visualSize.y );
+  vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+  vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+  vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+  return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+  vec4 normalisedVertexPosition = ComputeVertexPosition();
+  vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+
+  vec3 tangent = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aTangent );
+  vec3 binormal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aBiNormal );
+  vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
+
+  vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+  mvLightPosition = uViewMatrix * mvLightPosition;
+  vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+  vLightDirection.x = dot( vectorToLight, tangent );
+  vLightDirection.y = dot( vectorToLight, binormal );
+  vLightDirection.z = dot( vectorToLight, normal );
+
+  vec3 viewDirection = normalize( -mvVertexPosition.xyz );
+  vec3 halfVector = normalize( viewDirection + vectorToLight );
+  vHalfVector.x = dot( halfVector, tangent );
+  vHalfVector.y = dot( halfVector, binormal );
+  vHalfVector.z = dot( halfVector, normal );
+
+  vTexCoord = aTexCoord;
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/mesh-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/mesh-visual-shader.frag
new file mode 100644 (file)
index 0000000..77f8649
--- /dev/null
@@ -0,0 +1,15 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform sampler2D sDiffuse;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  vec4 texture = texture2D( sDiffuse, vTexCoord );
+  vec4 visualMixColor = vec4( mixColor, 1.0 );
+  gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb * visualMixColor.rgb + vSpecular * 0.3, texture.a * uColor.a * visualMixColor.a );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/mesh-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/mesh-visual-shader.vert
new file mode 100644 (file)
index 0000000..05b90ce
--- /dev/null
@@ -0,0 +1,58 @@
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  float scaleFactor = min( visualSize.x, visualSize.y );
+  vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+  vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+  vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+  return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+  vec4 normalisedVertexPosition = ComputeVertexPosition();
+  vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  //Illumination in Model-View space - Transform attributes and uniforms
+  vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+  vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
+
+  vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+  mvLightPosition = uViewMatrix * mvLightPosition;
+  vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+
+  vec3 viewDirection = normalize( -mvVertexPosition.xyz );
+
+  float lightDiffuse = dot( vectorToLight, normal );
+  lightDiffuse = max( 0.0,lightDiffuse );
+  vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
+
+  vec3 reflectDirection = reflect( -vectorToLight, normal );
+  vSpecular = pow( max( dot( reflectDirection, viewDirection ), 0.0 ), 4.0 );
+
+  vTexCoord = aTexCoord;
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/mesh-visual-simple-shader.frag b/dali-toolkit/internal/graphics/shaders/mesh-visual-simple-shader.frag
new file mode 100644 (file)
index 0000000..52b1e47
--- /dev/null
@@ -0,0 +1,10 @@
+precision mediump float;
+varying mediump vec3 vIllumination;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a ) * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/mesh-visual-simple-shader.vert b/dali-toolkit/internal/graphics/shaders/mesh-visual-simple-shader.vert
new file mode 100644 (file)
index 0000000..2a4b704
--- /dev/null
@@ -0,0 +1,48 @@
+attribute highp vec3 aPosition;
+attribute highp vec3 aNormal;
+varying mediump vec3 vIllumination;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  float scaleFactor = min( visualSize.x, visualSize.y );
+  vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+  vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+  vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+  return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+  vec4 normalisedVertexPosition = ComputeVertexPosition();
+  vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  //Illumination in Model-View space - Transform attributes and uniforms
+  vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+  vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;
+
+  vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+  mvLightPosition = uViewMatrix * mvLightPosition;
+  vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+
+  float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );
+  vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
+
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/model3d-view-nrmmap-shader.frag b/dali-toolkit/internal/graphics/shaders/model3d-view-nrmmap-shader.frag
new file mode 100644 (file)
index 0000000..b2db8e9
--- /dev/null
@@ -0,0 +1,22 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform sampler2D sDiffuse;
+uniform sampler2D sNormal;
+uniform sampler2D sGloss;
+uniform lowp vec4 uColor;
+
+void main()
+{
+  vec4 texture = texture2D( sDiffuse, vTexCoord );
+  vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );
+  vec4 glossMap = texture2D( sGloss, vTexCoord );
+
+  float lightDiffuse = max( 0.0, dot( normal, normalize(vLightDirection) ) );
+  lightDiffuse = lightDiffuse * 0.5 + 0.5;
+
+  float shininess = pow (max (dot (normalize( vHalfVector ), normal), 0.0), 16.0);
+
+  gl_FragColor = vec4( texture.rgb * uColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/model3d-view-nrmmap-shader.vert b/dali-toolkit/internal/graphics/shaders/model3d-view-nrmmap-shader.vert
new file mode 100644 (file)
index 0000000..3e00350
--- /dev/null
@@ -0,0 +1,42 @@
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+attribute highp vec3 aTangent;
+attribute highp vec3 aBiNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 uLightPosition;
+
+void main()
+{
+  vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);
+  vertexPosition = uObjectMatrix * vertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);
+  vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);
+
+  vec3 tangent = normalize(uNormalMatrix * aTangent);
+  vec3 binormal = normalize(uNormalMatrix * aBiNormal);
+  vec3 normal = normalize(uNormalMatrix * aNormal);
+
+  vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );
+  vLightDirection.x = dot(vecToLight, tangent);
+  vLightDirection.y = dot(vecToLight, binormal);
+  vLightDirection.z = dot(vecToLight, normal);
+
+  vec3 viewDir = normalize(-vertPos.xyz);
+  vec3 halfVector = normalize(viewDir + vecToLight);
+  vHalfVector.x = dot(halfVector, tangent);
+  vHalfVector.y = dot(halfVector, binormal);
+  vHalfVector.z = dot(halfVector, normal);
+
+  vTexCoord = aTexCoord;
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/model3d-view-shader.frag b/dali-toolkit/internal/graphics/shaders/model3d-view-shader.frag
new file mode 100644 (file)
index 0000000..0c48098
--- /dev/null
@@ -0,0 +1,12 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform sampler2D sDiffuse;
+uniform lowp vec4 uColor;
+
+void main()
+{
+  vec4 texture = texture2D( sDiffuse, vTexCoord );
+  gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb + vSpecular * 0.3, texture.a * uColor.a);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/model3d-view-shader.vert b/dali-toolkit/internal/graphics/shaders/model3d-view-shader.vert
new file mode 100644 (file)
index 0000000..7987a18
--- /dev/null
@@ -0,0 +1,39 @@
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 uLightPosition;
+
+void main()
+{
+  vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);
+  vertexPosition = uObjectMatrix * vertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  //Illumination in Model-View space - Transform attributes and uniforms
+  vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);
+  vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);
+  vec3 normal = normalize(uNormalMatrix * aNormal);
+
+  vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );
+  vec3 viewDir = normalize(-vertPos.xyz);
+
+  vec3 halfVector = normalize(viewDir + vecToLight);
+
+  float lightDiffuse = dot( vecToLight, normal );
+  lightDiffuse = max(0.0,lightDiffuse);
+  vIllumination = vec3(lightDiffuse * 0.5 + 0.5);
+
+  vec3 reflectDir = reflect(-vecToLight, normal);
+  vSpecular = pow( max(dot(reflectDir, viewDir), 0.0), 4.0 );
+
+  vTexCoord = aTexCoord;
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/model3d-view-simple-shader.frag b/dali-toolkit/internal/graphics/shaders/model3d-view-simple-shader.frag
new file mode 100644 (file)
index 0000000..d7be96f
--- /dev/null
@@ -0,0 +1,8 @@
+precision mediump float;
+varying mediump vec3 vIllumination;
+uniform lowp vec4 uColor;
+
+void main()
+{
+  gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/model3d-view-simple-shader.vert b/dali-toolkit/internal/graphics/shaders/model3d-view-simple-shader.vert
new file mode 100644 (file)
index 0000000..a94619e
--- /dev/null
@@ -0,0 +1,28 @@
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec3 vIllumination;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 uLightPosition;
+
+void main()
+{
+  vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);
+  vertexPosition = uObjectMatrix * vertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  //Illumination in Model-View space - Transform attributes and uniforms
+  vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);
+  vec3 normal = uNormalMatrix * aNormal;
+  vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);
+  vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );
+
+  float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );
+  vIllumination = vec3(lightDiffuse * 0.5 + 0.5);
+
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/motion-blur-effect.frag b/dali-toolkit/internal/graphics/shaders/motion-blur-effect.frag
new file mode 100644 (file)
index 0000000..b2c0857
--- /dev/null
@@ -0,0 +1,45 @@
+precision mediump float;
+
+uniform sampler2D sTexture;
+uniform vec4 uColor;
+
+uniform vec2 uObjectFadeStart;
+uniform vec2 uObjectFadeEnd;
+uniform float uAlphaScale;
+uniform float uBlurTexCoordScale;
+uniform float uNumSamples;
+uniform float uRecipNumSamples;
+uniform float uRecipNumSamplesMinusOne;
+
+// inputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+  // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
+  // the blurred object and the unblurred background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
+  vec2 centerToPixel = abs(vModelSpaceCenterToPos);
+  vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));
+  float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale; // apply global scaler
+  fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);// fade proportional to speed, so opaque when at rest
+
+  // scale velocity vector by user requirements
+  vec2 velocity = vScreenSpaceVelocityVector * uBlurTexCoordScale;
+
+  // standard actor texel
+  vec4 colActor = texture2D(sTexture, vTexCoord);
+
+  // blurred actor - gather texture samples from the actor texture in the direction of motion
+  vec4 col = colActor * uRecipNumSamples;
+  for(float i = 1.0; i < uNumSamples; i += 1.0)
+  {
+    float t = i * uRecipNumSamplesMinusOne;
+    col += texture2D(sTexture, vTexCoord + (velocity * t)) * uRecipNumSamples;
+  }
+  gl_FragColor = mix(colActor, col, vSpeed); // lerp blurred and non-blurred actor based on speed of motion
+  gl_FragColor.a = fadeToEdgesScale;//colActor.a * fadeToEdgesScale; // fade blurred actor to its edges based on speed of motion
+  gl_FragColor *= uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/motion-blur-effect.vert b/dali-toolkit/internal/graphics/shaders/motion-blur-effect.vert
new file mode 100644 (file)
index 0000000..ed3ca94
--- /dev/null
@@ -0,0 +1,75 @@
+precision mediump float;
+
+attribute vec2 aPosition;
+
+uniform mat4 uMvpMatrix;
+uniform mat4 uModelView;
+uniform mat4 uViewMatrix;
+uniform mat4 uProjection;
+uniform vec3 uSize;
+
+uniform mat4 uModelLastFrame;
+float timeDelta = 0.0167;
+
+uniform float uGeometryStretchFactor;
+uniform float uSpeedScalingFactor;
+
+// outputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+  // get view space position of vertex this frame and last frame
+  vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+
+  vec4 viewSpaceVertex = uModelView * vertexPosition;
+  vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertexPosition;
+  float reciprocalTimeDelta = 1.0 / timeDelta;
+
+  // work out vertex's last movement in view space
+  vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;
+
+  // get clip space position of vertex this frame and last frame
+  vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;
+  vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;
+
+  // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
+  // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
+  float t = 0.0;
+  float posDeltaLength = length(viewSpacePosDelta);
+  if(posDeltaLength > 0.001) // avoid div by 0 if object has barely moved
+  {
+    vec4 viewSpaceCenterToPos = uModelView * vec4(vertexPosition.xy, 0.0, 0.0);
+    float centerToVertexDist = length(viewSpaceCenterToPos);
+    if(centerToVertexDist > 0.001) // avoid div by 0 if object has vertex at model space origin
+    {
+      vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;
+      vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;
+      t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5; // scale and bias from [-1..1] to [0..1]
+    }
+  }
+  // output vertex position lerped with its last position, based on how much it is trailing,
+  // this stretches the geom back along where it has just been, giving a warping effect
+  // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
+  gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * uGeometryStretchFactor * reciprocalTimeDelta);
+
+  // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
+  vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;
+  vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;
+  // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
+  vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);
+  vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y; // TODO negated due to y being inverted in our coordinate system?
+  // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
+  vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;
+  vSpeed = clamp(vSpeed, 0.0, 1.0);
+
+  // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
+  vModelSpaceCenterToPos = viewSpaceVertex.xy;
+
+  vec2 texCoord = aPosition + vec2(0.5);
+  vTexCoord = texCoord;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/motion-stretch-effect.frag b/dali-toolkit/internal/graphics/shaders/motion-stretch-effect.frag
new file mode 100644 (file)
index 0000000..8754a4f
--- /dev/null
@@ -0,0 +1,30 @@
+precision mediump float;
+
+uniform sampler2D sTexture;
+uniform vec4 uColor;
+
+uniform vec2 uObjectFadeStart;
+uniform vec2 uObjectFadeEnd;
+uniform float uAlphaScale;
+
+// inputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+  // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
+  // the stretched object and the background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
+  vec2 centerToPixel = abs( vModelSpaceCenterToPos );
+  vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));
+  float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale; // apply global scaler
+  fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);                // fade proportional to speed, so opaque when at rest
+
+  // standard actor texel
+  vec4 colActor = texture2D(sTexture, vTexCoord);
+  gl_FragColor = colActor;
+  gl_FragColor.a *= fadeToEdgesScale; // fade actor to its edges based on speed of motion
+  gl_FragColor *= uColor;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/motion-stretch-effect.vert b/dali-toolkit/internal/graphics/shaders/motion-stretch-effect.vert
new file mode 100644 (file)
index 0000000..3ac7364
--- /dev/null
@@ -0,0 +1,77 @@
+precision mediump float;
+
+attribute vec2 aPosition;
+
+uniform mat4 uMvpMatrix;
+uniform mat4 uModelView;
+uniform mat4 uViewMatrix;
+uniform mat4 uProjection;
+uniform vec3 uSize;
+
+uniform mat4  uModelLastFrame;
+float timeDelta = 0.0167;
+
+uniform float uGeometryStretchFactor;
+uniform float uSpeedScalingFactor;
+
+// outputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+  // get view space position of vertex this frame and last frame
+  vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+
+  vec4 viewSpaceVertex = uModelView * vertexPosition;
+  vec4 viewSpaceVertexLastFrame = uViewMatrix * uModelLastFrame * vertexPosition;
+
+  // work out vertex's last movement in view space
+  vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;
+  float reciprocalTimeDelta = 1.0 / timeDelta;
+
+  // get clip space position of vertex this frame and last frame
+  vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;
+  vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;
+
+  // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
+  // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
+  float t = 0.0;
+  float posDeltaLength = length(viewSpacePosDelta);
+  if(posDeltaLength > 0.001) // avoid div by 0 if object has barely moved
+  {
+    vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0, 0.0);
+    float centerToVertexDist = length(viewSpaceCenterToPos);
+    if(centerToVertexDist > 0.001) // avoid div by 0 if object has vertex at model space origin
+    {
+      vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;
+      vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;
+      t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5; // scale and bias from [-1..1] to [0..1]
+    }
+  }
+
+  // output vertex position lerped with its last position, based on how much it is trailing,
+  // this stretches the geom back along where it has just been, giving a warping effect
+  // We raise t to a power in order that non-trailing vertices are effected much more than trailing ones
+  // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
+  gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * t * t * uGeometryStretchFactor * reciprocalTimeDelta);
+
+  // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
+  vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;
+  vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;
+  // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
+  vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);
+  vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y; // TODO negated due to y being inverted in our coordinate system?
+  // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
+  vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;
+  vSpeed = clamp(vSpeed, 0.0, 1.0);
+
+  // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
+  vModelSpaceCenterToPos = viewSpaceVertex.xy;
+
+  vec2 texCoord = aPosition + vec2(0.5);
+  vTexCoord = texCoord;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/npatch-visual-3x3-shader.vert b/dali-toolkit/internal/graphics/shaders/npatch-visual-3x3-shader.vert
new file mode 100644 (file)
index 0000000..1586312
--- /dev/null
@@ -0,0 +1,39 @@
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vMaskTexCoord;
+uniform highp   mat4 uMvpMatrix;
+uniform highp   vec3 uSize;
+uniform mediump vec2 uFixed[ 3 ];
+uniform mediump vec2 uStretchTotal;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp   vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+void main()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+
+  mediump vec2 size = visualSize.xy;
+
+  mediump vec2 fixedFactor  = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y  + 1.0 ) * 0.5 ) ].y );
+  mediump vec2 stretch  = floor( aPosition * 0.5 );
+  mediump vec2 fixedTotal   = uFixed[ 2 ];
+
+  mediump vec4 gridPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );
+  mediump vec4 vertexPosition = gridPosition;
+  vertexPosition.xy -= size * vec2( 0.5, 0.5 );
+  vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;
+
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  vTexCoord = ( fixedFactor + stretch * uStretchTotal ) / ( fixedTotal + uStretchTotal );
+
+  vMaskTexCoord = gridPosition.xy / size;
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/npatch-visual-mask-shader.frag b/dali-toolkit/internal/graphics/shaders/npatch-visual-mask-shader.frag
new file mode 100644 (file)
index 0000000..6b85462
--- /dev/null
@@ -0,0 +1,23 @@
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vMaskTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sMask;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+uniform mediump float auxiliaryImageAlpha;
+
+void main()
+{
+  // Where mask image is transparent, all of background image must show through.
+  // where mask image is opaque, only mask should be shown
+  // where mask is translucent, less of background should be shown.
+  // auxiliaryImageAlpha controls how much of mask is visible
+
+  mediump vec4 color = texture2D( sTexture, vTexCoord );
+  mediump vec4 mask= texture2D( sMask, vMaskTexCoord );
+
+  mediump vec3 mixedColor = color.rgb * mix( 1.0-mask.a, 1.0, 1.0-auxiliaryImageAlpha)
+                            + mask.rgb*mask.a * auxiliaryImageAlpha;
+  gl_FragColor = vec4(mixedColor,1.0) * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/npatch-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/npatch-visual-shader.frag
new file mode 100644 (file)
index 0000000..acfd7f5
--- /dev/null
@@ -0,0 +1,10 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/npatch-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/npatch-visual-shader.vert
new file mode 100644 (file)
index 0000000..07f645b
--- /dev/null
@@ -0,0 +1,38 @@
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vMaskTexCoord;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];
+uniform mediump vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];
+
+// Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+void main()
+{
+  mediump vec2 fixedFactor= vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );
+  mediump vec2 stretch= vec2( uNinePatchFactorsX[ int( ( aPosition.x ) * 0.5 ) ].y, uNinePatchFactorsY[ int( ( aPosition.y ) * 0.5 ) ].y );
+
+  mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );
+  mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );
+
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+
+  mediump vec4 gridPosition = vec4( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal, 0.0, 1.0 );
+  mediump vec4 vertexPosition = gridPosition;
+  vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
+  vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );
+  vMaskTexCoord = gridPosition.xy / visualSize;
+
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/page-turn-book-spine-effect.frag b/dali-toolkit/internal/graphics/shaders/page-turn-book-spine-effect.frag
new file mode 100644 (file)
index 0000000..c4544aa
--- /dev/null
@@ -0,0 +1,27 @@
+precision mediump float;
+varying mediump vec2 vTexCoord;
+uniform vec3 uSize;
+uniform vec2 uSpineShadowParameter;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+  if( gl_FrontFacing ) // display front side
+  {
+    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+  }
+  else // display back side, flip the image horizontally by changing the x component of the texture coordinate
+  {
+    gl_FragColor = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) ) * uColor;
+  }
+  // display book spine, a stripe of shadowed texture
+  float pixelPos = vTexCoord.x * uSize.x;
+  if( pixelPos < uSpineShadowParameter.x )
+  {
+    float x = pixelPos - uSpineShadowParameter.x;
+    float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );
+    vec2 spineNormal = normalize(vec2(uSpineShadowParameter.y*x/uSpineShadowParameter.x, y));
+    gl_FragColor.rgb *= spineNormal.y;
+  }
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/page-turn-book-spine-effect.vert b/dali-toolkit/internal/graphics/shaders/page-turn-book-spine-effect.vert
new file mode 100644 (file)
index 0000000..900aeb9
--- /dev/null
@@ -0,0 +1,14 @@
+precision mediump float;
+attribute mediump vec2 aPosition;
+uniform mediump mat4 uMvpMatrix;
+uniform vec3 uSize;
+uniform float uTextureWidth;
+varying vec2 vTexCoord;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition*uSize.xy, 0.0, 1.0);
+  gl_Position = uMvpMatrix * vertexPosition;
+  vTexCoord = aPosition + vec2(0.5);
+  vTexCoord.x /= uTextureWidth;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/page-turn-effect.frag b/dali-toolkit/internal/graphics/shaders/page-turn-effect.frag
new file mode 100644 (file)
index 0000000..8fa6e77
--- /dev/null
@@ -0,0 +1,36 @@
+precision mediump float;
+
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform vec3 uSize;
+uniform vec2 uSpineShadowParameter;
+varying vec3 vNormal;
+varying vec4 vPosition;
+
+void main()
+{
+  // need to re-normalize the interpolated normal
+  vec3 normal = normalize( vNormal );
+  // display page content
+  vec4 texel;
+  // display back image of the page, flip the texture
+  if(  dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) );
+  // display front image of the page
+  else texel = texture2D( sTexture, vTexCoord );
+
+  // display book spine, a stripe of shadowed texture
+  float pixelPos = vTexCoord.x * uSize.x;
+  float spineShadowCoef = 1.0;
+  if( pixelPos < uSpineShadowParameter.x )
+  {
+    float x = pixelPos - uSpineShadowParameter.x;
+    float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );
+    spineShadowCoef = normalize( vec2( uSpineShadowParameter.y*x/uSpineShadowParameter.x, y ) ).y;
+  }
+  // calculate the lighting
+  // set the ambient color as vec3(0.4);
+  float lightColor = abs( normal.z ) * 0.6 + 0.4;
+  gl_FragColor = vec4( ( spineShadowCoef * lightColor ) * texel.rgb , texel.a ) * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/page-turn-effect.vert b/dali-toolkit/internal/graphics/shaders/page-turn-effect.vert
new file mode 100644 (file)
index 0000000..9705061
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * The common parameters for all the vertices, calculate in CPU then pass into the shader as uniforms
+ *
+ * first part of the page, (outside the the line passing through original center and vertical to curve direction)
+ * no Z change, only 2D rotation and translation
+ * ([0][0],[0][1],[1][0],[1][1]) mat2 rotateMatrix
+ * ([2][0],[2][1]) vec2 translationVector
+ *
+ * ([0][2],[0][3]) vec2 originalCenter: Typically the press down position of the Pan Gesture
+ * ([1][2],[1][3]) vec2 currentCenter: Typically the current position of the Pan Gesture
+ * ([3][0],[3][1]) vec2 curveDirection: The normalized vector pointing from original center to current center
+ * ([2][2]) float vanishingPointY: The Y coordinate of the intersection of the spine
+ *   and the line which goes through the original center and is vertical to the curveDirection
+ * ([2][3]) float curveEndY: The Y coordinate of intersection of the spine and the line through both original and current center
+ * ([3][2]) float curveHeight: The height of the interpolated hermite curve.
+ * ([3][3]) float currentLength: The length from the current center to the curveEnd.
+ */
+
+precision mediump float;
+
+attribute mediump vec2 aPosition;
+
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uModelView;
+
+uniform mat4 uCommonParameters;
+
+uniform vec3 uSize;
+uniform float uIsTurningBack;
+uniform float uTextureWidth;
+varying vec3 vNormal;
+varying vec4 vPosition;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+  vec4 position = vec4( aPosition*uSize.xy, 0.0, 1.0);
+  vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);
+  vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);
+  vec3 normal = vec3(0.0,0.0,1.0);
+
+  if(currentCenter.x < originalCenter.x)
+  {
+    // change the coordinate origin from the center of the page to its top-left
+    position.xy += uSize.xy * 0.5;
+    vec2 curveDirection = vec2( uCommonParameters[3]);
+    vec3 vanishingPoint = vec3(0.0, uCommonParameters[2][2], 0.0);
+    // first part of the page, (outside the the line passing through original center and vertical to curve direction)
+    //no Z change, only 2D rotation and translation
+    if( dot(curveDirection, position.xy - originalCenter) < 0.0 )
+    {
+      position.y -= vanishingPoint.y;
+      position.xy = mat2(uCommonParameters)*position.xy + vec2( uCommonParameters[2]);
+    }
+    // second part of the page, bent as a ruled surface
+    else
+    {
+      // calculate on the flat plane, between
+      // the first line passing through current vertex and vanishing point
+      // the second line passing through original center and current center
+      vec2 curveEnd = vec2( 0.0, uCommonParameters[2][3] );
+      vec2 curFlatDirection = vec2(0.0,1.0);
+      float lengthFromCurve = position.y - originalCenter.y;
+      float lengthOnCurve = position.x;
+      if(currentCenter.y != originalCenter.y)
+      {
+        curFlatDirection = normalize(position.xy - vanishingPoint.xy);
+        lengthFromCurve = (curveEnd.x*curveDirection.y-curveEnd.y*curveDirection.x-position.x*curveDirection.y+position.y*curveDirection.x)
+        / (curFlatDirection.x*curveDirection.y-curFlatDirection.y*curveDirection.x);
+        lengthOnCurve = length(position.xy+lengthFromCurve*curFlatDirection-curveEnd);
+      }
+
+      // define the control points of hermite curve, composed with two segments
+      // calculation is carried out on the 2D plane which is passing through both current and original center and vertical to the image plane
+      float currentLength = uCommonParameters[3][3];
+      float originalLength =  abs(originalCenter.x/curveDirection.x);
+      float height = uCommonParameters[3][2];
+      float percentage = currentLength/originalLength;
+      //vec2 SegmentOneControlPoint0 = vec2(0.0, 0.0);
+      vec2 SegmentOneControlPoint1 = vec2((0.65*percentage - 0.15)*originalLength, (0.8 + 0.2 * percentage)*height);
+      vec2 SegmentTwoControlPoint0 = SegmentOneControlPoint1;
+      vec2 SegmentTwoControlPoint1 = vec2(currentLength, 0.0);
+      vec2 SegmentOneTangentVector0 = SegmentOneControlPoint1;
+      vec2 SegmentOneTangentVector1 = vec2(0.5*originalLength,0.0);
+      vec2 SegmentTwoTangentVector0 = SegmentOneTangentVector1;
+      vec2 SegmentTwoTangentVector1 = SegmentOneTangentVector1;
+
+      // calculate the corresponding curve point position and its tangent vector
+      // it is a linear mapping onto nonlinear curves, might cause some unwanted deformation
+      // but as there are no analytical method to calculate the curve length on arbitrary segment
+      // no efficient way to solve this nonlinear mapping, Numerical approximation would cost too much computation in shader
+      vec2 curvePoint2D;
+      vec2 tangent;
+      float t0 = lengthOnCurve / originalLength;
+      if(t0<=0.5)
+      {
+        float t = 2.0*t0;
+        float t_2 = t*t;
+        float t_3 = t*t_2;
+        curvePoint2D = (-2.0*t_3+3.0*t_2)*SegmentOneControlPoint1
+        + (t_3-2.0*t_2+t)*SegmentOneTangentVector0 + (t_3-t_2)*SegmentOneTangentVector1;
+        tangent = (-6.0*t_2+6.0*t)*SegmentOneControlPoint1
+        + (3.0*t_2-4.0*t+1.0)*SegmentOneTangentVector0 + (3.0*t_2-2.0*t)*SegmentOneTangentVector1;
+      }
+      else
+      {
+        float t = 2.0*t0-1.0;
+        float t_2 = t*t;
+        float t_3 = t*t_2;
+        curvePoint2D = (2.0*t_3-3.0*t_2+1.0)*SegmentTwoControlPoint0 + (-2.0*t_3+3.0*t_2)*SegmentTwoControlPoint1
+        + (t_3-2.0*t_2+t)*SegmentTwoTangentVector0 + (t_3-t_2)*SegmentTwoTangentVector1;
+        tangent = (6.0*t_2-6.0*t)*SegmentTwoControlPoint0 + (-6.0*t_2+6.0*t)*SegmentTwoControlPoint1
+        + (3.0*t_2-4.0*t+1.0)*SegmentTwoTangentVector0 + (3.0*t_2-2.0*t)*SegmentTwoTangentVector1;
+        // a trick to eliminate some optical illusion caused by the gradient matter of normal in per-fragment shading
+        // which is caused by linear interpolation of normal vs. nonlinear lighting
+        // will notice some artifact in the areas with dramatically normal changes, so compress the normal differences here
+        tangent.y *=  min(1.0, length(position.xyz - vanishingPoint) / uSize.y );
+      }
+      vec3 curvePoint = vec3(curveEnd - curvePoint2D.x*curveDirection,max(0.0,curvePoint2D.y));
+      vec3 tangentVector = vec3(-tangent.x*curveDirection,tangent.y);
+
+      // locate the new vertex position on the line passing through both vanishing point and the calculated curve point position
+      vec3 curLiftDirection = vec3(0.0,-1.0,0.0);
+      if(currentCenter.y != originalCenter.y)
+      {
+        curLiftDirection = normalize(curvePoint - vanishingPoint);
+        tangentVector *= (curveDirection.y > 0.0) ? -1.0 : 1.0;
+        // an heuristic adjustment here, to compensate the linear parameter mapping onto the nonlinear curve
+        float Y0 = position.y - curveDirection.y * (position.x/curveDirection.x);
+        float proportion;
+        float refLength;
+        if(abs(Y0-vanishingPoint.y) > abs(curveEnd.y-vanishingPoint.y))
+        {
+          proportion = abs(curveEnd.y - Y0) / (abs(curveEnd.y-Y0)+abs(curveEnd.y - vanishingPoint.y));
+          refLength = proportion*length(originalCenter-vanishingPoint.xy) / (proportion-1.0);
+        }
+        else
+        {
+          proportion = abs(curveEnd.y - Y0) / abs(curveEnd.y - vanishingPoint.y);
+          refLength = proportion*length(originalCenter-vanishingPoint.xy);
+        }
+        float Y1 = currentCenter.y - (normalize(currentCenter-vanishingPoint.xy)).y * refLength;
+        position.y = mix(Y0, Y1, t0);
+      }
+      position.xz = curvePoint.xz - lengthFromCurve*curLiftDirection.xz;
+      // calculate the normal vector, will be used for lighting
+      normal = cross(curLiftDirection, normalize(tangentVector));
+      // the signature of Z is decided by the page turning direction:
+      // from left to right(negative); from right to left (positive)
+      position.z *= -uIsTurningBack;
+      normal.xy *= -uIsTurningBack;
+    }
+    // change the coordinate origin from the top-left of the page to its center
+    position.xy -= uSize.xy * 0.5;
+  }
+  vNormal =  uNormalMatrix * normal;
+  gl_Position = uMvpMatrix * position;
+  // varying parameters for fragment shader
+  vTexCoord = aPosition + vec2(0.5);
+  vTexCoord.x /= uTextureWidth;
+  vPosition = uModelView * position;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/primitive-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/primitive-visual-shader.frag
new file mode 100644 (file)
index 0000000..678a852
--- /dev/null
@@ -0,0 +1,12 @@
+//Very simple fragment shader that merely applies the vertex shading to the color at each fragment.
+
+precision mediump float;
+varying mediump vec3 vIllumination;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  vec4 baseColor = vec4(mixColor, 1.0) * uColor;
+  gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/primitive-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/primitive-visual-shader.vert
new file mode 100644 (file)
index 0000000..6a1b758
--- /dev/null
@@ -0,0 +1,53 @@
+//A simple shader that applies diffuse lighting to a mono-coloured object.
+
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec3 vIllumination;
+uniform mediump vec3 uSize;
+uniform mediump vec3 uObjectDimensions;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  float scaleFactor = min( visualSize.x / uObjectDimensions.x, visualSize.y / uObjectDimensions.y );
+  vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+  vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+  vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+
+  return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+  vec4 normalisedVertexPosition = ComputeVertexPosition();
+  vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+  vertexPosition = uMvpMatrix * vertexPosition;
+
+  //Illumination in Model-View space - Transform attributes and uniforms
+  vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+  vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;
+
+  vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+  mvLightPosition = uViewMatrix * mvLightPosition;
+  vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+
+  float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );
+  vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
+
+  gl_Position = vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/shadow-view-render-shader.frag b/dali-toolkit/internal/graphics/shaders/shadow-view-render-shader.frag
new file mode 100644 (file)
index 0000000..d193acf
--- /dev/null
@@ -0,0 +1,10 @@
+varying mediump vec2 vTexCoord;
+uniform lowp vec4 uShadowColor;
+uniform sampler2D sTexture;
+
+void main()
+{
+  lowp float alpha;
+  alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;
+  gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/shadow-view-render-shader.vert b/dali-toolkit/internal/graphics/shaders/shadow-view-render-shader.vert
new file mode 100644 (file)
index 0000000..4b38884
--- /dev/null
@@ -0,0 +1,17 @@
+attribute mediump vec2 aPosition;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelMatrix;
+uniform vec3 uSize;
+varying vec2 vTexCoord;
+
+uniform mediump mat4 uLightCameraProjectionMatrix;
+uniform mediump mat4 uLightCameraViewMatrix;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  gl_Position = uMvpMatrix * vertexPosition;
+  vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix  * vertexPosition;
+  vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/spread-filter-shader.frag b/dali-toolkit/internal/graphics/shaders/spread-filter-shader.frag
new file mode 100644 (file)
index 0000000..ac82763
--- /dev/null
@@ -0,0 +1,17 @@
+precision highp float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform int uSpread;
+uniform vec2 uTexScale;
+
+void main()
+{
+  vec4 color = texture2D( sTexture, vTexCoord);
+  for( int i = 1; i <= uSpread; ++i )
+  {
+    vec2 offset = uTexScale * float(i);
+    color = max( texture2D( sTexture, vTexCoord + offset), color );
+    color = max( texture2D( sTexture, vTexCoord - offset), color );
+  }
+  gl_FragColor = color;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/super-blur-view.frag b/dali-toolkit/internal/graphics/shaders/super-blur-view.frag
new file mode 100644 (file)
index 0000000..aad41e1
--- /dev/null
@@ -0,0 +1,10 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp float uAlpha;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+  gl_FragColor.a *= uAlpha;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-atlas-l8-shader.frag b/dali-toolkit/internal/graphics/shaders/text-atlas-l8-shader.frag
new file mode 100644 (file)
index 0000000..e42de21
--- /dev/null
@@ -0,0 +1,11 @@
+uniform lowp    vec4      uColor;
+uniform lowp    vec4      textColorAnimatable;
+uniform         sampler2D sTexture;
+varying mediump vec2      vTexCoord;
+varying mediump vec4      vColor;
+
+void main()
+{
+  mediump vec4 color = texture2D( sTexture, vTexCoord );
+  gl_FragColor = vec4( vColor.rgb * uColor.rgb * textColorAnimatable.rgb, uColor.a * vColor.a * textColorAnimatable.a * color.r );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-atlas-rgba-shader.frag b/dali-toolkit/internal/graphics/shaders/text-atlas-rgba-shader.frag
new file mode 100644 (file)
index 0000000..966ee90
--- /dev/null
@@ -0,0 +1,9 @@
+uniform lowp    vec4      uColor;
+uniform lowp    vec4      textColorAnimatable;
+uniform         sampler2D sTexture;
+varying mediump vec2      vTexCoord;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-atlas-shader.vert b/dali-toolkit/internal/graphics/shaders/text-atlas-shader.vert
new file mode 100644 (file)
index 0000000..388f0c2
--- /dev/null
@@ -0,0 +1,15 @@
+attribute mediump vec2    aPosition;
+attribute mediump vec2    aTexCoord;
+attribute mediump vec4    aColor;
+uniform   mediump vec2    uOffset;
+uniform     highp mat4    uMvpMatrix;
+varying   mediump vec2    vTexCoord;
+varying   mediump vec4    vColor;
+
+void main()
+{
+  mediump vec4 position = vec4( aPosition.xy + uOffset, 0.0, 1.0 );
+  gl_Position = uMvpMatrix * position;
+  vTexCoord = aTexCoord;
+  vColor = aColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-controller-background-shader.frag b/dali-toolkit/internal/graphics/shaders/text-controller-background-shader.frag
new file mode 100644 (file)
index 0000000..c935d22
--- /dev/null
@@ -0,0 +1,7 @@
+varying mediump vec4      vColor;
+uniform lowp    vec4      uColor;
+
+void main()
+{
+  gl_FragColor = vColor * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-controller-background-shader.vert b/dali-toolkit/internal/graphics/shaders/text-controller-background-shader.vert
new file mode 100644 (file)
index 0000000..9ce403c
--- /dev/null
@@ -0,0 +1,11 @@
+attribute mediump vec2    aPosition;
+attribute mediump vec4    aColor;
+varying   mediump vec4    vColor;
+uniform   highp mat4      uMvpMatrix;
+
+void main()
+{
+  mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
+  gl_Position = uMvpMatrix * position;
+  vColor = aColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-decorator-shader.frag b/dali-toolkit/internal/graphics/shaders/text-decorator-shader.frag
new file mode 100644 (file)
index 0000000..7402dde
--- /dev/null
@@ -0,0 +1,6 @@
+uniform      lowp vec4 uColor;
+
+void main()
+{
+  gl_FragColor = uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-decorator-shader.vert b/dali-toolkit/internal/graphics/shaders/text-decorator-shader.vert
new file mode 100644 (file)
index 0000000..6afdfca
--- /dev/null
@@ -0,0 +1,8 @@
+attribute mediump vec2    aPosition;
+uniform   highp mat4      uMvpMatrix;
+
+void main()
+{
+  mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
+  gl_Position = uMvpMatrix * position;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-scroller-shader.frag b/dali-toolkit/internal/graphics/shaders/text-scroller-shader.frag
new file mode 100644 (file)
index 0000000..25b85a3
--- /dev/null
@@ -0,0 +1,14 @@
+varying highp vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  if ( vTexCoord.y > 1.0 )
+    discard;
+
+  mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+
+  gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-scroller-shader.vert b/dali-toolkit/internal/graphics/shaders/text-scroller-shader.vert
new file mode 100644 (file)
index 0000000..6c2cd05
--- /dev/null
@@ -0,0 +1,30 @@
+attribute mediump vec2 aPosition;
+varying highp vec2 vTexCoord;
+uniform highp vec3 uSize;
+uniform mediump float uDelta;
+uniform mediump vec2 uTextureSize;
+uniform mediump float uGap;
+uniform mediump float uHorizontalAlign;
+uniform mediump float uVerticalAlign;
+
+uniform highp mat4 uMvpMatrix;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+void main()
+{
+  mediump vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
+  mediump vec2 visualSize = mix( uSize.xy * size, size, offsetSizeMode.zw );
+
+  vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + floor( aPosition.x * visualSize.x ) + 0.5 - uGap * 0.5 ) / uTextureSize.x + 0.5;
+  vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + floor( aPosition.y * visualSize.y ) + 0.5 ) / ( uTextureSize.y ) + 0.5;
+
+  mediump vec4 vertexPosition = vec4( floor( ( aPosition + anchorPoint ) * visualSize + ( visualOffset + origin ) * uSize.xy ), 0.0, 1.0 );
+
+  gl_Position = uMvpMatrix * vertexPosition;
+}
\ No newline at end of file
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-shader.frag
new file mode 100644 (file)
index 0000000..e9e1069
--- /dev/null
@@ -0,0 +1,11 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+
+  gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-with-style-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-with-style-shader.frag
new file mode 100644 (file)
index 0000000..d8506cb
--- /dev/null
@@ -0,0 +1,14 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sStyle;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+  mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );
+
+  // Draw the text as overlay above the style
+  gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/text-visual-shader.vert
new file mode 100644 (file)
index 0000000..893d075
--- /dev/null
@@ -0,0 +1,26 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec4 pixelArea;
+
+varying mediump vec2 vTexCoord;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+  vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-shader.frag
new file mode 100644 (file)
index 0000000..ab44460
--- /dev/null
@@ -0,0 +1,13 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  mediump float textTexture = texture2D( sTexture, vTexCoord ).r;
+
+  // Set the color of the text to what it is animated to.
+  gl_FragColor = uTextColorAnimatable * textTexture * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-emoji-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-emoji-shader.frag
new file mode 100644 (file)
index 0000000..544f0be
--- /dev/null
@@ -0,0 +1,21 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sMask;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+  mediump float maskTexture = texture2D( sMask, vTexCoord ).r;
+
+  // Set the color of non-transparent pixel in text to what it is animated to.
+  // Markup text with multiple text colors are not animated (but can be supported later on if required).
+  // Emoji color are not animated.
+  mediump float vstep = step( 0.0001, textTexture.a );
+  textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture );
+
+  // Draw the text as overlay above the style
+  gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-and-emoji-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-and-emoji-shader.frag
new file mode 100644 (file)
index 0000000..b892a17
--- /dev/null
@@ -0,0 +1,24 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sStyle;
+uniform sampler2D sMask;
+uniform lowp float uHasMultipleTextColors;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+  mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );
+  mediump float maskTexture = texture2D( sMask, vTexCoord ).r;
+
+  // Set the color of non-transparent pixel in text to what it is animated to.
+  // Markup text with multiple text colors are not animated (but can be supported later on if required).
+  // Emoji color are not animated.
+  mediump float vstep = step( 0.0001, textTexture.a );
+  textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) );
+
+  // Draw the text as overlay above the style
+  gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-shader.frag
new file mode 100644 (file)
index 0000000..f5d8b1c
--- /dev/null
@@ -0,0 +1,15 @@
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sStyle;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  mediump float textTexture = texture2D( sTexture, vTexCoord ).r;
+  mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );
+
+  // Draw the text as overlay above the style
+  gl_FragColor = ( uTextColorAnimatable * textTexture + styleTexture * ( 1.0 - uTextColorAnimatable.a * textTexture ) ) * uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/video-view-texture.frag b/dali-toolkit/internal/graphics/shaders/video-view-texture.frag
new file mode 100644 (file)
index 0000000..306f12e
--- /dev/null
@@ -0,0 +1,8 @@
+uniform lowp vec4 uColor;
+varying mediump vec2 vTexCoord;
+uniform samplerExternalOES sTexture;
+
+void main()
+{
+  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/video-view-texture.vert b/dali-toolkit/internal/graphics/shaders/video-view-texture.vert
new file mode 100644 (file)
index 0000000..79cbb23
--- /dev/null
@@ -0,0 +1,11 @@
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+varying mediump vec2 sTexCoordRect;
+
+void main()
+{
+  gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);
+  vTexCoord = aPosition + vec2(0.5);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/video-view.frag b/dali-toolkit/internal/graphics/shaders/video-view.frag
new file mode 100644 (file)
index 0000000..8045c0d
--- /dev/null
@@ -0,0 +1,4 @@
+void main()
+{
+  gl_FragColor = vec4(0.0);
+}
diff --git a/dali-toolkit/internal/graphics/shaders/video-view.vert b/dali-toolkit/internal/graphics/shaders/video-view.vert
new file mode 100644 (file)
index 0000000..3f824dd
--- /dev/null
@@ -0,0 +1,10 @@
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+void main()
+{
+  mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+  vertexPosition.xyz *= uSize;
+  gl_Position = uMvpMatrix * vertexPosition;
+}
diff --git a/dali-toolkit/internal/graphics/shaders/wireframe-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/wireframe-visual-shader.frag
new file mode 100644 (file)
index 0000000..78d8759
--- /dev/null
@@ -0,0 +1,7 @@
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+  gl_FragColor = uColor * vec4( mixColor, 1.0 );
+}
diff --git a/dali-toolkit/internal/graphics/shaders/wireframe-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/wireframe-visual-shader.vert
new file mode 100644 (file)
index 0000000..5e0bfb0
--- /dev/null
@@ -0,0 +1,22 @@
+attribute mediump vec2  aPosition;
+uniform   highp   mat4  uMvpMatrix;
+uniform   highp   vec3  uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp   vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+  gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
index 7016759..648c17a 100644 (file)
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 #ifdef DEBUG_ENABLED
 #define DECORATOR_DEBUG
 
 #endif
 
-#define MAKE_SHADER(A)#A
-
-namespace
-{
-const char* VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec2    aPosition;
-uniform   highp mat4      uMvpMatrix;
-
-void main()
-{
-  mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
-  gl_Position = uMvpMatrix * position;
-}
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
-uniform      lowp vec4 uColor;
-
-void main()
-{
-  gl_FragColor = uColor;
-}
-);
-}
-
 namespace Dali
 {
 namespace Internal
@@ -270,7 +246,7 @@ struct Decorator::Impl : public ConnectionTracker
     mHidePrimaryCursorAndGrabHandle( false )
   {
     mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
-    mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+    mHighlightShader = Shader::New( SHADER_TEXT_DECORATOR_SHADER_VERT, SHADER_TEXT_DECORATOR_SHADER_FRAG );
     SetupGestures();
   }
 
index 4fc28f8..80a1111 100755 (executable)
@@ -31,6 +31,7 @@
 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
 #include <dali-toolkit/internal/text/rendering/atlas/atlas-mesh-factory.h>
 #include <dali-toolkit/internal/text/text-view.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -42,52 +43,6 @@ namespace
   Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_RENDERING");
 #endif
 
-#define MAKE_SHADER(A)#A
-
-const char* VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec2    aPosition;
-attribute mediump vec2    aTexCoord;
-attribute mediump vec4    aColor;
-uniform   mediump vec2    uOffset;
-uniform     highp mat4    uMvpMatrix;
-varying   mediump vec2    vTexCoord;
-varying   mediump vec4    vColor;
-
-void main()
-{
-  mediump vec4 position = vec4( aPosition.xy + uOffset, 0.0, 1.0 );
-  gl_Position = uMvpMatrix * position;
-  vTexCoord = aTexCoord;
-  vColor = aColor;
-}
-);
-
-const char* FRAGMENT_SHADER_L8 = MAKE_SHADER(
-uniform lowp    vec4      uColor;
-uniform lowp    vec4      textColorAnimatable;
-uniform         sampler2D sTexture;
-varying mediump vec2      vTexCoord;
-varying mediump vec4      vColor;
-
-void main()
-{
-  mediump vec4 color = texture2D( sTexture, vTexCoord );
-  gl_FragColor = vec4( vColor.rgb * uColor.rgb * textColorAnimatable.rgb, uColor.a * vColor.a * textColorAnimatable.a * color.r );
-}
-);
-
-const char* FRAGMENT_SHADER_RGBA = MAKE_SHADER(
-uniform lowp    vec4      uColor;
-uniform lowp    vec4      textColorAnimatable;
-uniform         sampler2D sTexture;
-varying mediump vec2      vTexCoord;
-
-void main()
-{
-  gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable;
-}
-);
-
 const float ZERO( 0.0f );
 const float HALF( 0.5f );
 const float ONE( 1.0f );
@@ -696,7 +651,7 @@ struct AtlasRenderer::Impl
       // The glyph is an emoji and is not a shadow.
       if( !mShaderRgba )
       {
-        mShaderRgba = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_RGBA );
+        mShaderRgba = Shader::New( SHADER_TEXT_ATLAS_SHADER_VERT, SHADER_TEXT_ATLAS_RGBA_SHADER_FRAG );
       }
       shader = mShaderRgba;
     }
@@ -705,7 +660,7 @@ struct AtlasRenderer::Impl
       // The glyph is text or a shadow.
       if( !mShaderL8 )
       {
-        mShaderL8 = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_L8 );
+        mShaderL8 = Shader::New( SHADER_TEXT_ATLAS_SHADER_VERT, SHADER_TEXT_ATLAS_L8_SHADER_FRAG );
       }
       shader = mShaderL8;
     }
index 6554a2c..da5e2e7 100644 (file)
@@ -35,6 +35,7 @@
 #include <dali-toolkit/internal/text/text-controller-impl-event-handler.h>
 #include <dali-toolkit/internal/text/text-run-container.h>
 #include <dali-toolkit/internal/text/text-selection-handle-controller.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 using namespace Dali;
 
@@ -45,32 +46,6 @@ namespace
 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
 #endif
 
-#define MAKE_SHADER(A)#A
-
-const char* VERTEX_SHADER_BACKGROUND = MAKE_SHADER(
-attribute mediump vec2    aPosition;
-attribute mediump vec4    aColor;
-varying   mediump vec4    vColor;
-uniform   highp mat4      uMvpMatrix;
-
-void main()
-{
-  mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
-  gl_Position = uMvpMatrix * position;
-  vColor = aColor;
-}
-);
-
-const char* FRAGMENT_SHADER_BACKGROUND = MAKE_SHADER(
-varying mediump vec4      vColor;
-uniform lowp    vec4      uColor;
-
-void main()
-{
-  gl_FragColor = vColor * uColor;
-}
-);
-
 struct BackgroundVertex
 {
   Vector2 mPosition;        ///< Vertex posiiton
@@ -2108,7 +2083,7 @@ Actor Controller::Impl::CreateBackgroundActor()
 
       if( !mShaderBackground )
       {
-        mShaderBackground = Shader::New( VERTEX_SHADER_BACKGROUND, FRAGMENT_SHADER_BACKGROUND );
+        mShaderBackground = Shader::New( SHADER_TEXT_CONTROLLER_BACKGROUND_SHADER_VERT, SHADER_TEXT_CONTROLLER_BACKGROUND_SHADER_FRAG );
       }
 
       Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, mShaderBackground );
index b2c1b19..d908d33 100755 (executable)
@@ -23,6 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/text-scroller-interface.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -39,56 +40,6 @@ namespace
 
 const int MINIMUM_SCROLL_SPEED = 1; // Speed should be set by Property system.
 
-const char* VERTEX_SHADER_SCROLL = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  varying highp vec2 vTexCoord;\n
-  uniform highp vec3 uSize;\n
-  uniform mediump float uDelta;\n
-  uniform mediump vec2 uTextureSize;\n
-  uniform mediump float uGap;\n
-  uniform mediump float uHorizontalAlign;\n
-  uniform mediump float uVerticalAlign;\n
-  \n
-  uniform highp   mat4 uMvpMatrix;\n
-  \n
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  void main()\n
-  {\n
-    mediump vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );\n
-    mediump vec2 visualSize = mix( uSize.xy * size, size, offsetSizeMode.zw );\n
-    \n
-    vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + floor( aPosition.x * visualSize.x ) + 0.5 - uGap * 0.5 ) / uTextureSize.x + 0.5;\n
-    vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + floor( aPosition.y * visualSize.y ) + 0.5 ) / ( uTextureSize.y ) + 0.5;\n
-    \n
-    mediump vec4 vertexPosition = vec4( floor( ( aPosition + anchorPoint ) * visualSize + ( visualOffset + origin ) * uSize.xy ), 0.0, 1.0 );\n
-    \n
-    gl_Position = uMvpMatrix * vertexPosition;\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  varying highp vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    if ( vTexCoord.y > 1.0 )\n
-      discard;\n
-    \n
-    mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-    \n
-    gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
-  }\n
-);
-
 /**
  * @brief How the text should be aligned horizontally when scrolling the text.
  *
@@ -281,7 +232,7 @@ void TextScroller::SetParameters( Actor scrollingTextActor, Renderer renderer, T
   mTextureSet = mRenderer.GetTextures();
 
   // Set the shader and texture for scrolling
-  Shader shader = Shader::New( VERTEX_SHADER_SCROLL, FRAGMENT_SHADER, Shader::Hint::NONE );
+  Shader shader = Shader::New( SHADER_TEXT_SCROLLER_SHADER_VERT, SHADER_TEXT_SCROLLER_SHADER_FRAG, Shader::Hint::NONE );
   mRenderer.SetShader( shader );
   mRenderer.SetTextures( textureSet );
 
index 29fd9e8..bd52a8b 100644 (file)
 #include <cstring> // for strcmp
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 
 namespace Dali
@@ -47,38 +48,6 @@ DALI_SIGNAL_REGISTRATION( Toolkit, CubeTransitionEffect, "transitionCompleted",
 
 DALI_TYPE_REGISTRATION_END()
 
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  varying mediump vec2 vTexCoord;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump vec4 uTextureRect;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vertexPosition.xyz *= uSize;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-    \n
-    vTexCoord = aPosition + vec2(0.5);\n
-    vTexCoord = mix(uTextureRect.xy, uTextureRect.zw, vTexCoord);\n
-
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec4 uSamplerRect;
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
-  }\n
-);
-
 Actor CreateTile( const Vector4& samplerRect )
 {
  Actor tile = Actor::New();
@@ -247,7 +216,7 @@ void CubeTransitionEffect::Initialize()
 void CubeTransitionEffect::OnSceneConnection( int depth )
 {
   Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
-  Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+  Shader shader = Shader::New( SHADER_CUBE_TRANSITION_EFFECT_VERT, SHADER_CUBE_TRANSITION_EFFECT_FRAG );
 
   TextureSet textureSet = TextureSet::New();
 
index 05d1724..9b4bc8c 100755 (executable)
@@ -25,6 +25,7 @@
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -93,89 +94,6 @@ const Toolkit::DevelAnimatedGradientVisual::AnimationParameter::DirectionType::T
 const Toolkit::DevelAnimatedGradientVisual::AnimationParameter::MotionType::Type    DEFAULT_ANIMATION_MOTION_TYPE    = Toolkit::DevelAnimatedGradientVisual::AnimationParameter::MotionType::LOOP;
 const Toolkit::DevelAnimatedGradientVisual::AnimationParameter::EasingType::Type    DEFAULT_ANIMATION_EASING_TYPE    = Toolkit::DevelAnimatedGradientVisual::AnimationParameter::EasingType::LINEAR;
 
-const char* const BASIC_VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;
-  uniform highp   mat4 uMvpMatrix;
-  uniform highp   vec3 uSize;
-
-  uniform mediump vec2 start_point;
-  uniform mediump vec2 end_point;
-  uniform mediump vec2 rotate_center;
-  uniform mediump float rotate_angle;
-
-  varying mediump vec2 vTexCoord;
-  varying mediump vec2 vStart;
-  varying mediump vec2 vEnd;
-
-  vec2 rotate(vec2 x, vec2 c, float a)
-  {
-    vec2 d = x - c;
-    vec2 r = vec2(d.x * cos(a) - d.y * sin(a), d.x * sin(a) + d.y * cos(a));
-
-\n  #ifdef UNIT_TYPE_BOUNDING_BOX \n return r + c;             \n #endif \n /* UnitType::OBJECT_BOUNDING_BOX */
-\n  #ifdef UNIT_TYPE_USER         \n return (r + c) / uSize.x; \n #endif \n /* UnitType::USER_SPACE          */
-  }
-
-  //Visual size and offset
-  uniform mediump vec2 offset;
-  uniform highp vec2 size;
-  uniform mediump vec4 offsetSizeMode;
-  uniform mediump vec2 origin;
-  uniform mediump vec2 anchorPoint;
-
-  vec4 ComputeVertexPosition()
-  {
-    vec2 visualSize = mix( uSize.xy*size, size, offsetSizeMode.zw );
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
-    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
-  }
-
-  void main()
-  {
-    vStart = rotate( start_point, rotate_center, rotate_angle );
-    vEnd = rotate( end_point, rotate_center, rotate_angle );
-    gl_Position = uMvpMatrix * ComputeVertexPosition();
-
-\n  #ifdef UNIT_TYPE_BOUNDING_BOX \n vTexCoord = vec2(aPosition.x, -aPosition.y);                     \n #endif \n /* UnitType::OBJECT_BOUNDING_BOX */
-\n  #ifdef UNIT_TYPE_USER         \n vTexCoord = vec2(aPosition.x, -aPosition.y * uSize.y / uSize.x); \n #endif \n /* UnitType::USER_SPACE          */
-  }
-);
-
-const char* const BASIC_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  precision mediump float;
-
-  uniform mediump vec4 start_color;
-  uniform mediump vec4 end_color;
-  uniform mediump float gradient_offset;
-
-  varying mediump vec2 vTexCoord;
-  varying mediump vec2 vStart;
-  varying mediump vec2 vEnd;
-
-  float get_position(vec2 x, vec2 s, vec2 e)
-  {
-    vec2 df = e - s;
-    vec2 dx = x - s;
-
-\n  #ifdef GRADIENT_TYPE_LINEAR \n return dot(dx,df)/dot(df,df);       \n #endif \n /* GradientType::LINEAR */
-\n  #ifdef GRADIENT_TYPE_RADIAL \n return sqrt(dot(dx,dx)/dot(df,df)); \n #endif \n /* GradientType::RADIAL */
-  }
-  float recalculate(float r)
-  {
-\n  #ifdef SPREAD_TYPE_REFLECT \n return 1.0 - abs(mod(r, 2.0) - 1.0); \n #endif \n /* SpreadType::REFLECT */
-\n  #ifdef SPREAD_TYPE_REPEAT  \n return fract(r);                     \n #endif \n /* SpreadType::REPEAT  */
-\n  #ifdef SPREAD_TYPE_CLAMP   \n return clamp(r, 0.0, 1.0);           \n #endif \n /* SpreadType::CLAMP   */
-  }
-
-  void main()
-  {
-    float r = get_position( vTexCoord, vStart, vEnd );
-    r = recalculate( r + gradient_offset );
-    vec4 color = mix( start_color, end_color, r );
-    gl_FragColor = color;
-  }
-);
-
 Property::Value GetStartValue( const Property::Map& map, Property::Index index, const char* const name )
 {
   // Get start value of animation parameter
@@ -737,10 +655,10 @@ Shader AnimatedGradientVisual::CreateShader()
   std::string frag;
 
   vert = "#define " + tagUnit + "\n"
-       + BASIC_VERTEX_SHADER;
+       + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_VERT.data();
   frag = "#define " + tagGrad + "\n"
        + "#define " + tagSpread + "\n"
-       + BASIC_FRAGMENT_SHADER;
+       + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_FRAG.data();
 
   shader = Shader::New( vert, frag );
   return shader;
index 5a83d92..09cad55 100755 (executable)
@@ -249,6 +249,8 @@ void AnimatedImageVisual::DoCreatePropertyMap( Property::Map& map ) const
   map.Insert( Toolkit::ImageVisual::Property::CACHE_SIZE, static_cast<int>(mCacheSize) );
   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>(mImageCache->GetTotalFrameCount()) : -1 );
 
   map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior );
 }
index a90b31e..1eea6e6 100644 (file)
@@ -110,6 +110,11 @@ int32_t FixedImageCache::GetCurrentFrameIndex() const
   return static_cast<int32_t>(mFront);
 }
 
+int32_t FixedImageCache::GetTotalFrameCount() const
+{
+  return mImageUrls.size();
+}
+
 bool FixedImageCache::IsFrontReady() const
 {
   return ( mReadyFlags.size() > 0 && mReadyFlags[mFront] == true );
index bd232b4..3eaac8a 100644 (file)
@@ -77,6 +77,11 @@ public:
    */
   int32_t GetCurrentFrameIndex() const override;
 
+  /**
+   * Get total frame count of the animated image file.
+   */
+  int32_t GetTotalFrameCount() const override;
+
 private:
   /**
    * @return true if the front frame is ready
index b16b94e..adb6e58 100644 (file)
@@ -101,6 +101,11 @@ public:
    */
   virtual int32_t GetCurrentFrameIndex() const = 0;
 
+  /**
+   * Get total frame count of the animated image file.
+   */
+  virtual int32_t GetTotalFrameCount() const = 0;
+
 private:
 
   /**
index 2733d7a..565252f 100644 (file)
@@ -192,6 +192,11 @@ int32_t RollingAnimatedImageCache::GetCurrentFrameIndex() const
   return mQueue.Front().mFrameNumber;
 }
 
+int32_t RollingAnimatedImageCache::GetTotalFrameCount() const
+{
+  return mFrameCount;
+}
+
 bool RollingAnimatedImageCache::IsFrontReady() const
 {
   return ( !mQueue.IsEmpty() && mQueue.Front().mReady );
index db35741..595adc0 100644 (file)
@@ -95,6 +95,11 @@ public:
    */
   int32_t GetCurrentFrameIndex() const override;
 
+  /**
+   * Get total frame count of the animated image file.
+   */
+  int32_t GetTotalFrameCount() const override;
+
 private:
   /**
    * @return true if the front frame is ready
index e838060..dee6149 100644 (file)
@@ -165,6 +165,11 @@ int32_t RollingImageCache::GetCurrentFrameIndex() const
   return mQueue.Front().mUrlIndex;
 }
 
+int32_t RollingImageCache::GetTotalFrameCount() const
+{
+  return mImageUrls.size();
+}
+
 bool RollingImageCache::IsFrontReady() const
 {
   return ( !mQueue.IsEmpty() && mQueue.Front().mReady );
index c20586f..f33a7b3 100644 (file)
@@ -88,6 +88,11 @@ public:
    */
   int32_t GetCurrentFrameIndex() const override;
 
+  /**
+   * Get total frame count of the animated image file.
+   */
+  int32_t GetTotalFrameCount() const override;
+
 private:
   /**
    * @return true if the front frame is ready
index a2d102a..db97880 100644 (file)
@@ -293,7 +293,7 @@ void AnimatedVectorImageVisual::DoSetOnScene( Actor& actor )
   }
   else
   {
-    shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, false );
+    shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, IsRoundedCornerRequired() );
   }
 
   Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
index 71e2383..be58a9f 100644 (file)
@@ -28,6 +28,7 @@
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -47,104 +48,6 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( DevelArcVisual::Cap, BUTT )
 DALI_ENUM_TO_STRING_WITH_SCOPE( DevelArcVisual::Cap, ROUND )
 DALI_ENUM_TO_STRING_TABLE_END( CAP )
 
-const char* VERTEX_SHADER =
-  "INPUT mediump vec2 aPosition;\n"
-  "OUTPUT mediump vec2 vPosition;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-
-  "//Visual size and offset\n"
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-
-  "vec4 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  vPosition = aPosition* visualSize;\n"
-  "  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
-  "}\n";
-
-const char* FRAGMENT_SHADER_BUTT_CAP =
-  "INPUT mediump vec2 vPosition;\n"
-
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform mediump float thickness;\n"
-  "uniform mediump float radius;\n"
-  "uniform mediump float startAngle;\n"
-  "uniform mediump float sweepAngle;\n"
-
-  "const mediump float M_PI_OVER_2 = 1.57079632679;\n"
-  "const mediump float M_PI = 3.14159265359;\n"
-  "const mediump float M_PI_2 = 6.28318530718;\n"
-
-  "mediump float GetOpacity()\n"
-  "{\n"
-  "  mediump float start = radians( mod( startAngle, 360.0 ) );\n"
-  "  mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );\n"
-  "  mediump float dist = length( vPosition );\n"
-  "  if( angle <= radians( sweepAngle ) )\n"
-  "  {\n"
-  "    return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );\n"
-  "  }\n"
-  "  mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );\n"
-  "  mediump vec2 q0 = vec2( dist * cos( start - M_PI_OVER_2 ), dist * sin( start - M_PI_OVER_2 ) );\n"
-  "  mediump vec2 q1 = vec2( dist * cos( end - M_PI_OVER_2 ), dist * sin( end - M_PI_OVER_2 ) );\n"
-  "  mediump float opacity = 1.0 - smoothstep( 0.0, 2.0, min( length( vPosition - q0 ), length( vPosition - q1 ) ) );\n"
-  "  opacity *= step( 0.0, thickness / 2.0 - abs( dist - radius ) );\n"
-  "  return opacity;\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;\n"
-  "  OUT_COLOR.a *= GetOpacity();\n"
-  "}\n";
-
-const char* FRAGMENT_SHADER_ROUND_CAP =
-  "INPUT mediump vec2 vPosition;\n"
-
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform mediump float thickness;\n"
-  "uniform mediump float radius;\n"
-  "uniform mediump float startAngle;\n"
-  "uniform mediump float sweepAngle;\n"
-
-  "const mediump float M_PI_OVER_2 = 1.57079632679;\n"
-  "const mediump float M_PI_2 = 6.28318530718;\n"
-
-  "mediump float GetOpacity()\n"
-  "{\n"
-  "  mediump float start = radians( mod( startAngle, 360.0 ) );\n"
-  "  mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );\n"
-  "  mediump float dist = length( vPosition );\n"
-  "  if( angle <= radians( sweepAngle ) )\n"
-  "  {\n"
-  "    return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );\n"
-  "  }\n"
-  "  mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );\n"
-  "  mediump vec2 q0 = vec2( radius * cos( start - M_PI_OVER_2 ), radius * sin( start - M_PI_OVER_2 ) );\n"
-  "  mediump vec2 q1 = vec2( radius * cos( end - M_PI_OVER_2 ), radius * sin( end - M_PI_OVER_2 ) );\n"
-  "  return smoothstep( -1.0, 1.0, thickness / 2.0 - min( length( vPosition - q0 ), length( vPosition - q1 ) ) );\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;\n"
-  "  OUT_COLOR.a *= GetOpacity();\n"
-  "}\n";
-
 }
 
 ArcVisualPtr ArcVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
@@ -244,13 +147,46 @@ void ArcVisual::DoSetOnScene( Actor& actor )
   ResourceReady( Toolkit::Visual::ResourceStatus::READY );
 }
 
+void ArcVisual::DoSetOffScene(Actor& actor)
+{
+  if(mImpl->mRenderer)
+  {
+    // Update values from Renderer
+    mThickness  = mImpl->mRenderer.GetProperty<float>(mThicknessIndex);
+    mStartAngle = mImpl->mRenderer.GetProperty<float>(mStartAngleIndex);
+    mSweepAngle = mImpl->mRenderer.GetProperty<float>(mSweepAngleIndex);
+  }
+
+  actor.RemoveRenderer(mImpl->mRenderer);
+  mImpl->mRenderer.Reset();
+
+  mThicknessIndex  = Property::INVALID_INDEX;
+  mStartAngleIndex = Property::INVALID_INDEX;
+  mSweepAngleIndex = Property::INVALID_INDEX;
+}
+
 void ArcVisual::DoCreatePropertyMap( Property::Map& map ) const
 {
+  float thickness, startAngle, sweepAngle;
+  if(mImpl->mRenderer)
+  {
+    // Update values from Renderer
+    thickness  = mImpl->mRenderer.GetProperty<float>(mThicknessIndex);
+    startAngle = mImpl->mRenderer.GetProperty<float>(mStartAngleIndex);
+    sweepAngle = mImpl->mRenderer.GetProperty<float>(mSweepAngleIndex);
+  }
+  else
+  {
+    thickness  = mThickness;
+    startAngle = mStartAngle;
+    sweepAngle = mSweepAngle;
+  }
+
   map.Clear();
   map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::ARC );
-  map.Insert( Toolkit::DevelArcVisual::Property::THICKNESS, mThickness );
-  map.Insert( Toolkit::DevelArcVisual::Property::START_ANGLE, mStartAngle );
-  map.Insert( Toolkit::DevelArcVisual::Property::SWEEP_ANGLE, mSweepAngle );
+  map.Insert(Toolkit::DevelArcVisual::Property::THICKNESS, thickness);
+  map.Insert(Toolkit::DevelArcVisual::Property::START_ANGLE, startAngle);
+  map.Insert(Toolkit::DevelArcVisual::Property::SWEEP_ANGLE, sweepAngle);
   map.Insert( Toolkit::DevelArcVisual::Property::CAP, mCapType );
 }
 
@@ -297,7 +233,7 @@ void ArcVisual::InitializeRenderer()
     shader = mFactoryCache.GetShader( VisualFactoryCache::ARC_BUTT_CAP_SHADER );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_BUTT_CAP );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_ARC_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_ARC_VISUAL_BUTT_CAP_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::ARC_BUTT_CAP_SHADER, shader );
     }
   }
@@ -306,16 +242,16 @@ void ArcVisual::InitializeRenderer()
     shader = mFactoryCache.GetShader( VisualFactoryCache::ARC_ROUND_CAP_SHADER );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUND_CAP );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_ARC_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_ARC_VISUAL_ROUND_CAP_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::ARC_ROUND_CAP_SHADER, shader );
     }
   }
 
   mImpl->mRenderer = Renderer::New( geometry, shader );
 
-  mThicknessIndex = mImpl->mRenderer.RegisterProperty( THICKNESS_NAME, mThickness );
-  mStartAngleIndex = mImpl->mRenderer.RegisterProperty( START_ANGLE_NAME, mStartAngle );
-  mSweepAngleIndex = mImpl->mRenderer.RegisterProperty( SWEEP_ANGLE_NAME, mSweepAngle );
+  mThicknessIndex  = mImpl->mRenderer.RegisterProperty(DevelArcVisual::Property::THICKNESS, THICKNESS_NAME, mThickness);
+  mStartAngleIndex = mImpl->mRenderer.RegisterProperty(DevelArcVisual::Property::START_ANGLE, START_ANGLE_NAME, mStartAngle);
+  mSweepAngleIndex = mImpl->mRenderer.RegisterProperty(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_NAME, mSweepAngle);
 
   mRadiusIndex = mImpl->mRenderer.RegisterProperty( RADIUS_NAME, mRadius );
 
index 90ac861..15f57d3 100644 (file)
@@ -99,6 +99,11 @@ protected:
   void DoSetOnScene( Actor& actor ) override;
 
   /**
+   * @copydoc Visual::Base::DoSetOffScene
+   */
+  void DoSetOffScene(Actor& actor) override;
+
+  /**
    * @copydoc Visual::Base::OnSetTransform
    */
   void OnSetTransform() override;
index 452fda9..f62afc3 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -44,74 +45,6 @@ namespace
 const char * const POSITION_ATTRIBUTE_NAME("aPosition");
 const char * const DRIFT_ATTRIBUTE_NAME("aDrift");
 const char * const INDEX_NAME("indices");
-
-const char* VERTEX_SHADER =
-  "INPUT mediump vec2 aPosition;\n"
-  "INPUT mediump vec2 aDrift;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-  "uniform mediump float borderSize;\n"
-
-  "//Visual size and offset\n"
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-
-  "vec2 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  return (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy;\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  vec2 position = ComputeVertexPosition() + aDrift*borderSize;\n"
-  "  gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);\n"
-  "}\n";
-
-const char* FRAGMENT_SHADER =
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec4 borderColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-
-  "void main()\n"
-  "{\n"
-  "  OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;\n"
-  "}\n";
-
-const char* VERTEX_SHADER_ANTI_ALIASING =
-  "INPUT mediump vec2 aPosition;\n"
-  "INPUT mediump vec2 aDrift;\n"
-  "OUTPUT mediump float vAlpha;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-  "uniform mediump float borderSize;\n"
-
-  "void main()\n"
-  "{\n"
-  "  vec2 position = aPosition*(uSize.xy+vec2(0.75)) + aDrift*(borderSize+1.5);\n"
-  "  gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);\n"
-  "  vAlpha = min( abs(aDrift.x), abs(aDrift.y) )*(borderSize+1.5);"
-  "}\n";
-
-const char* FRAGMENT_SHADER_ANTI_ALIASING =
-  "INPUT mediump float vAlpha;\n"
-
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec4 borderColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform mediump float borderSize;\n"
-
-  "void main()\n"
-  "{\n"
-  "  OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;\n"
-  "  OUT_COLOR.a *= smoothstep(0.0, 1.5, vAlpha) * smoothstep( borderSize + 1.5, borderSize, vAlpha );\n"
-  "}\n";
 }
 
 BorderVisualPtr BorderVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
@@ -257,7 +190,7 @@ Shader BorderVisual::GetBorderShader()
     shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ANTI_ALIASING, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ANTI_ALIASING );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_BORDER_VISUAL_ANTI_ALIASING_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_BORDER_VISUAL_ANTI_ALIASING_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING, shader );
     }
   }
@@ -266,7 +199,7 @@ Shader BorderVisual::GetBorderShader()
     shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_BORDER_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_BORDER_VISUAL_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER, shader );
     }
   }
index 68dc04a..492f203 100644 (file)
@@ -31,6 +31,7 @@
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -41,145 +42,6 @@ namespace Toolkit
 namespace Internal
 {
 
-namespace
-{
-
-const char* VERTEX_SHADER =
-  "INPUT mediump vec2 aPosition;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-
-  "//Visual size and offset\n"
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-  "uniform mediump vec2 extraSize;\n"
-
-  "vec4 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
-  "}\n";
-
-
-const char* FRAGMENT_SHADER =
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-
-  "void main()\n"
-  "{\n"
-  "  OUT_COLOR = vec4(mixColor, 1.0) * uColor;\n"
-  "}\n";
-
-const char* VERTEX_SHADER_ROUNDED_CORNER =
-  "INPUT mediump vec2 aPosition;\n"
-  "OUTPUT mediump vec2 vPosition;\n"
-  "OUTPUT mediump vec2 vRectSize;\n"
-  "OUTPUT mediump float vCornerRadius;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-
-  "//Visual size and offset\n"
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec2 extraSize;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-  "uniform mediump float cornerRadius;\n"
-  "uniform mediump float cornerRadiusPolicy;\n"
-
-  "vec4 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  mediump float minSize = min( visualSize.x, visualSize.y );\n"
-  "  vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n"
-  "  vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n"
-  "  vRectSize = visualSize / 2.0 - vCornerRadius;\n"
-  "  vPosition = aPosition* visualSize;\n"
-  "  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
-  "}\n";
-
-//float distance = length( max( abs( position - center ), size ) - size ) - radius;
-const char* FRAGMENT_SHADER_ROUNDED_CORNER =
-  "INPUT mediump vec2 vPosition;\n"
-  "INPUT mediump vec2 vRectSize;\n"
-  "INPUT mediump float vCornerRadius;\n"
-
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-
-  "void main()\n"
-  "{\n"
-  "  mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n"
-  "  OUT_COLOR = vec4(mixColor, 1.0) * uColor;\n"
-  "  OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist );\n"
-  "}\n";
-
-const char* VERTEX_SHADER_BLUR_EDGE =
-  "INPUT mediump vec2 aPosition;\n"
-  "OUTPUT mediump vec2 vPosition;\n"
-  "OUTPUT mediump vec2 vRectSize;\n"
-
-  "uniform highp   mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-
-  "//Visual size and offset\n"
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec2 extraSize;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-  "uniform mediump float blurRadius;\n"
-
-  "vec4 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize + blurRadius * 2.0;\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  vRectSize = visualSize / 2.0;\n"
-  "  vPosition = aPosition* visualSize;\n"
-  "  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
-  "}\n";
-
-const char* FRAGMENT_SHADER_BLUR_EDGE =
-  "INPUT mediump vec2 vPosition;\n"
-  "INPUT mediump vec2 vRectSize;\n"
-
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform mediump float blurRadius;\n"
-
-  "void main()\n"
-  "{\n"
-  "  mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );\n"
-  "  OUT_COLOR = vec4(mixColor, 1.0) * uColor;\n"
-  "  OUT_COLOR.a *= blur.x * blur.y;\n"
-  "}\n";
-
-}
-
 ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
 {
   ColorVisualPtr colorVisualPtr( new ColorVisual( factoryCache ) );
@@ -363,7 +225,7 @@ Shader ColorVisual::GetShader()
     shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_BLUR_EDGE, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_BLUR_EDGE );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_COLOR_VISUAL_BLUR_EDGE_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_COLOR_VISUAL_BLUR_EDGE_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE, shader );
     }
   }
@@ -372,7 +234,7 @@ Shader ColorVisual::GetShader()
     shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_COLOR_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_COLOR_VISUAL_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER, shader );
     }
   }
@@ -381,7 +243,7 @@ Shader ColorVisual::GetShader()
     shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER );
     if( !shader )
     {
-      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ROUNDED_CORNER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUNDED_CORNER );
+      shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_COLOR_VISUAL_ROUNDED_CORNER_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_COLOR_VISUAL_ROUNDED_CORNER_SHADER_FRAG.data() );
       mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER, shader );
     }
   }
index b86f9a7..504b0e0 100644 (file)
 #include <dali-toolkit/internal/visuals/gradient/linear-gradient.h>
 #include <dali-toolkit/internal/visuals/gradient/radial-gradient.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-bounding-box-rounded-corner-shader-vert.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-bounding-box-shader-vert.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-linear-rounded-corner-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-linear-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-radial-rounded-corner-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-radial-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-user-space-rounded-corner-shader-vert.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-user-space-shader-vert.h>
 
 namespace Dali
 {
@@ -83,220 +91,34 @@ VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[][4] =
   }
 };
 
-const char* VERTEX_SHADER[] =
+const std::string_view VERTEX_SHADER[] =
 {
-// vertex shader for gradient units as OBJECT_BOUNDING_BOX
-DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  uniform mediump mat3 uAlignmentMatrix;\n
-  varying mediump vec2 vTexCoord;\n
-  \n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp   vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
-    \n
-    gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-  }\n
-),
-
-// vertex shader for gradient units as USER_SPACE
-DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  uniform mediump mat3 uAlignmentMatrix;\n
-  varying mediump vec2 vTexCoord;\n
-  \n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp   vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vertexPosition.xyz *= uSize;\n
-    gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-    \n
-    vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
-  }\n
-),
-
-// vertex shader for gradient units as OBJECT_BOUNDING_BOX with corner radius
-DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  uniform mediump mat3 uAlignmentMatrix;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec2 vPosition;\n
-  varying mediump vec2 vRectSize;\n
-  varying mediump float vCornerRadius;\n
-  \n
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp   vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-  uniform mediump float cornerRadius;\n
-  uniform mediump float cornerRadiusPolicy;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-    mediump float minSize = min( visualSize.x, visualSize.y );\n
-    vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n
-    vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n
-    vRectSize = visualSize * 0.5 - vCornerRadius;\n
-    vPosition = aPosition * visualSize;\n
-    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
-    \n
-    gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-  }\n
-),
-
-// vertex shader for gradient units as USER_SPACE with corner radius
-DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  uniform mediump mat3 uAlignmentMatrix;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec2 vPosition;\n
-  varying mediump vec2 vRectSize;\n
-  varying mediump float vCornerRadius;\n
-  \n
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp   vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-  uniform mediump float cornerRadius;\n
-  uniform mediump float cornerRadiusPolicy;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-    mediump float minSize = min( visualSize.x, visualSize.y );\n
-    vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n
-    vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n
-    vRectSize = visualSize * 0.5 - vCornerRadius;\n
-    vPosition = aPosition * visualSize;\n
-    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
-    vertexPosition.xyz *= uSize;\n
-    gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-    \n
-    vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
-  }\n
-)
+  // vertex shader for gradient units as OBJECT_BOUNDING_BOX
+  SHADER_GRADIENT_VISUAL_BOUNDING_BOX_SHADER_VERT,
+
+  // vertex shader for gradient units as USER_SPACE
+  SHADER_GRADIENT_VISUAL_USER_SPACE_SHADER_VERT,
+
+  // vertex shader for gradient units as OBJECT_BOUNDING_BOX with corner radius
+  SHADER_GRADIENT_VISUAL_BOUNDING_BOX_ROUNDED_CORNER_SHADER_VERT,
+
+  // vertex shader for gradient units as USER_SPACE with corner radius
+  SHADER_GRADIENT_VISUAL_USER_SPACE_ROUNDED_CORNER_SHADER_VERT
 };
 
-const char* FRAGMENT_SHADER[] =
+const std::string_view FRAGMENT_SHADER[] =
 {
-// fragment shader for linear gradient
-DALI_COMPOSE_SHADER(
-  uniform sampler2D sTexture;\n // sampler1D?
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  varying mediump vec2 vTexCoord;\n
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
-  }\n
-),
-
-// fragment shader for radial gradient
-DALI_COMPOSE_SHADER(
-  uniform sampler2D sTexture;\n // sampler1D?
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  varying mediump vec2 vTexCoord;\n
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
-  }\n
-),
-
-// fragment shader for linear gradient with corner radius
-DALI_COMPOSE_SHADER(
-  uniform sampler2D sTexture;\n // sampler1D?
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec2 vPosition;\n
-  varying mediump vec2 vRectSize;\n
-  varying mediump float vCornerRadius;\n
-  \n
-  void main()\n
-  {\n
-    mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
-    gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
-    gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
-  }\n
-),
-
-// fragment shader for radial gradient with corner radius
-DALI_COMPOSE_SHADER(
-  uniform sampler2D sTexture;\n // sampler1D?
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec2 vPosition;\n
-  varying mediump vec2 vRectSize;\n
-  varying mediump float vCornerRadius;\n
-  \n
-  void main()\n
-  {\n
-    mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
-    gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
-    gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
-  }\n
-)
+  // fragment shader for linear gradient
+  SHADER_GRADIENT_VISUAL_LINEAR_SHADER_FRAG,
+
+  // fragment shader for radial gradient
+  SHADER_GRADIENT_VISUAL_RADIAL_SHADER_FRAG,
+
+  // fragment shader for linear gradient with corner radius
+  SHADER_GRADIENT_VISUAL_LINEAR_ROUNDED_CORNER_SHADER_FRAG,
+
+  // fragment shader for radial gradient with corner radius
+  SHADER_GRADIENT_VISUAL_RADIAL_ROUNDED_CORNER_SHADER_FRAG
 };
 
 Dali::WrapMode::Type GetWrapMode( Toolkit::GradientVisual::SpreadMethod::Type spread )
index 5bc09ce..523c374 100644 (file)
@@ -21,6 +21,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali/integration-api/debug.h>
 
 namespace Dali
@@ -37,155 +38,6 @@ namespace
 
 const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
 
-const char* VERTEX_SHADER =
-  "INPUT mediump vec2 aPosition;\n"
-  "OUTPUT mediump vec2 vTexCoord;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-  "uniform mediump vec4 pixelArea;"
-  "//Visual size and offset\n"
-
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-  "uniform mediump vec2 extraSize;\n"
-
-  "vec4 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
-  "}\n"
-  "\n"
-  "void main()\n"
-  "{\n"
-  "  gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
-  "  vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n"
-  "}\n";
-
-const char* FRAGMENT_SHADER_NO_ATLAS =
-  "INPUT mediump vec2 vTexCoord;\n"
-
-  "uniform sampler2D sTexture;\n"
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform lowp float preMultipliedAlpha;\n"
-
-  "void main()\n"
-  "{\n"
-  "  OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n"
-  "}\n";
-
-
-const char* FRAGMENT_SHADER_ATLAS_CLAMP =
-  "INPUT mediump vec2 vTexCoord;\n"
-
-  "uniform sampler2D sTexture;\n"
-  "uniform mediump vec4 uAtlasRect;\n"
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform lowp float preMultipliedAlpha;\n"
-
-  "void main()\n"
-  "{\n"
-  "  mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );\n"
-  "  OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );\n"
-  "}\n";
-
-
-const char* FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP =
-  "INPUT mediump vec2 vTexCoord;\n"
-
-  "uniform sampler2D sTexture;\n"
-  "uniform mediump vec4 uAtlasRect;\n"
-  "// WrapMode -- 0: CLAMP; 1: REPEAT; 2: REFLECT;"
-  "uniform lowp vec2 wrapMode;\n"
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform lowp float preMultipliedAlpha;\n"
-  "mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )\n"
-
-  "{\n"
-  "  mediump float coord;\n"
-  "  if( wrap > 1.5 )\n // REFLECT"
-  "    coord = 1.0-abs(fract(coordinate*0.5)*2.0 - 1.0);\n"
-  "  else \n// warp == 0 or 1"
-  "    coord = mix(coordinate, fract( coordinate ), wrap);\n"
-  "  return clamp( mix(range.x, range.y, coord), range.x, range.y );"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),"
-  "                                wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );\n"
-  "  OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );\n"
-  "}\n";
-
-const char* VERTEX_SHADER_ROUNDED_CORNER =
-  "INPUT mediump vec2 aPosition;\n"
-  "OUTPUT mediump vec2 vTexCoord;\n"
-  "OUTPUT mediump vec2 vPosition;\n"
-  "OUTPUT mediump vec2 vRectSize;\n"
-  "OUTPUT mediump float vCornerRadius;\n"
-
-  "uniform highp mat4 uMvpMatrix;\n"
-  "uniform highp vec3 uSize;\n"
-  "uniform mediump vec4 pixelArea;"
-
-  "//Visual size and offset\n"
-  "uniform mediump vec2 offset;\n"
-  "uniform highp vec2 size;\n"
-  "uniform mediump vec4 offsetSizeMode;\n"
-  "uniform mediump vec2 origin;\n"
-  "uniform mediump vec2 anchorPoint;\n"
-  "uniform mediump float cornerRadius;\n"
-  "uniform mediump float cornerRadiusPolicy;\n"
-  "uniform mediump vec2 extraSize;\n"
-
-  "vec4 ComputeVertexPosition()\n"
-  "{\n"
-  "  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
-  "  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
-  "  mediump float minSize = min( visualSize.x, visualSize.y );\n"
-  "  vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n"
-  "  vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n"
-  "  vRectSize = visualSize * 0.5 - vCornerRadius;\n"
-  "  vPosition = aPosition* visualSize;\n"
-  "  return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
-  "}\n"
-
-  "void main()\n"
-  "{\n"
-  "  gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
-  "  vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n"
-  "}\n";
-
-
-//float distance = length( max( abs( position - center ), size ) - size ) - radius;
-const char* FRAGMENT_SHADER_ROUNDED_CORNER =
-  "INPUT mediump vec2 vTexCoord;\n"
-  "INPUT mediump vec2 vPosition;\n"
-  "INPUT mediump vec2 vRectSize;\n"
-  "INPUT mediump float vCornerRadius;\n"
-
-  "uniform sampler2D sTexture;\n"
-  "uniform lowp vec4 uColor;\n"
-  "uniform lowp vec3 mixColor;\n"
-  "uniform lowp float preMultipliedAlpha;\n"
-
-  "void main()\n"
-  "{\n"
-  "  mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n"
-  "  mediump float opacity = 1.0 - smoothstep( -1.0, 1.0, dist );\n"
-
-  "  OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n"
-  "  OUT_COLOR.a *= opacity;\n"
-  "  OUT_COLOR.rgb *= mix( 1.0, opacity, preMultipliedAlpha );\n"
-  "}\n";
-
 // global string variable to caching complate vertex shader
 static std::string gVertexShader;
 
@@ -212,7 +64,8 @@ Shader ImageVisualShaderFactory::GetShader( VisualFactoryCache& factoryCache, bo
       shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
       if( !shader )
       {
-        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ATLAS_CLAMP );
+        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(),
+                              Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_ATLAS_CLAMP_SHADER_FRAG.data() );
         shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
         factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
       }
@@ -222,7 +75,8 @@ Shader ImageVisualShaderFactory::GetShader( VisualFactoryCache& factoryCache, bo
       shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_CUSTOM_WRAP );
       if( !shader )
       {
-        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP );
+        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(),
+                              Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_ATLAS_VARIOUS_WRAP_SHADER_FRAG.data() );
         shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
         factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_CUSTOM_WRAP, shader );
       }
@@ -235,7 +89,8 @@ Shader ImageVisualShaderFactory::GetShader( VisualFactoryCache& factoryCache, bo
       shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER );
       if( !shader )
       {
-        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ROUNDED_CORNER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUNDED_CORNER );
+        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_ROUNDED_CORNER_SHADER_VERT.data(),
+                              Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_ROUNDED_CORNER_SHADER_FRAG.data() );
         shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
         factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER, shader );
       }
@@ -245,7 +100,8 @@ Shader ImageVisualShaderFactory::GetShader( VisualFactoryCache& factoryCache, bo
       shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER );
       if( !shader )
       {
-        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_NO_ATLAS );
+        shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(),
+                              Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_NO_ATLAS_SHADER_FRAG.data() );
         shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
         factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER, shader );
       }
@@ -259,7 +115,7 @@ std::string_view ImageVisualShaderFactory::GetVertexShaderSource()
 {
   if(gVertexShader.empty())
   {
-    gVertexShader = Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER;
+    gVertexShader = Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data();
   }
 
   return gVertexShader;
@@ -269,7 +125,7 @@ std::string_view ImageVisualShaderFactory::GetFragmentShaderSource()
 {
   if(gFragmentShaderNoAtlas.empty())
   {
-    gFragmentShaderNoAtlas = Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_NO_ATLAS;
+    gFragmentShaderNoAtlas = Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_NO_ATLAS_SHADER_FRAG.data();
   }
   return gFragmentShaderNoAtlas;
 }
index 0cd4c1b..3a91784 100644 (file)
@@ -143,32 +143,32 @@ ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
   return new ImageVisual( factoryCache, shaderFactory, imageUrl, size, fittingMode, samplingMode );
 }
 
-ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
-                          ImageVisualShaderFactory& shaderFactory,
-                          const VisualUrl& imageUrl,
-                          ImageDimensions size,
-                          FittingMode::Type fittingMode,
-                          Dali::SamplingMode::Type samplingMode )
-: Visual::Base( factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE ),
-  mPixelArea( FULL_TEXTURE_RECT ),
+ImageVisual::ImageVisual(VisualFactoryCache&       factoryCache,
+                         ImageVisualShaderFactory& shaderFactory,
+                         const VisualUrl&          imageUrl,
+                         ImageDimensions           size,
+                         FittingMode::Type         fittingMode,
+                         Dali::SamplingMode::Type  samplingMode)
+: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE),
+  mPixelArea(FULL_TEXTURE_RECT),
   mPlacementActor(),
-  mImageUrl( imageUrl ),
-  mMaskingData( ),
-  mDesiredSize( size ),
-  mTextureId( TextureManager::INVALID_TEXTURE_ID ),
+  mImageUrl(imageUrl),
+  mMaskingData(),
+  mDesiredSize(size),
+  mTextureId(TextureManager::INVALID_TEXTURE_ID),
   mTextures(),
-  mImageVisualShaderFactory( shaderFactory ),
-  mFittingMode( fittingMode ),
-  mSamplingMode( samplingMode ),
-  mWrapModeU( WrapMode::DEFAULT ),
-  mWrapModeV( WrapMode::DEFAULT ),
-  mLoadPolicy( Toolkit::ImageVisual::LoadPolicy::ATTACHED ),
-  mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DETACHED ),
-  mAtlasRect( 0.0f, 0.0f, 0.0f, 0.0f ),
-  mAtlasRectSize( 0, 0 ),
-  mAttemptAtlasing( false ),
-  mLoading( false ),
-  mOrientationCorrection( true )
+  mImageVisualShaderFactory(shaderFactory),
+  mFittingMode(fittingMode),
+  mSamplingMode(samplingMode),
+  mWrapModeU(WrapMode::DEFAULT),
+  mWrapModeV(WrapMode::DEFAULT),
+  mLoadPolicy(Toolkit::ImageVisual::LoadPolicy::ATTACHED),
+  mReleasePolicy(Toolkit::ImageVisual::ReleasePolicy::DETACHED),
+  mAtlasRect(0.0f, 0.0f, 0.0f, 0.0f),
+  mAtlasRectSize(0, 0),
+  mLoadState(TextureManager::LoadState::NOT_STARTED),
+  mAttemptAtlasing(false),
+  mOrientationCorrection(true)
 {
   EnablePreMultipliedAlpha( mFactoryCache.GetPreMultiplyOnLoad() );
 }
@@ -570,16 +570,29 @@ void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& t
     ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
     : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
-  textures = textureManager.LoadTexture( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode,
-                                         mMaskingData, IsSynchronousLoadingRequired(), mTextureId,
-                                         atlasRect, mAtlasRectSize, atlasing, mLoading, mWrapModeU,
-                                         mWrapModeV, textureObserver, atlasUploadObserver, atlasManager,
-                                         mOrientationCorrection, forceReload, preMultiplyOnLoad);
+  bool synchronousLoading = IsSynchronousLoadingRequired();
+  bool loadingStatus;
+
+  textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, mWrapModeU, mWrapModeV, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
 
   if( textures )
   {
+    if(loadingStatus)
+    {
+      mLoadState = TextureManager::LoadState::LOADING;
+    }
+    else
+    {
+      mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+    }
+
     EnablePreMultipliedAlpha( preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD );
   }
+  else if(synchronousLoading)
+  {
+    // Synchronous loading is failed
+    mLoadState = TextureManager::LoadState::LOAD_FAILED;
+  }
 
   if( atlasing ) // Flag needs to be set before creating renderer
   {
@@ -666,7 +679,7 @@ void ImageVisual::DoSetOnScene( Actor& actor )
     mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
   }
 
-  if( mLoading == false )
+  if(mLoadState == TextureManager::LoadState::LOAD_FINISHED)
   {
     actor.AddRenderer( mImpl->mRenderer );
     mPlacementActor.Reset();
@@ -674,6 +687,19 @@ void ImageVisual::DoSetOnScene( Actor& actor )
     // Image loaded and ready to display
     ResourceReady( Toolkit::Visual::ResourceStatus::READY );
   }
+  else if(mLoadState == TextureManager::LoadState::LOAD_FAILED)
+  {
+    Texture brokenImage = mFactoryCache.GetBrokenVisualImage();
+
+    mTextures = TextureSet::New();
+    mTextures.SetTexture(0u, brokenImage);
+    mImpl->mRenderer.SetTextures(mTextures);
+
+    actor.AddRenderer(mImpl->mRenderer);
+    mPlacementActor.Reset();
+
+    ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+  }
 }
 
 void ImageVisual::DoSetOffScene( Actor& actor )
@@ -686,9 +712,10 @@ void ImageVisual::DoSetOffScene( Actor& actor )
   {
     RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
     mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+    mLoadState = TextureManager::LoadState::NOT_STARTED;
   }
 
-  mLoading = false;
   mImpl->mRenderer.Reset();
   mPlacementActor.Reset();
 }
@@ -791,9 +818,10 @@ void ImageVisual::UploadCompleted()
     // reset the weak handle so that the renderer only get added to actor once
     mPlacementActor.Reset();
   }
+
   // Image loaded
   ResourceReady( Toolkit::Visual::ResourceStatus::READY );
-  mLoading = false;
+  mLoadState = TextureManager::LoadState::LOAD_FINISHED;
 }
 
 // From Texture Manager
@@ -844,10 +872,12 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur
   if( loadingSuccess )
   {
     resourceStatus = Toolkit::Visual::ResourceStatus::READY;
+    mLoadState     = TextureManager::LoadState::LOAD_FINISHED;
   }
   else
   {
     resourceStatus = Toolkit::Visual::ResourceStatus::FAILED;
+    mLoadState     = TextureManager::LoadState::LOAD_FAILED;
   }
 
   // use geometry if needed
@@ -882,7 +912,6 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur
 
   // Signal to observers ( control ) that resources are ready. Must be all resources.
   ResourceReady( resourceStatus );
-  mLoading = false;
 }
 
 void ImageVisual::RemoveTexture()
index 9ae50df..fb1a529 100644 (file)
@@ -350,13 +350,11 @@ private:
   Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
   Vector4 mAtlasRect;
   Dali::ImageDimensions mAtlasRectSize;
+  TextureManager::LoadState                       mLoadState;       ///< The texture loading state
   bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
-  bool mLoading;  ///< True if the texture is still loading.
   bool mOrientationCorrection; ///< true if the image will have it's orientation corrected.
 };
 
-
-
 } // namespace Internal
 
 } // namespace Toolkit
index 4d6a4cd..f34f66c 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -94,253 +95,6 @@ DALI_ENUM_TO_STRING_TABLE_END( SHADING_MODE )
 const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
 const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
 
-//Shaders
-//If a shader requires certain textures, they must be listed in order,
-//as detailed in the TextureIndex enum documentation.
-
-//A basic shader that doesn't use textures at all.
-const char* SIMPLE_VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute highp vec3 aPosition;\n
-  attribute highp vec3 aNormal;\n
-  varying mediump vec3 vIllumination;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump mat4 uModelView;\n
-  uniform mediump mat4 uViewMatrix;\n
-  uniform mediump mat3 uNormalMatrix;
-  uniform mediump mat4 uObjectMatrix;\n
-  uniform mediump vec3 lightPosition;\n
-  uniform mediump vec2 uStageOffset;\n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform mediump vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    float scaleFactor = min( visualSize.x, visualSize.y );\n
-    vec3 originFlipY =  vec3(origin.x, -origin.y, 0.0);
-    vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
-    vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
-    return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    vec4 normalisedVertexPosition = ComputeVertexPosition();\n
-    vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-    //Illumination in Model-View space - Transform attributes and uniforms\n
-    vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
-    vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
-
-    vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
-    mvLightPosition = uViewMatrix * mvLightPosition;\n
-    vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-
-    float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );\n
-    vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
-
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-//Fragment shader corresponding to the texture-less shader.
-const char* SIMPLE_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  precision mediump float;\n
-  varying mediump vec3 vIllumination;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  uniform lowp float preMultipliedAlpha;\n
-
-  void main()\n
-  {\n
-    gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a ) * vec4( mixColor, 1.0 );\n
-  }\n
-);
-
-//Diffuse and specular illumination shader with albedo texture. Texture is index 0.
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute highp vec3 aPosition;\n
-  attribute highp vec2 aTexCoord;\n
-  attribute highp vec3 aNormal;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vIllumination;\n
-  varying mediump float vSpecular;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump mat4 uModelView;
-  uniform mediump mat4 uViewMatrix;\n
-  uniform mediump mat3 uNormalMatrix;
-  uniform mediump mat4 uObjectMatrix;\n
-  uniform mediump vec3 lightPosition;\n
-  uniform mediump vec2 uStageOffset;\n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform mediump vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    float scaleFactor = min( visualSize.x, visualSize.y );\n
-    vec3 originFlipY =  vec3(origin.x, -origin.y, 0.0);
-    vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
-    vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
-    return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
-  }\n
-
-  void main()
-  {\n
-    vec4 normalisedVertexPosition = ComputeVertexPosition();\n
-    vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-    //Illumination in Model-View space - Transform attributes and uniforms\n
-    vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
-    vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );\n
-
-    vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
-    mvLightPosition = uViewMatrix * mvLightPosition;\n
-    vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-
-    vec3 viewDirection = normalize( -mvVertexPosition.xyz );
-
-    float lightDiffuse = dot( vectorToLight, normal );\n
-    lightDiffuse = max( 0.0,lightDiffuse );\n
-    vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
-
-    vec3 reflectDirection = reflect( -vectorToLight, normal );
-    vSpecular = pow( max( dot( reflectDirection, viewDirection ), 0.0 ), 4.0 );
-
-    vTexCoord = aTexCoord;\n
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-//Fragment shader corresponding to the diffuse and specular illumination shader with albedo texture
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  precision mediump float;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vIllumination;\n
-  varying mediump float vSpecular;\n
-  uniform sampler2D sDiffuse;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  uniform lowp float preMultipliedAlpha;\n
-
-  void main()\n
-  {\n
-    vec4 texture = texture2D( sDiffuse, vTexCoord );\n
-    vec4 visualMixColor = vec4( mixColor, 1.0 );\n
-    gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb * visualMixColor.rgb + vSpecular * 0.3, texture.a * uColor.a * visualMixColor.a );\n
-  }\n
-);
-
-//Diffuse and specular illumination shader with albedo texture, normal map and gloss map shader.
-//Diffuse (albedo) texture is index 0, normal is 1, gloss is 2. They must be declared in this order.
-const char* NORMAL_MAP_VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute highp vec3 aPosition;\n
-  attribute highp vec2 aTexCoord;\n
-  attribute highp vec3 aNormal;\n
-  attribute highp vec3 aTangent;\n
-  attribute highp vec3 aBiNormal;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vLightDirection;\n
-  varying mediump vec3 vHalfVector;\n
-  uniform mediump vec3 uSize;\n
-  uniform mediump mat4 uMvpMatrix;\n
-  uniform mediump mat4 uModelView;
-  uniform mediump mat4 uViewMatrix;\n
-  uniform mediump mat3 uNormalMatrix;
-  uniform mediump mat4 uObjectMatrix;\n
-  uniform mediump vec3 lightPosition;\n
-  uniform mediump vec2 uStageOffset;\n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform mediump vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    float scaleFactor = min( visualSize.x, visualSize.y );\n
-    vec3 originFlipY =  vec3(origin.x, -origin.y, 0.0);
-    vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
-    vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
-    return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
-  }\n
-
-  void main()
-  {\n
-    vec4 normalisedVertexPosition = ComputeVertexPosition();\n
-    vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-    vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
-
-    vec3 tangent = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aTangent );
-    vec3 binormal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aBiNormal );
-    vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
-
-    vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
-    mvLightPosition = uViewMatrix * mvLightPosition;\n
-    vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-    vLightDirection.x = dot( vectorToLight, tangent );
-    vLightDirection.y = dot( vectorToLight, binormal );
-    vLightDirection.z = dot( vectorToLight, normal );
-
-    vec3 viewDirection = normalize( -mvVertexPosition.xyz );
-    vec3 halfVector = normalize( viewDirection + vectorToLight );
-    vHalfVector.x = dot( halfVector, tangent );
-    vHalfVector.y = dot( halfVector, binormal );
-    vHalfVector.z = dot( halfVector, normal );
-
-    vTexCoord = aTexCoord;\n
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-//Fragment shader corresponding to the shader that uses all textures (diffuse, normal and gloss maps)
-const char* NORMAL_MAP_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  precision mediump float;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec3 vLightDirection;\n
-  varying mediump vec3 vHalfVector;\n
-  uniform sampler2D sDiffuse;\n
-  uniform sampler2D sNormal;\n
-  uniform sampler2D sGloss;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  uniform lowp float preMultipliedAlpha;\n
-
-  void main()\n
-  {\n
-    vec4 texture = texture2D( sDiffuse, vTexCoord );\n
-    vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n
-    vec4 glossMap = texture2D( sGloss, vTexCoord );\n
-    vec4 visualMixColor = vec4( mixColor, 1.0 );\n
-
-    float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );\n
-    lightDiffuse = lightDiffuse * 0.5 + 0.5;\n
-
-    float shininess = pow ( max ( dot ( normalize( vHalfVector ), normal ), 0.0 ), 16.0 )  ;
-
-    gl_FragColor = vec4( texture.rgb * uColor.rgb * visualMixColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a * visualMixColor.a );\n
-  }\n
-);
-
 } // unnamed namespace
 
 MeshVisualPtr MeshVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
@@ -564,7 +318,7 @@ void MeshVisual::InitializeRenderer()
 void MeshVisual::SupplyEmptyGeometry()
 {
   mGeometry = Geometry::New();
-  mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+  mShader = Shader::New( SHADER_MESH_VISUAL_SIMPLE_SHADER_VERT, SHADER_MESH_VISUAL_SIMPLE_SHADER_FRAG );
   mImpl->mRenderer = Renderer::New( mGeometry, mShader );
 
   DALI_LOG_ERROR( "Initialisation error in mesh visual.\n" );
@@ -588,15 +342,15 @@ void MeshVisual::CreateShader()
 {
   if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING )
   {
-    mShader = Shader::New( NORMAL_MAP_VERTEX_SHADER, NORMAL_MAP_FRAGMENT_SHADER );
+    mShader = Shader::New( SHADER_MESH_VISUAL_NORMAL_MAP_SHADER_VERT, SHADER_MESH_VISUAL_NORMAL_MAP_SHADER_FRAG );
   }
   else if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING )
   {
-    mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+    mShader = Shader::New( SHADER_MESH_VISUAL_SHADER_VERT, SHADER_MESH_VISUAL_SHADER_FRAG );
   }
   else //Textureless
   {
-    mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+    mShader = Shader::New( SHADER_MESH_VISUAL_SIMPLE_SHADER_VERT, SHADER_MESH_VISUAL_SIMPLE_SHADER_FRAG );
   }
 
   UpdateShaderUniforms();
index 6dcf020..8bbdb09 100644 (file)
@@ -33,6 +33,7 @@
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
 #include <dali-toolkit/internal/visuals/rendering-addon.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -45,128 +46,6 @@ namespace Internal
 
 namespace
 {
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec2 vMaskTexCoord;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];\n
-  uniform mediump vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];\n
-  \n
-
-  // Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp   vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-  uniform mediump vec2 extraSize;\n
-
-  void main()\n
-  {\n
-    mediump vec2 fixedFactor  = vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );\n
-    mediump vec2 stretch      = vec2( uNinePatchFactorsX[ int( ( aPosition.x       ) * 0.5 ) ].y, uNinePatchFactorsY[ int( ( aPosition.y       ) * 0.5 ) ].y );\n
-    \n
-    mediump vec2 fixedTotal   = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );\n
-    mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );\n
-    \n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-    \n
-    mediump vec4 gridPosition = vec4( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal, 0.0, 1.0 );\n
-    mediump vec4 vertexPosition = gridPosition;\n
-    vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );\n
-    vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-    \n
-    vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );\n
-    vMaskTexCoord = gridPosition.xy / visualSize;\n
-    \n
-    gl_Position = vertexPosition;\n
-  }\n
-);
-
-const char* VERTEX_SHADER_3X3 = DALI_COMPOSE_SHADER(
-    attribute mediump vec2 aPosition;\n
-    varying mediump vec2 vTexCoord;\n
-    varying mediump vec2 vMaskTexCoord;\n
-    uniform highp   mat4 uMvpMatrix;\n
-    uniform highp   vec3 uSize;\n
-    uniform mediump vec2 uFixed[ 3 ];\n
-    uniform mediump vec2 uStretchTotal;\n
-    \n
-    //Visual size and offset
-    uniform mediump vec2 offset;\n
-    uniform highp   vec2 size;\n
-    uniform mediump vec4 offsetSizeMode;\n
-    uniform mediump vec2 origin;\n
-    uniform mediump vec2 anchorPoint;\n
-    uniform mediump vec2 extraSize;\n
-    \n
-    void main()\n
-    {\n
-      vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n
-      vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-      \n
-      mediump vec2 size         = visualSize.xy;\n
-      \n
-      mediump vec2 fixedFactor  = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y  + 1.0 ) * 0.5 ) ].y );\n
-      mediump vec2 stretch      = floor( aPosition * 0.5 );\n
-      mediump vec2 fixedTotal   = uFixed[ 2 ];\n
-      \n
-      mediump vec4 gridPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );\n
-      mediump vec4 vertexPosition = gridPosition;\n
-      vertexPosition.xy -= size * vec2( 0.5, 0.5 );\n
-      vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;\n
-      \n
-      vertexPosition = uMvpMatrix * vertexPosition;\n
-      \n
-      vTexCoord = ( fixedFactor + stretch * uStretchTotal ) / ( fixedTotal + uStretchTotal );\n
-      \n
-      vMaskTexCoord = gridPosition.xy / size;\n
-      gl_Position = vertexPosition;\n
-    }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  uniform lowp float preMultipliedAlpha;\n
-  \n
-  void main()\n
-  {\n
-    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
-  }\n
-);
-
-const char* FRAGMENT_MASK_SHADER = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  varying mediump vec2 vMaskTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform sampler2D sMask;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  uniform lowp float preMultipliedAlpha;\n
-  uniform mediump float auxiliaryImageAlpha;\n
-  \n
-  void main()\n
-  {\n
-      // Where mask image is transparent, all of background image must show through.
-      // where mask image is opaque, only mask should be shown
-      // where mask is translucent, less of background should be shown.
-      // auxiliaryImageAlpha controls how much of mask is visible
-
-      mediump vec4 color = texture2D( sTexture, vTexCoord );\n
-      mediump vec4 mask  = texture2D( sMask, vMaskTexCoord );\n
-
-      mediump vec3 mixedColor = color.rgb * mix( 1.0-mask.a, 1.0, 1.0-auxiliaryImageAlpha)
-                                + mask.rgb*mask.a * auxiliaryImageAlpha;\n
-      gl_FragColor = vec4(mixedColor,1.0) * uColor * vec4( mixColor, 1.0 );\n
-  }\n
-);
 
 /**
  * @brief Creates the geometry formed from the vertices and indices
@@ -562,8 +441,8 @@ Shader NPatchVisual::CreateShader()
   NPatchUtility::StretchRanges::SizeType xStretchCount = 0;
   NPatchUtility::StretchRanges::SizeType yStretchCount = 0;
 
-  auto fragmentShader = mAuxiliaryPixelBuffer ? FRAGMENT_MASK_SHADER
-                                              : FRAGMENT_SHADER;
+  auto fragmentShader = mAuxiliaryPixelBuffer ? SHADER_NPATCH_VISUAL_MASK_SHADER_FRAG
+                                              : SHADER_NPATCH_VISUAL_SHADER_FRAG;
   auto shaderType = mAuxiliaryPixelBuffer ? VisualFactoryCache::NINE_PATCH_MASK_SHADER
                                           : VisualFactoryCache::NINE_PATCH_SHADER;
 
@@ -582,7 +461,7 @@ Shader NPatchVisual::CreateShader()
       shader = mFactoryCache.GetShader( shaderType );
       if( DALI_UNLIKELY( !shader ) )
       {
-        shader = Shader::New( VERTEX_SHADER_3X3, fragmentShader );
+        shader = Shader::New( SHADER_NPATCH_VISUAL_3X3_SHADER_VERT, fragmentShader );
         // Only cache vanilla 9 patch shaders
         mFactoryCache.SaveShader( shaderType, shader );
       }
@@ -592,7 +471,7 @@ Shader NPatchVisual::CreateShader()
       std::stringstream vertexShader;
       vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
                    << "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
-                   << VERTEX_SHADER;
+                   << SHADER_NPATCH_VISUAL_SHADER_VERT;
 
       shader = Shader::New( vertexShader.str(), fragmentShader );
     }
@@ -611,7 +490,7 @@ Shader NPatchVisual::CreateShader()
     if( ( xStretchCount == 1 && yStretchCount == 1 ) ||
         ( xStretchCount == 0 && yStretchCount == 0 ) )
     {
-      const char* vertexShader = VERTEX_SHADER_3X3;
+      const char* vertexShader = SHADER_NPATCH_VISUAL_3X3_SHADER_VERT.data();
 
       if( !mImpl->mCustomShader->mVertexShader.empty() )
       {
@@ -624,7 +503,7 @@ Shader NPatchVisual::CreateShader()
       std::stringstream vertexShader;
       vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
                    << "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
-                   << VERTEX_SHADER;
+                   << SHADER_NPATCH_VISUAL_SHADER_VERT;
 
       shader = Shader::New( vertexShader.str(), fragmentShader, hints );
     }
index 21c9064..7ad7bf5 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -92,74 +93,6 @@ const char * const POSITION( "aPosition");
 const char * const NORMAL( "aNormal" );
 const char * const INDICES( "aIndices" );
 
-//A simple shader that applies diffuse lighting to a mono-coloured object.
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute highp   vec3 aPosition;\n
-  attribute highp   vec2 aTexCoord;\n
-  attribute highp   vec3 aNormal;\n
-  varying   mediump vec3 vIllumination;\n
-  uniform   mediump vec3 uSize;\n
-  uniform   mediump vec3 uObjectDimensions;\n
-  uniform   mediump mat4 uMvpMatrix;\n
-  uniform   mediump mat4 uModelView;\n
-  uniform   mediump mat4 uViewMatrix;\n
-  uniform   mediump mat3 uNormalMatrix;\n
-  uniform   mediump mat4 uObjectMatrix;\n
-  uniform   mediump vec3 lightPosition;\n
-  uniform   mediump vec2 uStageOffset;\n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform mediump vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    float scaleFactor = min( visualSize.x / uObjectDimensions.x, visualSize.y / uObjectDimensions.y );\n
-    vec3 originFlipY =  vec3(origin.x, -origin.y, 0.0);
-    vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
-    vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
-
-    return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    vec4 normalisedVertexPosition = ComputeVertexPosition();\n
-    vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
-    vertexPosition = uMvpMatrix * vertexPosition;\n
-
-     //Illumination in Model-View space - Transform attributes and uniforms\n
-     vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
-     vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
-
-     vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
-     mvLightPosition = uViewMatrix * mvLightPosition;\n
-     vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-
-     float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );\n
-     vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
-
-     gl_Position = vertexPosition;\n
-  }\n
-);
-
-//Very simple fragment shader that merely applies the vertex shading to the color at each fragment.
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
-  precision mediump float;\n
-  varying   mediump vec3  vIllumination;\n
-  uniform   lowp    vec4  uColor;\n
-  uniform   lowp    vec3  mixColor;\n
-  void main()\n
-  {\n
-      vec4 baseColor = vec4(mixColor, 1.0) * uColor;\n
-    gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );\n
-  }\n
-);
-
 } // unnamed namespace
 
 PrimitiveVisualPtr PrimitiveVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
@@ -478,7 +411,7 @@ void PrimitiveVisual::UpdateShaderUniforms()
 
 void PrimitiveVisual::CreateShader()
 {
-  mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+  mShader = Shader::New( SHADER_PRIMITIVE_VISUAL_SHADER_VERT, SHADER_PRIMITIVE_VISUAL_SHADER_FRAG );
   UpdateShaderUniforms();
 }
 
index 09d8de2..bce5c27 100644 (file)
@@ -141,7 +141,7 @@ void SvgVisual::DoSetOnScene( Actor& actor )
   Shader shader;
   if( !mImpl->mCustomShader )
   {
-    shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, false );
+    shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, IsRoundedCornerRequired() );
   }
   else
   {
index f8d5f53..29b18a1 100755 (executable)
@@ -41,6 +41,7 @@
 #include <dali-toolkit/internal/text/script-run.h>
 #include <dali-toolkit/internal/text/text-enumerations-impl.h>
 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -55,151 +56,6 @@ namespace
 {
 const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
 
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-  attribute mediump vec2 aPosition;\n
-  uniform highp   mat4 uMvpMatrix;\n
-  uniform highp   vec3 uSize;\n
-  uniform mediump vec4 pixelArea;\n
-
-  varying mediump vec2 vTexCoord;\n
-
-  //Visual size and offset
-  uniform mediump vec2 offset;\n
-  uniform highp   vec2 size;\n
-  uniform mediump vec4 offsetSizeMode;\n
-  uniform mediump vec2 origin;\n
-  uniform mediump vec2 anchorPoint;\n
-
-  vec4 ComputeVertexPosition()\n
-  {\n
-    vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-    vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-    return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-  }\n
-
-  void main()\n
-  {\n
-    gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-    vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uTextColorAnimatable;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    mediump float textTexture = texture2D( sTexture, vTexCoord ).r;\n
-
-    // Set the color of the text to what it is animated to.
-    gl_FragColor = uTextColorAnimatable * textTexture * uColor * vec4( mixColor, 1.0 );
-  }\n
-);
-
-const char* FRAGMENT_SHADER_MULTI_COLOR_TEXT = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-
-    gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
-  }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform sampler2D sStyle;\n
-  uniform lowp vec4 uTextColorAnimatable;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    mediump float textTexture = texture2D( sTexture, vTexCoord ).r;\n
-    mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n
-
-    // Draw the text as overlay above the style
-    gl_FragColor = ( uTextColorAnimatable * textTexture + styleTexture * ( 1.0 - uTextColorAnimatable.a * textTexture ) ) * uColor * vec4( mixColor, 1.0 );\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform sampler2D sStyle;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-    mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n
-
-    // Draw the text as overlay above the style
-    gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform sampler2D sMask;\n
-  uniform lowp vec4 uTextColorAnimatable;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-    mediump float maskTexture = texture2D( sMask, vTexCoord ).r;\n
-
-    // Set the color of non-transparent pixel in text to what it is animated to.
-    // Markup text with multiple text colors are not animated (but can be supported later on if required).
-    // Emoji color are not animated.
-    mediump float vstep = step( 0.0001, textTexture.a );\n
-    textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture );\n
-
-    // Draw the text as overlay above the style
-    gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );\n
-  }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI = DALI_COMPOSE_SHADER(
-  varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
-  uniform sampler2D sStyle;\n
-  uniform sampler2D sMask;\n
-  uniform lowp float uHasMultipleTextColors;\n
-  uniform lowp vec4 uTextColorAnimatable;\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-  \n
-  void main()\n
-  {\n
-    mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-    mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n
-    mediump float maskTexture = texture2D( sMask, vTexCoord ).r;\n
-
-    // Set the color of non-transparent pixel in text to what it is animated to.
-    // Markup text with multiple text colors are not animated (but can be supported later on if required).
-    // Emoji color are not animated.
-    mediump float vstep = step( 0.0001, textTexture.a );\n
-    textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) );\n
-
-    // Draw the text as overlay above the style
-    gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );\n
-  }\n
-);
-
 /**
  * Return Property index for the given string key
  * param[in] stringKey the string index key
@@ -929,7 +785,7 @@ Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMult
     shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT );
     if( !shader )
     {
-      shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_MULTI_COLOR_TEXT );
+      shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_MULTI_COLOR_TEXT_SHADER_FRAG );
       shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
       factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT, shader );
     }
@@ -940,7 +796,7 @@ Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMult
     shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE );
     if( !shader )
     {
-      shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE );
+      shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_MULTI_COLOR_TEXT_WITH_STYLE_SHADER_FRAG );
       shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
       factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, shader );
     }
@@ -950,7 +806,7 @@ Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMult
     shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT );
     if( !shader )
     {
-      shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT );
+      shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_SHADER_FRAG );
       shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
       factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT, shader );
     }
@@ -960,7 +816,7 @@ Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMult
     shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE );
     if( !shader )
     {
-      shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE );
+      shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_STYLE_SHADER_FRAG );
       shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
       factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE, shader );
     }
@@ -970,7 +826,7 @@ Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMult
     shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI );
     if( !shader )
     {
-      shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI );
+      shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_EMOJI_SHADER_FRAG );
       shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
       factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI, shader );
     }
@@ -980,7 +836,7 @@ Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMult
     shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI );
     if( !shader )
     {
-      shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI );
+      shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI_SHADER_FRAG );
       shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
       factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI, shader );
     }
index bcde348..1db057b 100644 (file)
@@ -132,7 +132,6 @@ TextureManager::TextureManager()
   mExternalTextures(),
   mLifecycleObservers(),
   mLoadQueue(),
-  mBrokenImageUrl(""),
   mCurrentTextureId( 0 ),
   mQueueLoadFlag(false)
 {
@@ -163,18 +162,7 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
     }
     if( !pixelBuffer )
     {
-      // use broken image
-      pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
-      PixelData pixelData;
-      if( pixelBuffer )
-      {
-        pixelData = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
-      }
-      Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelData.GetPixelFormat(),
-                                      pixelData.GetWidth(), pixelData.GetHeight() );
-      texture.Upload( pixelData );
-      textureSet = TextureSet::New();
-      textureSet.SetTexture( 0u, texture );
+      DALI_LOG_ERROR("TextureManager::LoadAnimatedImageTexture: Synchronous loading is failed\n");
     }
     else
     {
@@ -294,18 +282,7 @@ TextureSet TextureManager::LoadTexture(
     }
     if( !data )
     {
-      // use broken image
-      Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
-      if( pixelBuffer )
-      {
-        PreMultiply( pixelBuffer, preMultiplyOnLoad );
-        data = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
-      }
-      Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, data.GetPixelFormat(),
-                                      data.GetWidth(), data.GetHeight() );
-      texture.Upload( data );
-      textureSet = TextureSet::New();
-      textureSet.SetTexture( 0u, texture );
+      DALI_LOG_ERROR("TextureManager::LoadTexture: Synchronous loading is failed\n");
     }
     else
     {
@@ -1376,11 +1353,6 @@ void TextureManager::AsyncLoadingHelper::AsyncLoadComplete(uint32_t           id
   mTextureManager.AsyncLoadComplete( mLoadingInfoContainer, id, pixelBuffer );
 }
 
-void TextureManager::SetBrokenImageUrl(const std::string& brokenImageUrl)
-{
-  mBrokenImageUrl = brokenImageUrl;
-}
-
 Geometry TextureManager::GetRenderGeometry(TextureId textureId, uint32_t& frontElements, uint32_t& backElements )
 {
   return RenderingAddOn::Get().IsValid() ?
index 89a8ed0..6e17945 100644 (file)
@@ -422,12 +422,6 @@ public:
   void RemoveObserver( TextureManager::LifecycleObserver& observer );
 
   /**
-   * @brief Set an image to be used when a visual has failed to correctly render
-   * @param[in] brokenImageUrl The broken image url.
-   */
-  void SetBrokenImageUrl(const std::string& brokenImageUrl);
-
-  /**
    * @brief Returns the geometry associated with texture.
    * @param[in] textureId Id of the texture
    * @param[out] frontElements number of front elements
@@ -897,7 +891,6 @@ private:  // Member Variables:
   std::vector< ExternalTextureInfo >            mExternalTextures;     ///< Externally provided textures
   Dali::Vector<LifecycleObserver*>              mLifecycleObservers;   ///< Lifecycle observers of texture manager
   Dali::Vector<LoadQueueElement>                mLoadQueue;            ///< Queue of textures to load after NotifyObservers
-  std::string                                   mBrokenImageUrl;       ///< Broken image url
   TextureId                                     mCurrentTextureId;     ///< The current value used for the unique Texture Id generation
   bool                                          mQueueLoadFlag;        ///< Flag that causes Load Textures to be queued.
 };
index fc962bd..67ab688 100644 (file)
@@ -242,12 +242,14 @@ void Internal::Visual::Base::Impl::CustomShader::CreatePropertyMap( Property::Ma
 }
 
 Internal::Visual::Base::Impl::Transform::Transform()
-: mOffset( 0.0f,0.0f ),
-  mSize( 1.0f,1.0f ),
-  mExtraSize( 0.0f,0.0f ),
-  mOffsetSizeMode( 0.0f,0.0f,0.0f,0.0f ),
-  mOrigin( Toolkit::Align::TOP_BEGIN ),
-  mAnchorPoint( Toolkit::Align::TOP_BEGIN )
+: mOffset(0.0f, 0.0f),
+  mSize(1.0f, 1.0f),
+  mExtraSize(0.0f, 0.0f),
+  mOffsetSizeMode(0.0f, 0.0f, 0.0f, 0.0f),
+  mOrigin(Toolkit::Align::TOP_BEGIN),
+  mAnchorPoint(Toolkit::Align::TOP_BEGIN),
+  mOffsetIndex(Property::INVALID_INDEX),
+  mSizeIndex(Property::INVALID_INDEX)
 {
 }
 
@@ -378,8 +380,8 @@ void Internal::Visual::Base::Impl::Transform::GetPropertyMap( Property::Map& map
 
 void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer renderer, Toolkit::Direction::Type direction )
 {
-  renderer.RegisterProperty( SIZE, mSize );
-  renderer.RegisterProperty( OFFSET, direction == Toolkit::Direction::LEFT_TO_RIGHT ? mOffset : mOffset * Vector2(-1.0f,1.0f));
+  mSizeIndex   = renderer.RegisterProperty(SIZE, mSize);
+  mOffsetIndex = renderer.RegisterProperty(OFFSET, direction == Toolkit::Direction::LEFT_TO_RIGHT ? mOffset : mOffset * Vector2(-1.0f, 1.0f));
   renderer.RegisterProperty( OFFSET_SIZE_MODE, mOffsetSizeMode );
   renderer.RegisterProperty( ORIGIN, PointToVector2( mOrigin, direction ) - Vector2(0.5,0.5) );
   renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) );
index a1056ac..718b5e4 100644 (file)
@@ -116,6 +116,8 @@ struct Base::Impl
     Vector4 mOffsetSizeMode;
     Toolkit::Align::Type mOrigin;
     Toolkit::Align::Type mAnchorPoint;
+    Property::Index      mOffsetIndex;
+    Property::Index      mSizeIndex;
   };
 
   Renderer        mRenderer;
index 6e04f0a..e8e984f 100755 (executable)
@@ -345,6 +345,14 @@ void Visual::Base::SetOffScene( Actor& actor )
       // Update values from Renderer
       mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
       mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
+      if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
+      {
+        mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
+      }
+      if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
+      {
+        mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
+      }
       if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
       {
         mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
@@ -365,6 +373,14 @@ void Visual::Base::CreatePropertyMap( Property::Map& map ) const
     // Update values from Renderer
     mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
     mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
+    if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
+    {
+      mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
+    }
+    if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
+    {
+      mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
+    }
     if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
     {
       mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
@@ -777,6 +793,14 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
     {
       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
     }
+    else if(key.indexKey == Toolkit::Visual::Transform::Property::OFFSET)
+    {
+      return Dali::Property(mImpl->mRenderer, OFFSET);
+    }
+    else if(key.indexKey == Toolkit::Visual::Transform::Property::SIZE)
+    {
+      return Dali::Property(mImpl->mRenderer, SIZE);
+    }
   }
   else
   {
@@ -788,6 +812,14 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
     {
       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
     }
+    else if(key.stringKey == OFFSET)
+    {
+      return Dali::Property(mImpl->mRenderer, OFFSET);
+    }
+    else if(key.stringKey == SIZE)
+    {
+      return Dali::Property(mImpl->mRenderer, SIZE);
+    }
   }
 
   // Other cases
@@ -799,8 +831,10 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
       // Register CORNER_RADIUS property
       mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
       mImpl->mRenderer.RegisterProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
-      index = mImpl->mCornerRadiusIndex;
 
+      mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+
+      index = mImpl->mCornerRadiusIndex;
       mImpl->mNeedCornerRadius = true;
 
       // Change shader
index bb6eb81..e6a0efd 100644 (file)
@@ -246,7 +246,6 @@ void VisualFactoryCache::SetBrokenImageUrl(const std::string& brokenImageUrl)
   }
 
   mAtlasManager->SetBrokenImage( mBrokenImageUrl );
-  mTextureManager.SetBrokenImageUrl( mBrokenImageUrl );
 }
 
 } // namespace Internal
index 3707465..f563fc1 100644 (file)
@@ -25,6 +25,7 @@
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 namespace Dali
 {
@@ -39,43 +40,6 @@ namespace
 {
 const char * const POSITION_ATTRIBUTE_NAME("aPosition");
 const char * const INDEX_NAME("indices");
-
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-attribute mediump vec2  aPosition;\n
-uniform   highp   mat4  uMvpMatrix;\n
-uniform   highp   vec3  uSize;\n
-\n
-
-//Visual size and offset
-uniform mediump vec2 offset;\n
-uniform highp   vec2 size;\n
-uniform mediump vec4 offsetSizeMode;\n
-uniform mediump vec2 origin;\n
-uniform mediump vec2 anchorPoint;\n
-
-vec4 ComputeVertexPosition()\n
-{\n
-  vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
-  vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
-  return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-}\n
-
-void main()\n
-{\n
-  gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-}\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(\n
-  uniform lowp vec4 uColor;\n
-  uniform lowp vec3 mixColor;\n
-\n
-void main()\n
-{\n
-  gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
-}\n
-);
-
 }
 
 WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
@@ -183,7 +147,7 @@ void WireframeVisual::InitializeRenderer()
   Shader shader = mFactoryCache.GetShader( VisualFactoryCache::WIREFRAME_SHADER );
   if( !shader )
   {
-    shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+    shader = Shader::New( SHADER_WIREFRAME_VISUAL_SHADER_VERT, SHADER_WIREFRAME_VISUAL_SHADER_FRAG );
     mFactoryCache.SaveShader( VisualFactoryCache::WIREFRAME_SHADER, shader );
   }
 
index ecbf1db..384c67e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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,7 @@ namespace Toolkit
 {
 const unsigned int TOOLKIT_MAJOR_VERSION = 2;
 const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 6;
+const unsigned int TOOLKIT_MICRO_VERSION = 11;
 const char* const  TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index bea661d..6f19efc 100644 (file)
@@ -163,7 +163,7 @@ enum Type
 {
   /**
    * @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
-   * @details Name "offset", type Property::VECTOR2.
+   * @details Name "offset", type Property::VECTOR2, animatable.
    * @SINCE_1_2.60
    *
    * @see OFFSET_POLICY
@@ -172,7 +172,7 @@ enum Type
 
   /**
    * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
-   * @details Name "size", type Property::VECTOR2.
+   * @details Name "size", type Property::VECTOR2, animatable.
    * @see SIZE_POLICY
    */
   SIZE,
index ec2879b..e7e130a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    2.0.6
+Version:    2.0.11
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT