From: Adam Bialogonski Date: Fri, 22 Jul 2022 09:28:14 +0000 (+0100) Subject: [dali_2.1.32] Merge branch 'devel/master' X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=c9838bbf5eb41f8475bcef2198b338f7020b0397;hp=020b07151378db83ab8e12eb3e2d51db0ed69996 [dali_2.1.32] Merge branch 'devel/master' Change-Id: Ifc3979c1834ac73b40b3b356ec21e9ccd9a26901 --- diff --git a/.gitignore b/.gitignore index 8fef0e8..e4e5fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -50,5 +50,5 @@ core 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 +dali-scene3d/internal/graphics/generated/* +dali-scene3d/internal/graphics/builtin-shader-extern-gen.h diff --git a/README.md b/README.md index e4cfdbc..b744509 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ * Build with the Visual Studio project. * Build with CMake. * [4. Building for MacOS](#4-building-for-macos) - * [DALi Scene Loader](#dali-scene-loader) + * [DALi Scene3D](#dali-scene3d) # Build Instructions @@ -131,6 +131,6 @@ To build, run: % make install -j8 ``` -# DALi Scene Loader +# DALi Scene3D -For information about the DALi Scene Loader library, refer to dali-scene-loader/README.md. +For information about the DALi Scene3D library, refer to dali-scene3d/README.md. diff --git a/automated-tests/patch-coverage.pl b/automated-tests/patch-coverage.pl index 1f836a4..2f8bdb4 100755 --- a/automated-tests/patch-coverage.pl +++ b/automated-tests/patch-coverage.pl @@ -985,7 +985,7 @@ sub parse_diff $files{$file}->{"patch"} = [@checklines]; $files{$file}->{"b_lines"} = {%b_lines}; - my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit|-scene-loader)?/!} (keys(%files)); + my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit|-scene3d)?/!} (keys(%files)); if($pd_debug) { diff --git a/automated-tests/resources/animationTest.gltf b/automated-tests/resources/animationTest.gltf new file mode 100644 index 0000000..6c7b12c --- /dev/null +++ b/automated-tests/resources/animationTest.gltf @@ -0,0 +1,1419 @@ +{ + "accessors" : [ + { + "bufferView" : 0, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 1, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 2, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 3, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 4, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 5, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 6, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 7, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 8, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 9, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 10, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 11, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 12, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 13, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 14, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 15, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 16, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 17, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 18, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 19, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 20, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 21, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 22, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 23, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 24, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 25, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 26, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 27, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 28, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 29, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 30, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 31, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 32, + "componentType" : 5126, + "count" : 24, + "max" : [ + 1, + 1, + 1 + ], + "min" : [ + -1, + -1, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 33, + "componentType" : 5126, + "count" : 24, + "type" : "VEC3" + }, + { + "bufferView" : 34, + "componentType" : 5126, + "count" : 24, + "type" : "VEC2" + }, + { + "bufferView" : 35, + "componentType" : 5121, + "count" : 36, + "type" : "SCALAR" + }, + { + "bufferView" : 36, + "componentType" : 5126, + "count" : 4, + "max" : [ + 1, + 0, + 1 + ], + "min" : [ + -1, + 0, + -1 + ], + "type" : "VEC3" + }, + { + "bufferView" : 37, + "componentType" : 5126, + "count" : 4, + "type" : "VEC3" + }, + { + "bufferView" : 38, + "componentType" : 5126, + "count" : 4, + "type" : "VEC2" + }, + { + "bufferView" : 39, + "componentType" : 5121, + "count" : 6, + "type" : "SCALAR" + }, + { + "bufferView" : 40, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.6666666666666667 + ], + "min" : [ + 0.041666666666666664 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 41, + "componentType" : 5126, + "count" : 5, + "type" : "VEC3" + }, + { + "bufferView" : 42, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.6666666666666667 + ], + "min" : [ + 0.041666666666666664 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 43, + "componentType" : 5126, + "count" : 15, + "type" : "VEC3" + }, + { + "bufferView" : 44, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.6666666666666667 + ], + "min" : [ + 0.041666666666666664 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 45, + "componentType" : 5126, + "count" : 15, + "type" : "VEC3" + }, + { + "bufferView" : 46, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.7083333333333333 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 47, + "componentType" : 5126, + "count" : 5, + "type" : "VEC4" + }, + { + "bufferView" : 48, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.7083333333333333 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 49, + "componentType" : 5126, + "count" : 15, + "type" : "VEC4" + }, + { + "bufferView" : 50, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.7083333333333333 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 51, + "componentType" : 5126, + "count" : 5, + "type" : "VEC4" + }, + { + "bufferView" : 52, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.7083333333333333 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 53, + "componentType" : 5126, + "count" : 5, + "type" : "VEC3" + }, + { + "bufferView" : 54, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.6666666666666667 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 55, + "componentType" : 5126, + "count" : 15, + "type" : "VEC3" + }, + { + "bufferView" : 56, + "componentType" : 5126, + "count" : 5, + "max" : [ + 1.6666666666666667 + ], + "min" : [ + 0 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 57, + "componentType" : 5126, + "count" : 5, + "type" : "VEC3" + } + ], + "animations" : [ + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 0, + "path" : "scale" + } + } + ], + "name" : "Step Scale", + "samplers" : [ + { + "input" : 40, + "interpolation" : "STEP", + "output" : 41 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 3, + "path" : "scale" + } + } + ], + "name" : "Linear Scale", + "samplers" : [ + { + "input" : 40, + "interpolation" : "LINEAR", + "output" : 41 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 4, + "path" : "scale" + } + } + ], + "name" : "CubicSpline Scale", + "samplers" : [ + { + "input" : 44, + "interpolation" : "CUBICSPLINE", + "output" : 45 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 5, + "path" : "rotation" + } + } + ], + "name" : "Step Rotation", + "samplers" : [ + { + "input" : 46, + "interpolation" : "STEP", + "output" : 47 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 6, + "path" : "rotation" + } + } + ], + "name" : "CubicSpline Rotation", + "samplers" : [ + { + "input" : 48, + "interpolation" : "CUBICSPLINE", + "output" : 49 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 7, + "path" : "rotation" + } + } + ], + "name" : "Linear Rotation", + "samplers" : [ + { + "input" : 50, + "interpolation" : "LINEAR", + "output" : 51 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 8, + "path" : "translation" + } + } + ], + "name" : "Step Translation", + "samplers" : [ + { + "input" : 52, + "interpolation" : "STEP", + "output" : 53 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 9, + "path" : "translation" + } + } + ], + "name" : "CubicSpline Translation", + "samplers" : [ + { + "input" : 54, + "interpolation" : "CUBICSPLINE", + "output" : 55 + } + ] + }, + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 10, + "path" : "translation" + } + } + ], + "name" : "Linear Translation", + "samplers" : [ + { + "input" : 56, + "interpolation" : "LINEAR", + "output" : 57 + } + ] + } + ], + "asset" : { + "generator" : "Khronos Blender glTF 2.0 I/O", + "version" : "2.0" + }, + "bufferViews" : [ + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 0 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 288 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 576 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 768 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 804 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 1092 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 1380 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 1572 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 1608 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 1896 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 2184 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 2376 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 2412 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 2700 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 2988 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 3180 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 3216 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 3504 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 3792 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 3984 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 4020 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 4308 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 4596 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 4788 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 4824 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 5112 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 5400 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 5592 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 5628 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 5916 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 6204 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 6396 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 6432 + }, + { + "buffer" : 0, + "byteLength" : 288, + "byteOffset" : 6720 + }, + { + "buffer" : 0, + "byteLength" : 192, + "byteOffset" : 7008 + }, + { + "buffer" : 0, + "byteLength" : 36, + "byteOffset" : 7200 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 7236 + }, + { + "buffer" : 0, + "byteLength" : 48, + "byteOffset" : 7284 + }, + { + "buffer" : 0, + "byteLength" : 32, + "byteOffset" : 7332 + }, + { + "buffer" : 0, + "byteLength" : 6, + "byteOffset" : 7364 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 7372 + }, + { + "buffer" : 0, + "byteLength" : 60, + "byteOffset" : 7392 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 7452 + }, + { + "buffer" : 0, + "byteLength" : 180, + "byteOffset" : 7472 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 7652 + }, + { + "buffer" : 0, + "byteLength" : 180, + "byteOffset" : 7672 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 7852 + }, + { + "buffer" : 0, + "byteLength" : 80, + "byteOffset" : 7872 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 7952 + }, + { + "buffer" : 0, + "byteLength" : 240, + "byteOffset" : 7972 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 8212 + }, + { + "buffer" : 0, + "byteLength" : 80, + "byteOffset" : 8232 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 8312 + }, + { + "buffer" : 0, + "byteLength" : 60, + "byteOffset" : 8332 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 8392 + }, + { + "buffer" : 0, + "byteLength" : 180, + "byteOffset" : 8412 + }, + { + "buffer" : 0, + "byteLength" : 20, + "byteOffset" : 8592 + }, + { + "buffer" : 0, + "byteLength" : 60, + "byteOffset" : 8612 + } + ], + "buffers" : [ + { + "byteLength" : 8672, + "uri" : "interpolation.bin" + } + ], + "extensions" : {}, + "images" : [ + { + "mimeType" : "image/jpeg", + "name" : "l.jpg", + "uri" : "l.jpg" + } + ], + "materials" : [ + { + "name" : "Material", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.001", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.002", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.007", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.006", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.008", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.004", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.005", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.003", + "pbrMetallicRoughness" : { + "baseColorFactor" : [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1 + ], + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + }, + { + "name" : "Material.009", + "pbrMetallicRoughness" : { + "baseColorTexture" : { + "index" : 0, + "texCoord" : 0 + }, + "metallicFactor" : 0, + "roughnessFactor" : 0.5 + } + } + ], + "meshes" : [ + { + "name" : "Cube", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 1, + "POSITION" : 0, + "TEXCOORD_0" : 2 + }, + "material" : 0 + } + ] + }, + { + "name" : "Cube.001", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 5, + "POSITION" : 4, + "TEXCOORD_0" : 6 + }, + "material" : 1 + } + ] + }, + { + "name" : "Cube.002", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 9, + "POSITION" : 8, + "TEXCOORD_0" : 10 + }, + "material" : 2 + } + ] + }, + { + "name" : "Cube.003", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 13, + "POSITION" : 12, + "TEXCOORD_0" : 14 + }, + "material" : 3 + } + ] + }, + { + "name" : "Cube.004", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 17, + "POSITION" : 16, + "TEXCOORD_0" : 18 + }, + "material" : 4 + } + ] + }, + { + "name" : "Cube.005", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 21, + "POSITION" : 20, + "TEXCOORD_0" : 22 + }, + "material" : 5 + } + ] + }, + { + "name" : "Cube.006", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 25, + "POSITION" : 24, + "TEXCOORD_0" : 26 + }, + "material" : 6 + } + ] + }, + { + "name" : "Cube.008", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 29, + "POSITION" : 28, + "TEXCOORD_0" : 30 + }, + "material" : 7 + } + ] + }, + { + "name" : "Cube.009", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 33, + "POSITION" : 32, + "TEXCOORD_0" : 34 + }, + "material" : 8 + } + ] + }, + { + "name" : "Plane.001", + "primitives" : [ + { + "attributes" : { + "NORMAL" : 37, + "POSITION" : 36, + "TEXCOORD_0" : 38 + }, + "material" : 9 + } + ] + } + ], + "nodes" : [ + { + "name" : "Cube" + }, + { + "name" : "Light", + "rotation" : [ + 0.16907575726509094, + 0.7558802962303162, + -0.27217137813568115, + 0.570947527885437 + ], + "scale" : [ + 1, + 1, + 0.9999999403953552 + ], + "translation" : [ + 0.18540644645690918, + 5.903861999511719, + 8.732584953308105 + ] + }, + { + "name" : "Camera", + "rotation" : [ + 0.6819981932640076, + 0, + 0, + 0.7313538193702698 + ], + "scale" : [ + 1, + 0.39365354180336, + 1 + ], + "translation" : [ + 0.31374117732048035, + 4.958309173583984, + 29.236623764038086 + ] + }, + { + "name" : "Cube.001", + "translation" : [ + -3.2963297367095947, + 0, + 6.461143493652344e-05 + ] + }, + { + "name" : "Cube.002", + "translation" : [ + 3.3401193618774414, + 0, + 0.008944988250732422 + ] + }, + { + "name" : "Cube.003", + "translation" : [ + 0, + 3.356412410736084, + 0 + ] + }, + { + "name" : "Cube.004", + "rotation" : [ + 0, + 0, + -0.006683696992695332, + 0.9999777674674988 + ], + "translation" : [ + 3.33506178855896, + 3.356412410736084, + 0 + ] + }, + { + "name" : "Cube.005", + "rotation" : [ + 0, + 0, + -0.03925982117652893, + 0.9992290735244751 + ], + "scale" : [ + 0.9999999403953552, + 0.9999999403953552, + 1 + ], + "translation" : [ + -3.311399221420288, + 3.356412410736084, + 0 + ] + }, + { + "name" : "Cube.006", + "translation" : [ + 0, + 6.665226459503174, + 0 + ] + }, + { + "name" : "Cube.008", + "translation" : [ + 3.3051798343658447, + 6.734194278717041, + 0 + ] + }, + { + "name" : "Cube.009", + "translation" : [ + -3.2975807189941406, + 6.958913326263428, + 0 + ] + }, + { + "name" : "Plane", + "rotation" : [ + 0.7071068286895752, + 0, + 0, + 0.7071068286895752 + ], + "scale" : [ + 4.218648433685303, + 1, + 0.3652837574481964 + ], + "translation" : [ + 0, + -1.7941787242889404, + 1.0036747455596924 + ] + } + ], + "scene" : 0, + "scenes" : [ + { + "name" : "Scene", + "nodes" : [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ] + } + ], + "textures" : [ + { + "source" : 0 + } + ] +} diff --git a/automated-tests/resources/beer.bin b/automated-tests/resources/beer.bin new file mode 100644 index 0000000..08571fd Binary files /dev/null and b/automated-tests/resources/beer.bin differ diff --git a/automated-tests/resources/beer_modelViewTest.dli b/automated-tests/resources/beer_modelViewTest.dli new file mode 100644 index 0000000..20be585 --- /dev/null +++ b/automated-tests/resources/beer_modelViewTest.dli @@ -0,0 +1,181 @@ +{ + "asset": { "version": "1.0" }, + "scene": 0, + "scenes": [ { "nodes": [ 0 ] } ], + "nodes": [ + { + "name": "Scene", + "matrix": [ 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1 ], + "children": [ 1, 2 ] + }, + { + "name": "Cube", + "matrix": [ 2.5, 0, 0, 0, 0, 2.5, 0, 0, 0, 0, 2.5, 0, 0, 0, 0, 1 ], + "model": { + "mesh": 0, + "material": 0, + "shader": 0 + } + }, + { + "name": "bottle", + "matrix": [ 0.125, 0, 0, 0, 0, -0, 0.125, 0, 0, -0.125, -0, 0, -0, 0, -1.5, 1 ], + "children": [ 3, 4, 5, 6 ] + }, + { + "name": "bottle-cap", + "model": { + "mesh": 3, + "material": 2, + "shader": 1 + } + }, + { + "name": "bottle-alpha-front", + "model": { + "mesh": 1, + "material": 1, + "shader": 2 + } + }, + { + "name": "bottle-alpha-back", + "model": { + "mesh": 1, + "material": 1, + "shader": 3 + } + }, + { + "name": "bottle-label", + "model": { + "mesh": 2, + "material": 0, + "shader": 4 + } + } + ], + "meshes": [ + { + "uri": "cube.bin", + "attributes": 31, + "primitive": "TRIANGLES", + "indices": { "byteOffset": 0, "byteLength": 72 }, + "positions": { "byteOffset": 72, "byteLength": 288 }, + "normals": { "byteOffset": 360, "byteLength": 288 }, + "textures": { "byteOffset": 648, "byteLength": 192 }, + "tangents": { "byteOffset": 840, "byteLength": 288 } + }, + { + "uri": "beer.bin", + "attributes": 31, + "primitive": "TRIANGLES", + "indices": { "byteOffset": 0, "byteLength": 19920 }, + "positions": { "byteOffset": 19920, "byteLength": 54792 }, + "normals": { "byteOffset": 74712, "byteLength": 54792 }, + "textures": { "byteOffset": 129504, "byteLength": 36528 }, + "tangents": { "byteOffset": 166032, "byteLength": 54792 } + }, + { + "uri": "beer.bin", + "attributes": 31, + "primitive": "TRIANGLES", + "indices": { "byteOffset": 220824, "byteLength": 13200 }, + "positions": { "byteOffset": 234024, "byteLength": 14628 }, + "normals": { "byteOffset": 248652, "byteLength": 14628 }, + "textures": { "byteOffset": 263280, "byteLength": 9752 }, + "tangents": { "byteOffset": 273032, "byteLength": 14628 } + }, + { + "uri": "beer.bin", + "attributes": 31, + "primitive": "TRIANGLES", + "indices": { "byteOffset": 287660, "byteLength": 31440 }, + "positions": { "byteOffset": 319100, "byteLength": 121032 }, + "normals": { "byteOffset": 440132, "byteLength": 121032 }, + "textures": { "byteOffset": 561164, "byteLength": 80688 }, + "tangents": { "byteOffset": 641852, "byteLength": 121032 } + } + ], + "skeletons": [ + ], + "cameras": [ + { + "fov": 60, + "near": 0.1, + "far": 100, + "matrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 3.5, 1 ] + } + ], + "lights": [ + ], + "materials": [ + { + "color": [ 1.0, 0.95, 0.5 ], + "metallic": 0.25, + "roughness": 1.0, + "environment": 1 + }, + { + "color": [ 0.1, 0.4, 0.0, 0.6 ], + "metallic": 0.4, + "roughness": 0.0, + "environment": 1 + }, + { + "color": [ 0.5, 0.5, 0.5 ], + "metallic": 1.0, + "roughness": 0.0, + "environment": 1 + } + ], + "environment": [ + { + }, + { + "cubeSpecular": "Studio/Radiance.ktx", + "cubeDiffuse": "Studio/Irradiance.ktx", + "iblIntensity": 0.75 + } + ], + "shaders": [ + { + "vertex": "dli_pbr.vsh", + "fragment": "dli_pbr.fsh", + "rendererState": "DEPTH_TEST|CULL_FRONT", + "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], + "uMaxLOD": 6 + }, + { + "vertex": "dli_pbr.vsh", + "fragment": "dli_pbr.fsh", + "rendererState": "DEPTH_TEST|DEPTH_WRITE", + "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], + "uMaxLOD": 6 + }, + { + "vertex": "dli_pbr.vsh", + "fragment": "dli_pbr.fsh", + "defines": [ "THREE_TEX" ], + "rendererState": "ALPHA_BLEND|DEPTH_TEST|CULL_FRONT", + "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], + "uMaxLOD": 6 + }, + { + "vertex": "dli_pbr.vsh", + "fragment": "dli_pbr.fsh", + "defines": [ "THREE_TEX" ], + "rendererState": "ALPHA_BLEND|DEPTH_TEST|CULL_BACK", + "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], + "uMaxLOD": 6 + }, + { + "vertex": "dli_pbr.vsh", + "fragment": "dli_pbr.fsh", + "defines": [ "FLIP_V" ], + "rendererState": "DEPTH_TEST|DEPTH_WRITE|CULL_BACK", + "uCubeMatrix": [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ], + "uMaxLOD": 6 + } + ] +} diff --git a/automated-tests/resources/cube.bin b/automated-tests/resources/cube.bin new file mode 100644 index 0000000..f5bd426 Binary files /dev/null and b/automated-tests/resources/cube.bin differ diff --git a/automated-tests/resources/cubemap_array_horizontal.png b/automated-tests/resources/cubemap_array_horizontal.png new file mode 100644 index 0000000..a935915 Binary files /dev/null and b/automated-tests/resources/cubemap_array_horizontal.png differ diff --git a/automated-tests/resources/cubemap_array_vertical.png b/automated-tests/resources/cubemap_array_vertical.png new file mode 100644 index 0000000..d6bf296 Binary files /dev/null and b/automated-tests/resources/cubemap_array_vertical.png differ diff --git a/automated-tests/resources/forest_diffuse_cubemap_cross_vertical.png b/automated-tests/resources/forest_diffuse_cubemap_cross_vertical.png new file mode 100644 index 0000000..6e6bf0f Binary files /dev/null and b/automated-tests/resources/forest_diffuse_cubemap_cross_vertical.png differ diff --git a/automated-tests/resources/test.bvh b/automated-tests/resources/test.bvh new file mode 100644 index 0000000..28bd0da --- /dev/null +++ b/automated-tests/resources/test.bvh @@ -0,0 +1,20 @@ +HIERARCHY +ROOT root +{ + OFFSET 0.0 -0.948831 1.32574 + CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation + JOINT first + { + OFFSET -0.0 4.130377 -0.008512 + CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation + End Site + { + OFFSET 0 0 0 + } + } +} +MOTION +Frames: 2 +Frame Time: 0.3 +0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 +0.0 10.0 0.0 0.0 0.0 0.0 10.0 0.0 0.0 90.0 0.0 0.0 \ No newline at end of file diff --git a/automated-tests/src/dali-scene-loader-internal/CMakeLists.txt b/automated-tests/src/dali-scene3d-internal/CMakeLists.txt similarity index 97% rename from automated-tests/src/dali-scene-loader-internal/CMakeLists.txt rename to automated-tests/src/dali-scene3d-internal/CMakeLists.txt index 0270d3d..4b454c9 100755 --- a/automated-tests/src/dali-scene-loader-internal/CMakeLists.txt +++ b/automated-tests/src/dali-scene3d-internal/CMakeLists.txt @@ -1,9 +1,9 @@ -SET(PKG_NAME "dali-scene-loader-internal") +SET(PKG_NAME "dali-scene3d-internal") SET(EXEC_NAME "tct-${PKG_NAME}-core") SET(RPM_NAME "core-${PKG_NAME}-tests") -SET(CAPI_LIB "dali-scene-loader") +SET(CAPI_LIB "dali-scene3d") # List of test case sources (Only these get parsed for test cases) SET(TC_SOURCES @@ -63,7 +63,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED dali2-core dali2-adaptor dali2-toolkit - dali2-scene-loader + dali2-scene3d ) ADD_COMPILE_OPTIONS( -O0 -ggdb --coverage -Wall -Werror -DDEBUG_ENABLED) diff --git a/automated-tests/src/dali-scene-loader-internal/tct-dali-scene-loader-internal-core.cpp b/automated-tests/src/dali-scene3d-internal/tct-dali-scene3d-internal-core.cpp similarity index 71% rename from automated-tests/src/dali-scene-loader-internal/tct-dali-scene-loader-internal-core.cpp rename to automated-tests/src/dali-scene3d-internal/tct-dali-scene3d-internal-core.cpp index 7bfea6e..c5ed18f 100644 --- a/automated-tests/src/dali-scene-loader-internal/tct-dali-scene-loader-internal-core.cpp +++ b/automated-tests/src/dali-scene3d-internal/tct-dali-scene3d-internal-core.cpp @@ -1,5 +1,5 @@ #include -#include "tct-dali-scene-loader-internal-core.h" +#include "tct-dali-scene3d-internal-core.h" int main(int argc, char * const argv[]) { diff --git a/automated-tests/src/dali-scene-loader-internal/utc-Dali-Gltf2Asset.cpp b/automated-tests/src/dali-scene3d-internal/utc-Dali-Gltf2Asset.cpp similarity index 98% rename from automated-tests/src/dali-scene-loader-internal/utc-Dali-Gltf2Asset.cpp rename to automated-tests/src/dali-scene3d-internal/utc-Dali-Gltf2Asset.cpp index 8574137..9b01631 100644 --- a/automated-tests/src/dali-scene-loader-internal/utc-Dali-Gltf2Asset.cpp +++ b/automated-tests/src/dali-scene3d-internal/utc-Dali-Gltf2Asset.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/internal/gltf2-asset.h" +#include "dali-scene3d/internal/loader/gltf2-asset.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliGltf2AssetComponentIsUnsigned(void) { diff --git a/automated-tests/src/dali-scene-loader-internal/utc-Dali-Hash.cpp b/automated-tests/src/dali-scene3d-internal/utc-Dali-Hash.cpp similarity index 94% rename from automated-tests/src/dali-scene-loader-internal/utc-Dali-Hash.cpp rename to automated-tests/src/dali-scene3d-internal/utc-Dali-Hash.cpp index efd5053..74aa2c5 100644 --- a/automated-tests/src/dali-scene-loader-internal/utc-Dali-Hash.cpp +++ b/automated-tests/src/dali-scene3d-internal/utc-Dali-Hash.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/internal/hash.h" +#include "dali-scene3d/internal/loader/hash.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliHash(void) { diff --git a/automated-tests/src/dali-scene-loader-internal/utc-Dali-JsonReader.cpp b/automated-tests/src/dali-scene3d-internal/utc-Dali-JsonReader.cpp similarity index 97% rename from automated-tests/src/dali-scene-loader-internal/utc-Dali-JsonReader.cpp rename to automated-tests/src/dali-scene3d-internal/utc-Dali-JsonReader.cpp index 6b7e000..abeb99c 100644 --- a/automated-tests/src/dali-scene-loader-internal/utc-Dali-JsonReader.cpp +++ b/automated-tests/src/dali-scene3d-internal/utc-Dali-JsonReader.cpp @@ -18,7 +18,7 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/internal/json-reader.h" +#include "dali-scene3d/internal/loader/json-reader.h" #include #include diff --git a/automated-tests/src/dali-scene-loader-internal/utc-Dali-JsonUtil.cpp b/automated-tests/src/dali-scene3d-internal/utc-Dali-JsonUtil.cpp similarity index 99% rename from automated-tests/src/dali-scene-loader-internal/utc-Dali-JsonUtil.cpp rename to automated-tests/src/dali-scene3d-internal/utc-Dali-JsonUtil.cpp index 41ac039..b9f25be 100644 --- a/automated-tests/src/dali-scene-loader-internal/utc-Dali-JsonUtil.cpp +++ b/automated-tests/src/dali-scene3d-internal/utc-Dali-JsonUtil.cpp @@ -18,7 +18,7 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/internal/json-util.h" +#include "dali-scene3d/internal/loader/json-util.h" #include "dali-toolkit/devel-api/builder/json-parser.h" #include #include @@ -27,7 +27,7 @@ using namespace Dali; using namespace Dali::Toolkit; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { diff --git a/automated-tests/src/dali-scene-loader/CMakeLists.txt b/automated-tests/src/dali-scene3d/CMakeLists.txt similarity index 95% rename from automated-tests/src/dali-scene-loader/CMakeLists.txt rename to automated-tests/src/dali-scene3d/CMakeLists.txt index 8e700d8..d86c377 100755 --- a/automated-tests/src/dali-scene-loader/CMakeLists.txt +++ b/automated-tests/src/dali-scene3d/CMakeLists.txt @@ -1,21 +1,25 @@ -SET(PKG_NAME "dali-scene-loader") +SET(PKG_NAME "dali-scene3d") SET(EXEC_NAME "tct-${PKG_NAME}-core") SET(RPM_NAME "core-${PKG_NAME}-tests") -SET(CAPI_LIB "dali-scene-loader") +SET(CAPI_LIB "dali-scene3d") # List of test case sources (Only these get parsed for test cases) SET(TC_SOURCES utc-Dali-AlphaFunctionHelper.cpp utc-Dali-AnimationDefinition.cpp utc-Dali-AnimatedProperty.cpp + utc-Dali-BvhLoader.cpp utc-Dali-CameraParameters.cpp + utc-Dali-CubeLoader.cpp + utc-Dali-CubeMapLoader.cpp utc-Dali-DliLoader.cpp utc-Dali-EnvironmentDefinition.cpp utc-Dali-FacialAnimation.cpp utc-Dali-Gltf2Loader.cpp utc-Dali-KtxLoader.cpp + utc-Dali-ModelView.cpp utc-Dali-MatrixStack.cpp utc-Dali-MeshDefinition.cpp utc-Dali-NodeDefinition.cpp @@ -79,7 +83,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED dali2-core dali2-adaptor dali2-toolkit - dali2-scene-loader + dali2-scene3d ) ADD_COMPILE_OPTIONS( -O0 -ggdb --coverage -Wall -Werror -DDEBUG_ENABLED) diff --git a/automated-tests/src/dali-scene-loader/tct-dali-scene-loader-core.cpp b/automated-tests/src/dali-scene3d/tct-dali-scene3d-core.cpp similarity index 75% rename from automated-tests/src/dali-scene-loader/tct-dali-scene-loader-core.cpp rename to automated-tests/src/dali-scene3d/tct-dali-scene3d-core.cpp index 5b79502..3a43985 100644 --- a/automated-tests/src/dali-scene-loader/tct-dali-scene-loader-core.cpp +++ b/automated-tests/src/dali-scene3d/tct-dali-scene3d-core.cpp @@ -1,5 +1,5 @@ #include -#include "tct-dali-scene-loader-core.h" +#include "tct-dali-scene3d-core.h" int main(int argc, char * const argv[]) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-AlphaFunctionHelper.cpp b/automated-tests/src/dali-scene3d/utc-Dali-AlphaFunctionHelper.cpp similarity index 95% rename from automated-tests/src/dali-scene-loader/utc-Dali-AlphaFunctionHelper.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-AlphaFunctionHelper.cpp index da40b27..53de7d2 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-AlphaFunctionHelper.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-AlphaFunctionHelper.cpp @@ -18,11 +18,11 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/alpha-function-helper.h" +#include "dali-scene3d/public-api/loader/alpha-function-helper.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; #define ALPHA_FN_PAIR(x) { #x, AlphaFunction::x } diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-AnimatedProperty.cpp b/automated-tests/src/dali-scene3d/utc-Dali-AnimatedProperty.cpp similarity index 93% rename from automated-tests/src/dali-scene-loader/utc-Dali-AnimatedProperty.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-AnimatedProperty.cpp index c660a1d..0a59e26 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-AnimatedProperty.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-AnimatedProperty.cpp @@ -18,11 +18,11 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/animated-property.h" +#include "dali-scene3d/public-api/loader/animated-property.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliAnimatedPropertyGetPropertyType(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-AnimationDefinition.cpp b/automated-tests/src/dali-scene3d/utc-Dali-AnimationDefinition.cpp similarity index 96% rename from automated-tests/src/dali-scene-loader/utc-Dali-AnimationDefinition.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-AnimationDefinition.cpp index e27fb36..5cde1b9 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-AnimationDefinition.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-AnimationDefinition.cpp @@ -18,11 +18,11 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/animation-definition.h" +#include "dali-scene3d/public-api/loader/animation-definition.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliAnimationDefinitionStopForModification(void) { diff --git a/automated-tests/src/dali-scene3d/utc-Dali-BvhLoader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-BvhLoader.cpp new file mode 100644 index 0000000..91fdb19 --- /dev/null +++ b/automated-tests/src/dali-scene3d/utc-Dali-BvhLoader.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +using namespace Dali; +using namespace Dali::Scene3D::Loader; + +int UtcDaliLoadBvh(void) +{ + TestApplication application; + + AnimationDefinition animDef = LoadBvh(TEST_RESOURCE_DIR "/test.bvh", "testBvh"); + + DALI_TEST_EQUAL(animDef.mName, "testBvh"); + DALI_TEST_EQUAL(animDef.mDuration, 0.3f); + + DALI_TEST_EQUAL(animDef.mProperties[0].mNodeName, "root"); + DALI_TEST_EQUAL(animDef.mProperties[0].mPropertyName, "position"); + DALI_TEST_EQUAL(animDef.mProperties[0].mKeyFrames.GetType(), Property::Type::VECTOR3); + DALI_TEST_EQUAL(animDef.mProperties[0].mTimePeriod.durationSeconds, 0.3f); + + DALI_TEST_EQUAL(animDef.mProperties[1].mNodeName, "root"); + DALI_TEST_EQUAL(animDef.mProperties[1].mPropertyName, "orientation"); + DALI_TEST_EQUAL(animDef.mProperties[1].mKeyFrames.GetType(), Property::Type::ROTATION); + DALI_TEST_EQUAL(animDef.mProperties[1].mTimePeriod.durationSeconds, 0.3f); + + DALI_TEST_EQUAL(animDef.mProperties[2].mNodeName, "first"); + DALI_TEST_EQUAL(animDef.mProperties[2].mPropertyName, "position"); + DALI_TEST_EQUAL(animDef.mProperties[2].mKeyFrames.GetType(), Property::Type::VECTOR3); + DALI_TEST_EQUAL(animDef.mProperties[2].mTimePeriod.durationSeconds, 0.3f); + + DALI_TEST_EQUAL(animDef.mProperties[3].mNodeName, "first"); + DALI_TEST_EQUAL(animDef.mProperties[3].mPropertyName, "orientation"); + DALI_TEST_EQUAL(animDef.mProperties[3].mKeyFrames.GetType(), Property::Type::ROTATION); + DALI_TEST_EQUAL(animDef.mProperties[3].mTimePeriod.durationSeconds, 0.3f); + + Actor root = Actor::New(); + root.SetProperty(Actor::Property::NAME, "root"); + + Actor first = Actor::New(); + first.SetProperty(Actor::Property::NAME, "first"); + root.Add(first); + + auto getActor = [&root](const std::string& name) { + return root.FindChildByName(name); + }; + + Animation animation = animDef.ReAnimate(getActor); + DALI_TEST_EQUAL(animation.GetDuration(), animDef.mDuration); + + application.GetScene().Add(root); + + application.SendNotification(); + application.Render(20); + + DALI_TEST_EQUALS(Vector2(0, 0), root.GetProperty(Actor::Property::POSITION), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(0, 0), first.GetProperty(Actor::Property::POSITION), TEST_LOCATION); + Vector3 rootWorldPositionBefore = root.GetProperty(Actor::Property::WORLD_POSITION); + Vector3 firstWorldPositionBefore = first.GetProperty(Actor::Property::WORLD_POSITION); + + animation.Play(); + + application.SendNotification(); + application.Render(1000); + + DALI_TEST_EQUALS(Vector2(0, 10), root.GetProperty(Actor::Property::POSITION), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(10, 0), first.GetProperty(Actor::Property::POSITION), TEST_LOCATION); + + Vector3 rootWorldPositionAfter = root.GetProperty(Actor::Property::WORLD_POSITION); + Vector3 firstWorldPositionAfter = first.GetProperty(Actor::Property::WORLD_POSITION); + + DALI_TEST_EQUALS(Vector3(0, 10, 0), rootWorldPositionAfter - rootWorldPositionBefore, TEST_LOCATION); + DALI_TEST_EQUALS(Vector3(10, 10, 0), firstWorldPositionAfter - firstWorldPositionBefore, TEST_LOCATION); + + END_TEST; +} + + + +int UtcDaliLoadBvhFailed(void) +{ + TestApplication application; + + AnimationDefinition animDef = LoadBvh("/nothing.bvh", "testBvh"); + DALI_TEST_EQUALS(0u, animDef.mProperties.size(), TEST_LOCATION); + END_TEST; +} diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-CameraParameters.cpp b/automated-tests/src/dali-scene3d/utc-Dali-CameraParameters.cpp similarity index 95% rename from automated-tests/src/dali-scene-loader/utc-Dali-CameraParameters.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-CameraParameters.cpp index 5ad4a40..15e575b 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-CameraParameters.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-CameraParameters.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/camera-parameters.h" +#include "dali-scene3d/public-api/loader/camera-parameters.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliCameraParameters(void) { diff --git a/automated-tests/src/dali-scene3d/utc-Dali-CubeLoader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-CubeLoader.cpp new file mode 100644 index 0000000..57482c3 --- /dev/null +++ b/automated-tests/src/dali-scene3d/utc-Dali-CubeLoader.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Enable debug log for test coverage +#define DEBUG_ENABLED 1 + +#include "dali-scene3d/public-api/loader/cube-loader.h" +#include +#include + +#include + +using namespace Dali; +using namespace Dali::Scene3D::Loader; + +int UtcDaliCubeLoaderFailNonexistent(void) +{ + CubeData data; + DALI_TEST_CHECK(!LoadCubeData("non-existent.jpg", data)); + END_TEST; +} + +int UtcDaliCubeLoaderFailInvalid1(void) +{ + CubeData data; + DALI_TEST_CHECK(!LoadCubeData(TEST_RESOURCE_DIR "/gallery-small-1.jpg", data)); // Wrong sized image + END_TEST; +} + +int UtcDaliCubeLoaderSuccess01(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png"; // cross horizontal + DALI_TEST_CHECK(LoadCubeData(path, cubeData)); + + DALI_TEST_EQUAL(6u, cubeData.data.size()); + for (auto& face: cubeData.data) + { + uint32_t size = 512; + DALI_TEST_EQUAL(size, face[0].GetWidth()); + DALI_TEST_EQUAL(size, face[0].GetHeight()); + DALI_TEST_EQUAL(Pixel::Format::RGBA8888, face[0].GetPixelFormat()); + } + + END_TEST; +} + +int UtcDaliCubeLoaderSuccess02(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap_cross_vertical.png"; // cross vertical + DALI_TEST_CHECK(LoadCubeData(path, cubeData)); + + DALI_TEST_EQUAL(6u, cubeData.data.size()); + for (auto& face: cubeData.data) + { + uint32_t size = 256; + DALI_TEST_EQUAL(size, face[0].GetWidth()); + DALI_TEST_EQUAL(size, face[0].GetHeight()); + DALI_TEST_EQUAL(Pixel::Format::RGBA8888, face[0].GetPixelFormat()); + } + + END_TEST; +} + +int UtcDaliCubeLoaderSuccess03(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/cubemap_array_horizontal.png"; // array horizontal + DALI_TEST_CHECK(LoadCubeData(path, cubeData)); + + DALI_TEST_EQUAL(6u, cubeData.data.size()); + for (auto& face: cubeData.data) + { + uint32_t size = 100; + DALI_TEST_EQUAL(size, face[0].GetWidth()); + DALI_TEST_EQUAL(size, face[0].GetHeight()); + DALI_TEST_EQUAL(Pixel::Format::RGB888, face[0].GetPixelFormat()); + } + + END_TEST; +} + +int UtcDaliCubeLoaderSuccess04(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/cubemap_array_vertical.png"; // array horizontal + DALI_TEST_CHECK(LoadCubeData(path, cubeData)); + + DALI_TEST_EQUAL(6u, cubeData.data.size()); + for (auto& face: cubeData.data) + { + uint32_t size = 100; + DALI_TEST_EQUAL(size, face[0].GetWidth()); + DALI_TEST_EQUAL(size, face[0].GetHeight()); + DALI_TEST_EQUAL(Pixel::Format::RGB888, face[0].GetPixelFormat()); + } + + END_TEST; +} + +int UtcDaliCubeLoaderCubeDataCreateTexture(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png"; + DALI_TEST_CHECK(LoadCubeData(path, cubeData)); + + TestApplication app; + auto texture = cubeData.CreateTexture(); + + DALI_TEST_CHECK(texture); + DALI_TEST_EQUAL(512u, texture.GetWidth()); + DALI_TEST_EQUAL(512u, texture.GetHeight()); + + END_TEST; +} diff --git a/automated-tests/src/dali-scene3d/utc-Dali-CubeMapLoader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-CubeMapLoader.cpp new file mode 100644 index 0000000..d00a15b --- /dev/null +++ b/automated-tests/src/dali-scene3d/utc-Dali-CubeMapLoader.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Enable debug log for test coverage +#define DEBUG_ENABLED 1 + +#include "dali-scene3d/public-api/loader/cube-map-loader.h" +#include +#include + +#include + +using namespace Dali; +using namespace Dali::Scene3D::Loader; + +int UtcDaliCubeMapLoaderFailNonexistent(void) +{ + CubeData data; + DALI_TEST_CHECK(!LoadCubeMapData("non-existent.jpg", data)); + END_TEST; +} + +int UtcDaliCubeMapLoaderFailInvalid1(void) +{ + CubeData data; + DALI_TEST_CHECK(!LoadCubeMapData(TEST_RESOURCE_DIR "/gallery-small-1.jpg", data)); // Wrong sized image + END_TEST; +} + +int UtcDaliCubeMapLoaderSuccess01(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_radiance.ktx"; + DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + + DALI_TEST_EQUAL(6u, cubeData.data.size()); + for (auto& face: cubeData.data) + { + uint32_t size = 64; + for (auto& mipData: face) + { + DALI_TEST_EQUAL(size, mipData.GetWidth()); + DALI_TEST_EQUAL(size, mipData.GetHeight()); + DALI_TEST_EQUAL(Pixel::Format::RGB888, mipData.GetPixelFormat()); + size /= 2; + } + } + + END_TEST; +} + +int UtcDaliCubeMapLoaderSuccess02(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png"; // cross horizontal + DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + + DALI_TEST_EQUAL(6u, cubeData.data.size()); + for (auto& face: cubeData.data) + { + uint32_t size = 512; + DALI_TEST_EQUAL(size, face[0].GetWidth()); + DALI_TEST_EQUAL(size, face[0].GetHeight()); + DALI_TEST_EQUAL(Pixel::Format::RGBA8888, face[0].GetPixelFormat()); + } + + END_TEST; +} + +int UtcDaliCubeMapLoaderCubeDataCreateTexture01(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_radiance.ktx"; + DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + + TestApplication app; + auto texture = cubeData.CreateTexture(); + + DALI_TEST_CHECK(texture); + DALI_TEST_EQUAL(64u, texture.GetWidth()); + DALI_TEST_EQUAL(64u, texture.GetHeight()); + + END_TEST; +} + +int UtcDaliCubeMapLoaderCubeDataCreateTexture02(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png"; + DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + + TestApplication app; + auto texture = cubeData.CreateTexture(); + + DALI_TEST_CHECK(texture); + DALI_TEST_EQUAL(512u, texture.GetWidth()); + DALI_TEST_EQUAL(512u, texture.GetHeight()); + + END_TEST; +} diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-DliLoader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-DliLoader.cpp similarity index 98% rename from automated-tests/src/dali-scene-loader/utc-Dali-DliLoader.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-DliLoader.cpp index b63df36..6a33200 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-DliLoader.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-DliLoader.cpp @@ -20,14 +20,14 @@ #include #include -#include "dali-scene-loader/internal/json-util.h" -#include "dali-scene-loader/public-api/dli-loader.h" -#include "dali-scene-loader/public-api/load-result.h" -#include "dali-scene-loader/public-api/resource-bundle.h" -#include "dali-scene-loader/public-api/scene-definition.h" +#include "dali-scene3d/internal/loader/json-util.h" +#include "dali-scene3d/public-api/loader/dli-loader.h" +#include "dali-scene3d/public-api/loader/load-result.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" +#include "dali-scene3d/public-api/loader/scene-definition.h" using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-EnvironmentDefinition.cpp b/automated-tests/src/dali-scene3d/utc-Dali-EnvironmentDefinition.cpp similarity index 97% rename from automated-tests/src/dali-scene-loader/utc-Dali-EnvironmentDefinition.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-EnvironmentDefinition.cpp index e151c6a..8286bc3 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-EnvironmentDefinition.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-EnvironmentDefinition.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/environment-definition.h" +#include "dali-scene3d/public-api/loader/environment-definition.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliEnvironmentDefinitionLoadRawDefault(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-FacialAnimation.cpp b/automated-tests/src/dali-scene3d/utc-Dali-FacialAnimation.cpp similarity index 95% rename from automated-tests/src/dali-scene-loader/utc-Dali-FacialAnimation.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-FacialAnimation.cpp index f6eb2fa..22692e0 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-FacialAnimation.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-FacialAnimation.cpp @@ -16,11 +16,11 @@ */ #include -#include -#include +#include +#include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliLoadFacialAnimation(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-Gltf2Loader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp similarity index 97% rename from automated-tests/src/dali-scene-loader/utc-Dali-Gltf2Loader.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp index 4a40524..a9ba508 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-Gltf2Loader.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp @@ -20,14 +20,14 @@ #include #include -#include "dali-scene-loader/public-api/gltf2-loader.h" -#include "dali-scene-loader/public-api/load-result.h" -#include "dali-scene-loader/public-api/resource-bundle.h" -#include "dali-scene-loader/public-api/scene-definition.h" -#include "dali-scene-loader/public-api/shader-definition-factory.h" +#include "dali-scene3d/public-api/loader/gltf2-loader.h" +#include "dali-scene3d/public-api/loader/load-result.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" +#include "dali-scene3d/public-api/loader/scene-definition.h" +#include "dali-scene3d/public-api/loader/shader-definition-factory.h" using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; #define DALI_TEST_THROW(expression, exception, predicate) \ { \ diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-KtxLoader.cpp similarity index 84% rename from automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-KtxLoader.cpp index 783745d..55f48d7 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-KtxLoader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,40 +18,40 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/ktx-loader.h" +#include "dali-scene3d/public-api/loader/ktx-loader.h" #include #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliKtxLoaderFailNonexistent(void) { CubeData data; - DALI_TEST_CHECK(!LoadCubeMapData("non-existent.ktx", data)); + DALI_TEST_CHECK(!LoadKtxData("non-existent.ktx", data)); END_TEST; } int UtcDaliKtxLoaderFailInvalid1(void) { CubeData data; - DALI_TEST_CHECK(!LoadCubeMapData(TEST_RESOURCE_DIR "/invalid.svg", data)); // file smaller than KTX header + DALI_TEST_CHECK(!LoadKtxData(TEST_RESOURCE_DIR "/invalid.svg", data)); // file smaller than KTX header END_TEST; } int UtcDaliKtxLoaderFailInvalid2(void) { CubeData data; - DALI_TEST_CHECK(!LoadCubeMapData(TEST_RESOURCE_DIR "/anim.gif", data)); // not a KTX + DALI_TEST_CHECK(!LoadKtxData(TEST_RESOURCE_DIR "/anim.gif", data)); // not a KTX END_TEST; } int UtcDaliKtxLoaderFailTruncated(void) { CubeData data; - DALI_TEST_CHECK(!LoadCubeMapData(TEST_RESOURCE_DIR "/truncated.ktx", data)); + DALI_TEST_CHECK(!LoadKtxData(TEST_RESOURCE_DIR "/truncated.ktx", data)); END_TEST; } @@ -59,7 +59,7 @@ int UtcDaliKtxLoaderSuccess(void) { CubeData cubeData; auto path = TEST_RESOURCE_DIR "/forest_radiance.ktx"; - DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + DALI_TEST_CHECK(LoadKtxData(path, cubeData)); DALI_TEST_EQUAL(6u, cubeData.data.size()); for (auto& face: cubeData.data) @@ -103,7 +103,7 @@ int UtcDaliKtxLoaderFormats(void) for (auto i : pathFormats) { CubeData cubeData; - DALI_TEST_CHECK(LoadCubeMapData(resPath + i.first + ".ktx", cubeData)); + DALI_TEST_CHECK(LoadKtxData(resPath + i.first + ".ktx", cubeData)); DALI_TEST_EQUAL(cubeData.data[0][0].GetPixelFormat(), i.second); } @@ -135,7 +135,7 @@ int UtcDaliKtxLoaderCubeDataCreateTexture2(void) { CubeData cubeData; auto path = TEST_RESOURCE_DIR "/forest_radiance.ktx"; - DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + DALI_TEST_CHECK(LoadKtxData(path, cubeData)); TestApplication app; auto texture = cubeData.CreateTexture(); @@ -151,7 +151,7 @@ int UtcDaliKtxLoaderCubeDataCreateTexture3(void) { CubeData cubeData; auto path = TEST_RESOURCE_DIR "/papermill_E_diffuse-64.ktx"; - DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + DALI_TEST_CHECK(LoadKtxData(path, cubeData)); TestApplication app; auto texture = cubeData.CreateTexture(); diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-MatrixStack.cpp b/automated-tests/src/dali-scene3d/utc-Dali-MatrixStack.cpp similarity index 94% rename from automated-tests/src/dali-scene-loader/utc-Dali-MatrixStack.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-MatrixStack.cpp index 776ded7..b9d8aff 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-MatrixStack.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-MatrixStack.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/matrix-stack.h" +#include "dali-scene3d/public-api/loader/matrix-stack.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliMatrixStack(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-MeshDefinition.cpp b/automated-tests/src/dali-scene3d/utc-Dali-MeshDefinition.cpp similarity index 94% rename from automated-tests/src/dali-scene-loader/utc-Dali-MeshDefinition.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-MeshDefinition.cpp index 37c170b..377e68d 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-MeshDefinition.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-MeshDefinition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ #include -#include "dali-scene-loader/public-api/mesh-definition.h" +#include "dali-scene3d/public-api/loader/mesh-definition.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliMeshDefinitionBlobApplyMinMaxBothMinMaxApplied(void) { diff --git a/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp b/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp new file mode 100644 index 0000000..5424874 --- /dev/null +++ b/automated-tests/src/dali-scene3d/utc-Dali-ModelView.cpp @@ -0,0 +1,572 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include + +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +void model_view_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void model_view_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ +/** + * For the AnimatedCube.gltf and its Assets + * Donated by Norbert Nopper for glTF testing. + * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube + */ +const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf"; +const char* TEST_GLTF_TRIANGLE_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedTriangle.gltf"; +const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf"; +const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli"; +const char* TEST_DLI_BEER_FILE_NAME = TEST_RESOURCE_DIR "/beer_modelViewTest.dli"; +/** + * For the diffuse and specular cube map texture. + * These textures are based off version of Wave engine sample + * Take from https://github.com/WaveEngine/Samples + * + * Copyright (c) 2022 Wave Coorporation + * + * 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. + */ +const char* TEST_DIFFUSE_TEXTURE = TEST_RESOURCE_DIR "/forest_irradiance.ktx"; +const char* TEST_SPECULAR_TEXTURE = TEST_RESOURCE_DIR "/forest_radiance.ktx"; +} // namespace + +// Negative test case for a method +int UtcDaliModelViewUninitialized(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliModelViewUninitialized"); + + Scene3D::ModelView view; + + try + { + // New() must be called to create a ModelView or it wont be valid. + Actor a = Actor::New(); + view.Add(a); + DALI_TEST_CHECK(false); + } + catch(Dali::DaliException& e) + { + // Tests that a negative test of an assertion succeeds + DALI_TEST_PRINT_ASSERT(e); + DALI_TEST_CHECK(!view); + } + END_TEST; +} + +// Positive test case for a method +int UtcDaliModelViewNew(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliModelViewNew"); + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + DALI_TEST_CHECK(view); + END_TEST; +} + +// Positive test case for a method +int UtcDaliModelViewDownCast(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliModelViewDownCast"); + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + BaseHandle handle(view); + + Scene3D::ModelView modelView = Scene3D::ModelView::DownCast(handle); + DALI_TEST_CHECK(view); + DALI_TEST_CHECK(modelView); + DALI_TEST_CHECK(modelView == view); + END_TEST; +} + +int UtcDaliModelViewTypeRegistry(void) +{ + ToolkitTestApplication application; + + TypeRegistry typeRegistry = TypeRegistry::Get(); + DALI_TEST_CHECK(typeRegistry); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo("ModelView"); + DALI_TEST_CHECK(typeInfo); + + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK(handle); + + Scene3D::ModelView modelView = Scene3D::ModelView::DownCast(handle); + DALI_TEST_CHECK(modelView); + + END_TEST; +} + +// Positive test case for a method +int UtcDaliModelViewAddRemove(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliModelViewAddRemove"); + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + DALI_TEST_CHECK(view); + + Actor actor = Actor::New(); + DALI_TEST_CHECK(!actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)); + + view.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + view.SetProperty(Actor::Property::SIZE, application.GetScene().GetSize()); + view.Add(actor); + application.GetScene().Add(view); + + DALI_TEST_CHECK(actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)); + + view.Remove(actor); + + DALI_TEST_CHECK(!actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)); + END_TEST; +} + +int UtcDaliModelViewCopyAndAssignment(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + DALI_TEST_CHECK(view); + + Scene3D::ModelView copy(view); + DALI_TEST_CHECK(view == copy); + + Scene3D::ModelView assign; + DALI_TEST_CHECK(!assign); + + assign = copy; + DALI_TEST_CHECK(assign == view); + + END_TEST; +} + +int UtcDaliModelViewMoveConstructor(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION); + view.SetProperty(Actor::Property::SENSITIVE, false); + DALI_TEST_CHECK(false == view.GetProperty(Actor::Property::SENSITIVE)); + + Scene3D::ModelView moved = std::move(view); + DALI_TEST_CHECK(moved); + DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_CHECK(false == moved.GetProperty(Actor::Property::SENSITIVE)); + DALI_TEST_CHECK(!view); + + END_TEST; +} + +int UtcDaliModelViewMoveAssignment(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + DALI_TEST_EQUALS(1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION); + view.SetProperty(Actor::Property::SENSITIVE, false); + DALI_TEST_CHECK(false == view.GetProperty(Actor::Property::SENSITIVE)); + + Scene3D::ModelView moved; + moved = std::move(view); + DALI_TEST_CHECK(moved); + DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_CHECK(false == moved.GetProperty(Actor::Property::SENSITIVE)); + DALI_TEST_CHECK(!view); + + END_TEST; +} + +int UtcDaliModelViewOnScene01(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + uint32_t modelCount = view.GetModelRoot().GetChildCount(); + DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewOnScene02(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_DLI_FILE_NAME); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + uint32_t modelCount = view.GetModelRoot().GetChildCount(); + DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION); + + Actor rootActor = view.GetModelRoot(); + Vector3 rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewOnSizeSet(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Vector2 size(200.0f, 300.0f); + view.SetProperty(Actor::Property::SIZE, size); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(view.GetCurrentProperty(Actor::Property::SIZE), size, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewGetNaturalSize(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + + Vector3 naturalSize = view.GetNaturalSize(); + + DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION); + + Actor root = view.GetModelRoot(); + DALI_TEST_CHECK(root); + + END_TEST; +} + +int UtcDaliModelViewSetImageBasedLightSource01(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Actor meshActor = view.FindChildByName("AnimatedCube"); + DALI_TEST_CHECK(meshActor); + + Renderer renderer = meshActor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + TextureSet textureSet = renderer.GetTextures(); + DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION); + + Texture diffuseTexture = textureSet.GetTexture(5u); + Texture specularTexture = textureSet.GetTexture(6u); + + view.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE); + + Texture newDiffuseTexture = textureSet.GetTexture(5u); + Texture newSpecularTexture = textureSet.GetTexture(6u); + + DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION); + DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewSetImageBasedLightSource02(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Actor meshActor = view.FindChildByName("AnimatedCube"); + DALI_TEST_CHECK(meshActor); + + Renderer renderer = meshActor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + TextureSet textureSet = renderer.GetTextures(); + DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION); + + Texture diffuseTexture = textureSet.GetTexture(5u); + Texture specularTexture = textureSet.GetTexture(6u); + + view.SetImageBasedLightSource("", ""); + + Texture newDiffuseTexture = textureSet.GetTexture(5u); + Texture newSpecularTexture = textureSet.GetTexture(6u); + + DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION); + DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewSetImageBasedLightSource03(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Actor meshActor = view.FindChildByName("AnimatedCube"); + DALI_TEST_CHECK(meshActor); + + Renderer renderer = meshActor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + TextureSet textureSet = renderer.GetTextures(); + DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION); + + Texture diffuseTexture = textureSet.GetTexture(5u); + Texture specularTexture = textureSet.GetTexture(6u); + + view.SetImageBasedLightSource("dummy.ktx", "dummy.ktx"); + + Texture newDiffuseTexture = textureSet.GetTexture(5u); + Texture newSpecularTexture = textureSet.GetTexture(6u); + + DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION); + DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewFitSize01(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Actor rootActor = view.GetModelRoot(); + Vector3 rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); + + Vector3 rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); + DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + + view.FitSize(true); + rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); + + rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); + DALI_TEST_EQUALS(Vector3(25, 25, 25), rootScale, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewFitSize02(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_DLI_BEER_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Actor rootActor = view.GetModelRoot(); + Vector3 rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION); + + Vector3 rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); + DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + + view.FitSize(true); + rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(5, 5, 5), rootSize, TEST_LOCATION); + + rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); + DALI_TEST_EQUALS(Vector3(10, 10, 10), rootScale, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewFitSize03(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector2(0, 0)); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Actor rootActor = view.GetModelRoot(); + Vector3 rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); + + Vector3 rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); + DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + + view.FitSize(true); + rootSize = rootActor.GetProperty(Dali::Actor::Property::SIZE); + DALI_TEST_EQUALS(Vector3(2, 2, 2), rootSize, TEST_LOCATION); + + rootScale = rootActor.GetProperty(Dali::Actor::Property::SCALE); + DALI_TEST_EQUALS(Vector3(1, 1, 1), rootScale, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewFitCenter(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_TRIANGLE_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + Vector3 naturalSize = view.GetNaturalSize(); + DALI_TEST_EQUALS(Vector3(1, 1, 0), naturalSize, TEST_LOCATION); + + Actor rootActor = view.GetModelRoot(); + Vector3 anchorPoint = rootActor.GetProperty(Dali::Actor::Property::ANCHOR_POINT); + DALI_TEST_EQUALS(Vector3(0.5, 0.5, 0.5), anchorPoint, TEST_LOCATION); + + view.FitCenter(true); + anchorPoint = rootActor.GetProperty(Dali::Actor::Property::ANCHOR_POINT); + DALI_TEST_EQUALS(Vector3(1.0, 1.0, 0.5), anchorPoint, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewAnimation01(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + uint32_t animationCount = view.GetAnimationCount(); + DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION); + + Animation animationByIndex = view.GetAnimation(0u); + DALI_TEST_CHECK(animationByIndex); + + Animation animationByName = view.GetAnimation("animation_AnimatedCube"); + DALI_TEST_CHECK(animationByName); + DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliModelViewAnimation02(void) +{ + ToolkitTestApplication application; + + Scene3D::ModelView view = Scene3D::ModelView::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + + application.GetScene().Add(view); + + application.SendNotification(); + application.Render(); + + uint32_t animationCount = view.GetAnimationCount(); + DALI_TEST_EQUALS(9, animationCount, TEST_LOCATION); + + Animation animation1 = view.GetAnimation("Step Scale"); + DALI_TEST_CHECK(animation1); + DALI_TEST_EQUALS(1.66667f, animation1.GetDuration(), 0.001f, TEST_LOCATION); + + Animation animation2 = view.GetAnimation("CubicSpline Scale"); + DALI_TEST_CHECK(animation2); + DALI_TEST_EQUALS(1.66667f, animation2.GetDuration(), 0.001f, TEST_LOCATION); + + DALI_TEST_NOT_EQUALS(animation1, animation2, 0.0f, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-NodeDefinition.cpp b/automated-tests/src/dali-scene3d/utc-Dali-NodeDefinition.cpp similarity index 97% rename from automated-tests/src/dali-scene-loader/utc-Dali-NodeDefinition.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-NodeDefinition.cpp index 7f1a7cf..835fdbf 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-NodeDefinition.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-NodeDefinition.cpp @@ -18,14 +18,14 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/node-definition.h" -#include "dali-scene-loader/public-api/view-projection.h" +#include "dali-scene3d/public-api/loader/node-definition.h" +#include "dali-scene3d/public-api/loader/view-projection.h" #include #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-RendererState.cpp b/automated-tests/src/dali-scene3d/utc-Dali-RendererState.cpp similarity index 97% rename from automated-tests/src/dali-scene-loader/utc-Dali-RendererState.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-RendererState.cpp index a6f6251..fb1e23d 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-RendererState.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-RendererState.cpp @@ -18,15 +18,15 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/renderer-state.h" -#include "dali-scene-loader/public-api/parse-renderer-state.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/renderer-state.h" +#include "dali-scene3d/public-api/loader/parse-renderer-state.h" +#include "dali-scene3d/public-api/loader/utils.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; -namespace sl = SceneLoader; +namespace sl = Dali::Scene3D::Loader; namespace rs = RendererState; int UtcDaliRendererStateFromBlendFactors(void) diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-ResourceBundle.cpp b/automated-tests/src/dali-scene3d/utc-Dali-ResourceBundle.cpp similarity index 93% rename from automated-tests/src/dali-scene-loader/utc-Dali-ResourceBundle.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-ResourceBundle.cpp index 8f03828..20c1bcb 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-ResourceBundle.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-ResourceBundle.cpp @@ -18,13 +18,13 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/resource-bundle.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" +#include "dali-scene3d/public-api/loader/utils.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliResourceRefCounts(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-SceneDefinition.cpp b/automated-tests/src/dali-scene3d/utc-Dali-SceneDefinition.cpp similarity index 98% rename from automated-tests/src/dali-scene-loader/utc-Dali-SceneDefinition.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-SceneDefinition.cpp index 9b163bd..dc2fc92 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-SceneDefinition.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-SceneDefinition.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/scene-definition.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/scene-definition.h" +#include "dali-scene3d/public-api/loader/utils.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliSceneDefinitionAddNode(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinition.cpp b/automated-tests/src/dali-scene3d/utc-Dali-ShaderDefinition.cpp similarity index 93% rename from automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinition.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-ShaderDefinition.cpp index e58e702..3804038 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinition.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-ShaderDefinition.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/shader-definition.h" +#include "dali-scene3d/public-api/loader/shader-definition.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; int UtcDaliShaderDefinitionFailedToLoad(void) { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinitionFactory.cpp b/automated-tests/src/dali-scene3d/utc-Dali-ShaderDefinitionFactory.cpp similarity index 97% rename from automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinitionFactory.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-ShaderDefinitionFactory.cpp index 534189e..b8e6357 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-ShaderDefinitionFactory.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-ShaderDefinitionFactory.cpp @@ -21,13 +21,13 @@ #include #include #include -#include "dali-scene-loader/public-api/gltf2-loader.h" -#include "dali-scene-loader/public-api/node-definition.h" -#include "dali-scene-loader/public-api/resource-bundle.h" -#include "dali-scene-loader/public-api/shader-definition-factory.h" +#include "dali-scene3d/public-api/loader/gltf2-loader.h" +#include "dali-scene3d/public-api/loader/node-definition.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" +#include "dali-scene3d/public-api/loader/shader-definition-factory.h" using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-StringCallback.cpp b/automated-tests/src/dali-scene3d/utc-Dali-StringCallback.cpp similarity index 88% rename from automated-tests/src/dali-scene-loader/utc-Dali-StringCallback.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-StringCallback.cpp index 113f40a..f89ec02 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-StringCallback.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-StringCallback.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/string-callback.h" +#include "dali-scene3d/public-api/loader/string-callback.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { @@ -41,6 +41,6 @@ int UtcDaliUtilsDefaultStringCallback(void) { InstallLogFunction(TestLogFunction); DefaultErrorCallback("Hello world!"); - DALI_TEST_EQUAL(std::string(sBuffer), "2: string-callback.cpp: DefaultErrorCallback(26) > Hello world!"); + DALI_TEST_EQUAL(std::string(sBuffer), "2: string-callback.cpp: DefaultErrorCallback(28) > Hello world!"); END_TEST; } diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-Utils.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Utils.cpp similarity index 95% rename from automated-tests/src/dali-scene-loader/utc-Dali-Utils.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-Utils.cpp index 68e30a0..05b53e7 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-Utils.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Utils.cpp @@ -18,12 +18,12 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/utils.h" #include #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-ViewProjection.cpp b/automated-tests/src/dali-scene3d/utc-Dali-ViewProjection.cpp similarity index 95% rename from automated-tests/src/dali-scene-loader/utc-Dali-ViewProjection.cpp rename to automated-tests/src/dali-scene3d/utc-Dali-ViewProjection.cpp index c4567ab..0c47b6b 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-ViewProjection.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-ViewProjection.cpp @@ -18,11 +18,11 @@ // Enable debug log for test coverage #define DEBUG_ENABLED 1 -#include "dali-scene-loader/public-api/view-projection.h" +#include "dali-scene3d/public-api/loader/view-projection.h" #include using namespace Dali; -using namespace Dali::SceneLoader; +using namespace Dali::Scene3D::Loader; namespace { diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp index 2bbdcc8..60e1892 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp @@ -171,3 +171,38 @@ int utcDaliAccessibilityHidden(void) END_TEST; } + +int utcDaliAutomationId(void) +{ + ToolkitTestApplication application; + Dali::Property::Index automationIdIndex = Toolkit::DevelControl::Property::AUTOMATION_ID; + std::string automationIdKey = "automationId"; + std::string automationIdValue = "test123"; + + auto control = Toolkit::Control::New(); + auto* controlAccessible = Accessibility::Accessible::Get(control); + + // Check that there is no automationId initially + DALI_TEST_CHECK(control.GetProperty(automationIdIndex).empty()); + auto attributes = controlAccessible->GetAttributes(); + DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end()); + + // Set automationId + control.SetProperty(automationIdIndex, automationIdValue); + + // Check that automationId is set + DALI_TEST_EQUALS(control.GetProperty(automationIdIndex), automationIdValue, TEST_LOCATION); + attributes = controlAccessible->GetAttributes(); + DALI_TEST_CHECK(attributes.find(automationIdKey) != attributes.end()); + DALI_TEST_EQUALS(attributes[automationIdKey], automationIdValue, TEST_LOCATION); + + // Unset automationId + control.SetProperty(automationIdIndex, ""); + + // Check that there is no automationId + DALI_TEST_CHECK(control.GetProperty(automationIdIndex).empty()); + attributes = controlAccessible->GetAttributes(); + DALI_TEST_CHECK(attributes.find(automationIdKey) == attributes.end()); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp index 301f191..bc52a6f 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp @@ -973,7 +973,7 @@ int UtcDaliTextShapeEmojiSequences(void) struct GlyphInfoData glyphsVS15[] = { {1u, 3842u, 0.f, 0.f, 0.f, 0.f, 14.0f, 0.f, false, false}, - {1u, 8203u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, false, false}, + {1u, 3u, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, false, false}, }; CharacterIndex characterIndicesVS15[] = {0u, 0u}; Length charactersPerGlyphVS15[] = {0u, 2u}; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 075cf2a..0e86810 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -55,15 +55,16 @@ namespace Adaptor class WebEngine; class MockWebEngineContext; +class MockWebEngineCookieManager; namespace { - // Generally only one WebEngine instance exists. // If > 1, a new web engine has been created by CreateWindowSignal. -static WebEngine* gInstance = nullptr; -static int gInstanceCount = 0; -static MockWebEngineContext* gWebEngineContextInstance = nullptr; +WebEngine* gInstance = nullptr; +int gInstanceCount = 0; +MockWebEngineContext* gWebEngineContextInstance = nullptr; +MockWebEngineCookieManager* gMockWebEngineCookieManager = nullptr; bool OnGoBack(); bool OnGoForward(); @@ -342,6 +343,15 @@ private: float mockZoomFactor; }; +Dali::WebEngineContext* GetContext() +{ + if (!gWebEngineContextInstance) + { + gWebEngineContextInstance = new MockWebEngineContext(); + } + return gWebEngineContextInstance; +} + class MockWebEngineCookieManager : public Dali::WebEngineCookieManager { public: @@ -384,6 +394,15 @@ private: Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy; }; +Dali::WebEngineCookieManager* GetCookieManager() +{ + if (!gMockWebEngineCookieManager) + { + gMockWebEngineCookieManager = new MockWebEngineCookieManager(); + } + return gMockWebEngineCookieManager; +} + class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem { public: @@ -1211,13 +1230,6 @@ public: } mockWebEngineSettings = new MockWebEngineSettings(); - MockWebEngineContext* engineContext = new MockWebEngineContext(); - mockWebEngineContext = engineContext; - if ( gInstanceCount == 1 ) - { - gWebEngineContextInstance = engineContext; - } - mockWebEngineCookieManager = new MockWebEngineCookieManager(); mockWebEngineBackForwardList = new MockWebEngineBackForwardList(); } @@ -1226,13 +1238,10 @@ public: gInstanceCount--; if( !gInstanceCount ) { - gInstance = 0; - gWebEngineContextInstance = 0; + gInstance = nullptr; } delete mockWebEngineSettings; - delete mockWebEngineContext; - delete mockWebEngineCookieManager; delete mockWebEngineBackForwardList; } @@ -1241,16 +1250,6 @@ public: return *mockWebEngineSettings; } - Dali::WebEngineContext& GetContext() const - { - return *mockWebEngineContext; - } - - Dali::WebEngineCookieManager& GetCookieManager() const - { - return *mockWebEngineCookieManager; - } - Dali::WebEngineBackForwardList& GetBackForwardList() const { return *mockWebEngineBackForwardList; @@ -1604,8 +1603,6 @@ public: Dali::Vector2 mScrollSize; Dali::Vector2 mContentSize; WebEngineBackForwardList* mockWebEngineBackForwardList; - WebEngineContext* mockWebEngineContext; - WebEngineCookieManager* mockWebEngineCookieManager; WebEngineSettings* mockWebEngineSettings; std::vector mResultCallbacks; @@ -1938,17 +1935,11 @@ bool OnRequestIntercepted() bool OnChangesWatch() { - DisconnectFromGlobalSignal( &OnChangesWatch ); - - if ( gInstance ) + DisconnectFromGlobalSignal(&OnChangesWatch); + if (gMockWebEngineCookieManager) { - MockWebEngineCookieManager* temp = (MockWebEngineCookieManager *)(&(gInstance->GetCookieManager())); - if ( temp ) - { - temp->mChangesWatchCallback(); - } + gMockWebEngineCookieManager->mChangesWatchCallback(); } - return false; } @@ -2004,6 +1995,16 @@ WebEngine WebEngine::New() return WebEngine( baseObject ); } +Dali::WebEngineContext* WebEngine::GetContext() +{ + return Internal::Adaptor::GetContext(); +} + +Dali::WebEngineCookieManager* WebEngine::GetCookieManager() +{ + return Internal::Adaptor::GetCookieManager(); +} + WebEngine::WebEngine( const WebEngine& WebEngine ) : BaseHandle( WebEngine ) { @@ -2037,16 +2038,6 @@ 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(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index ccab3e0..60e9eea 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -2260,55 +2260,6 @@ int UtcDaliKeyboardFocusManagerWithUserInteractionEnabled(void) END_TEST; } - -int UtcDaliKeyboardFocusManagerWithHide(void) -{ - ToolkitTestApplication application; - - tet_infoline(" UtcDaliKeyboardFocusManagerWithHide"); - - KeyboardFocusManager manager = KeyboardFocusManager::Get(); - DALI_TEST_CHECK(manager); - - // Create the first control and add it to the stage - Control first = Control::New(); - first.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); - application.GetScene().Add(first); - - // Create the second control and add it to the first control. - Control second = Control::New(); - second.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); - first.Add(second); - - - // flush the queue and render once - application.SendNotification(); - application.Render(); - - // Check that no actor is being focused yet. - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - // Check that the focus is set on the actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); - - // If the currently focused actor becomes VISIBLE false, it loses focus. - first.SetProperty(Actor::Property::VISIBLE, false); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - first.SetProperty(Actor::Property::VISIBLE, true); - // Check that the focus is set on the actor - DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); - - // If the currently focused actor becomes VISIBLE false, When the parent is hidden, the child also loses focus. - first.SetProperty(Actor::Property::VISIBLE, false); - DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); - - - END_TEST; -} - int UtcDaliKeyboardFocusManagerFocusFinderRootActor(void) { ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Model3dView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Model3dView.cpp index acdf9d7..afe7253 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Model3dView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Model3dView.cpp @@ -24,12 +24,12 @@ using namespace Dali; using namespace Dali::Toolkit; -void model_view_startup(void) +void model3d_view_startup(void) { test_return_value = TET_UNDEF; } -void model_view_cleanup(void) +void model3d_view_cleanup(void) { test_return_value = TET_PASS; } @@ -42,7 +42,7 @@ const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/"; } // namespace // Negative test case for a method -int UtcDaliModelViewUninitialized(void) +int UtcDaliModel3dViewUninitialized(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliModel3dViewUninitialized"); @@ -66,7 +66,7 @@ int UtcDaliModelViewUninitialized(void) } // Positive test case for a method -int UtcDaliModelViewNew(void) +int UtcDaliModel3dViewNew(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliModel3dViewNew"); @@ -80,7 +80,7 @@ int UtcDaliModelViewNew(void) } // Positive test case for a method -int UtcDaliModelViewDownCast(void) +int UtcDaliModel3dViewDownCast(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliModelViewDownCast"); @@ -96,7 +96,7 @@ int UtcDaliModelViewDownCast(void) } // Positive test case for a method -int UtcDaliModelViewPropertyNames(void) +int UtcDaliModel3dViewPropertyNames(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliModel3dViewPropertyNames"); @@ -126,7 +126,7 @@ int UtcDaliModelViewPropertyNames(void) } // Positive test case for a method -int UtcDaliModelViewAddRemove(void) +int UtcDaliModel3dViewAddRemove(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliModel3dViewAddRemove"); @@ -150,7 +150,7 @@ int UtcDaliModelViewAddRemove(void) END_TEST; } -int UtcDaliModelCopyAndAssignment(void) +int UtcDaliModel3dViewCopyAndAssignment(void) { ToolkitTestApplication application; @@ -169,7 +169,7 @@ int UtcDaliModelCopyAndAssignment(void) END_TEST; } -int UtcDaliModelMoveConstructor(void) +int UtcDaliModel3dViewMoveConstructor(void) { ToolkitTestApplication application; @@ -187,7 +187,7 @@ int UtcDaliModelMoveConstructor(void) END_TEST; } -int UtcDaliModelMoveAssignment(void) +int UtcDaliModel3dViewMoveAssignment(void) { ToolkitTestApplication application; @@ -206,7 +206,7 @@ int UtcDaliModelMoveAssignment(void) END_TEST; } -int UtcDaliModelTypeRegistry(void) +int UtcDaliModel3dViewTypeRegistry(void) { ToolkitTestApplication application; @@ -225,7 +225,7 @@ int UtcDaliModelTypeRegistry(void) END_TEST; } -int UtcDaliModelOnSizeSet(void) +int UtcDaliModel3dViewOnSizeSet(void) { ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index f24108c..f762e8d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -2701,14 +2701,14 @@ int utcDaliTextFieldEvent03(void) application.Render(); // Tap first to get the focus. - TestGenerateTap(application, 3.0f, 25.0f); + TestGenerateTap(application, 3.0f, 25.0f, 100); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - TestGenerateTap(application, 3.0f, 25.0f); + TestGenerateTap(application, 3.0f, 25.0f, 200); // Render and notify application.SendNotification(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 2ff4a7d..0ece717 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -1140,27 +1140,33 @@ int UtcDaliToolkitTextLabelEmojisP(void) // EMOJI Sequences case for coverage. std::string emojiSequences = + "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font "Text VS15 ☪︎\n" //text presentation sequence and selector "Color VS16 ☪️\n" //emoji presentation sequence and selector "Default ☪ \n" //default presentation "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence "WomanScientist 👩‍🔬\n" // emoji zwj sequence - "WomanScientistLightSkinTone👩🏻‍🔬 \n" //emoji modifier sequence: skin tone & JWZ - "LeftRightArrowText↔︎\n" //text presentation sequence and selector - "LeftRightArrowEmoji↔️\n" //emoji presentation sequence and selector - "SouthKoreaFlag🇰🇷\n" //emoji flag sequence + "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ + "LeftRightArrowText↔︎\n" // text presentation sequence and selector + "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector + "SouthKoreaFlag🇰🇷\n" // emoji flag sequence "JordanFlag🇯🇴\n" // emoji flag sequence - "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" //emoji tag sequence like England flag + "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag "Runner 🏃‍➡️ \n" - "VictoryHandMediumLightSkinTone:✌️🏼\n" //emoji modifier sequence: skin tone - "RainbowFlag:🏳️‍🌈 \n" //emoji zwj sequence: Rainbow Flag - "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence - "keycap#_text #⃣ \n" // unqualified emoji keycap sequence - "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence - "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence - "two adjacent glyphs ☪️️️☪️\n" //This line should be rendered as two adjacent glyphs - "Digit 8️ 8︎ 8\n" // should be rendered according to selector - "Surfing Medium Skin Female: 🏄🏼‍♀️"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign + "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone + "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag + "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence + "keycap#_text #⃣ \n" // unqualified emoji keycap sequence + "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence + "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence + "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs + "Digit 8️ 8︎ 8\n" // should be rendered according to selector + "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign + "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji + "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15 + "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16 + + ; label.SetProperty(TextLabel::Property::TEXT, emojiSequences); label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp old mode 100644 new mode 100755 index 442d75d..30693fc --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -22,8 +22,6 @@ #include "dali-toolkit-test-utils/toolkit-timer.h" #include -#include -#include #include #include #include @@ -31,9 +29,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -890,10 +889,7 @@ int UtcDaliWebViewGetWebContext(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0); END_TEST; @@ -903,10 +899,7 @@ int UtcDaliWebViewGetWebCookieManager(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager(); DALI_TEST_CHECK(cookieManager != 0); END_TEST; @@ -1519,14 +1512,11 @@ int UtcDaliWebBackForwardListCheckItem(void) // test cases for web context. -int UtcDaliWebContextGetSetCacheModel(void) +int UtcDaliWebContextGetSetCacheModelEtc(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0) std::string kDefaultValue; @@ -1595,10 +1585,7 @@ int UtcDaliWebContextGetWebDatabaseStorageOrigins(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0) std::string kDefaultValue; @@ -1665,10 +1652,7 @@ int UtcDaliWebContextHttpRequestInterceptor(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebContext* context = view.GetContext(); + Dali::WebEngineContext* context = WebView::GetContext(); DALI_TEST_CHECK(context != 0) // load url. @@ -1708,10 +1692,7 @@ int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager(); DALI_TEST_CHECK(cookieManager != 0) const std::string kDefaultValue; @@ -1736,10 +1717,7 @@ int UtcDaliWebCookieManagerChangesWatch(void) { ToolkitTestApplication application; - WebView view = WebView::New(); - DALI_TEST_CHECK(view); - - Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager(); + Dali::WebEngineCookieManager* cookieManager = WebView::GetCookieManager(); DALI_TEST_CHECK(cookieManager != 0) cookieManager->ChangesWatch(&OnChangesWatch); diff --git a/build/tizen/.gitignore b/build/tizen/.gitignore index 2d253c9..f09a06e 100644 --- a/build/tizen/.gitignore +++ b/build/tizen/.gitignore @@ -2,5 +2,5 @@ build dali.info *.dylib dali2-*-config.cmake -libdali2-scene-loader.so* +libdali2-scene3d.so* dali-shader-generator diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 31cfe9f..6609ae5 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -34,7 +34,7 @@ OPTION(ENABLE_LINK_TEST "Enable the link test" ON) OPTION(INSTALL_DOXYGEN_DOC "Install doxygen doc" ON) OPTION(CONFIGURE_AUTOMATED_TESTS "Configure automated tests" ON) OPTION(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" ON) -OPTION(BUILD_SCENE_LOADER "Whether to build dali-scene-loader." ON) +OPTION(BUILD_SCENE3D "Whether to build dali-scene3d." ON) IF( ENABLE_PKG_CONFIGURE ) FIND_PACKAGE( PkgConfig REQUIRED ) @@ -511,7 +511,7 @@ IF( ENABLE_COVERAGE ) ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}rename_cov_data ./rename-cov-data ) ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}cov_data ${LCOV_BIN} ${LCOV_OPTS} --base-directory . --directory . -c -o dali.info - COMMAND ${LCOV_BIN} ${LCOV_OPTS} --remove dali.info \"*/dali-env/*\" \"/usr/include/*\" \"*/dali-env/*\" \"*solid-color-actor*\" \"*/dali-toolkit/third-party/*\" \"*/dali-scene-loader/third-party/*\" -o dali.info ) + COMMAND ${LCOV_BIN} ${LCOV_OPTS} --remove dali.info \"*/dali-env/*\" \"/usr/include/*\" \"*/dali-env/*\" \"*solid-color-actor*\" \"*/dali-toolkit/third-party/*\" \"*/dali-scene3d/third-party/*\" -o dali.info ) ADD_CUSTOM_TARGET( ${DALI_TOOLKIT_PREFIX}coverage genhtml -p ${ROOT_SRC_DIR} ${LCOV_OPTS} -o ${COVERAGE_OUTPUT_DIR} dali.info DEPENDS cov_data ) @@ -554,8 +554,8 @@ IF( ENABLE_COVERAGE ) ENDIF( LCOV_BIN ) ENDIF() -IF ( BUILD_SCENE_LOADER ) - ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/dali-scene-loader ) +IF ( BUILD_SCENE3D ) + ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/dali-scene3d ) ENDIF() @@ -572,9 +572,9 @@ IF( DOXYGEN_FOUND ) CONFIGURE_FILE( ${DOXYGEN_SRC_DIR}/dali.doxy.in ${DOXYGEN_SRC_DIR}/dali.doxy @ONLY ) CONFIGURE_FILE( ${DOXYGEN_INTERNAL_SRC_DIR}/dali-internal.doxy.in ${DOXYGEN_INTERNAL_SRC_DIR}/dali-internal.doxy @ONLY ) - IF ( BUILD_SCENE_LOADER ) + IF ( BUILD_SCENE3D ) ADD_CUSTOM_TARGET( doc_doxygen ALL - DEPENDS ${name} dali2-scene-loader + DEPENDS ${name} dali2-scene3d COMMAND ${DOXYGEN_EXECUTABLE} -u ${DOXYGEN_SRC_DIR}/dali.doxy COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_SRC_DIR}/dali.doxy COMMAND ${CMAKE_COMMAND} -P ${DOXYGEN_SRC_DIR}/check_for_errors.cmake @@ -630,7 +630,7 @@ MESSAGE( STATUS "Use pkg configure: " ${ENABLE_PKG_CONFIGURE} ) MESSAGE( STATUS "Vector Based Text Rendering: " ${ENABLE_VECTOR_BASED_TEXT_RENDERING} ) MESSAGE( STATUS "Enable link test: " ${ENABLE_LINK_TEST} ) MESSAGE( STATUS "Configure automated tests: " ${CONFIGURE_AUTOMATED_TESTS} ) -MESSAGE( STATUS "Build Dali Scene Loader: " ${BUILD_SCENE_LOADER} ) +MESSAGE( STATUS "Build Dali Scene3D: " ${BUILD_SCENE3D} ) MESSAGE( STATUS "CXXFLAGS: " ${CMAKE_CXX_FLAGS} ) MESSAGE( STATUS "LDFLAGS: " ${CMAKE_SHARED_LINKER_FLAGS_INIT}${CMAKE_SHARED_LINKER_FLAGS} ) diff --git a/build/tizen/dali-scene-loader/CMakeLists.txt b/build/tizen/dali-scene3d/CMakeLists.txt similarity index 82% rename from build/tizen/dali-scene-loader/CMakeLists.txt rename to build/tizen/dali-scene3d/CMakeLists.txt index f900b5a..08e646e 100644 --- a/build/tizen/dali-scene-loader/CMakeLists.txt +++ b/build/tizen/dali-scene3d/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.8.2) -set(name "dali2-scene-loader") +set(name "dali2-scene3d") project(${name} CXX) @@ -8,13 +8,13 @@ set(${name}_VERSION_MINOR 0) set(${name}_VERSION_PATCH 0) set(${name}_VERSION ${${name}_VERSION_MAJOR}.${${name}_VERSION_MINOR}.${${name}_VERSION_PATCH} ) -SET(DALI_SCENE_LOADER_VERSION ${${name}_VERSION} ) +SET(DALI_SCENE3D_VERSION ${${name}_VERSION} ) if(CMAKE_BUILD_TYPE MATCHES Debug) add_definitions("-DDEBUG_ENABLED") endif() -ADD_DEFINITIONS( "-DBUILDING_DALI_SCENE_LOADER" ) +ADD_DEFINITIONS( "-DBUILDING_DALI_SCENE3D" ) foreach(flag ${PKGS_CFLAGS}) set(extra_flags "${extra_flags} ${flag}") @@ -34,7 +34,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") set(prefix ${CMAKE_INSTALL_PREFIX}) set(repo_root_dir "${CMAKE_CURRENT_LIST_DIR}/../../../") -set(scene_loader_dir "${repo_root_dir}/dali-scene-loader") +set(scene3d_dir "${repo_root_dir}/dali-scene3d") option(ENABLE_PKG_CONFIGURE "Use pkgconfig" ON) option(ENABLE_COVERAGE "Coverage" OFF) @@ -66,13 +66,13 @@ if (ENABLE_PKG_CONFIGURE) set(EXEC_PREFIX ${CMAKE_INSTALL_PREFIX}) set(DEV_INCLUDE_PATH ${INCLUDE_DIR}) - set(core_pkg_cfg_file dali2-scene-loader.pc) + set(core_pkg_cfg_file dali2-scene3d.pc) configure_file(${CMAKE_CURRENT_LIST_DIR}/${core_pkg_cfg_file}.in ${core_pkg_cfg_file} @ONLY) endif() -set(scene_loader_src_files "") -include("${scene_loader_dir}/internal/file.list") -include("${scene_loader_dir}/public-api/file.list") +set(scene3d_src_files "") +include("${scene3d_dir}/internal/file.list") +include("${scene3d_dir}/public-api/file.list") set(prefix_include_dir "${prefix}/include") include_directories(${repo_root_dir} @@ -80,10 +80,10 @@ include_directories(${repo_root_dir} ) # 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") +SET(SHADER_SOURCE_DIR "${scene3d_dir}/internal/graphics/shaders/") +SET(SHADER_GENERATED_DIR "${scene3d_dir}/internal/graphics/generated") -SET(GENERATED_SHADER_DIR ${scene_loader_dir}/internal/graphics/) +SET(GENERATED_SHADER_DIR ${scene3d_dir}/internal/graphics/) SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_SHADER_DIR}/generated/" "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h") @@ -104,9 +104,9 @@ ADD_CUSTOM_COMMAND(OUTPUT ${BUILT_IN_SHADER_GEN_CPP} DEPENDS ${SHADER_GENERATOR_BINARY} COMMAND ${SHADER_GENERATOR_BINARY} ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}) -SET( scene_loader_src_files ${scene_loader_src_files} ${BUILT_IN_SHADER_GEN_CPP} ) +SET( scene3d_src_files ${scene3d_src_files} ${BUILT_IN_SHADER_GEN_CPP} ) -add_library(${name} SHARED ${scene_loader_src_files}) +add_library(${name} SHARED ${scene3d_src_files}) target_link_libraries(${name} ${DALICORE_LDFLAGS} ${DALIADAPTOR_LDFLAGS} dali2-toolkit @@ -119,7 +119,7 @@ endif() IF( INSTALL_CMAKE_MODULES ) SET_TARGET_PROPERTIES( ${name} PROPERTIES - VERSION ${DALI_SCENE_LOADER_VERSION} + VERSION ${DALI_SCENE3D_VERSION} SOVERSION ${${name}_VERSION_MAJOR} CLEAN_DIRECT_OUPUT 1 ) @@ -160,9 +160,9 @@ ELSE() INSTALL( TARGETS ${name} DESTINATION ${LIB_DIR} ) ENDIF() -file(GLOB scene_loader_include_files ${scene_loader_public_api_dir}) -install(DIRECTORY ${scene_loader_include_files} - DESTINATION "${prefix_include_dir}/dali-scene-loader" +file(GLOB scene3d_include_files ${scene3d_public_api_dir}) +install(DIRECTORY ${scene3d_include_files} + DESTINATION "${prefix_include_dir}/dali-scene3d" FILES_MATCHING PATTERN "*.h" ) diff --git a/build/tizen/dali-scene-loader/build.sh b/build/tizen/dali-scene3d/build.sh similarity index 100% rename from build/tizen/dali-scene-loader/build.sh rename to build/tizen/dali-scene3d/build.sh diff --git a/build/tizen/dali-scene-loader/dali2-scene-loader.pc.in b/build/tizen/dali-scene3d/dali2-scene3d.pc.in similarity index 51% rename from build/tizen/dali-scene-loader/dali2-scene-loader.pc.in rename to build/tizen/dali-scene3d/dali2-scene3d.pc.in index 8f7e885..106e032 100644 --- a/build/tizen/dali-scene-loader/dali2-scene-loader.pc.in +++ b/build/tizen/dali-scene3d/dali2-scene3d.pc.in @@ -1,12 +1,12 @@ prefix=@PREFIX@ exec_prefix=@EXEC_PREFIX@ -apiversion=@DALI_SCENE_LOADER_VERSION@ +apiversion=@DALI_SCENE3D_VERSION@ libdir=@LIB_DIR@ includedir=@DEV_INCLUDE_PATH@ -Name: Dali 3D Engine Scene Loader -Description: Dali Scene Loader library +Name: Dali 3D Engine Scene3D +Description: Dali Scene3D library Version: ${apiversion} Requires: dali2-toolkit -Libs: -L${libdir} -ldali2-scene-loader +Libs: -L${libdir} -ldali2-scene3d Cflags: -I${includedir} diff --git a/build/tizen/docs-internal/dali-internal.doxy.in b/build/tizen/docs-internal/dali-internal.doxy.in index 7cf973a..1807df0 100644 --- a/build/tizen/docs-internal/dali-internal.doxy.in +++ b/build/tizen/docs-internal/dali-internal.doxy.in @@ -2293,7 +2293,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = DALI_CORE_API \ DALI_ADAPTOR_API \ DALI_TOOLKIT_API \ - DALI_SCENE_LOADER_API \ + DALI_SCENE3D_API \ DALI_INTERNAL \ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this diff --git a/build/tizen/docs/dali.doxy.in b/build/tizen/docs/dali.doxy.in index 0fefc0e..f60c723 100644 --- a/build/tizen/docs/dali.doxy.in +++ b/build/tizen/docs/dali.doxy.in @@ -999,7 +999,7 @@ INPUT = @DOXYGEN_DOCS_DIR@/content \ @prefix@/include/dali/devel-api \ ../../../dali-toolkit/public-api \ ../../../dali-toolkit/devel-api \ - ../../../dali-scene-loader/public-api \ + ../../../dali-scene3d/public-api \ ../../../automated-tests/README.md # This tag can be used to specify the character encoding of the source files @@ -2274,7 +2274,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = DALI_CORE_API \ DALI_ADAPTOR_API \ DALI_TOOLKIT_API \ - DALI_SCENE_LOADER_API \ + DALI_SCENE3D_API \ DALI_INTERNAL \ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this diff --git a/dali-scene-loader/internal/file.list b/dali-scene-loader/internal/file.list deleted file mode 100644 index 70d94f3..0000000 --- a/dali-scene-loader/internal/file.list +++ /dev/null @@ -1,8 +0,0 @@ -set(scene_loader_internal_dir "${scene_loader_dir}/internal") - -set(scene_loader_src_files ${scene_loader_src_files} - ${scene_loader_internal_dir}/gltf2-asset.cpp - ${scene_loader_internal_dir}/hash.cpp - ${scene_loader_internal_dir}/json-reader.cpp - ${scene_loader_internal_dir}/json-util.cpp -) diff --git a/dali-scene-loader/public-api/file.list b/dali-scene-loader/public-api/file.list deleted file mode 100644 index 488ed7b..0000000 --- a/dali-scene-loader/public-api/file.list +++ /dev/null @@ -1,29 +0,0 @@ -set(scene_loader_public_api_dir "${scene_loader_dir}/public-api") - -set(scene_loader_src_files ${scene_loader_src_files} - ${scene_loader_public_api_dir}/alpha-function-helper.cpp - ${scene_loader_public_api_dir}/animated-property.cpp - ${scene_loader_public_api_dir}/animation-definition.cpp - ${scene_loader_public_api_dir}/blend-shape-details.cpp - ${scene_loader_public_api_dir}/camera-parameters.cpp - ${scene_loader_public_api_dir}/customization.cpp - ${scene_loader_public_api_dir}/dli-loader.cpp - ${scene_loader_public_api_dir}/environment-definition.cpp - ${scene_loader_public_api_dir}/facial-animation-loader.cpp - ${scene_loader_public_api_dir}/gltf2-loader.cpp - ${scene_loader_public_api_dir}/ktx-loader.cpp - ${scene_loader_public_api_dir}/material-definition.cpp - ${scene_loader_public_api_dir}/matrix-stack.cpp - ${scene_loader_public_api_dir}/mesh-definition.cpp - ${scene_loader_public_api_dir}/node-definition.cpp - ${scene_loader_public_api_dir}/parse-renderer-state.cpp - ${scene_loader_public_api_dir}/renderer-state.cpp - ${scene_loader_public_api_dir}/resource-bundle.cpp - ${scene_loader_public_api_dir}/scene-definition.cpp - ${scene_loader_public_api_dir}/shader-definition.cpp - ${scene_loader_public_api_dir}/shader-definition-factory.cpp - ${scene_loader_public_api_dir}/skinning-details.cpp - ${scene_loader_public_api_dir}/string-callback.cpp - ${scene_loader_public_api_dir}/utils.cpp - ${scene_loader_public_api_dir}/view-projection.cpp -) diff --git a/dali-scene-loader.manifest b/dali-scene3d.manifest similarity index 100% rename from dali-scene-loader.manifest rename to dali-scene3d.manifest diff --git a/dali-scene-loader.manifest-smack b/dali-scene3d.manifest-smack similarity index 100% rename from dali-scene-loader.manifest-smack rename to dali-scene3d.manifest-smack diff --git a/dali-scene-loader/README.md b/dali-scene3d/README.md similarity index 99% rename from dali-scene-loader/README.md rename to dali-scene3d/README.md index b29c463..4174487 100644 --- a/dali-scene-loader/README.md +++ b/dali-scene3d/README.md @@ -213,7 +213,7 @@ DLI supports meshes that allow deformation by skeletal animation. These must def * `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`. +:warning: The maximum number of bones supported by DALi Scene3D 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`. @@ -241,7 +241,7 @@ Blend shapes provide alternate configurations of vertex `positions`, `normals` a ``` 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 `byteOffset` and `byteLength` of a buffer in the binary which defines the width (2 bytes) and height (2 bytes) of the texture that dali-scene3d 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; diff --git a/dali-scene3d/internal/controls/model-view/model-view-impl.cpp b/dali-scene3d/internal/controls/model-view/model-view-impl.cpp new file mode 100644 index 0000000..568b899 --- /dev/null +++ b/dali-scene3d/internal/controls/model-view/model-view-impl.cpp @@ -0,0 +1,552 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include "model-view-impl.h" + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Dali; + +namespace Dali +{ +namespace Scene3D +{ +namespace Internal +{ +namespace +{ +BaseHandle Create() +{ + return Scene3D::ModelView::New(std::string()); +} + +// Setup properties, signals and actions using the type-registry. +DALI_TYPE_REGISTRATION_BEGIN(Scene3D::ModelView, Toolkit::Control, Create); +DALI_TYPE_REGISTRATION_END() + +static constexpr uint32_t OFFSET_FOR_DIFFUSE_CUBE_TEXTURE = 2u; +static constexpr uint32_t OFFSET_FOR_SPECULAR_CUBE_TEXTURE = 1u; + +static constexpr Vector3 Y_DIRECTION(1.0f, -1.0f, 1.0f); + +static constexpr std::string_view KTX_EXTENSION = ".ktx"; +static constexpr std::string_view OBJ_EXTENSION = ".obj"; +static constexpr std::string_view GLTF_EXTENSION = ".gltf"; +static constexpr std::string_view DLI_EXTENSION = ".dli"; + +struct BoundingVolume +{ + void Init() + { + pointMin = Vector3(std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()); + pointMax = Vector3(std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min()); + } + + void ConsiderNewPointInVolume(const Vector3& position) + { + pointMin.x = std::min(position.x, pointMin.x); + pointMin.y = std::min(position.y, pointMin.y); + pointMin.z = std::min(position.z, pointMin.z); + + pointMax.x = std::max(position.x, pointMax.x); + pointMax.y = std::max(position.y, pointMax.y); + pointMax.z = std::max(position.z, pointMax.z); + } + + Vector3 CalculateSize() + { + return pointMax - pointMin; + } + + Vector3 CalculatePivot() + { + Vector3 pivot = pointMin / (pointMin - pointMax); + for(uint32_t i = 0; i < 3; ++i) + { + // To avoid divid by zero + if(pointMin[i] == pointMax[i]) + { + pivot[i] = 0.5f; + } + } + return pivot; + } + + Vector3 pointMin; + Vector3 pointMax; +}; + +Texture LoadCubeMap(const std::string& cubeMapPath) +{ + Texture cubeTexture; + Dali::Scene3D::Loader::CubeData cubeData; + if(Dali::Scene3D::Loader::LoadCubeMapData(cubeMapPath, cubeData)) + { + cubeTexture = cubeData.CreateTexture(); + } + else + { + DALI_LOG_ERROR("Fail to load cube map, %s\n", cubeMapPath.c_str()); + } + + return cubeTexture; +} + +void ConfigureBlendShapeShaders( + Dali::Scene3D::Loader::ResourceBundle& resources, const Dali::Scene3D::Loader::SceneDefinition& scene, Actor root, std::vector&& requests) +{ + std::vector errors; + auto onError = [&errors](const std::string& msg) { errors.push_back(msg); }; + if(!scene.ConfigureBlendshapeShaders(resources, root, std::move(requests), onError)) + { + Dali::Scene3D::Loader::ExceptionFlinger flinger(ASSERT_LOCATION); + for(auto& msg : errors) + { + flinger << msg << '\n'; + } + } +} + +void AddModelTreeToAABB(BoundingVolume& AABB, const Dali::Scene3D::Loader::SceneDefinition& scene, const Dali::Scene3D::Loader::Customization::Choices& choices, Dali::Scene3D::Loader::Index iNode, Dali::Scene3D::Loader::NodeDefinition::CreateParams& nodeParams, Matrix parentMatrix) +{ + static constexpr uint32_t BOX_POINT_COUNT = 8; + static uint32_t BBIndex[BOX_POINT_COUNT][3] = {{0, 0, 0}, {0, 1, 0}, {1, 0, 0}, {1, 1, 0}, {0, 0, 1}, {0, 1, 1}, {1, 0, 1}, {1, 1, 1}}; + + Matrix nodeMatrix; + const Dali::Scene3D::Loader::NodeDefinition* node = scene.GetNode(iNode); + Matrix localMatrix = node->GetLocalSpace(); + Matrix::Multiply(nodeMatrix, localMatrix, parentMatrix); + + Vector3 volume[2]; + if(node->GetExtents(nodeParams.mResources, volume[0], volume[1])) + { + for(uint32_t i = 0; i < BOX_POINT_COUNT; ++i) + { + Vector4 position = Vector4(volume[BBIndex[i][0]].x, volume[BBIndex[i][1]].y, volume[BBIndex[i][2]].z, 1.0f); + Vector4 objectPosition = nodeMatrix * position; + objectPosition /= objectPosition.w; + + AABB.ConsiderNewPointInVolume(Vector3(objectPosition)); + } + } + + if(node->mCustomization) + { + if(!node->mChildren.empty()) + { + auto choice = choices.Get(node->mCustomization->mTag); + Dali::Scene3D::Loader::Index i = std::min(choice != Dali::Scene3D::Loader::Customization::NONE ? choice : 0, static_cast(node->mChildren.size() - 1)); + + AddModelTreeToAABB(AABB, scene, choices, node->mChildren[i], nodeParams, nodeMatrix); + } + } + else + { + for(auto i : node->mChildren) + { + AddModelTreeToAABB(AABB, scene, choices, i, nodeParams, nodeMatrix); + } + } +} + +} // anonymous namespace + +ModelView::ModelView(const std::string& modelPath, const std::string& resourcePath) +: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)), + mModelPath(modelPath), + mResourcePath(resourcePath), + mModelLayer(), + mModelRoot(), + mNaturalSize(Vector3::ZERO), + mModelPivot(AnchorPoint::CENTER), + mIblScaleFactor(1.0f), + mFitSize(false), + mFitCenter(false) +{ +} + +ModelView::~ModelView() +{ +} + +Dali::Scene3D::ModelView ModelView::New(const std::string& modelPath, const std::string& resourcePath) +{ + ModelView* impl = new ModelView(modelPath, resourcePath); + + Dali::Scene3D::ModelView handle = Dali::Scene3D::ModelView(*impl); + + // Second-phase init of the implementation + // This can only be done after the CustomActor connection has been made... + impl->Initialize(); + + return handle; +} + +const Actor ModelView::GetModelRoot() +{ + return mModelRoot; +} + +void ModelView::FitSize(bool fit) +{ + mFitSize = fit; + ScaleModel(); +} + +void ModelView::FitCenter(bool fit) +{ + mFitCenter = fit; + FitModelPosition(); +} + +void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor) +{ + Texture diffuseTexture = LoadCubeMap(diffuse); + if(diffuseTexture) + { + Texture specularTexture = LoadCubeMap(specular); + if(specularTexture) + { + mDiffuseTexture = diffuseTexture; + mSpecularTexture = specularTexture; + mIblScaleFactor = scaleFactor; + + SetImageBasedLight(mModelRoot); + } + } +} + +uint32_t ModelView::GetAnimationCount() +{ + return mAnimations.size(); +} + +Dali::Animation ModelView::GetAnimation(uint32_t index) +{ + Dali::Animation animation; + if(mAnimations.size() > index) + { + animation = mAnimations[index].second; + } + return animation; +} + +Dali::Animation ModelView::GetAnimation(const std::string& name) +{ + Dali::Animation animation; + if(!name.empty()) + { + for(auto&& animationData : mAnimations) + { + if(animationData.first == name) + { + animation = animationData.second; + break; + } + } + } + return animation; +} + +/////////////////////////////////////////////////////////// +// +// Private methods +// + +void ModelView::OnSceneConnection(int depth) +{ + if(!mModelRoot) + { + LoadModel(); + } + + Control::OnSceneConnection(depth); +} + +void ModelView::OnInitialize() +{ + Actor self = Self(); + mModelLayer = Layer::New(); + mModelLayer.SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D); + mModelLayer.SetProperty(Layer::Property::DEPTH_TEST, true); + mModelLayer.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mModelLayer.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + mModelLayer.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, + Dimension::ALL_DIMENSIONS); + + // Models in glTF and dli are defined as right hand coordinate system. + // DALi uses left hand coordinate system. Scaling negative is for change winding order. + mModelLayer.SetProperty(Dali::Actor::Property::SCALE_Y, -1.0f); + self.Add(mModelLayer); +} + +Vector3 ModelView::GetNaturalSize() +{ + if(!mModelRoot) + { + LoadModel(); + } + + return mNaturalSize; +} + +float ModelView::GetHeightForWidth(float width) +{ + Extents padding; + padding = Self().GetProperty(Toolkit::Control::Property::PADDING); + return Control::GetHeightForWidth(width) + padding.top + padding.bottom; +} + +float ModelView::GetWidthForHeight(float height) +{ + Extents padding; + padding = Self().GetProperty(Toolkit::Control::Property::PADDING); + return Control::GetWidthForHeight(height) + padding.start + padding.end; +} + +void ModelView::OnRelayout(const Vector2& size, RelayoutContainer& container) +{ + Control::OnRelayout(size, container); + ScaleModel(); +} + +void ModelView::LoadModel() +{ + std::filesystem::path modelPath(mModelPath); + if(mResourcePath.empty()) + { + mResourcePath = std::string(modelPath.parent_path()) + "/"; + } + std::string extension = modelPath.extension(); + std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); + + Dali::Scene3D::Loader::ResourceBundle::PathProvider pathProvider = [&](Dali::Scene3D::Loader::ResourceType::Value type) { + return mResourcePath; + }; + + Dali::Scene3D::Loader::ResourceBundle resources; + Dali::Scene3D::Loader::SceneDefinition scene; + std::vector animGroups; + std::vector cameraParameters; + std::vector lights; + + std::vector animations; + animations.clear(); + + Dali::Scene3D::Loader::LoadResult output{resources, scene, animations, animGroups, cameraParameters, lights}; + + if(extension == DLI_EXTENSION) + { + Dali::Scene3D::Loader::DliLoader loader; + Dali::Scene3D::Loader::DliLoader::InputParams input{ + pathProvider(Dali::Scene3D::Loader::ResourceType::Mesh), + nullptr, + {}, + {}, + nullptr, + {}}; + Dali::Scene3D::Loader::DliLoader::LoadParams loadParams{input, output}; + if(!loader.LoadScene(mModelPath, loadParams)) + { + Dali::Scene3D::Loader::ExceptionFlinger(ASSERT_LOCATION) << "Failed to load scene from '" << mModelPath << "': " << loader.GetParseError(); + } + } + else if(extension == GLTF_EXTENSION) + { + Dali::Scene3D::Loader::ShaderDefinitionFactory sdf; + sdf.SetResources(resources); + Dali::Scene3D::Loader::LoadGltfScene(mModelPath, sdf, output); + + resources.mEnvironmentMaps.push_back({}); + } + else + { + DALI_LOG_ERROR("Unsupported model type.\n"); + } + + Dali::Scene3D::Loader::Transforms xforms{Dali::Scene3D::Loader::MatrixStack{}, Dali::Scene3D::Loader::ViewProjection{}}; + Dali::Scene3D::Loader::NodeDefinition::CreateParams nodeParams{resources, xforms, {}, {}, {}}; + Dali::Scene3D::Loader::Customization::Choices choices; + + mModelRoot = Actor::New(); + + BoundingVolume AABB; + for(auto iRoot : scene.GetRoots()) + { + auto resourceRefs = resources.CreateRefCounter(); + scene.CountResourceRefs(iRoot, choices, resourceRefs); + resources.CountEnvironmentReferences(resourceRefs); + + resources.LoadResources(resourceRefs, pathProvider); + + // glTF Mesh is defined in right hand coordinate system, with positive Y for Up direction. + // Because DALi uses left hand system, Y direciton will be flipped for environment map sampling. + for(auto&& env : resources.mEnvironmentMaps) + { + env.first.mYDirection = Y_DIRECTION; + } + + if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams)) + { + scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor); + scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables)); + ConfigureBlendShapeShaders(resources, scene, actor, std::move(nodeParams.mBlendshapeRequests)); + + scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables)); + + mModelRoot.Add(actor); + } + + AddModelTreeToAABB(AABB, scene, choices, iRoot, nodeParams, Matrix::IDENTITY); + } + + if(!animations.empty()) + { + auto getActor = [&](const std::string& name) { + return mModelRoot.FindChildByName(name); + }; + + mAnimations.clear(); + for(auto&& animation : animations) + { + Dali::Animation anim = animation.ReAnimate(getActor); + + mAnimations.push_back({animation.mName, anim}); + } + } + + SetImageBasedLight(mModelRoot); + + mNaturalSize = AABB.CalculateSize(); + mModelPivot = AABB.CalculatePivot(); + mModelRoot.SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); + + FitModelPosition(); + ScaleModel(); + + mModelLayer.Add(mModelRoot); +} + +void ModelView::ScaleModel() +{ + if(mModelRoot) + { + if(mFitSize) + { + Vector3 size = Self().GetProperty(Dali::Actor::Property::SIZE); + if(size.x > 0.0f && size.y > 0.0f) + { + float scaleFactor = MAXFLOAT; + scaleFactor = std::min(size.x / mNaturalSize.x, scaleFactor); + scaleFactor = std::min(size.y / mNaturalSize.y, scaleFactor); + mModelRoot.SetProperty(Dali::Actor::Property::SCALE, scaleFactor); + } + else + { + DALI_LOG_ERROR("ModelView size is wrong."); + } + } + else + { + mModelRoot.SetProperty(Dali::Actor::Property::SCALE, 1.0f); + } + } +} + +void ModelView::FitModelPosition() +{ + if(mModelRoot) + { + if(mFitCenter) + { + // Loaded model pivot is not the model center. + mModelRoot.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mModelRoot.SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3::ONE - mModelPivot); + } + else + { + mModelRoot.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mModelRoot.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + } + } +} + +void ModelView::SetImageBasedLight(Actor node) +{ + if(!mDiffuseTexture || !mSpecularTexture || !node) + { + return; + } + + uint32_t rendererCount = node.GetRendererCount(); + if(rendererCount) + { + node.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), mIblScaleFactor); + } + + for(uint32_t i = 0; i < rendererCount; ++i) + { + Dali::Renderer renderer = node.GetRendererAt(i); + if(renderer) + { + Dali::TextureSet textures = renderer.GetTextures(); + if(textures) + { + uint32_t textureCount = textures.GetTextureCount(); + // EnvMap requires at least 2 texture, diffuse and specular + if(textureCount > 2u) + { + textures.SetTexture(textureCount - OFFSET_FOR_DIFFUSE_CUBE_TEXTURE, mDiffuseTexture); + textures.SetTexture(textureCount - OFFSET_FOR_SPECULAR_CUBE_TEXTURE, mSpecularTexture); + } + } + } + } + + uint32_t childrenCount = node.GetChildCount(); + for(uint32_t i = 0; i < childrenCount; ++i) + { + SetImageBasedLight(node.GetChildAt(i)); + } +} + +} // namespace Internal +} // namespace Scene3D +} // namespace Dali diff --git a/dali-scene3d/internal/controls/model-view/model-view-impl.h b/dali-scene3d/internal/controls/model-view/model-view-impl.h new file mode 100644 index 0000000..14b31f9 --- /dev/null +++ b/dali-scene3d/internal/controls/model-view/model-view-impl.h @@ -0,0 +1,187 @@ +#ifndef DALI_SCENE3D_INTERNAL_MODEL_VIEW_H +#define DALI_SCENE3D_INTERNAL_MODEL_VIEW_H + +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Scene3D +{ +class ModelView; + +namespace Internal +{ +/** + * @brief Impl class for ModelView. + */ +class ModelView : public Dali::Toolkit::Internal::Control +{ +public: + using AnimationData = std::pair; + + /** + * @brief Creates a new ModelView. + * + * @return A public handle to the newly allocated ModelView. + */ + static Dali::Scene3D::ModelView New(const std::string& modelPath, const std::string& resourcePath); + + /** + * @copydoc ModelView::GetModelRoot() + */ + const Actor GetModelRoot(); + + /** + * @copydoc ModelView::FitModel() + */ + void FitSize(bool fit); + + /** + * @copydoc ModelView::FitCenter() + */ + void FitCenter(bool fit); + + /** + * @copydoc ModelView::SetImageBasedLightSource() + */ + void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor); + + /** + * @copydoc ModelView::GetAnimationCount() + */ + uint32_t GetAnimationCount(); + + /** + * @copydoc ModelView::GetAnimation() + */ + Dali::Animation GetAnimation(uint32_t index); + + /** + * @copydoc ModelView::GetAnimation() + */ + Dali::Animation GetAnimation(const std::string& name); + +protected: + /** + * @brief Constructs a new ModelView. + */ + ModelView(const std::string& modelPath, const std::string& resourcePath); + + /** + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~ModelView(); + +private: + /** + * @copydoc CustomActorImpl::OnSceneConnection() + */ + void OnSceneConnection(int depth) override; + + /** + * @copydoc Toolkit::Control::OnInitialize() + */ + void OnInitialize() override; + + /** + * @copydoc Toolkit::Control::GetNaturalSize + */ + Vector3 GetNaturalSize() override; + + /** + * @copydoc Toolkit::Control::GetHeightForWidth() + */ + float GetHeightForWidth(float width) override; + + /** + * @copydoc Toolkit::Control::GetWidthForHeight() + */ + float GetWidthForHeight(float height) override; + + /** + * @copydoc Toolkit::Control::OnRelayout() + */ + void OnRelayout(const Vector2& size, RelayoutContainer& container) override; + + /** + * @brief Loads a model from file + */ + void LoadModel(); + + /** + * @brief Scales the model to fit the control or to return to original size. + */ + void ScaleModel(); + + /** + * @brief Changes model anchor point to set the model at center or returns to the original model pivot. + */ + void FitModelPosition(); + + /** + * @brief Changes IBL information of the input node. + */ + void SetImageBasedLight(Actor node); + +private: + std::string mModelPath; + std::string mResourcePath; + Dali::Layer mModelLayer; + Dali::Actor mModelRoot; + std::vector mAnimations; + + Dali::Texture mSpecularTexture; + Dali::Texture mDiffuseTexture; + Vector3 mNaturalSize; + Vector3 mModelPivot; + float mIblScaleFactor; + bool mFitSize; + bool mFitCenter; +}; + +} // namespace Internal + +// Helpers for public-api forwarding methods +inline Dali::Scene3D::Internal::ModelView& GetImpl(Dali::Scene3D::ModelView& obj) +{ + DALI_ASSERT_ALWAYS(obj); + Dali::RefObject& handle = obj.GetImplementation(); + return static_cast(handle); +} + +inline const Dali::Scene3D::Internal::ModelView& GetImpl(const Dali::Scene3D::ModelView& obj) +{ + DALI_ASSERT_ALWAYS(obj); + const Dali::RefObject& handle = obj.GetImplementation(); + return static_cast(handle); +} + +} // namespace Scene3D + +} // namespace Dali + +#endif // DALI_SCENE3D_INTERNAL_MODEL_VIEW_H diff --git a/dali-scene3d/internal/file.list b/dali-scene3d/internal/file.list new file mode 100644 index 0000000..b236f3c --- /dev/null +++ b/dali-scene3d/internal/file.list @@ -0,0 +1,9 @@ +set(scene3d_internal_dir "${scene3d_dir}/internal") + +set(scene3d_src_files ${scene3d_src_files} + ${scene3d_internal_dir}/loader/gltf2-asset.cpp + ${scene3d_internal_dir}/loader/hash.cpp + ${scene3d_internal_dir}/loader/json-reader.cpp + ${scene3d_internal_dir}/loader/json-util.cpp + ${scene3d_internal_dir}/controls/model-view/model-view-impl.cpp +) diff --git a/dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.frag b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag similarity index 98% rename from dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.frag rename to dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag index 3c295e3..a55e9c3 100644 --- a/dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.frag +++ b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag @@ -64,10 +64,11 @@ uniform vec3 uEmissiveFactor; #endif //// For IBL +uniform sampler2D sbrdfLUT; uniform samplerCube sDiffuseEnvSampler; uniform samplerCube sSpecularEnvSampler; -uniform sampler2D sbrdfLUT; uniform float uIblIntensity; +uniform vec3 uYDirection; // For Alpha Mode. uniform lowp float uOpaque; @@ -201,8 +202,8 @@ void main() mediump vec3 reflection = -normalize(reflect(v, n)); lowp vec3 color = vec3(0.0); - lowp vec3 diffuseLight = linear(texture(sDiffuseEnvSampler, n).rgb); - lowp vec3 specularLight = linear(texture(sSpecularEnvSampler, reflection).rgb); + lowp vec3 diffuseLight = linear(texture(sDiffuseEnvSampler, n * uYDirection).rgb); + lowp vec3 specularLight = linear(texture(sSpecularEnvSampler, reflection * uYDirection).rgb); // retrieve a scale and bias to F0. See [1], Figure 3 lowp vec3 brdf = linear(texture(sbrdfLUT, vec2(NdotV, 1.0 - perceptualRoughness)).rgb); diff --git a/dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.vert b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert similarity index 100% rename from dali-scene-loader/internal/graphics/shaders/default-physically-based-shader.vert rename to dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert diff --git a/dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.frag b/dali-scene3d/internal/graphics/shaders/scene3d-joint-debug.frag similarity index 100% rename from dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.frag rename to dali-scene3d/internal/graphics/shaders/scene3d-joint-debug.frag diff --git a/dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.vert b/dali-scene3d/internal/graphics/shaders/scene3d-joint-debug.vert similarity index 100% rename from dali-scene-loader/internal/graphics/shaders/scene-loader-joint-debug.vert rename to dali-scene3d/internal/graphics/shaders/scene3d-joint-debug.vert diff --git a/dali-scene-loader/internal/gltf2-asset.cpp b/dali-scene3d/internal/loader/gltf2-asset.cpp similarity index 97% rename from dali-scene-loader/internal/gltf2-asset.cpp rename to dali-scene3d/internal/loader/gltf2-asset.cpp index d0e183a..8297045 100644 --- a/dali-scene-loader/internal/gltf2-asset.cpp +++ b/dali-scene3d/internal/loader/gltf2-asset.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Samsung Electronics Co., Ltd. +* Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "dali-scene-loader/internal/gltf2-asset.h" +#include "dali-scene3d/internal/loader/gltf2-asset.h" #include #include #include "dali/public-api/math/matrix.h" diff --git a/dali-scene-loader/internal/gltf2-asset.h b/dali-scene3d/internal/loader/gltf2-asset.h similarity index 97% rename from dali-scene-loader/internal/gltf2-asset.h rename to dali-scene3d/internal/loader/gltf2-asset.h index e074c28..7769751 100644 --- a/dali-scene-loader/internal/gltf2-asset.h +++ b/dali-scene3d/internal/loader/gltf2-asset.h @@ -1,5 +1,5 @@ -#ifndef DALI_SCENE_LOADER_GLTF2_ASSET_H_ -#define DALI_SCENE_LOADER_GLTF2_ASSET_H_ +#ifndef DALI_SCENE3D_LOADER_GLTF2_ASSET_H_ +#define DALI_SCENE3D_LOADER_GLTF2_ASSET_H_ /* * Copyright (c) 2022 Samsung Electronics Co., Ltd. * @@ -18,8 +18,8 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/internal/json-reader.h" -#include "dali-scene-loader/public-api/index.h" +#include "dali-scene3d/internal/loader/json-reader.h" +#include "dali-scene3d/public-api/loader/index.h" // EXTERNAL INCLUDES #include @@ -31,7 +31,7 @@ namespace gltf2 { -using Index = Dali::SceneLoader::Index; +using Index = Dali::Scene3D::Loader::Index; template class Ref @@ -88,7 +88,7 @@ public: private: std::vector* mVector = nullptr; - Index mIndex = Dali::SceneLoader::INVALID_INDEX; + Index mIndex = Dali::Scene3D::Loader::INVALID_INDEX; }; struct Asset @@ -595,4 +595,4 @@ Dali::Quaternion ReadQuaternion(const json_value_s& j); } // namespace gltf2 -#endif //DALI_SCENE_LOADER_GLTF2_ASSET_H_ +#endif //DALI_SCENE3D_LOADER_GLTF2_ASSET_H_ diff --git a/dali-scene-loader/internal/hash.cpp b/dali-scene3d/internal/loader/hash.cpp similarity index 90% rename from dali-scene-loader/internal/hash.cpp rename to dali-scene3d/internal/loader/hash.cpp index 43d410f..d1ea70f 100644 --- a/dali-scene-loader/internal/hash.cpp +++ b/dali-scene3d/internal/loader/hash.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,13 @@ * limitations under the License. * */ -#include "dali-scene-loader/internal/hash.h" +#include "dali-scene3d/internal/loader/hash.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { Hash::Hash(uint64_t initial) : mValue(initial) @@ -91,5 +93,6 @@ uint64_t Hash::Concatenate(uint64_t value) return mValue * 31 + value; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/internal/hash.h b/dali-scene3d/internal/loader/hash.h similarity index 91% rename from dali-scene-loader/internal/hash.h rename to dali-scene3d/internal/loader/hash.h index 22b770e..a5bba8e 100644 --- a/dali-scene-loader/internal/hash.h +++ b/dali-scene3d/internal/loader/hash.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_HASH_H_ -#define DALI_SCENE_LOADER_HASH_H_ +#ifndef DALI_SCENE3D_LOADER_HASH_H_ +#define DALI_SCENE3D_LOADER_HASH_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Rudimentary hash generator that follows a builder pattern. @@ -117,7 +119,8 @@ Hash& Hash::AddObjectBytes(const T& value) return *this; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_HASH_H_ +#endif // DALI_SCENE3D_LOADER_HASH_H_ diff --git a/dali-scene-loader/internal/json-reader.cpp b/dali-scene3d/internal/loader/json-reader.cpp similarity index 94% rename from dali-scene-loader/internal/json-reader.cpp rename to dali-scene3d/internal/loader/json-reader.cpp index 0353817..ead6269 100644 --- a/dali-scene-loader/internal/json-reader.cpp +++ b/dali-scene3d/internal/loader/json-reader.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Samsung Electronics Co., Ltd. +* Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "dali-scene-loader/internal/json-reader.h" +#include "dali-scene3d/internal/loader/json-reader.h" #include #include diff --git a/dali-scene-loader/internal/json-reader.h b/dali-scene3d/internal/loader/json-reader.h similarity index 97% rename from dali-scene-loader/internal/json-reader.h rename to dali-scene3d/internal/loader/json-reader.h index 4fb6f7a..c0a8abd 100644 --- a/dali-scene-loader/internal/json-reader.h +++ b/dali-scene3d/internal/loader/json-reader.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_JSON_READER_H_ -#define DALI_SCENE_LOADER_JSON_READER_H_ +#ifndef DALI_SCENE3D_LOADER_JSON_READER_H_ +#define DALI_SCENE3D_LOADER_JSON_READER_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/third-party/json.h" +#include "dali-scene3d/third-party/json.h" // EXTERNAL INCLUDES #include @@ -447,4 +447,4 @@ void SetObjectReader(const Reader& r) } // namespace json -#endif //DALI_SCENE_LOADER_JSON_READER_H_ +#endif //DALI_SCENE3D_LOADER_JSON_READER_H_ diff --git a/dali-scene-loader/internal/json-util.cpp b/dali-scene3d/internal/loader/json-util.cpp similarity index 98% rename from dali-scene-loader/internal/json-util.cpp rename to dali-scene3d/internal/loader/json-util.cpp index 765568d..fcb91ad 100644 --- a/dali-scene-loader/internal/json-util.cpp +++ b/dali-scene3d/internal/loader/json-util.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. * */ -#include "dali-scene-loader/internal/json-util.h" +#include "dali-scene3d/internal/loader/json-util.h" // EXTERNAL INCLUDES #include @@ -32,7 +32,9 @@ namespace Dali { using namespace Toolkit; -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -525,5 +527,6 @@ Property::Value ReadPropertyValue(const Toolkit::TreeNode& tn) return propValue; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/internal/json-util.h b/dali-scene3d/internal/loader/json-util.h similarity index 90% rename from dali-scene-loader/internal/json-util.h rename to dali-scene3d/internal/loader/json-util.h index 9121bcd..1d2b983 100644 --- a/dali-scene-loader/internal/json-util.h +++ b/dali-scene3d/internal/loader/json-util.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_JSON_UTIL_H_ -#define DALI_SCENE_LOADER_JSON_UTIL_H_ +#ifndef DALI_SCENE3D_LOADER_JSON_UTIL_H_ +#define DALI_SCENE3D_LOADER_JSON_UTIL_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/index.h" +#include "dali-scene3d/public-api/loader/index.h" // EXTERNAL INCLUDES #include "dali-toolkit/devel-api/builder/tree-node.h" @@ -29,7 +29,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { bool ReadBool(const Toolkit::TreeNode* node, bool& num); @@ -88,7 +90,8 @@ Property::Value ReadPropertyValue(const Property::Type& propType, const Toolkit: */ Property::Value ReadPropertyValue(const Toolkit::TreeNode& tn); -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_JSON_UTIL_H_ +#endif //DALI_SCENE3D_LOADER_JSON_UTIL_H_ diff --git a/dali-scene-loader/public-api/api.h b/dali-scene3d/public-api/api.h similarity index 61% rename from dali-scene-loader/public-api/api.h rename to dali-scene3d/public-api/api.h index 45f4a1c..47ee583 100644 --- a/dali-scene-loader/public-api/api.h +++ b/dali-scene3d/public-api/api.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_API_H -#define DALI_SCENE_LOADER_API_H +#ifndef DALI_SCENE3D_API_H +#define DALI_SCENE3D_API_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,15 @@ */ #if __GNUC__ >= 4 -#define DALI_SCENE_LOADER_API __attribute__((visibility("default"))) +#define DALI_SCENE3D_API __attribute__((visibility("default"))) #elif defined(WIN32) -#ifdef BUILDING_DALI_SCENE_LOADER -#define DALI_SCENE_LOADER_API __declspec(dllexport) +#ifdef BUILDING_DALI_SCENE3D +#define DALI_SCENE3D_API __declspec(dllexport) #else -#define DALI_SCENE_LOADER_API __declspec(dllimport) -#endif // BUILDING_DALI_SCENE_LOADER +#define DALI_SCENE3D_API __declspec(dllimport) +#endif // BUILDING_DALI_SCENE3D #endif -#endif //DALI_SCENE_LOADER_API_H +#endif //DALI_SCENE3D_API_H diff --git a/dali-scene3d/public-api/controls/model-view/model-view.cpp b/dali-scene3d/public-api/controls/model-view/model-view.cpp new file mode 100644 index 0000000..b21726e --- /dev/null +++ b/dali-scene3d/public-api/controls/model-view/model-view.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Scene3D +{ +ModelView::ModelView() +{ +} + +ModelView::ModelView(const ModelView& modelView) = default; + +ModelView::ModelView(ModelView&& rhs) = default; + +ModelView& ModelView::operator=(const ModelView& modelView) = default; + +ModelView& ModelView::operator=(ModelView&& rhs) = default; + +ModelView::~ModelView() +{ +} + +ModelView ModelView::New(const std::string& modelPath, const std::string& resourcePath) +{ + return Internal::ModelView::New(modelPath, resourcePath); +} + +ModelView ModelView::DownCast(BaseHandle handle) +{ + return Control::DownCast(handle); +} + +ModelView::ModelView(Internal::ModelView& implementation) +: Control(implementation) +{ +} + +ModelView::ModelView(Dali::Internal::CustomActor* internal) +: Control(internal) +{ + VerifyCustomActorPointer(internal); +} + +const Actor ModelView::GetModelRoot() +{ + return GetImpl(*this).GetModelRoot(); +} + +void ModelView::FitSize(bool fit) +{ + GetImpl(*this).FitSize(fit); +} + +void ModelView::FitCenter(bool fit) +{ + GetImpl(*this).FitCenter(fit); +} + +void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor) +{ + GetImpl(*this).SetImageBasedLightSource(diffuse, specular, scaleFactor); +} + +uint32_t ModelView::GetAnimationCount() +{ + return GetImpl(*this).GetAnimationCount(); +} + +Dali::Animation ModelView::GetAnimation(uint32_t index) +{ + return GetImpl(*this).GetAnimation(index); +} + +Dali::Animation ModelView::GetAnimation(const std::string& name) +{ + return GetImpl(*this).GetAnimation(name); +} + +} // namespace Scene3D + +} // namespace Dali diff --git a/dali-scene3d/public-api/controls/model-view/model-view.h b/dali-scene3d/public-api/controls/model-view/model-view.h new file mode 100644 index 0000000..4c27f1a --- /dev/null +++ b/dali-scene3d/public-api/controls/model-view/model-view.h @@ -0,0 +1,214 @@ +#ifndef DALI_SCENE3D_MODEL_VIEW_H +#define DALI_SCENE3D_MODEL_VIEW_H + +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +// EXTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Scene3D +{ +namespace Internal DALI_INTERNAL +{ +class ModelView; +} + +/** + * @addtogroup dali_toolkit_controls_model_view + * @{ + */ + +/** + * @brief ModelView is a control to show 3D model objects. + * ModelView supports to load glTF 2.0 and DLI models for the input format + * and also supports Physically Based Rendering with Image Based Lighting. + * + * The Animations defined in the glTF or DLI models are also loaded and can be retrieved by using GetAnimation() method. + * The number of animation is also retrieved by GetAnimationCount() method. + * + * By default, The loaded model has it's own position and size which are defined in vertex buffer regardless of the Control size. + * The model can be resized and repositioned to fit to the ModelView Control with FitSize() and FitCenter() methods. + * + * @code + * + * ModelView modelView = ModelView::New(modelUrl); + * modelView.SetProperty(Dali::Actor::Property::SIZE, Vector2(width, height)); + * modelView.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + * modelView.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + * modelView.SetImageBasedLightSource(diffuseUrl, specularUrl, scaleFactor); + * modelView.FitSize(true); + * modelView.FitCenter(true); + * window.Add(modelView); + * uint32_t animationCount = modelView.GetAnimationCount(); + * Dali::Animation animation = modelView.GetAnimation(0); + * animation.Play(); + * + * @endcode + */ +class DALI_SCENE3D_API ModelView : public Dali::Toolkit::Control +{ +public: + /** + * @brief Create an initialized ModelView. + * @param[in] modelPath model file path.(e.g., glTF, and DLI). + * @param[in] resourcePath resource file path that includes binary, image etc. + * @note If resourcePath is empty, the parent directory path of modelPath is used for resource path. + * @return A handle to a newly allocated Dali resource + */ + static ModelView New(const std::string& modelPath, const std::string& resourcePath = std::string()); + + /** + * @brief Creates an uninitialized ModelView. + * + * Only derived versions can be instantiated. Calling member + * functions with an uninitialized Dali::Object is not allowed. + */ + ModelView(); + + /** + * @brief Destructor. + * + * This is non-virtual since derived Handle types must not contain data or virtual methods. + */ + ~ModelView(); + + /** + * @brief Copy constructor. + * @param[in] modelView Handle to an object + */ + ModelView(const ModelView& modelView); + + /** + * @brief Move constructor + * + * @param[in] rhs A reference to the moved handle + */ + ModelView(ModelView&& rhs); + + /** + * @brief Assignment operator. + * @param[in] modelView Handle to an object + * @return reference to this + */ + ModelView& operator=(const ModelView& modelView); + + /** + * @brief Move assignment + * + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + ModelView& operator=(ModelView&& rhs); + + /** + * @brief Downcasts an Object handle to ModelView. + * + * If handle points to a ModelView, the downcast produces valid handle. + * If not, the returned handle is left uninitialized. + * + * @param[in] handle Handle to an object + * @return Handle to a ModelView or an uninitialized handle + */ + static ModelView DownCast(BaseHandle handle); + + /** + * @brief Retrieves model root Actor. + * @return Root Actor of the model. + */ + const Actor GetModelRoot(); + + /** + * @brief Fits the model to the Control size. + * @param[in] fit true to fit model size to control. + * @note This method makes model fit to the Control size by keeping original model ratio. + * It means If model size is (2, 2, 2) and ModelView size is (10, 8), then the model become looks (8, 8, 8). + * If ModelView Size x or y is 0, this method don't work anything. + * If ModelView Size z is 0, this method considers only x and y values of ModelView Size. + */ + void FitSize(bool fit); + + /** + * @brief Moves the model to the center of control. + * @param[in] fit true to fit model to center of control. + * @note This method doesn't changes size of model. + */ + void FitCenter(bool fit); + + /** + * @brief Changes Image Based Light as the input textures. + * @param[in] diffuse cube map that can be used as a diffuse IBL source. + * @param[in] specular cube map that can be used as a specular IBL source. + * @param[in] scaleFactor scale factor that controls light source intensity in [0.0f, 1.0f]. Default value is 1.0f. + */ + void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor = 1.0f); + + /** + * @brief Gets number of animations those loaded from model file. + * @return The number of loaded animations. + * @note This method should be called after Model load finished. + */ + uint32_t GetAnimationCount(); + + /** + * @brief Gets animation at the index. + * @param[in] index Index of animation to be retrieved. + * @return Animation at the index. + * @note This method should be called after Model load finished. + */ + Dali::Animation GetAnimation(uint32_t index); + + /** + * @brief Retrieves animation with the given name. + * @param[in] name string name of animation to be retrieved. + * @return Animation that has the given name. + * @note This method should be called after Model load finished. + */ + Dali::Animation GetAnimation(const std::string& name); + +public: // Not intended for application developers + /// @cond internal + /** + * @brief Creates a handle using the Toolkit::Internal implementation. + * + * @param[in] implementation The Control implementation + */ + DALI_INTERNAL ModelView(Internal::ModelView& implementation); + + /** + * @brief Allows the creation of this Control from an Internal::CustomActor pointer. + * + * @param[in] internal A pointer to the internal CustomActor + */ + DALI_INTERNAL ModelView(Dali::Internal::CustomActor* internal); + /// @endcond +}; + +/** + * @} + */ +} // namespace Scene3D + +} // namespace Dali + +#endif // DALI_SCENE3D_MODEL_VIEW_H diff --git a/dali-scene3d/public-api/file.list b/dali-scene3d/public-api/file.list new file mode 100644 index 0000000..23d4702 --- /dev/null +++ b/dali-scene3d/public-api/file.list @@ -0,0 +1,34 @@ +set(scene3d_public_api_dir "${scene3d_dir}/public-api") + +set(scene3d_src_files ${scene3d_src_files} + ${scene3d_public_api_dir}/controls/model-view/model-view.cpp + ${scene3d_public_api_dir}/loader/alpha-function-helper.cpp + ${scene3d_public_api_dir}/loader/animated-property.cpp + ${scene3d_public_api_dir}/loader/animation-definition.cpp + ${scene3d_public_api_dir}/loader/blend-shape-details.cpp + ${scene3d_public_api_dir}/loader/bvh-loader.cpp + ${scene3d_public_api_dir}/loader/camera-parameters.cpp + ${scene3d_public_api_dir}/loader/cube-data.cpp + ${scene3d_public_api_dir}/loader/cube-loader.cpp + ${scene3d_public_api_dir}/loader/cube-map-loader.cpp + ${scene3d_public_api_dir}/loader/customization.cpp + ${scene3d_public_api_dir}/loader/dli-loader.cpp + ${scene3d_public_api_dir}/loader/environment-definition.cpp + ${scene3d_public_api_dir}/loader/facial-animation-loader.cpp + ${scene3d_public_api_dir}/loader/gltf2-loader.cpp + ${scene3d_public_api_dir}/loader/ktx-loader.cpp + ${scene3d_public_api_dir}/loader/material-definition.cpp + ${scene3d_public_api_dir}/loader/matrix-stack.cpp + ${scene3d_public_api_dir}/loader/mesh-definition.cpp + ${scene3d_public_api_dir}/loader/node-definition.cpp + ${scene3d_public_api_dir}/loader/parse-renderer-state.cpp + ${scene3d_public_api_dir}/loader/renderer-state.cpp + ${scene3d_public_api_dir}/loader/resource-bundle.cpp + ${scene3d_public_api_dir}/loader/scene-definition.cpp + ${scene3d_public_api_dir}/loader/shader-definition.cpp + ${scene3d_public_api_dir}/loader/shader-definition-factory.cpp + ${scene3d_public_api_dir}/loader/skinning-details.cpp + ${scene3d_public_api_dir}/loader/string-callback.cpp + ${scene3d_public_api_dir}/loader/utils.cpp + ${scene3d_public_api_dir}/loader/view-projection.cpp +) \ No newline at end of file diff --git a/dali-scene-loader/public-api/alpha-function-helper.cpp b/dali-scene3d/public-api/loader/alpha-function-helper.cpp similarity index 90% rename from dali-scene-loader/public-api/alpha-function-helper.cpp rename to dali-scene3d/public-api/loader/alpha-function-helper.cpp index b5168e0..1ac61ee 100644 --- a/dali-scene-loader/public-api/alpha-function-helper.cpp +++ b/dali-scene3d/public-api/loader/alpha-function-helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,14 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/alpha-function-helper.h" +#include "dali-scene3d/public-api/loader/alpha-function-helper.h" #include namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -65,5 +67,6 @@ void RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn) "Function with given key already exists."); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/alpha-function-helper.h b/dali-scene3d/public-api/loader/alpha-function-helper.h similarity index 63% rename from dali-scene-loader/public-api/alpha-function-helper.h rename to dali-scene3d/public-api/loader/alpha-function-helper.h index a524b81..d421a3e 100644 --- a/dali-scene-loader/public-api/alpha-function-helper.h +++ b/dali-scene3d/public-api/loader/alpha-function-helper.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_ALPHA_FUNCTION_HELPER_H_ -#define DALI_SCENE_LOADER_ALPHA_FUNCTION_HELPER_H_ +#ifndef DALI_SCENE3D_LOADER_ALPHA_FUNCTION_HELPER_H_ +#define DALI_SCENE3D_LOADER_ALPHA_FUNCTION_HELPER_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,28 +17,31 @@ * */ -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" #include #include "dali/public-api/animation/alpha-function.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @return Given a name, provide a AlphaFunction; if the name was not * recognised, get the default one. */ -AlphaFunction DALI_SCENE_LOADER_API GetAlphaFunction(const std::string& name, bool* found = nullptr); +AlphaFunction DALI_SCENE3D_API GetAlphaFunction(const std::string& name, bool* found = nullptr); /** * @brief Registers an alpha function only if one with the same @a name has * not yet been registered. Throws Exception the name isn't unique. */ -void DALI_SCENE_LOADER_API RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn) noexcept(false); +void DALI_SCENE3D_API RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn) noexcept(false); -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_ALPHA_FUNCTION_HELPER_H_ +#endif //DALI_SCENE3D_LOADER_ALPHA_FUNCTION_HELPER_H_ diff --git a/dali-scene-loader/public-api/animated-property.cpp b/dali-scene3d/public-api/loader/animated-property.cpp similarity index 85% rename from dali-scene-loader/public-api/animated-property.cpp rename to dali-scene3d/public-api/loader/animated-property.cpp index 3d1542d..5f15815 100644 --- a/dali-scene-loader/public-api/animated-property.cpp +++ b/dali-scene3d/public-api/loader/animated-property.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,13 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/animated-property.h" +#include "dali-scene3d/public-api/loader/animated-property.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { void AnimatedProperty::Animate(Animation& anim, GetActor getActor) { @@ -43,5 +45,6 @@ void AnimatedProperty::Animate(Animation& anim, GetActor getActor) } } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/animated-property.h b/dali-scene3d/public-api/loader/animated-property.h similarity index 87% rename from dali-scene-loader/public-api/animated-property.h rename to dali-scene3d/public-api/loader/animated-property.h index 085b977..6433d5c 100644 --- a/dali-scene-loader/public-api/animated-property.h +++ b/dali-scene3d/public-api/loader/animated-property.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_ANIMATED_PROPERTY_H -#define DALI_SCENE_LOADER_ANIMATED_PROPERTY_H +#ifndef DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H +#define DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include @@ -29,7 +29,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Intermediate representation for a property that's given to @@ -38,7 +40,7 @@ namespace SceneLoader * changing properties (e.g. from the SDK) requires the whole Animation * object to be recreated with all of its properties (incl. modifications). */ -struct DALI_SCENE_LOADER_API AnimatedProperty +struct DALI_SCENE3D_API AnimatedProperty { public: // METHODS /** @@ -90,7 +92,8 @@ public: // DATA TimePeriod mTimePeriod = TimePeriod(0.f); }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_ANIMATED_PROPERTY_H +#endif //DALI_SCENE3D_LOADER_ANIMATED_PROPERTY_H diff --git a/dali-scene-loader/public-api/animation-definition.cpp b/dali-scene3d/public-api/loader/animation-definition.cpp similarity index 92% rename from dali-scene-loader/public-api/animation-definition.cpp rename to dali-scene3d/public-api/loader/animation-definition.cpp index 850dd00..6f24d9e 100644 --- a/dali-scene-loader/public-api/animation-definition.cpp +++ b/dali-scene3d/public-api/loader/animation-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,13 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/animation-definition.h" +#include "dali-scene3d/public-api/loader/animation-definition.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { const float AnimationDefinition::DEFAULT_DURATION_SECONDS = 1.f; const float AnimationDefinition::MIN_DURATION_SECONDS = 1e-2f; @@ -83,5 +85,6 @@ AnimationDefinition& AnimationDefinition::operator=(AnimationDefinition&& other) return *this; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/animation-definition.h b/dali-scene3d/public-api/loader/animation-definition.h similarity index 84% rename from dali-scene-loader/public-api/animation-definition.h rename to dali-scene3d/public-api/loader/animation-definition.h index ea0dcb9..cb8e5db 100644 --- a/dali-scene-loader/public-api/animation-definition.h +++ b/dali-scene3d/public-api/loader/animation-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_ANIMATION_DEFINITION_H -#define DALI_SCENE_LOADER_ANIMATION_DEFINITION_H +#ifndef DALI_SCENE3D_LOADER_ANIMATION_DEFINITION_H +#define DALI_SCENE3D_LOADER_ANIMATION_DEFINITION_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,18 +17,20 @@ * */ -#include "dali-scene-loader/public-api/animated-property.h" -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/animated-property.h" #include "dali/public-api/common/vector-wrapper.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Animation handle + name + definition of properties. */ -class DALI_SCENE_LOADER_API AnimationDefinition +class DALI_SCENE3D_API AnimationDefinition { public: // STATIC // For Animations created in the SDK. @@ -81,7 +83,8 @@ struct AnimationGroupDefinition std::vector mAnimations; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_ANIMATION_DEFINITION_H +#endif //DALI_SCENE3D_LOADER_ANIMATION_DEFINITION_H diff --git a/dali-scene-loader/public-api/blend-shape-details.cpp b/dali-scene3d/public-api/loader/blend-shape-details.cpp similarity index 93% rename from dali-scene-loader/public-api/blend-shape-details.cpp rename to dali-scene3d/public-api/loader/blend-shape-details.cpp index 110f28c..01601f9 100644 --- a/dali-scene-loader/public-api/blend-shape-details.cpp +++ b/dali-scene3d/public-api/loader/blend-shape-details.cpp @@ -17,18 +17,20 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include #include // INTERNAL INCLUDES -#include +#include namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { const std::string BlendShapes::NUMBER_OF_BLEND_SHAPES("uNumberOfBlendShapes"); const std::string BlendShapes::UNNORMALIZE_FACTOR("uBlendShapeUnnormalizeFactor"); @@ -83,5 +85,6 @@ void BlendShapes::ConfigureProperties(const std::pair @@ -27,12 +27,14 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { struct MeshDefinition; struct MeshGeometry; -struct DALI_SCENE_LOADER_API BlendShapes +struct DALI_SCENE3D_API BlendShapes { enum class Version { @@ -71,7 +73,8 @@ struct DALI_SCENE_LOADER_API BlendShapes BlendShapes() = delete; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_BLEND_SHAPE_DETAILS_H +#endif // DALI_SCENE3D_LOADER_BLEND_SHAPE_DETAILS_H diff --git a/dali-scene3d/public-api/loader/bvh-loader.cpp b/dali-scene3d/public-api/loader/bvh-loader.cpp new file mode 100644 index 0000000..fc6815d --- /dev/null +++ b/dali-scene3d/public-api/loader/bvh-loader.cpp @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// FILE HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace Scene3D +{ +namespace Loader +{ +namespace +{ +static constexpr std::string_view TOKEN_OFFSET = "OFFSET"; +static constexpr std::string_view TOKEN_CHANNELS = "CHANNELS"; +static constexpr std::string_view TOKEN_XPOSITION = "Xposition"; +static constexpr std::string_view TOKEN_YPOSITION = "Yposition"; +static constexpr std::string_view TOKEN_ZPOSITION = "Zposition"; +static constexpr std::string_view TOKEN_XROTATION = "Xrotation"; +static constexpr std::string_view TOKEN_YROTATION = "Yrotation"; +static constexpr std::string_view TOKEN_ZROTATION = "Zrotation"; +static constexpr std::string_view TOKEN_JOINT = "JOINT"; +static constexpr std::string_view TOKEN_END_SITE = "End Site"; +static constexpr std::string_view TOKEN_FRAMES = "Frames"; +static constexpr std::string_view TOKEN_FRAME_TIME = "Frame Time"; +static constexpr std::string_view TOKEN_HIERARCHY = "HIERARCHY"; +static constexpr std::string_view TOKEN_ROOT = "ROOT"; +static constexpr std::string_view TOKEN_MOTION = "MOTION"; +static constexpr std::string_view PROPERTY_NAME_POSITION = "position"; +static constexpr std::string_view PROPERTY_NAME_ORIENTATION = "orientation"; +static constexpr std::string_view TOKEN_CLOSING_BRACE = "}"; + +enum class Channel +{ + XPOSITION = 0, + YPOSITION, + ZPOSITION, + XROTATION, + YROTATION, + ZROTATION +}; + +struct Frame +{ + std::vector values; +}; + +struct Joint +{ + std::string name; + Vector3 offset; + std::vector translations; + std::vector rotations; + std::vector channels; + std::vector> children; +}; + +void trim(std::string& s) +{ + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { + return !std::isspace(ch); + })); + s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { + return !std::isspace(ch); + }).base(), + s.end()); +} + +void ParseHierarchy(std::ifstream& file, std::shared_ptr& joint) +{ + std::string line; + while(std::getline(file, line)) + { + trim(line); + std::istringstream stream(line); + std::string token; + std::getline(stream, token, ' '); + + if(token == TOKEN_OFFSET.data()) + { + stream >> joint->offset.x >> joint->offset.y >> joint->offset.z; + } + else if(token == TOKEN_CHANNELS.data()) + { + uint32_t channelCount = 0; + std::getline(stream, token, ' '); + channelCount = static_cast(std::atoi(token.c_str())); + for(uint32_t i = 0; i < channelCount; ++i) + { + std::getline(stream, token, ' '); + trim(token); + if(token == TOKEN_XPOSITION.data()) + { + joint->channels.push_back(Channel::XPOSITION); + } + else if(token == TOKEN_YPOSITION.data()) + { + joint->channels.push_back(Channel::YPOSITION); + } + else if(token == TOKEN_ZPOSITION.data()) + { + joint->channels.push_back(Channel::ZPOSITION); + } + else if(token == TOKEN_XROTATION.data()) + { + joint->channels.push_back(Channel::XROTATION); + } + else if(token == TOKEN_YROTATION.data()) + { + joint->channels.push_back(Channel::YROTATION); + } + else if(token == TOKEN_ZROTATION.data()) + { + joint->channels.push_back(Channel::ZROTATION); + } + } + } + else if(token == TOKEN_JOINT.data()) + { + std::shared_ptr child(new Joint); + joint->children.push_back(child); + std::getline(stream, token, ' '); + child->name = token; + ParseHierarchy(file, child); + } + else if(line == TOKEN_END_SITE.data()) + { + while(std::getline(file, line)) + { + trim(line); + if(line == TOKEN_CLOSING_BRACE.data()) + { + break; + } + } + } + else if(token == TOKEN_CLOSING_BRACE.data()) + { + break; + } + } +} + +void MakeList(std::shared_ptr& joint, std::vector>& jointList) +{ + jointList.push_back(joint); + for(uint32_t i = 0; i < joint->children.size(); ++i) + { + MakeList(joint->children[i], jointList); + } +} + +void ParseMotion(std::ifstream& file, std::shared_ptr& hierarchy, uint32_t& frameCount, float& frameTime) +{ + std::vector> jointList; + MakeList(hierarchy, jointList); + + bool frameCountLoaded = false; + bool frameTimeLoaded = false; + std::string line; + while((!frameCountLoaded || !frameTimeLoaded) && std::getline(file, line)) + { + trim(line); + std::istringstream stream(line); + std::string token; + std::getline(stream, token, ':'); + trim(token); + if(token == TOKEN_FRAMES.data()) + { + stream >> frameCount; + frameCountLoaded = true; + } + else if(token == TOKEN_FRAME_TIME.data()) + { + stream >> frameTime; + frameTimeLoaded = true; + } + } + + while(getline(file, line)) + { + trim(line); + std::istringstream stream(line); + for(auto&& joint : jointList) + { + Vector3 translation; + Quaternion rotation[3]; + for(uint32_t i = 0; i < joint->channels.size(); ++i) + { + if(joint->channels[i] == Channel::XPOSITION) + { + stream >> translation.x; + } + else if(joint->channels[i] == Channel::YPOSITION) + { + stream >> translation.y; + } + else if(joint->channels[i] == Channel::ZPOSITION) + { + stream >> translation.z; + } + else if(joint->channels[i] == Channel::XROTATION) + { + float radian; + stream >> radian; + rotation[0] = Quaternion(Radian(Degree(radian)), Vector3::XAXIS); + } + else if(joint->channels[i] == Channel::YROTATION) + { + float radian; + stream >> radian; + rotation[1] = Quaternion(Radian(Degree(radian)), Vector3::YAXIS); + } + else if(joint->channels[i] == Channel::ZROTATION) + { + float radian; + stream >> radian; + rotation[2] = Quaternion(Radian(Degree(radian)), Vector3::ZAXIS); + } + } + joint->translations.push_back(translation); + joint->rotations.push_back(rotation[2] * rotation[0] * rotation[1]); + } + } +} + +bool ParseBvh(const std::string& path, uint32_t& frameCount, float& frameTime, std::shared_ptr& rootJoint) +{ + std::ifstream file(path.data()); + if(!file.is_open()) + { + return false; + } + + std::string line; + while(getline(file, line)) + { + trim(line); + std::istringstream stream(line); + std::string token; + std::getline(stream, token, ' '); + if(token == TOKEN_HIERARCHY.data()) + { + std::string line; + while(getline(file, line)) + { + trim(line); + std::istringstream stream(line); + std::string token; + std::getline(stream, token, ' '); + if(token == TOKEN_ROOT.data()) + { + std::getline(stream, token, ' '); + rootJoint->name = token; + ParseHierarchy(file, rootJoint); + break; + } + } + } + if(token == TOKEN_MOTION.data()) + { + ParseMotion(file, rootJoint, frameCount, frameTime); + } + } + return true; +} + +AnimationDefinition GenerateAnimation(const std::string& animationName, std::shared_ptr& hierarchy, uint32_t frameCount, float frameTime, const Vector3& scale) +{ + AnimationDefinition animationDefinition; + + animationDefinition.mName = animationName; + animationDefinition.mDuration = frameTime * (frameCount - 1); + float keyFrameInterval = (frameCount > 1u) ? 1.0f / static_cast(frameCount - 1u) : Dali::Math::MACHINE_EPSILON_10; + + std::vector> jointList; + MakeList(hierarchy, jointList); + + if(!jointList.empty()) + { + animationDefinition.mProperties.resize(jointList.size() * 2u); // translation and rotation + for(uint32_t i = 0; i < jointList.size(); ++i) + { + AnimatedProperty& translationProperty = animationDefinition.mProperties[i * 2u]; + translationProperty.mTimePeriod = Dali::TimePeriod(animationDefinition.mDuration); + translationProperty.mNodeName = jointList[i]->name; + translationProperty.mPropertyName = PROPERTY_NAME_POSITION.data(); + + AnimatedProperty& rotationProperty = animationDefinition.mProperties[i * 2u + 1]; + rotationProperty.mTimePeriod = Dali::TimePeriod(animationDefinition.mDuration); + rotationProperty.mNodeName = jointList[i]->name; + rotationProperty.mPropertyName = PROPERTY_NAME_ORIENTATION.data(); + + translationProperty.mKeyFrames = Dali::KeyFrames::New(); + rotationProperty.mKeyFrames = Dali::KeyFrames::New(); + for(uint32_t j = 0; j < frameCount; ++j) + { + translationProperty.mKeyFrames.Add(static_cast(j) * keyFrameInterval, (jointList[i]->translations[j] / scale)); + rotationProperty.mKeyFrames.Add(static_cast(j) * keyFrameInterval, jointList[i]->rotations[j]); + } + } + } + + return animationDefinition; +} +} // namespace + +AnimationDefinition LoadBvh(const std::string& path, const std::string& animationName, const Vector3& scale) +{ + uint32_t frameCount = 0; + float frameTime = 0.0f; + std::shared_ptr rootJoint(new Joint); + if(!ParseBvh(path, frameCount, frameTime, rootJoint)) + { + AnimationDefinition animationDefinition; + return animationDefinition; + } + + return GenerateAnimation(animationName, rootJoint, frameCount, frameTime, scale); +} +} // namespace Loader +} // namespace Scene3D +} // namespace Dali \ No newline at end of file diff --git a/dali-scene3d/public-api/loader/bvh-loader.h b/dali-scene3d/public-api/loader/bvh-loader.h new file mode 100644 index 0000000..2c3dbc7 --- /dev/null +++ b/dali-scene3d/public-api/loader/bvh-loader.h @@ -0,0 +1,45 @@ +#ifndef DALI_SCENE3D_LOADER_BVH_LOADER_H +#define DALI_SCENE3D_LOADER_BVH_LOADER_H + +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Scene3D +{ +namespace Loader +{ + +/** + * @brief Loads motion capture data from bvh file format. + * + * @param[in] path The file path. + * @param[in] animationName Name of the motion capture animation + * @param[in] scale The scale factor to set on the position property manually. + * @return AnimationDefinition that includes joint animation information. + */ +DALI_SCENE3D_API AnimationDefinition LoadBvh(const std::string& path, const std::string& animationName, const Vector3& scale = Vector3::ONE); + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali + +#endif // DALI_SCENE3D_LOADER_BVH_LOADER_H \ No newline at end of file diff --git a/dali-scene-loader/public-api/camera-parameters.cpp b/dali-scene3d/public-api/loader/camera-parameters.cpp similarity index 96% rename from dali-scene-loader/public-api/camera-parameters.cpp rename to dali-scene3d/public-api/loader/camera-parameters.cpp index d895255..5207a27 100644 --- a/dali-scene-loader/public-api/camera-parameters.cpp +++ b/dali-scene3d/public-api/loader/camera-parameters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,17 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/camera-parameters.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/camera-parameters.h" +#include "dali-scene3d/public-api/loader/utils.h" #include "dali/integration-api/debug.h" #include "dali/public-api/actors/camera-actor.h" #include "dali/public-api/math/quaternion.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -222,5 +224,6 @@ void CameraParameters::ConfigureCamera(CameraActor& camera) const camera.SetProperty(Actor::Property::SCALE, camScale); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/camera-parameters.h b/dali-scene3d/public-api/loader/camera-parameters.h similarity index 76% rename from dali-scene-loader/public-api/camera-parameters.h rename to dali-scene3d/public-api/loader/camera-parameters.h index 06370fc..74d6eec 100644 --- a/dali-scene-loader/public-api/camera-parameters.h +++ b/dali-scene3d/public-api/loader/camera-parameters.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_CAMERA_PARAMETERS_H -#define DALI_SCENE_LOADER_CAMERA_PARAMETERS_H +#ifndef DALI_SCENE3D_LOADER_CAMERA_PARAMETERS_H +#define DALI_SCENE3D_LOADER_CAMERA_PARAMETERS_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/view-projection.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/view-projection.h" // EXTERNAL INCLUDES #include "dali/public-api/math/matrix.h" @@ -29,9 +29,11 @@ namespace Dali { class CameraActor; -namespace SceneLoader +namespace Scene3D { -struct DALI_SCENE_LOADER_API CameraParameters +namespace Loader +{ +struct DALI_SCENE3D_API CameraParameters { Matrix matrix = Matrix::IDENTITY; Vector4 orthographicSize = Vector4{-1.f, 1.f, 1.f, -1.f}; @@ -53,13 +55,14 @@ struct DALI_SCENE_LOADER_API CameraParameters /** * @brief Configures the camera in the way that it is supposed to be used with - * scene-loader scenes. This means inverted Y and a rotation of 180 degrees + * scene3d scenes. This means inverted Y and a rotation of 180 degrees * along the Y axis, plus whatever the parameters define. */ void ConfigureCamera(CameraActor& camera) const; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_CAMERA_PARAMETERS_H +#endif // DALI_SCENE3D_LOADER_CAMERA_PARAMETERS_H diff --git a/dali-scene3d/public-api/loader/cube-data.cpp b/dali-scene3d/public-api/loader/cube-data.cpp new file mode 100644 index 0000000..2714cc8 --- /dev/null +++ b/dali-scene3d/public-api/loader/cube-data.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// FILE HEADER +#include "dali-scene3d/public-api/loader/cube-data.h" + +// EXTERNAL INCLUDES +#include "dali/public-api/rendering/texture.h" + +namespace Dali +{ +namespace Scene3D +{ +namespace Loader +{ +Texture CubeData::CreateTexture() const +{ + Texture texture = Texture::New(TextureType::TEXTURE_CUBE, data[0][0].GetPixelFormat(), data[0][0].GetWidth(), data[0][0].GetHeight()); + for(size_t iSide = 0u, iEndSize = data.size(); iSide < iEndSize; ++iSide) + { + auto& side = data[iSide]; + for(size_t iMipLevel = 0u, iEndMipLevel = data[0].size(); iMipLevel < iEndMipLevel; ++iMipLevel) + { + texture.Upload(side[iMipLevel], CubeMapLayer::POSITIVE_X + iSide, iMipLevel, 0u, 0u, side[iMipLevel].GetWidth(), side[iMipLevel].GetHeight()); + } + } + + // If mipmap is not defined explicitly, use GenerateMipmaps. + // TODO: Maybe we can use better way to know it already has mipmap or not. + if(data.size() > 0u && data[0].size() == 1u) + { + texture.GenerateMipmaps(); + } + + return texture; +} + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali diff --git a/dali-scene-loader/public-api/ktx-loader.h b/dali-scene3d/public-api/loader/cube-data.h similarity index 63% rename from dali-scene-loader/public-api/ktx-loader.h rename to dali-scene3d/public-api/loader/cube-data.h index d94f4ca..961e0b2 100644 --- a/dali-scene-loader/public-api/ktx-loader.h +++ b/dali-scene3d/public-api/loader/cube-data.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_KTX_LOADER_H -#define DALI_SCENE_LOADER_KTX_LOADER_H +#ifndef DALI_SCENE3D_LOADER_CUBE_DATA_H +#define DALI_SCENE3D_LOADER_CUBE_DATA_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include "dali/public-api/common/vector-wrapper.h" @@ -27,27 +27,28 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Stores the pixel data objects for each face of the cube texture and their mipmaps. */ -struct DALI_SCENE_LOADER_API CubeData +class DALI_SCENE3D_API CubeData { - std::vector > data; - +public: + /** + * @brief Create cube texture from image file + * @return Texture loaded cube texture. + */ Texture CreateTexture() const; -}; -/** - * @brief Loads cube map data texture from a ktx file. - * - * @param[in] path The file path. - * @param[out] cubedata The data structure with all pixel data objects. - */ -DALI_SCENE_LOADER_API bool LoadCubeMapData(const std::string& path, CubeData& cubedata); +public: + std::vector > data; +}; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_KTX_LOADER_H +#endif // DALI_SCENE3D_LOADER_CUBE_DATA_H diff --git a/dali-scene3d/public-api/loader/cube-loader.cpp b/dali-scene3d/public-api/loader/cube-loader.cpp new file mode 100644 index 0000000..7573421 --- /dev/null +++ b/dali-scene3d/public-api/loader/cube-loader.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// FILE HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include + +namespace Dali +{ +namespace +{ +/** + * @brief cube map face index + * Cube map layer order is as fallows: + * POSITIVE_X, NEGATIVE_X, POSITIVE_Y, NEGATIVE_Y, POSITIVE_Z, NEGATIVE_Z. @see CubeMapLayer + * The indices are for 4 kind of environment cube map. Cross_horizontal, Array_horizontal, Cross_vertical, and Array_vertical. + */ +const uint32_t CUBEMAP_INDEX_X[4][6] = {{2, 0, 1, 1, 1, 3}, {0, 1, 2, 3, 4, 5}, {1, 1, 1, 1, 0, 2}, {0, 0, 0, 0, 0, 0}}; +const uint32_t CUBEMAP_INDEX_Y[4][6] = {{1, 1, 0, 2, 1, 1}, {0, 0, 0, 0, 0, 0}, {1, 3, 0, 2, 1, 1}, {0, 1, 2, 3, 4, 5}}; + +enum CubeType +{ + CROSS_HORIZONTAL = 0, // Cross horizontal style cube map + ARRAY_HORIZONTAL, // array horizontal style cube map + CROSS_VERTICAL, // Cross vertical style cube map + ARRAY_VERTICAL, // array vertical style cube map + NONE +}; + +uint8_t* GetCroppedBuffer(uint8_t* sourceBuffer, uint32_t bytesPerPixel, uint32_t width, uint32_t height, uint32_t xOffset, uint32_t yOffset, uint32_t xFaceSize, uint32_t yFaceSize) +{ + uint32_t byteSize = bytesPerPixel * xFaceSize * yFaceSize; + uint8_t* destBuffer = reinterpret_cast(malloc(byteSize + 4u)); + + int32_t srcStride = width * bytesPerPixel; + int32_t destStride = xFaceSize * bytesPerPixel; + int32_t srcOffset = xOffset * bytesPerPixel + yOffset * srcStride; + int32_t destOffset = 0; + for(uint16_t row = yOffset; row < yOffset + yFaceSize; ++row) + { + memcpy(destBuffer + destOffset, sourceBuffer + srcOffset, destStride); + srcOffset += srcStride; + destOffset += destStride; + } + + return destBuffer; +} + +PixelData GetCubeFace(Devel::PixelBuffer pixelBuffer, uint32_t faceIndex, CubeType cubeType, uint32_t faceSize) +{ + PixelData pixelData; + if(cubeType != NONE) + { + uint8_t* imageBuffer = pixelBuffer.GetBuffer(); + uint32_t bytesPerPixel = Pixel::GetBytesPerPixel(pixelBuffer.GetPixelFormat()); + uint32_t imageWidth = pixelBuffer.GetWidth(); + uint32_t imageHeight = pixelBuffer.GetHeight(); + + uint32_t xOffset = CUBEMAP_INDEX_X[cubeType][faceIndex] * faceSize; + uint32_t yOffset = CUBEMAP_INDEX_Y[cubeType][faceIndex] * faceSize; + + uint8_t* tempImageBuffer = GetCroppedBuffer(imageBuffer, bytesPerPixel, imageWidth, imageHeight, xOffset, yOffset, faceSize, faceSize); + pixelData = PixelData::New(tempImageBuffer, faceSize * faceSize * bytesPerPixel, faceSize, faceSize, pixelBuffer.GetPixelFormat(), PixelData::FREE); + } + return pixelData; +} +} // namespace + +namespace Scene3D +{ +namespace Loader +{ +bool LoadCubeData(const std::string& path, CubeData& cubedata) +{ + Texture cubeTexture; + // Diffuse Cube Map + if(path.empty()) + { + return false; + } + + Devel::PixelBuffer pixelBuffer = LoadImageFromFile(path); + if(pixelBuffer) + { + uint32_t imageWidth = pixelBuffer.GetWidth(); + uint32_t imageHeight = pixelBuffer.GetHeight(); + + uint32_t faceSize = 0; + CubeType cubeType = NONE; + if(imageWidth / 4 == imageHeight / 3) + { + cubeType = CROSS_HORIZONTAL; + faceSize = imageWidth / 4; + } + else if(imageWidth / 6 == imageHeight) + { + cubeType = ARRAY_HORIZONTAL; + faceSize = imageHeight; + } + else if(imageWidth / 3 == imageHeight / 4) + { + cubeType = CROSS_VERTICAL; + faceSize = imageHeight / 4; + } + else if(imageWidth == imageHeight / 6) + { + cubeType = ARRAY_VERTICAL; + faceSize = imageWidth; + } + else + { + DALI_LOG_ERROR("The image is not a cube map\n"); + return false; + } + + cubedata.data.resize(6); + for(uint32_t i = 0; i < 6; ++i) + { + cubedata.data[i].resize(1); + } + for(uint32_t i = 0; i < 6; ++i) + { + cubedata.data[i][0] = GetCubeFace(pixelBuffer, i, cubeType, faceSize); + } + + return true; + } + return false; +} + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali diff --git a/dali-scene3d/public-api/loader/cube-loader.h b/dali-scene3d/public-api/loader/cube-loader.h new file mode 100644 index 0000000..37b30b2 --- /dev/null +++ b/dali-scene3d/public-api/loader/cube-loader.h @@ -0,0 +1,43 @@ +#ifndef DALI_SCENE3D_LOADER_CUBE_LOADER_H +#define DALI_SCENE3D_LOADER_CUBE_LOADER_H +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Scene3D +{ +namespace Loader +{ +/** + * @brief Loads cube map data texture from a cube style image file. + * + * @param[in] path The file path. + * @param[out] cubedata The data structure with all pixel data objects. + * @return bool True if the loading is succeded. + */ +bool LoadCubeData(const std::string& path, CubeData& cubedata); + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali + +#endif // DALI_SCENE3D_LOADER_CUBE_LOADER_H diff --git a/dali-scene3d/public-api/loader/cube-map-loader.cpp b/dali-scene3d/public-api/loader/cube-map-loader.cpp new file mode 100644 index 0000000..c4aae09 --- /dev/null +++ b/dali-scene3d/public-api/loader/cube-map-loader.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// FILE HEADER +#include + +// INTERNAL INCLUDES +#include +#include + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ +namespace +{ +const std::string_view KTX_EXTENSION = ".ktx"; +} + +namespace Scene3D +{ +namespace Loader +{ +bool LoadCubeMapData(const std::string& path, CubeData& cubedata) +{ + std::filesystem::path modelPath(path); + std::string extension = modelPath.extension(); + std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower); + + return (extension == KTX_EXTENSION) ? Dali::Scene3D::Loader::LoadKtxData(path, cubedata) : Dali::Scene3D::Loader::LoadCubeData(path, cubedata); +} + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali diff --git a/dali-scene3d/public-api/loader/cube-map-loader.h b/dali-scene3d/public-api/loader/cube-map-loader.h new file mode 100644 index 0000000..ec7fd24 --- /dev/null +++ b/dali-scene3d/public-api/loader/cube-map-loader.h @@ -0,0 +1,43 @@ +#ifndef DALI_SCENE3D_LOADER_CUBE_MAP_LOADER_H +#define DALI_SCENE3D_LOADER_CUBE_MAP_LOADER_H +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Scene3D +{ +namespace Loader +{ +/** + * @brief Loads cube map data texture from a cube map file. + * + * @param[in] path The file path. + * @param[out] cubedata The data structure with all pixel data objects. + * @return bool True if the loading is succeded. + */ +bool LoadCubeMapData(const std::string& path, CubeData& cubedata); + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali + +#endif // DALI_SCENE3D_LOADER_CUBE_MAP_LOADER_H diff --git a/dali-scene-loader/public-api/customization.cpp b/dali-scene3d/public-api/loader/customization.cpp similarity index 92% rename from dali-scene-loader/public-api/customization.cpp rename to dali-scene3d/public-api/loader/customization.cpp index ebf59c0..f48c191 100644 --- a/dali-scene-loader/public-api/customization.cpp +++ b/dali-scene3d/public-api/loader/customization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,14 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/customization.h" +#include "dali-scene3d/public-api/loader/customization.h" #include "dali/devel-api/common/map-wrapper.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { struct Customization::Map::Impl { @@ -109,5 +111,6 @@ void Customization::Choices::Clear() mImpl->mOptions.clear(); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/customization.h b/dali-scene3d/public-api/loader/customization.h similarity index 86% rename from dali-scene-loader/public-api/customization.h rename to dali-scene3d/public-api/loader/customization.h index cdac2fc..667cada 100644 --- a/dali-scene-loader/public-api/customization.h +++ b/dali-scene3d/public-api/loader/customization.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_CUSTOMIZATION_STATE_H_ -#define DALI_SCENE_LOADER_CUSTOMIZATION_STATE_H_ +#ifndef DALI_SCENE3D_LOADER_CUSTOMIZATION_STATE_H_ +#define DALI_SCENE3D_LOADER_CUSTOMIZATION_STATE_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include @@ -27,14 +27,16 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Offers a description of an aspect of the scene that can be customized: * the number of options, and the name of the nodes that are registered * for the tag, whose children will be shown / hidden based on selection. */ -struct DALI_SCENE_LOADER_API Customization +struct DALI_SCENE3D_API Customization { using Tag = std::string; using OptionType = uint32_t; @@ -42,7 +44,7 @@ struct DALI_SCENE_LOADER_API Customization /** * @brief A mapping of customizations to tags. */ - struct DALI_SCENE_LOADER_API Map + struct DALI_SCENE3D_API Map { Map(); ~Map(); @@ -81,7 +83,7 @@ struct DALI_SCENE_LOADER_API Customization /** * @brief A mapping of choices - indices of children of customization nodes to use - to tags. */ - struct DALI_SCENE_LOADER_API Choices + struct DALI_SCENE3D_API Choices { Choices(); ~Choices(); @@ -117,7 +119,8 @@ struct DALI_SCENE_LOADER_API Customization std::vector nodes; // to apply option to. }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_CUSTOMIZATION_STATE_H_ +#endif //DALI_SCENE3D_LOADER_CUSTOMIZATION_STATE_H_ diff --git a/dali-scene-loader/public-api/dli-loader.cpp b/dali-scene3d/public-api/loader/dli-loader.cpp similarity index 89% rename from dali-scene-loader/public-api/dli-loader.cpp rename to dali-scene3d/public-api/loader/dli-loader.cpp index 2c8bd97..96555f2 100644 --- a/dali-scene-loader/public-api/dli-loader.cpp +++ b/dali-scene3d/public-api/loader/dli-loader.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include "dali-scene-loader/public-api/dli-loader.h" +#include "dali-scene3d/public-api/loader/dli-loader.h" // EXTERNAL INCLUDES #include @@ -30,18 +30,18 @@ #include "dali/public-api/object/property-array.h" // INTERNAL INCLUDES -#include "dali-scene-loader/internal/json-util.h" -#include "dali-scene-loader/public-api/alpha-function-helper.h" -#include "dali-scene-loader/public-api/animation-definition.h" -#include "dali-scene-loader/public-api/blend-shape-details.h" -#include "dali-scene-loader/public-api/camera-parameters.h" -#include "dali-scene-loader/public-api/ktx-loader.h" -#include "dali-scene-loader/public-api/light-parameters.h" -#include "dali-scene-loader/public-api/load-result.h" -#include "dali-scene-loader/public-api/parse-renderer-state.h" -#include "dali-scene-loader/public-api/scene-definition.h" -#include "dali-scene-loader/public-api/skinning-details.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/internal/loader/json-util.h" +#include "dali-scene3d/public-api/loader/alpha-function-helper.h" +#include "dali-scene3d/public-api/loader/animation-definition.h" +#include "dali-scene3d/public-api/loader/blend-shape-details.h" +#include "dali-scene3d/public-api/loader/camera-parameters.h" +#include "dali-scene3d/public-api/loader/ktx-loader.h" +#include "dali-scene3d/public-api/loader/light-parameters.h" +#include "dali-scene3d/public-api/loader/load-result.h" +#include "dali-scene3d/public-api/loader/parse-renderer-state.h" +#include "dali-scene3d/public-api/loader/scene-definition.h" +#include "dali-scene3d/public-api/loader/skinning-details.h" +#include "dali-scene3d/public-api/loader/utils.h" #define DLI_0_1_COMPATIBILITY @@ -49,7 +49,9 @@ namespace Dali { using namespace Toolkit; -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace rs = RendererState; @@ -405,83 +407,86 @@ void DliLoader::Impl::ParseScene(LoadParams& params) // get index of root node. auto docRoot = mParser.GetRoot(); - - // Process resources first - these are shared - if(auto environments = docRoot->GetChild("environment")) + if(docRoot) { - ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials - } + // Process resources first - these are shared + if(auto environments = docRoot->GetChild("environment")) + { + ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials + } - if(auto meshes = docRoot->GetChild("meshes")) - { - ParseMeshes(meshes, output.mResources); - } + if(auto meshes = docRoot->GetChild("meshes")) + { + ParseMeshes(meshes, output.mResources); + } - if(auto shaders = docRoot->GetChild("shaders")) - { - ParseShaders(shaders, output.mResources); - } + if(auto shaders = docRoot->GetChild("shaders")) + { + ParseShaders(shaders, output.mResources); + } - if(auto materials = docRoot->GetChild("materials")) - { - ParseMaterials(materials, input.mConvertColorCode, output.mResources); - } + if(auto materials = docRoot->GetChild("materials")) + { + ParseMaterials(materials, input.mConvertColorCode, output.mResources); + } - for(auto& c : input.mPreNodeCategoryProcessors) - { - if(auto node = docRoot->GetChild(c.first)) + for(auto& c : input.mPreNodeCategoryProcessors) { - Property::Array array; - ParseProperties(*node, array); - c.second(std::move(array), mOnError); + if(auto node = docRoot->GetChild(c.first)) + { + Property::Array array; + ParseProperties(*node, array); + c.second(std::move(array), mOnError); + } } - } - // Process scenes - Index iScene = 0; // default scene - ReadIndex(docRoot->GetChild("scene"), iScene); + // Process scenes + Index iScene = 0; // default scene + ReadIndex(docRoot->GetChild("scene"), iScene); - auto tnScenes = RequireChild(docRoot, "scenes"); - auto tnNodes = RequireChild(docRoot, "nodes"); - ParseSceneInternal(iScene, tnScenes, tnNodes, params); + auto tnScenes = RequireChild(docRoot, "scenes"); + auto tnNodes = RequireChild(docRoot, "nodes"); + ParseSceneInternal(iScene, tnScenes, tnNodes, params); - ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources); + ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources); - output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources); - output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources); + output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources); + output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources); - // Ger cameras and lights - GetCameraParameters(output.mCameraParameters); - GetLightParameters(output.mLightParameters); + // Ger cameras and lights + GetCameraParameters(output.mCameraParameters); + GetLightParameters(output.mLightParameters); - // Post-node processors and animations last - for(auto& c : input.mPostNodeCategoryProcessors) - { - if(auto node = docRoot->GetChild(c.first)) + // Post-node processors and animations last + for(auto& c : input.mPostNodeCategoryProcessors) { - Property::Array array; - ParseProperties(*node, array); - c.second(std::move(array), mOnError); + if(auto node = docRoot->GetChild(c.first)) + { + Property::Array array; + ParseProperties(*node, array); + c.second(std::move(array), mOnError); + } } - } - if(auto animations = docRoot->GetChild("animations")) - { - ParseAnimations(animations, params); - } + if(auto animations = docRoot->GetChild("animations")) + { + ParseAnimations(animations, params); + } - if(!output.mAnimationDefinitions.empty()) - { - if(auto animationGroups = docRoot->GetChild("animationGroups")) + if(!output.mAnimationDefinitions.empty()) { - ParseAnimationGroups(animationGroups, params); + if(auto animationGroups = docRoot->GetChild("animationGroups")) + { + ParseAnimationGroups(animationGroups, params); + } } } } void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* tnScenes, const Toolkit::TreeNode* tnNodes, LoadParams& params) { - auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) { + auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) + { auto tn = GetNthChild(tnScenes, iScene); // now a "scene" object if(!tn) { @@ -1713,98 +1718,105 @@ void DliLoader::Impl::ParseAnimationGroups(const Toolkit::TreeNode* tnAnimationG void DliLoader::Impl::GetCameraParameters(std::vector& cameras) const { - if(const TreeNode* jsonCameras = mParser.GetRoot()->GetChild("cameras")) + if(mParser.GetRoot()) { - cameras.resize(jsonCameras->Size()); - auto iCamera = cameras.begin(); - for(auto i0 = jsonCameras->CBegin(), i1 = jsonCameras->CEnd(); i0 != i1; ++i0) + if(const TreeNode* jsonCameras = mParser.GetRoot()->GetChild("cameras")) { - auto& jsonCamera = (*i0).second; - - ReadFloat(jsonCamera.GetChild("fov"), iCamera->yFov); - ReadFloat(jsonCamera.GetChild("near"), iCamera->zNear); - ReadFloat(jsonCamera.GetChild("far"), iCamera->zFar); - if(ReadVector(jsonCamera.GetChild("orthographic"), iCamera->orthographicSize.AsFloat(), 4u)) + cameras.resize(jsonCameras->Size()); + auto iCamera = cameras.begin(); + for(auto i0 = jsonCameras->CBegin(), i1 = jsonCameras->CEnd(); i0 != i1; ++i0) { - iCamera->isPerspective = false; - } + auto& jsonCamera = (*i0).second; - if(auto jsonMatrix = jsonCamera.GetChild("matrix")) - { - ReadVector(jsonMatrix, iCamera->matrix.AsFloat(), 16u); - } + ReadFloat(jsonCamera.GetChild("fov"), iCamera->yFov); + ReadFloat(jsonCamera.GetChild("near"), iCamera->zNear); + ReadFloat(jsonCamera.GetChild("far"), iCamera->zFar); + if(ReadVector(jsonCamera.GetChild("orthographic"), iCamera->orthographicSize.AsFloat(), 4u)) + { + iCamera->isPerspective = false; + } + + if(auto jsonMatrix = jsonCamera.GetChild("matrix")) + { + ReadVector(jsonMatrix, iCamera->matrix.AsFloat(), 16u); + } - ++iCamera; + ++iCamera; + } } } } void DliLoader::Impl::GetLightParameters(std::vector& lights) const { - if(const TreeNode* jsonLights = mParser.GetRoot()->GetChild("lights")) + if(mParser.GetRoot()) { - lights.resize(jsonLights->Size()); - auto iLight = lights.begin(); - for(auto i0 = jsonLights->CBegin(), i1 = jsonLights->CEnd(); i0 != i1; ++i0) + if(const TreeNode* jsonLights = mParser.GetRoot()->GetChild("lights")) { - auto& jsonLight = (*i0).second; - if(!ReadVector(jsonLight.GetChild("matrix"), iLight->transform.AsFloat(), 16)) + lights.resize(jsonLights->Size()); + auto iLight = lights.begin(); + for(auto i0 = jsonLights->CBegin(), i1 = jsonLights->CEnd(); i0 != i1; ++i0) { - mOnError( - FormatString("Failed to parse light %d - \"matrix\" child with 16 floats expected.\n", - std::distance(jsonLights->CBegin(), i0))); - continue; - } + auto& jsonLight = (*i0).second; + if(!ReadVector(jsonLight.GetChild("matrix"), iLight->transform.AsFloat(), 16)) + { + mOnError( + FormatString("Failed to parse light %d - \"matrix\" child with 16 floats expected.\n", + std::distance(jsonLights->CBegin(), i0))); + continue; + } - int shadowMapSize = 0; - if(ReadInt(jsonLight.GetChild(SHADOW_MAP_SIZE), shadowMapSize) && shadowMapSize < 0) - { - mOnError( - FormatString("Failed to parse light %d - %s has an invalid value.", - std::distance(jsonLights->CBegin(), i0), - SHADOW_MAP_SIZE)); - continue; - } - iLight->shadowMapSize = shadowMapSize; + int shadowMapSize = 0; + if(ReadInt(jsonLight.GetChild(SHADOW_MAP_SIZE), shadowMapSize) && shadowMapSize < 0) + { + mOnError( + FormatString("Failed to parse light %d - %s has an invalid value.", + std::distance(jsonLights->CBegin(), i0), + SHADOW_MAP_SIZE)); + continue; + } + iLight->shadowMapSize = shadowMapSize; - float orthoSize = 0.f; - if(ReadFloat(jsonLight.GetChild(ORTHOGRAPHIC_SIZE), orthoSize) && - (orthoSize < .0f || std::isnan(orthoSize) || std::isinf(orthoSize))) - { - mOnError( - FormatString("Failed to parse light %d - %s has an invalid value.", - std::distance(jsonLights->CBegin(), i0), - ORTHOGRAPHIC_SIZE)); - continue; - } - iLight->orthographicSize = orthoSize; + float orthoSize = 0.f; + if(ReadFloat(jsonLight.GetChild(ORTHOGRAPHIC_SIZE), orthoSize) && + (orthoSize < .0f || std::isnan(orthoSize) || std::isinf(orthoSize))) + { + mOnError( + FormatString("Failed to parse light %d - %s has an invalid value.", + std::distance(jsonLights->CBegin(), i0), + ORTHOGRAPHIC_SIZE)); + continue; + } + iLight->orthographicSize = orthoSize; - if((iLight->shadowMapSize > 0) != (iLight->orthographicSize > .0f)) - { - mOnError(FormatString( - "Light %d: Both shadow map size and orthographic size must be set for shadows to work.", - std::distance(jsonLights->CBegin(), i0))); - } + if((iLight->shadowMapSize > 0) != (iLight->orthographicSize > .0f)) + { + mOnError(FormatString( + "Light %d: Both shadow map size and orthographic size must be set for shadows to work.", + std::distance(jsonLights->CBegin(), i0))); + } - if(!ReadVector(jsonLight.GetChild("color"), iLight->color.AsFloat(), 3)) // color is optional - { - iLight->color = Vector3::ONE; // default to white - } + if(!ReadVector(jsonLight.GetChild("color"), iLight->color.AsFloat(), 3)) // color is optional + { + iLight->color = Vector3::ONE; // default to white + } - if(!ReadFloat(jsonLight.GetChild("intensity"), iLight->intensity)) // intensity is optional - { - iLight->intensity = 1.0f; // default to 1.0 - } + if(!ReadFloat(jsonLight.GetChild("intensity"), iLight->intensity)) // intensity is optional + { + iLight->intensity = 1.0f; // default to 1.0 + } - if(!ReadFloat(jsonLight.GetChild("shadowIntensity"), iLight->shadowIntensity)) // intensity is optional - { - iLight->shadowIntensity = 1.0f; // default to 1.0 - } + if(!ReadFloat(jsonLight.GetChild("shadowIntensity"), iLight->shadowIntensity)) // intensity is optional + { + iLight->shadowIntensity = 1.0f; // default to 1.0 + } - ++iLight; + ++iLight; + } } } } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/dli-loader.h b/dali-scene3d/public-api/loader/dli-loader.h similarity index 88% rename from dali-scene-loader/public-api/dli-loader.h rename to dali-scene3d/public-api/loader/dli-loader.h index b46a7bf..c516f9a 100644 --- a/dali-scene-loader/public-api/dli-loader.h +++ b/dali-scene3d/public-api/loader/dli-loader.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_DLI_LOADER_H -#define DALI_SCENE_LOADER_DLI_LOADER_H +#ifndef DALI_SCENE3D_LOADER_DLI_LOADER_H +#define DALI_SCENE3D_LOADER_DLI_LOADER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,18 +18,20 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/animation-definition.h" -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/customization.h" -#include "dali-scene-loader/public-api/index.h" -#include "dali-scene-loader/public-api/string-callback.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/animation-definition.h" +#include "dali-scene3d/public-api/loader/customization.h" +#include "dali-scene3d/public-api/loader/index.h" +#include "dali-scene3d/public-api/loader/string-callback.h" // EXTERNAL INCLUDES #include "dali/public-api/common/vector-wrapper.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { typedef std::pair Metadata; @@ -43,7 +45,7 @@ class ResourceBundle; struct NodeDefinition; class SceneDefinition; -class DALI_SCENE_LOADER_API DliLoader +class DALI_SCENE3D_API DliLoader { public: using ConvertFontCode = void (*)(const std::string& code, std::string& fontFamily, std::string& slant, std::string& weight, float& size); @@ -135,7 +137,8 @@ private: const std::unique_ptr mImpl; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_DLI_LOADER_H +#endif // DALI_SCENE3D_LOADER_DLI_LOADER_H diff --git a/dali-scene-loader/public-api/environment-definition.cpp b/dali-scene3d/public-api/loader/environment-definition.cpp similarity index 91% rename from dali-scene-loader/public-api/environment-definition.cpp rename to dali-scene3d/public-api/loader/environment-definition.cpp index cc4e7e8..173959c 100644 --- a/dali-scene-loader/public-api/environment-definition.cpp +++ b/dali-scene3d/public-api/loader/environment-definition.cpp @@ -20,8 +20,9 @@ #include // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/environment-definition.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/cube-map-loader.h" +#include "dali-scene3d/public-api/loader/environment-definition.h" +#include "dali-scene3d/public-api/loader/utils.h" namespace { @@ -34,7 +35,9 @@ std::string GetDaliImagePath() namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -98,5 +101,6 @@ EnvironmentDefinition::Textures EnvironmentDefinition::Load(RawData&& raw) const return textures; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/environment-definition.h b/dali-scene3d/public-api/loader/environment-definition.h similarity index 82% rename from dali-scene-loader/public-api/environment-definition.h rename to dali-scene3d/public-api/loader/environment-definition.h index 90b0f9e..57cef30 100644 --- a/dali-scene-loader/public-api/environment-definition.h +++ b/dali-scene3d/public-api/loader/environment-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_ENVIRONMENT_DEFINITION_H -#define DALI_SCENE_LOADER_ENVIRONMENT_DEFINITION_H +#ifndef DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H +#define DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/ktx-loader.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/cube-data.h" // EXTERNAL INCLUDES #include "dali/public-api/math/quaternion.h" @@ -27,13 +27,15 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Defines an environment map with either or both of radiance * and irradiance maps. */ -struct DALI_SCENE_LOADER_API EnvironmentDefinition +struct DALI_SCENE3D_API EnvironmentDefinition { struct Textures { @@ -82,11 +84,13 @@ public: // DATA std::string mDiffuseMapPath; std::string mSpecularMapPath; Quaternion mCubeOrientation = Quaternion::IDENTITY; + Vector3 mYDirection = Vector3::ONE; float mIblIntensity = 1.0f; bool mUseBrdfTexture = false; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_ENVIRONMENT_DEFINITION_H +#endif //DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H diff --git a/dali-scene-loader/public-api/facial-animation-loader.cpp b/dali-scene3d/public-api/loader/facial-animation-loader.cpp similarity index 93% rename from dali-scene-loader/public-api/facial-animation-loader.cpp rename to dali-scene3d/public-api/loader/facial-animation-loader.cpp index 6c92d6a..2414b1b 100644 --- a/dali-scene-loader/public-api/facial-animation-loader.cpp +++ b/dali-scene3d/public-api/loader/facial-animation-loader.cpp @@ -16,15 +16,15 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES -#include -#include -#include +#include +#include +#include namespace js = json; @@ -89,7 +89,9 @@ const auto FACIAL_ANIMATION_READER = std::move(js::Reader() } // unnamed namespace -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { AnimationDefinition LoadFacialAnimation(const std::string& url) { @@ -175,5 +177,6 @@ AnimationDefinition LoadFacialAnimation(const std::string& url) return animationDefinition; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/facial-animation-loader.h b/dali-scene3d/public-api/loader/facial-animation-loader.h similarity index 67% rename from dali-scene-loader/public-api/facial-animation-loader.h rename to dali-scene3d/public-api/loader/facial-animation-loader.h index 4095b7c..b61d0a0 100644 --- a/dali-scene-loader/public-api/facial-animation-loader.h +++ b/dali-scene3d/public-api/loader/facial-animation-loader.h @@ -1,5 +1,5 @@ -#ifndef DALI_SCENE_LOADER_FACIAL_ANIMATION_LOADER_H -#define DALI_SCENE_LOADER_FACIAL_ANIMATION_LOADER_H +#ifndef DALI_SCENE3D_LOADER_FACIAL_ANIMATION_LOADER_H +#define DALI_SCENE3D_LOADER_FACIAL_ANIMATION_LOADER_H /* * Copyright (c) 2022 Samsung Electronics Co., Ltd. @@ -19,9 +19,9 @@ */ // INTERNAL INCLUDES -#include +#include -namespace Dali::SceneLoader +namespace Dali::Scene3D::Loader { /** * @brief Loads a facial animation encoded in a json file in the given @p url. @@ -32,7 +32,7 @@ namespace Dali::SceneLoader * * @return An animation definition. */ -DALI_SCENE_LOADER_API AnimationDefinition LoadFacialAnimation(const std::string& url); -} // namespace Dali::SceneLoader +DALI_SCENE3D_API AnimationDefinition LoadFacialAnimation(const std::string& url); +} // namespace Dali::Scene3D::Loader -#endif // DALI_SCENE_LOADER_FACIAL_ANIMATION_LOADER_H +#endif // DALI_SCENE3D_LOADER_FACIAL_ANIMATION_LOADER_H diff --git a/dali-scene-loader/public-api/gltf2-loader.cpp b/dali-scene3d/public-api/loader/gltf2-loader.cpp similarity index 98% rename from dali-scene-loader/public-api/gltf2-loader.cpp rename to dali-scene3d/public-api/loader/gltf2-loader.cpp index 8af87a1..918bb35 100644 --- a/dali-scene-loader/public-api/gltf2-loader.cpp +++ b/dali-scene3d/public-api/loader/gltf2-loader.cpp @@ -14,14 +14,14 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/gltf2-loader.h" +#include "dali-scene3d/public-api/loader/gltf2-loader.h" #include -#include "dali-scene-loader/internal/gltf2-asset.h" -#include "dali-scene-loader/public-api/load-result.h" -#include "dali-scene-loader/public-api/resource-bundle.h" -#include "dali-scene-loader/public-api/scene-definition.h" -#include "dali-scene-loader/public-api/shader-definition-factory.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/internal/loader/gltf2-asset.h" +#include "dali-scene3d/public-api/loader/load-result.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" +#include "dali-scene3d/public-api/loader/scene-definition.h" +#include "dali-scene3d/public-api/loader/shader-definition-factory.h" +#include "dali-scene3d/public-api/loader/utils.h" #include "dali/public-api/math/quaternion.h" #define ENUM_STRING_MAPPING(t, x) \ @@ -34,7 +34,9 @@ namespace js = json; namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -911,7 +913,7 @@ float LoadKeyFrames(const std::string& path, const gt::Animation::Channel& chann return duration; } -float LoadBlendShapeKeyFrames(const std::string& path, const gt::Animation::Channel& channel, const std::string& nodeName, uint32_t& propertyIndex, std::vector& properties) +float LoadBlendShapeKeyFrames(const std::string& path, const gt::Animation::Channel& channel, const std::string& nodeName, uint32_t& propertyIndex, std::vector& properties) { const gltf2::Accessor& input = *channel.mSampler->mInput; const gltf2::Accessor& output = *channel.mSampler->mOutput; @@ -1169,7 +1171,7 @@ void SetDefaultEnvironmentMap(const gt::Document& doc, ConversionContext& cctx) { EnvironmentDefinition envDef; envDef.mUseBrdfTexture = true; - envDef.mIblIntensity = DEFAULT_INTENSITY; + envDef.mIblIntensity = DEFAULT_INTENSITY; cctx.mOutput.mResources.mEnvironmentMaps.push_back({std::move(envDef), EnvironmentDefinition::Textures()}); } @@ -1217,7 +1219,6 @@ void LoadGltfScene(const std::string& url, ShaderDefinitionFactory& shaderFactor isMRendererModel = (doc.mAsset.mGenerator.find(MRENDERER_MODEL_IDENTIFICATION) != std::string_view::npos); } - gt::SetRefReaderObject(doc); DOCUMENT_READER.Read(rootObj, doc); @@ -1236,5 +1237,6 @@ void LoadGltfScene(const std::string& url, ShaderDefinitionFactory& shaderFactor SetDefaultEnvironmentMap(doc, cctx); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/gltf2-loader.h b/dali-scene3d/public-api/loader/gltf2-loader.h similarity index 69% rename from dali-scene-loader/public-api/gltf2-loader.h rename to dali-scene3d/public-api/loader/gltf2-loader.h index 9871ec0..765cd40 100644 --- a/dali-scene-loader/public-api/gltf2-loader.h +++ b/dali-scene3d/public-api/loader/gltf2-loader.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_GLTF2_LOADER_H -#define DALI_SCENE_LOADER_GLTF2_LOADER_H +#ifndef DALI_SCENE3D_LOADER_GLTF2_LOADER_H +#define DALI_SCENE3D_LOADER_GLTF2_LOADER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,16 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { struct CameraParameters; struct LoadResult; @@ -36,9 +38,10 @@ class ShaderDefinitionFactory; * @note Will throw std::runtime_error for JSON entities with types mismatching expectations, carrying * invalid values, or I/O errors. */ -DALI_SCENE_LOADER_API void LoadGltfScene(const std::string& url, ShaderDefinitionFactory& shaderFactory, LoadResult& params); +DALI_SCENE3D_API void LoadGltfScene(const std::string& url, ShaderDefinitionFactory& shaderFactory, LoadResult& params); -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_GLTF2_LOADER_H +#endif //DALI_SCENE3D_LOADER_GLTF2_LOADER_H diff --git a/dali-scene-loader/public-api/index.h b/dali-scene3d/public-api/loader/index.h similarity index 72% rename from dali-scene-loader/public-api/index.h rename to dali-scene3d/public-api/loader/index.h index 9ad5fc2..3048def 100644 --- a/dali-scene-loader/public-api/index.h +++ b/dali-scene3d/public-api/loader/index.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_INDEX_H_ -#define DALI_SCENE_LOADER_INDEX_H_ +#ifndef DALI_SCENE3D_LOADER_INDEX_H_ +#define DALI_SCENE3D_LOADER_INDEX_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,20 +18,23 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { using Index = uint32_t; constexpr Index INVALID_INDEX = static_cast(-1); -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_INDEX_H_ +#endif //DALI_SCENE3D_LOADER_INDEX_H_ diff --git a/dali-scene-loader/public-api/ktx-loader.cpp b/dali-scene3d/public-api/loader/ktx-loader.cpp similarity index 88% rename from dali-scene-loader/public-api/ktx-loader.cpp rename to dali-scene3d/public-api/loader/ktx-loader.cpp index 857163d..c2e7159 100644 --- a/dali-scene-loader/public-api/ktx-loader.cpp +++ b/dali-scene3d/public-api/loader/ktx-loader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,12 @@ */ // FILE HEADER -#include "dali-scene-loader/public-api/ktx-loader.h" +#include // EXTERNAL INCLUDES +#include #include #include -#include "dali/public-api/rendering/texture.h" namespace Dali { @@ -44,7 +44,9 @@ void FreeBuffer(uint8_t* buffer) } } // namespace -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { struct KtxFileHeader { @@ -183,22 +185,7 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Pixel::Format& format) return true; } -Texture CubeData::CreateTexture() const -{ - Texture texture = Texture::New(TextureType::TEXTURE_CUBE, data[0][0].GetPixelFormat(), data[0][0].GetWidth(), data[0][0].GetHeight()); - for(size_t iSide = 0u, iEndSize = data.size(); iSide < iEndSize; ++iSide) - { - auto& side = data[iSide]; - for(size_t iMipLevel = 0u, iEndMipLevel = data[0].size(); iMipLevel < iEndMipLevel; ++iMipLevel) - { - texture.Upload(side[iMipLevel], CubeMapLayer::POSITIVE_X + iSide, iMipLevel, 0u, 0u, side[iMipLevel].GetWidth(), side[iMipLevel].GetHeight()); - } - } - - return texture; -} - -bool LoadCubeMapData(const std::string& path, CubeData& cubedata) +bool LoadKtxData(const std::string& path, CubeData& cubedata) { std::fstream fp(path, std::ios::in | std::ios::binary); if(fp.is_open() == false) @@ -271,5 +258,6 @@ bool LoadCubeMapData(const std::string& path, CubeData& cubedata) return true; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene3d/public-api/loader/ktx-loader.h b/dali-scene3d/public-api/loader/ktx-loader.h new file mode 100644 index 0000000..63d27a6 --- /dev/null +++ b/dali-scene3d/public-api/loader/ktx-loader.h @@ -0,0 +1,43 @@ +#ifndef DALI_SCENE3D_LOADER_KTX_LOADER_H +#define DALI_SCENE3D_LOADER_KTX_LOADER_H +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Scene3D +{ +namespace Loader +{ +/** + * @brief Loads cube map data texture from a ktx file. + * + * @param[in] path The file path. + * @param[out] cubedata The data structure with all pixel data objects. + * @return bool True if the loading is succeded. + */ +bool LoadKtxData(const std::string& path, CubeData& cubedata); + +} // namespace Loader +} // namespace Scene3D +} // namespace Dali + +#endif // DALI_SCENE3D_LOADER_KTX_LOADER_H diff --git a/dali-scene-loader/public-api/light-parameters.h b/dali-scene3d/public-api/loader/light-parameters.h similarity index 71% rename from dali-scene-loader/public-api/light-parameters.h rename to dali-scene3d/public-api/loader/light-parameters.h index 11b014b..2fde52e 100644 --- a/dali-scene-loader/public-api/light-parameters.h +++ b/dali-scene3d/public-api/loader/light-parameters.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_LIGHT_PARAMETERS_H -#define DALI_SCENE_LOADER_LIGHT_PARAMETERS_H +#ifndef DALI_SCENE3D_LOADER_LIGHT_PARAMETERS_H +#define DALI_SCENE3D_LOADER_LIGHT_PARAMETERS_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include @@ -27,9 +27,11 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D { -struct DALI_SCENE_LOADER_API LightParameters +namespace Loader +{ +struct DALI_SCENE3D_API LightParameters { Matrix transform; @@ -40,7 +42,8 @@ struct DALI_SCENE_LOADER_API LightParameters float orthographicSize; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_LIGHT_PARAMETERS_H +#endif // DALI_SCENE3D_LOADER_LIGHT_PARAMETERS_H diff --git a/dali-scene-loader/public-api/load-result.h b/dali-scene3d/public-api/loader/load-result.h similarity index 74% rename from dali-scene-loader/public-api/load-result.h rename to dali-scene3d/public-api/loader/load-result.h index 4ed3ff5..a9428eb 100644 --- a/dali-scene-loader/public-api/load-result.h +++ b/dali-scene3d/public-api/loader/load-result.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_OUTPUT_H -#define DALI_SCENE_LOADER_OUTPUT_H +#ifndef DALI_SCENE3D_LOADER_OUTPUT_H +#define DALI_SCENE3D_LOADER_OUTPUT_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,16 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/animation-definition.h" -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/camera-parameters.h" -#include "dali-scene-loader/public-api/light-parameters.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/animation-definition.h" +#include "dali-scene3d/public-api/loader/camera-parameters.h" +#include "dali-scene3d/public-api/loader/light-parameters.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { class ResourceBundle; class SceneDefinition; @@ -33,7 +35,7 @@ class SceneDefinition; /** * @brief The outputs from loading and processing a scene. */ -struct DALI_SCENE_LOADER_API LoadResult +struct DALI_SCENE3D_API LoadResult { /** * @brief The bundle to store resources in. @@ -66,7 +68,8 @@ struct DALI_SCENE_LOADER_API LoadResult std::vector& mLightParameters; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_OUTPUT_H +#endif //DALI_SCENE3D_LOADER_OUTPUT_H diff --git a/dali-scene-loader/public-api/material-definition.cpp b/dali-scene3d/public-api/loader/material-definition.cpp similarity index 98% rename from dali-scene-loader/public-api/material-definition.cpp rename to dali-scene3d/public-api/loader/material-definition.cpp index 1766c3f..9becc3a 100644 --- a/dali-scene-loader/public-api/material-definition.cpp +++ b/dali-scene3d/public-api/loader/material-definition.cpp @@ -16,7 +16,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/material-definition.h" +#include "dali-scene3d/public-api/loader/material-definition.h" // EXTERNAL INCLUDES #include "dali-toolkit/public-api/image-loader/sync-image-loader.h" @@ -25,7 +25,9 @@ namespace Dali { using namespace Toolkit; -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -262,6 +264,13 @@ TextureSet MaterialDefinition::Load(const EnvironmentDefinition::Vector& environ if(mEnvironmentIdx < environments.size()) { auto& envTextures = environments[mEnvironmentIdx].second; + // If pre-computed brdf texture is defined, set the texture. + if(envTextures.mBrdf) + { + textureSet.SetTexture(n, envTextures.mBrdf); + ++n; + } + if(envTextures.mDiffuse) { textureSet.SetTexture(n, envTextures.mDiffuse); @@ -278,12 +287,6 @@ TextureSet MaterialDefinition::Load(const EnvironmentDefinition::Vector& environ textureSet.SetSampler(n, specularSampler); ++n; } - - // If pre-computed brdf texture is defined, set the texture. - if(envTextures.mBrdf) - { - textureSet.SetTexture(n, envTextures.mBrdf); - } } else { @@ -300,5 +303,6 @@ bool MaterialDefinition::CheckTextures(uint32_t flags) const }) != mTextureStages.end(); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/material-definition.h b/dali-scene3d/public-api/loader/material-definition.h similarity index 91% rename from dali-scene-loader/public-api/material-definition.h rename to dali-scene3d/public-api/loader/material-definition.h index 2c9ed6c..d96d888 100644 --- a/dali-scene-loader/public-api/material-definition.h +++ b/dali-scene3d/public-api/loader/material-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_MATERIAL_DEFINITION_H -#define DALI_SCENE_LOADER_MATERIAL_DEFINITION_H +#ifndef DALI_SCENE3D_LOADER_MATERIAL_DEFINITION_H +#define DALI_SCENE3D_LOADER_MATERIAL_DEFINITION_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +18,10 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/environment-definition.h" -#include "dali-scene-loader/public-api/index.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/environment-definition.h" +#include "dali-scene3d/public-api/loader/index.h" +#include "dali-scene3d/public-api/loader/utils.h" // EXTERNAL INCLUDES #include @@ -30,12 +30,14 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Helper enum for encoding and decoding sampler states. */ -struct DALI_SCENE_LOADER_API SamplerFlags +struct DALI_SCENE3D_API SamplerFlags { using Type = uint8_t; @@ -109,7 +111,7 @@ struct DALI_SCENE_LOADER_API SamplerFlags /** * @brief Defines a texture from a combination of an image URI and its sampler definition. */ -struct DALI_SCENE_LOADER_API TextureDefinition +struct DALI_SCENE3D_API TextureDefinition { std::string mImageUri; SamplerFlags::Type mSamplerFlags; @@ -123,7 +125,7 @@ struct DALI_SCENE_LOADER_API TextureDefinition * scene). Textures from the environment are added last when the DALi TextureSet * is being created. */ -struct DALI_SCENE_LOADER_API MaterialDefinition +struct DALI_SCENE3D_API MaterialDefinition { enum Flags : uint32_t { @@ -236,7 +238,8 @@ public: // DATA std::vector mTextureStages; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_MATERIAL_DEFINITION_H +#endif //DALI_SCENE3D_LOADER_MATERIAL_DEFINITION_H diff --git a/dali-scene-loader/public-api/matrix-stack.cpp b/dali-scene3d/public-api/loader/matrix-stack.cpp similarity index 82% rename from dali-scene-loader/public-api/matrix-stack.cpp rename to dali-scene3d/public-api/loader/matrix-stack.cpp index eb2316e..a7b8870 100644 --- a/dali-scene-loader/public-api/matrix-stack.cpp +++ b/dali-scene3d/public-api/loader/matrix-stack.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Samsung Electronics Co., Ltd. +* Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,14 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/matrix-stack.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/matrix-stack.h" +#include "dali-scene3d/public-api/loader/utils.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { MatrixStack::MatrixStack() { @@ -61,5 +63,6 @@ void MatrixStack::PopAll() mStack.clear(); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/matrix-stack.h b/dali-scene3d/public-api/loader/matrix-stack.h similarity index 77% rename from dali-scene-loader/public-api/matrix-stack.h rename to dali-scene3d/public-api/loader/matrix-stack.h index 5c5c923..63bbc90 100644 --- a/dali-scene-loader/public-api/matrix-stack.h +++ b/dali-scene3d/public-api/loader/matrix-stack.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_MATRIX_STACK_H_ -#define DALI_SCENE_LOADER_MATRIX_STACK_H_ +#ifndef DALI_SCENE3D_LOADERER_MATRIX_STACK_H_ +#define DALI_SCENE3D_LOADERER_MATRIX_STACK_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include "dali/public-api/common/vector-wrapper.h" @@ -26,14 +26,16 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief A stack of matrices whereby each newly pushed matrix is stored * after being multiplied by the previous one (if any). * @note Current implementation reserves space for 16 matrices. */ -class DALI_SCENE_LOADER_API MatrixStack +class DALI_SCENE3D_API MatrixStack { public: MatrixStack(); @@ -48,7 +50,8 @@ private: std::vector mStack; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_MATRIX_STACK_H_ +#endif //DALI_SCENE3D_LOADERER_MATRIX_STACK_H_ diff --git a/dali-scene-loader/public-api/mesh-definition.cpp b/dali-scene3d/public-api/loader/mesh-definition.cpp similarity index 96% rename from dali-scene-loader/public-api/mesh-definition.cpp rename to dali-scene3d/public-api/loader/mesh-definition.cpp index 373b445..b07d0e2 100644 --- a/dali-scene-loader/public-api/mesh-definition.cpp +++ b/dali-scene3d/public-api/loader/mesh-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/mesh-definition.h" +#include "dali-scene3d/public-api/loader/mesh-definition.h" // EXTERNAL INCLUDES #include @@ -25,7 +25,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -454,6 +456,21 @@ MeshDefinition::Accessor::Accessor(const MeshDefinition::Blob& blob, { } +void MeshDefinition::Blob::ComputeMinMax(std::vector& min, std::vector& max, uint32_t numComponents, uint32_t count, const float* values) +{ + min.assign(numComponents, MAXFLOAT); + max.assign(numComponents, -MAXFLOAT); + for(uint32_t i = 0; i < count; ++i) + { + for(uint32_t j = 0; j < numComponents; ++j) + { + min[j] = std::min(min[j], *values); + max[j] = std::max(max[j], *values); + values++; + } + } +} + void MeshDefinition::Blob::ApplyMinMax(const std::vector& min, const std::vector& max, uint32_t count, float* values) { DALI_ASSERT_DEBUG(max.size() == min.size() || max.size() * min.size() == 0); @@ -504,6 +521,11 @@ uint32_t MeshDefinition::Blob::GetBufferSize() const return IsConsecutive() ? mLength : (mLength * mElementSizeHint / mStride); } +void MeshDefinition::Blob::ComputeMinMax(uint32_t numComponents, uint32_t count, float* values) +{ + ComputeMinMax(mMin, mMax, numComponents, count, values); +} + void MeshDefinition::Blob::ApplyMinMax(uint32_t count, float* values) const { ApplyMinMax(mMin, mMax, count, values); @@ -545,7 +567,7 @@ void MeshDefinition::RequestTangents() } MeshDefinition::RawData -MeshDefinition::LoadRaw(const std::string& modelsPath) const +MeshDefinition::LoadRaw(const std::string& modelsPath) { RawData raw; if(IsQuad()) @@ -613,7 +635,14 @@ MeshDefinition::LoadRaw(const std::string& modelsPath) const } uint32_t numVector3 = bufferSize / sizeof(Vector3); - mPositions.mBlob.ApplyMinMax(numVector3, reinterpret_cast(buffer.data())); + if(mPositions.mBlob.mMin.size() != 3u || mPositions.mBlob.mMax.size() != 3u) + { + mPositions.mBlob.ComputeMinMax(3u, numVector3, reinterpret_cast(buffer.data())); + } + else + { + mPositions.mBlob.ApplyMinMax(numVector3, reinterpret_cast(buffer.data())); + } if(HasBlendShapes()) { @@ -703,7 +732,7 @@ MeshDefinition::LoadRaw(const std::string& modelsPath) const if(mColors.IsDefined()) { - uint32_t propertySize = mColors.mBlob.mElementSizeHint; + uint32_t propertySize = mColors.mBlob.mElementSizeHint; Property::Type propertyType = (propertySize == sizeof(Vector4)) ? Property::VECTOR4 : ((propertySize == sizeof(Vector3)) ? Property::VECTOR3 : Property::NONE); if(propertyType != Property::NONE) { @@ -892,5 +921,6 @@ MeshGeometry MeshDefinition::Load(RawData&& raw) const return meshGeometry; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/mesh-definition.h b/dali-scene3d/public-api/loader/mesh-definition.h similarity index 83% rename from dali-scene-loader/public-api/mesh-definition.h rename to dali-scene3d/public-api/loader/mesh-definition.h index 2fe4394..445fbe7 100644 --- a/dali-scene-loader/public-api/mesh-definition.h +++ b/dali-scene3d/public-api/loader/mesh-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_MESH_DEFINITION_H -#define DALI_SCENE_LOADER_MESH_DEFINITION_H +#ifndef DALI_SCENE3D_LOADER_MESH_DEFINITION_H +#define DALI_SCENE3D_LOADER_MESH_DEFINITION_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/blend-shape-details.h" -#include "dali-scene-loader/public-api/index.h" -#include "dali-scene-loader/public-api/mesh-geometry.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/blend-shape-details.h" +#include "dali-scene3d/public-api/loader/index.h" +#include "dali-scene3d/public-api/loader/mesh-geometry.h" +#include "dali-scene3d/public-api/loader/utils.h" // EXTERNAL INCLUDES #include @@ -30,14 +30,16 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Defines a mesh with its attributes, the primitive type to render it as, * and the file to load it from with the offset and length information for the * individual attribute buffers. */ -struct DALI_SCENE_LOADER_API MeshDefinition +struct DALI_SCENE3D_API MeshDefinition { using Vector = std::vector>; @@ -78,6 +80,8 @@ struct DALI_SCENE_LOADER_API MeshDefinition std::vector mMin; std::vector mMax; + static void ComputeMinMax(std::vector& min, std::vector& max, uint32_t numComponents, uint32_t count, const float* values); + static void ApplyMinMax(const std::vector& min, const std::vector& max, uint32_t count, float* values); Blob() = default; @@ -107,7 +111,20 @@ struct DALI_SCENE_LOADER_API MeshDefinition } /** - * @brief Applies the min / max values, if they're defined. + * @brief Computes the min / max of the input value data. + * The min and max are stored in mMin and mMax. + * + * @param[in] numComponents number of components of data type. e.g., 3 for Vector3. + * @param[in] count The number of data. + * @param[in] values Data for the mesh. + */ + void ComputeMinMax(uint32_t numComponents, uint32_t count, float* values); + + /** + * @brief Applies the min / max values, if they're defined in the model + * + * @param[in] count The number of data. + * @param[in] values Data for the mesh that min / max values will be applied. */ void ApplyMinMax(uint32_t count, float* values) const; }; @@ -224,7 +241,7 @@ struct DALI_SCENE_LOADER_API MeshDefinition * attribute buffers, as well as blend shape data. This is then returned. * @note This can be done on any thread. */ - RawData LoadRaw(const std::string& modelsPath) const; + RawData LoadRaw(const std::string& modelsPath); /** * @brief Creates a MeshGeometry based firstly on the value of the uri member: @@ -256,7 +273,8 @@ public: // DATA Index mSkeletonIdx = INVALID_INDEX; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_MESH_DEFINITION_H +#endif //DALI_SCENE3D_LOADER_MESH_DEFINITION_H diff --git a/dali-scene-loader/public-api/mesh-geometry.h b/dali-scene3d/public-api/loader/mesh-geometry.h similarity index 77% rename from dali-scene-loader/public-api/mesh-geometry.h rename to dali-scene3d/public-api/loader/mesh-geometry.h index 5b46e0f..331acf7 100644 --- a/dali-scene-loader/public-api/mesh-geometry.h +++ b/dali-scene3d/public-api/loader/mesh-geometry.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_MESH_GEOMETRY_H -#define DALI_SCENE_LOADER_MESH_GEOMETRY_H +#ifndef DALI_SCENE3D_LOADERER_MESH_GEOMETRY_H +#define DALI_SCENE3D_LOADERER_MESH_GEOMETRY_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include "dali/public-api/rendering/geometry.h" @@ -26,9 +26,11 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D { -struct DALI_SCENE_LOADER_API MeshGeometry +namespace Loader +{ +struct DALI_SCENE3D_API MeshGeometry { Geometry geometry; ///< The array of vertices. Texture blendShapeGeometry; ///< The array of vertices of the different blend shapes encoded inside a texture with power of two dimensions. @@ -36,7 +38,8 @@ struct DALI_SCENE_LOADER_API MeshGeometry unsigned int blendShapeBufferOffset{0}; ///< Offset used to calculate the start of each blend shape. }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_MESH_GEOMETRY_H +#endif // DALI_SCENE3D_LOADERER_MESH_GEOMETRY_H diff --git a/dali-scene-loader/public-api/node-definition.cpp b/dali-scene3d/public-api/loader/node-definition.cpp similarity index 76% rename from dali-scene-loader/public-api/node-definition.cpp rename to dali-scene3d/public-api/loader/node-definition.cpp index 7542782..c83fc44 100644 --- a/dali-scene-loader/public-api/node-definition.cpp +++ b/dali-scene3d/public-api/loader/node-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,27 @@ */ // INTERNAL -#include "dali-scene-loader/public-api/node-definition.h" -#include "dali-scene-loader/public-api/renderer-state.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/node-definition.h" +#include "dali-scene3d/public-api/loader/renderer-state.h" +#include "dali-scene3d/public-api/loader/utils.h" namespace Dali { -namespace SceneLoader +namespace { +constexpr std::string_view IBL_INTENSITY_STRING("uIblIntensity"); +constexpr std::string_view IBL_Y_DIRECTION("uYDirection"); +} // namespace + +namespace Scene3D +{ +namespace Loader +{ +bool NodeDefinition::Renderable::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const +{ + return false; +} + void NodeDefinition::Renderable::RegisterResources(IResourceReceiver& receiver) const { receiver.Register(ResourceType::Shader, mShaderIdx); @@ -89,6 +102,50 @@ Matrix NodeDefinition::GetLocalSpace() const return localSpace; } +std::string_view NodeDefinition::GetIblScaleFactorUniformName() +{ + return IBL_INTENSITY_STRING; +} + +std::string_view NodeDefinition::GetIblYDirectionUniformName() +{ + return IBL_Y_DIRECTION; +} + +bool NodeDefinition::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const +{ + if(mRenderable) + { + if(!mRenderable->GetExtents(resources, min, max)) + { + // If the renderable node don't have mesh accessor, use size to compute extents. + min = -mSize / 2.0f; + max = mSize / 2.0f; + } + return true; + } + return false; +} + +bool ModelNode::GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const +{ + auto& mesh = resources.mMeshes[mMeshIdx]; + uint32_t minSize = mesh.first.mPositions.mBlob.mMin.size(); + uint32_t maxSize = mesh.first.mPositions.mBlob.mMax.size(); + if(minSize == maxSize && minSize >= 2u && maxSize >= 2u) + { + min = Vector3(mesh.first.mPositions.mBlob.mMin[0], mesh.first.mPositions.mBlob.mMin[1], 0.0f); + max = Vector3(mesh.first.mPositions.mBlob.mMax[0], mesh.first.mPositions.mBlob.mMax[1], 0.0f); + if(minSize == 3u) + { + min.z = mesh.first.mPositions.mBlob.mMin[2]; + max.z = mesh.first.mPositions.mBlob.mMax[2]; + } + return true; + } + return false; +} + void ModelNode::RegisterResources(IResourceReceiver& receiver) const { Renderable::RegisterResources(receiver); @@ -167,10 +224,11 @@ void ModelNode::OnCreate(const NodeDefinition& node, NodeDefinition::CreateParam } Index envIdx = matDef.mEnvironmentIdx; - actor.RegisterProperty("uIblIntensity", resources.mEnvironmentMaps[envIdx].first.mIblIntensity); + actor.RegisterProperty(IBL_INTENSITY_STRING.data(), resources.mEnvironmentMaps[envIdx].first.mIblIntensity); + actor.RegisterProperty(IBL_Y_DIRECTION.data(), resources.mEnvironmentMaps[envIdx].first.mYDirection); - float opaque = 0.0f; - float mask = 0.0f; + float opaque = 0.0f; + float mask = 0.0f; float alphaCutoff = matDef.GetAlphaCutoff(); if(!MaskMatch(matDef.mFlags, MaterialDefinition::TRANSPARENCY)) { @@ -226,5 +284,6 @@ void ArcNode::GetEndVectorWithDiffAngle(float startAngle, float diffAngle, Vecto endVector.y = sinf(endAngle * Math::PI_OVER_180); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/node-definition.h b/dali-scene3d/public-api/loader/node-definition.h similarity index 75% rename from dali-scene-loader/public-api/node-definition.h rename to dali-scene3d/public-api/loader/node-definition.h index b496cf7..a86d7e9 100644 --- a/dali-scene-loader/public-api/node-definition.h +++ b/dali-scene3d/public-api/loader/node-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_NODE_DEFINITION_H_ -#define DALI_SCENE_LOADER_NODE_DEFINITION_H_ +#ifndef DALI_SCENE3D_LOADER_NODE_DEFINITION_H_ +#define DALI_SCENE3D_LOADER_NODE_DEFINITION_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/customization.h" -#include "dali-scene-loader/public-api/matrix-stack.h" -#include "dali-scene-loader/public-api/resource-bundle.h" +#include "dali-scene3d/public-api/loader/customization.h" +#include "dali-scene3d/public-api/loader/matrix-stack.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" // EXTERNAL INCLUDES #include @@ -33,14 +33,16 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { class ViewProjection; /** * @brief Interface to report (const) resource ids to. */ -class DALI_SCENE_LOADER_API IResourceReceiver +class DALI_SCENE3D_API IResourceReceiver { public: virtual ~IResourceReceiver() = default; @@ -53,7 +55,7 @@ public: * @note These are supposed to be transient. Obviously, the references collected * this way must not outlive the objects that they came from. */ -class DALI_SCENE_LOADER_API IResourceReflector +class DALI_SCENE3D_API IResourceReflector { public: virtual ~IResourceReflector() = default; @@ -66,7 +68,7 @@ public: * set up after the Actors were created. The target of the constraint * is the node definition that carries it. */ -struct DALI_SCENE_LOADER_API ConstraintDefinition +struct DALI_SCENE3D_API ConstraintDefinition { std::string mProperty; ///< name of the property to constrain. Index mSourceIdx; ///< index of the node to serve as the source of the constraint. @@ -87,7 +89,7 @@ struct DALI_SCENE_LOADER_API ConstraintDefinition } }; -struct DALI_SCENE_LOADER_API Transforms +struct DALI_SCENE3D_API Transforms { MatrixStack modelStack; const ViewProjection& viewProjection; @@ -97,7 +99,7 @@ struct DALI_SCENE_LOADER_API Transforms * @brief Information about a skeleton and the shader that needs to be configured with it. * @note Multiple skeletons shalt not share the same shader. */ -struct DALI_SCENE_LOADER_API SkinningShaderConfigurationRequest +struct DALI_SCENE3D_API SkinningShaderConfigurationRequest { Index mSkeletonIdx; Shader mShader; @@ -111,7 +113,7 @@ struct DALI_SCENE_LOADER_API SkinningShaderConfigurationRequest /** * @brief Needed to configure blend shape properties. */ -struct DALI_SCENE_LOADER_API BlendshapeShaderConfigurationRequest +struct DALI_SCENE3D_API BlendshapeShaderConfigurationRequest { std::string mNodeName; Index mMeshIdx; @@ -126,7 +128,7 @@ struct DALI_SCENE_LOADER_API BlendshapeShaderConfigurationRequest /** * @brief Request for creating a constraint, output from NodeDefinition::OnCreate. */ -struct DALI_SCENE_LOADER_API ConstraintRequest +struct DALI_SCENE3D_API ConstraintRequest { const ConstraintDefinition* const mConstraint; ///< Definition of the constraint to create. Actor mTarget; ///< Target of the constraint. @@ -137,7 +139,7 @@ struct DALI_SCENE_LOADER_API ConstraintRequest * and slots for customization and rendering logic, which are mutually exclusive in the * current implementation. */ -struct DALI_SCENE_LOADER_API NodeDefinition +struct DALI_SCENE3D_API NodeDefinition { public: // TYPES using Vector = std::vector; @@ -154,7 +156,7 @@ public: // TYPES std::vector mBlendshapeRequests; }; - class DALI_SCENE_LOADER_API Renderable + class DALI_SCENE3D_API Renderable { public: // DATA Index mShaderIdx = INVALID_INDEX; @@ -162,6 +164,7 @@ public: // TYPES public: // METHODS virtual ~Renderable() = default; + virtual bool GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const; virtual void RegisterResources(IResourceReceiver& receiver) const; virtual void ReflectResources(IResourceReflector& reflector); virtual void OnCreate(const NodeDefinition& node, CreateParams& params, Actor& actor) const; @@ -217,8 +220,35 @@ public: // METHODS */ Actor CreateActor(CreateParams& params) const; + /** + * @brief Gets local space matrix of this node + * @return Matrix of local space. + */ Matrix GetLocalSpace() const; + /** + * @brief Retrieves minimum and maximum position of this node in local space. + * @param[in] resources ResourceBundle that contains mesh information of this node. + * @param[out] min Minimum position of the mesh of this node. + * @param[out] max Maximum position of the mesh of this node. + * @return true If the node has mesh. + */ + bool GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const; + + /** + * @brief Retrieves Scale Factor uniform name. + * This uniform name can be used to change scale factor for ibl. + * @return std::string_view of the scale factor uniform name. + */ + static std::string_view GetIblScaleFactorUniformName(); + + /** + * @brief Retrieves ibl Ydirection uniform name. + * This uniform name can be used to flip y direction of ibl in shader. + * @return std::string_view of the YDirection uniform name. + */ + static std::string_view GetIblYDirectionUniformName(); + public: // DATA static const std::string ORIGINAL_MATRIX_PROPERTY_NAME; @@ -240,7 +270,7 @@ public: // DATA Index mParentIdx = INVALID_INDEX; }; -class DALI_SCENE_LOADER_API ModelNode : public NodeDefinition::Renderable +class DALI_SCENE3D_API ModelNode : public NodeDefinition::Renderable { public: // DATA Vector4 mColor = Color::WHITE; @@ -248,6 +278,7 @@ public: // DATA Index mMaterialIdx = INVALID_INDEX; public: // METHODS + bool GetExtents(const ResourceBundle& resources, Vector3& min, Vector3& max) const override; void RegisterResources(IResourceReceiver& receiver) const override; void ReflectResources(IResourceReflector& reflector) override; void OnCreate(const NodeDefinition& node, NodeDefinition::CreateParams& params, Actor& actor) const override; @@ -256,7 +287,7 @@ public: // METHODS /** * @brief Parameters for an Arc node. */ -class DALI_SCENE_LOADER_API ArcNode : public ModelNode +class DALI_SCENE3D_API ArcNode : public ModelNode { public: // DATA bool mAntiAliasing = true; @@ -271,7 +302,8 @@ public: // METHODS void OnCreate(const NodeDefinition& node, NodeDefinition::CreateParams& params, Actor& actor) const override; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_NODE_DEFINITION_H_ +#endif //DALI_SCENE3D_LOADER_NODE_DEFINITION_H_ diff --git a/dali-scene-loader/public-api/parse-renderer-state.cpp b/dali-scene3d/public-api/loader/parse-renderer-state.cpp similarity index 95% rename from dali-scene-loader/public-api/parse-renderer-state.cpp rename to dali-scene3d/public-api/loader/parse-renderer-state.cpp index 815dfaf..3c01701 100644 --- a/dali-scene-loader/public-api/parse-renderer-state.cpp +++ b/dali-scene3d/public-api/loader/parse-renderer-state.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,15 @@ * */ -#include "dali-scene-loader/public-api/parse-renderer-state.h" +#include "dali-scene3d/public-api/loader/parse-renderer-state.h" #include #include "dali/devel-api/common/map-wrapper.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace RendererState { @@ -52,7 +54,7 @@ Type InterpretComparison(const std::string_view& str) } std::map BLEND_FACTORS{ -#define DECL_BLEND_FACTOR(x) {#x, SceneLoader::BlendFactor::x} +#define DECL_BLEND_FACTOR(x) {#x, Dali::Scene3D::Loader::BlendFactor::x} DECL_BLEND_FACTOR(ZERO), DECL_BLEND_FACTOR(ONE), DECL_BLEND_FACTOR(SRC_COLOR), @@ -166,5 +168,6 @@ Type Parse(const char* string, size_t length, StringCallback onError) } } // namespace RendererState -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/parse-renderer-state.h b/dali-scene3d/public-api/loader/parse-renderer-state.h similarity index 72% rename from dali-scene-loader/public-api/parse-renderer-state.h rename to dali-scene3d/public-api/loader/parse-renderer-state.h index 38103d0..43ca5b3 100644 --- a/dali-scene-loader/public-api/parse-renderer-state.h +++ b/dali-scene3d/public-api/loader/parse-renderer-state.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_INTERPRET_RENDERER_STATE_H -#define DALI_SCENE_LOADER_INTERPRET_RENDERER_STATE_H +#ifndef DALI_SCENE3D_LOADERERER_INTERPRET_RENDERER_STATE_H +#define DALI_SCENE3D_LOADERERER_INTERPRET_RENDERER_STATE_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,14 @@ * */ -#include "dali-scene-loader/public-api/renderer-state.h" -#include "dali-scene-loader/public-api/string-callback.h" +#include "dali-scene3d/public-api/loader/renderer-state.h" +#include "dali-scene3d/public-api/loader/string-callback.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace RendererState { @@ -39,10 +41,11 @@ namespace RendererState * @param onError The callback to call when an error occurred. * @note No other characters are allowed. */ -DALI_SCENE_LOADER_API Type Parse(const char* string, size_t length = 0, StringCallback onError = DefaultErrorCallback); +DALI_SCENE3D_API Type Parse(const char* string, size_t length = 0, StringCallback onError = DefaultErrorCallback); } // namespace RendererState -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_INTERPRET_RENDERER_STATE_H +#endif //DALI_SCENE3D_LOADERERER_INTERPRET_RENDERER_STATE_H diff --git a/dali-scene-loader/public-api/renderer-state.cpp b/dali-scene3d/public-api/loader/renderer-state.cpp similarity index 93% rename from dali-scene-loader/public-api/renderer-state.cpp rename to dali-scene3d/public-api/loader/renderer-state.cpp index 80178b5..ad8059d 100644 --- a/dali-scene-loader/public-api/renderer-state.cpp +++ b/dali-scene3d/public-api/loader/renderer-state.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,14 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/renderer-state.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/renderer-state.h" +#include "dali-scene3d/public-api/loader/utils.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -96,5 +98,6 @@ void Apply(Type rendererState, Renderer& renderer) } // namespace RendererState -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/renderer-state.h b/dali-scene3d/public-api/loader/renderer-state.h similarity index 86% rename from dali-scene-loader/public-api/renderer-state.h rename to dali-scene3d/public-api/loader/renderer-state.h index f70100a..0dc3c52 100644 --- a/dali-scene-loader/public-api/renderer-state.h +++ b/dali-scene3d/public-api/loader/renderer-state.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_RENDERER_STATE_H -#define DALI_SCENE_LOADER_RENDERER_STATE_H +#ifndef DALI_SCENE3D_LOADER_RENDERER_STATE_H +#define DALI_SCENE3D_LOADER_RENDERER_STATE_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,20 +18,22 @@ */ // INTERAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include "dali/public-api/rendering/renderer.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /* * @brief Contains values for comparison functions used in depth and stencil testing. * @note Relative order of members must match DepthFunction::Type and StencilFunction::Type. */ -struct DALI_SCENE_LOADER_API Comparison +struct DALI_SCENE3D_API Comparison { enum Type { @@ -53,7 +55,7 @@ struct DALI_SCENE_LOADER_API Comparison * @brief Determines the blend factor used. * @note Relative order of members must match BlendFactor::Type. */ -struct DALI_SCENE_LOADER_API BlendFactor +struct DALI_SCENE3D_API BlendFactor { enum Type { @@ -82,7 +84,7 @@ struct DALI_SCENE_LOADER_API BlendFactor * @brief Determines which buffers shall the Renderer write into. * @note Relative order of members must match RenderMode::Type. */ -struct DALI_SCENE_LOADER_API BufferMode +struct DALI_SCENE3D_API BufferMode { enum Type { @@ -104,7 +106,7 @@ namespace RendererState { using Type = uint32_t; // 8 bits reserved for flags, 4 * 4 bit for blend factors, 4 bits for depth function -enum DALI_SCENE_LOADER_API Value : Type +enum DALI_SCENE3D_API Value : Type { NONE = 0x0, @@ -139,7 +141,7 @@ enum DALI_SCENE_LOADER_API Value : Type * @brief Encodes the given blend factors into a RenderMode value, maskable into other options, * passable into ApplyRenderMode(). */ -inline DALI_SCENE_LOADER_API constexpr uint32_t FromBlendFactors(BlendFactor::Type srcRgb, BlendFactor::Type destRgb, BlendFactor::Type srcAlpha, BlendFactor::Type destAlpha) +inline DALI_SCENE3D_API constexpr uint32_t FromBlendFactors(BlendFactor::Type srcRgb, BlendFactor::Type destRgb, BlendFactor::Type srcAlpha, BlendFactor::Type destAlpha) { return (srcRgb | (destRgb << BLEND_FACTOR_ITEM_BITS) | (srcAlpha << (BLEND_FACTOR_ITEM_BITS * 2)) | (destAlpha << (BLEND_FACTOR_ITEM_BITS * 3))) @@ -152,11 +154,12 @@ inline DALI_SCENE_LOADER_API constexpr uint32_t FromBlendFactors(BlendFactor::Ty * @note Blend factors are only set if not BlendFactor::OMIT. * @note Buffer mode is only set is not BufferMode::OMIT. */ -DALI_SCENE_LOADER_API void Apply(Type rendererState, Renderer& renderer); +DALI_SCENE3D_API void Apply(Type rendererState, Renderer& renderer); } // namespace RendererState -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_RENDERER_STATE_H +#endif //DALI_SCENE3D_LOADER_RENDERER_STATE_H diff --git a/dali-scene-loader/public-api/resource-bundle.cpp b/dali-scene3d/public-api/loader/resource-bundle.cpp similarity index 95% rename from dali-scene-loader/public-api/resource-bundle.cpp rename to dali-scene3d/public-api/loader/resource-bundle.cpp index 98b08bb..5df41e2 100644 --- a/dali-scene-loader/public-api/resource-bundle.cpp +++ b/dali-scene3d/public-api/loader/resource-bundle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // FILE HEADER -#include "dali-scene-loader/public-api/resource-bundle.h" +#include "dali-scene3d/public-api/loader/resource-bundle.h" // EXTERNAL #include @@ -29,7 +29,9 @@ namespace Dali { using namespace Toolkit; -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -146,5 +148,6 @@ void ResourceBundle::LoadResources(const ResourceRefCounts& refCounts, PathProvi } } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/resource-bundle.h b/dali-scene3d/public-api/loader/resource-bundle.h similarity index 81% rename from dali-scene-loader/public-api/resource-bundle.h rename to dali-scene3d/public-api/loader/resource-bundle.h index b1e0936..1537f72 100644 --- a/dali-scene-loader/public-api/resource-bundle.h +++ b/dali-scene3d/public-api/loader/resource-bundle.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_RESOURCE_BUNDLE_H_ -#define DALI_SCENE_LOADER_RESOURCE_BUNDLE_H_ +#ifndef DALI_SCENE3D_LOADERERERERER_RESOURCE_BUNDLE_H_ +#define DALI_SCENE3D_LOADERERERERER_RESOURCE_BUNDLE_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ */ // INTERNAL -#include "dali-scene-loader/public-api/environment-definition.h" -#include "dali-scene-loader/public-api/material-definition.h" -#include "dali-scene-loader/public-api/mesh-definition.h" -#include "dali-scene-loader/public-api/shader-definition.h" -#include "dali-scene-loader/public-api/skeleton-definition.h" +#include "dali-scene3d/public-api/loader/environment-definition.h" +#include "dali-scene3d/public-api/loader/material-definition.h" +#include "dali-scene3d/public-api/loader/mesh-definition.h" +#include "dali-scene3d/public-api/loader/shader-definition.h" +#include "dali-scene3d/public-api/loader/skeleton-definition.h" // EXTERNAL #include @@ -33,12 +33,14 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /* * @brief The types of resources that .dli may define. */ -struct DALI_SCENE_LOADER_API ResourceType +struct DALI_SCENE3D_API ResourceType { enum Value { @@ -54,7 +56,7 @@ struct DALI_SCENE_LOADER_API ResourceType /* * @return The string value corresponding to the given resource @a type. */ -DALI_SCENE_LOADER_API const char* GetResourceTypeName(ResourceType::Value type); +DALI_SCENE3D_API const char* GetResourceTypeName(ResourceType::Value type); using ResourceRefCounts = std::vector>; @@ -63,7 +65,7 @@ using ResourceRefCounts = std::vector>; * could be created from them, directly indexible into with values from a dli * document. */ -class DALI_SCENE_LOADER_API ResourceBundle +class DALI_SCENE3D_API ResourceBundle { public: struct Options @@ -122,7 +124,8 @@ public: // DATA SkeletonDefinition::Vector mSkeletons; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_RESOURCE_BUNDLE_H_ +#endif //DALI_SCENE3D_LOADERERERERER_RESOURCE_BUNDLE_H_ diff --git a/dali-scene-loader/public-api/scene-definition.cpp b/dali-scene3d/public-api/loader/scene-definition.cpp similarity index 98% rename from dali-scene-loader/public-api/scene-definition.cpp rename to dali-scene3d/public-api/loader/scene-definition.cpp index ff8bdfa..6e26c0f 100644 --- a/dali-scene-loader/public-api/scene-definition.cpp +++ b/dali-scene3d/public-api/loader/scene-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ #include "dali/public-api/animation/constraints.h" // INTERNAL -#include "dali-scene-loader/internal/graphics/builtin-shader-extern-gen.h" -#include "dali-scene-loader/public-api/blend-shape-details.h" -#include "dali-scene-loader/public-api/scene-definition.h" -#include "dali-scene-loader/public-api/skinning-details.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/internal/graphics/builtin-shader-extern-gen.h" +#include "dali-scene3d/public-api/loader/blend-shape-details.h" +#include "dali-scene3d/public-api/loader/scene-definition.h" +#include "dali-scene3d/public-api/loader/skinning-details.h" +#include "dali-scene3d/public-api/loader/utils.h" //#define DEBUG_SCENE_DEFINITION //#define DEBUG_JOINTS @@ -39,7 +39,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -122,7 +124,7 @@ void EnsureJointDebugShaderCreated() { if(0 == sNumScenes) { - sJointDebugShader = Shader::New(SHADER_SCENE_LOADER_JOINT_DEBUG_VERT, SHADER_SCENE_LOADER_JOINT_DEBUG_FRAG); + sJointDebugShader = Shader::New(SHADER_SCENE3D_JOINT_DEBUG_VERT, SHADER_SCENE3D_JOINT_DEBUG_FRAG); } ++sNumScenes; } @@ -376,7 +378,7 @@ SceneDefinition::~SceneDefinition() #endif } -uint32_t SceneLoader::SceneDefinition::AddRootNode(Index iNode) +uint32_t Dali::Scene3D::Loader::SceneDefinition::AddRootNode(Index iNode) { if(iNode < mNodes.size()) { @@ -1194,5 +1196,6 @@ bool SceneDefinition::FindNode(const std::string& name, std::unique_ptr @@ -33,7 +33,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { class MatrixStack; @@ -41,7 +43,7 @@ class MatrixStack; * @brief Intermediate representation of a scene with functionality required to * create DALi objects (Actors, Renderers) from it. */ -class DALI_SCENE_LOADER_API SceneDefinition +class DALI_SCENE3D_API SceneDefinition { public: // TYPES using NodePredicate = std::function; @@ -272,7 +274,8 @@ private: // DATA std::vector mRootNodeIds; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_SCENE_DEFINITION_H_ +#endif //DALI_SCENE3D_LOADERER_SCENE_DEFINITION_H_ diff --git a/dali-scene-loader/public-api/shader-definition-factory.cpp b/dali-scene3d/public-api/loader/shader-definition-factory.cpp similarity index 94% rename from dali-scene-loader/public-api/shader-definition-factory.cpp rename to dali-scene3d/public-api/loader/shader-definition-factory.cpp index e025ebe..59dd3b4 100644 --- a/dali-scene-loader/public-api/shader-definition-factory.cpp +++ b/dali-scene3d/public-api/loader/shader-definition-factory.cpp @@ -14,16 +14,18 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/shader-definition-factory.h" +#include "dali-scene3d/public-api/loader/shader-definition-factory.h" #include -#include "dali-scene-loader/internal/hash.h" -#include "dali-scene-loader/public-api/blend-shape-details.h" -#include "dali-scene-loader/public-api/node-definition.h" +#include "dali-scene3d/internal/loader/hash.h" +#include "dali-scene3d/public-api/loader/blend-shape-details.h" +#include "dali-scene3d/public-api/loader/node-definition.h" #include "dali/devel-api/common/map-wrapper.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -193,7 +195,7 @@ Index ShaderDefinitionFactory::ProduceShader(const NodeDefinition& nodeDef) ShaderDefinition shaderDef; shaderDef.mUseBuiltInShader = true; - shaderDef.mRendererState = RendererState::DEPTH_TEST | RendererState::DEPTH_WRITE | RendererState::CULL_BACK; + shaderDef.mRendererState = RendererState::DEPTH_TEST | RendererState::DEPTH_WRITE | RendererState::CULL_BACK; auto& materialDef = *receiver.mMaterialDef; const bool hasTransparency = MaskMatch(materialDef.mFlags, MaterialDefinition::TRANSPARENCY); @@ -312,5 +314,6 @@ Index ShaderDefinitionFactory::ProduceShader(const NodeDefinition& nodeDef) return result; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/shader-definition-factory.h b/dali-scene3d/public-api/loader/shader-definition-factory.h similarity index 76% rename from dali-scene-loader/public-api/shader-definition-factory.h rename to dali-scene3d/public-api/loader/shader-definition-factory.h index 387984d..8c4434a 100644 --- a/dali-scene-loader/public-api/shader-definition-factory.h +++ b/dali-scene3d/public-api/loader/shader-definition-factory.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_SHADER_DEFINITION_FACTORY_H_ -#define DALI_SCENE_LOADER_SHADER_DEFINITION_FACTORY_H_ +#ifndef DALI_SCENE3D_LOADER_SHADER_DEFINITION_FACTORY_H_ +#define DALI_SCENE3D_LOADER_SHADER_DEFINITION_FACTORY_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,20 +18,22 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" -#include "dali-scene-loader/public-api/index.h" +#include "dali-scene3d/public-api/api.h" +#include "dali-scene3d/public-api/loader/index.h" // EXTERNAL INCLUDER #include namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { struct NodeDefinition; class ResourceBundle; -class DALI_SCENE_LOADER_API ShaderDefinitionFactory +class DALI_SCENE3D_API ShaderDefinitionFactory { public: ShaderDefinitionFactory(); @@ -56,7 +58,8 @@ private: const std::unique_ptr mImpl; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_SHADER_DEFINITION_FACTORY_H_ +#endif //DALI_SCENE3D_LOADER_SHADER_DEFINITION_FACTORY_H_ diff --git a/dali-scene-loader/public-api/shader-definition.cpp b/dali-scene3d/public-api/loader/shader-definition.cpp similarity index 93% rename from dali-scene-loader/public-api/shader-definition.cpp rename to dali-scene3d/public-api/loader/shader-definition.cpp index 1927351..ad263e4 100644 --- a/dali-scene-loader/public-api/shader-definition.cpp +++ b/dali-scene3d/public-api/loader/shader-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,15 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/shader-definition.h" -#include "dali-scene-loader/public-api/utils.h" -#include +#include "dali-scene3d/public-api/loader/shader-definition.h" +#include +#include "dali-scene3d/public-api/loader/utils.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -143,5 +145,6 @@ Shader ShaderDefinition::Load(RawData&& raw) const return shader; } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/shader-definition.h b/dali-scene3d/public-api/loader/shader-definition.h similarity index 86% rename from dali-scene-loader/public-api/shader-definition.h rename to dali-scene3d/public-api/loader/shader-definition.h index 386a0c9..d381c57 100644 --- a/dali-scene-loader/public-api/shader-definition.h +++ b/dali-scene3d/public-api/loader/shader-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_SHADER_DEFINITION_H -#define DALI_SCENE_LOADER_SHADER_DEFINITION_H +#ifndef DALI_SCENE3D_LOADER_SHADER_DEFINITION_H +#define DALI_SCENE3D_LOADER_SHADER_DEFINITION_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/renderer-state.h" +#include "dali-scene3d/public-api/loader/renderer-state.h" // EXTERNAL INCLUDES #include @@ -27,14 +27,16 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /* * @brief Defines a shader with paths to the files which define its * vertex and fragment components, and a mapping of uniform names (which are * used to refer to them in GLSL) to data. */ -struct DALI_SCENE_LOADER_API ShaderDefinition +struct DALI_SCENE3D_API ShaderDefinition { using Vector = std::vector>; @@ -83,7 +85,8 @@ public: // DATA bool mUseBuiltInShader{false}; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_SHADER_DEFINITION_H +#endif //DALI_SCENE3D_LOADER_SHADER_DEFINITION_H diff --git a/dali-scene-loader/public-api/skeleton-definition.h b/dali-scene3d/public-api/loader/skeleton-definition.h similarity index 78% rename from dali-scene-loader/public-api/skeleton-definition.h rename to dali-scene3d/public-api/loader/skeleton-definition.h index 9bd7133..b2d61a8 100644 --- a/dali-scene-loader/public-api/skeleton-definition.h +++ b/dali-scene3d/public-api/loader/skeleton-definition.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_SKELETON_H -#define DALI_SCENE_LOADER_SKELETON_H +#ifndef DALI_SCENE3D_LOADERER_SKELETON_H +#define DALI_SCENE3D_LOADERER_SKELETON_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/index.h" +#include "dali-scene3d/public-api/loader/index.h" // EXTERNAL INCLUDES #include "dali/public-api/common/vector-wrapper.h" @@ -26,7 +26,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /* * @brief A set of joints (stored as node indices), and an optional root node index. @@ -34,7 +36,7 @@ namespace SceneLoader * @note Client code should not change the order of joints, as they are indexed by mesh vertex data. * @note Client code should make no assumption about the relation of the joint IDs. */ -struct DALI_SCENE_LOADER_API SkeletonDefinition +struct DALI_SCENE3D_API SkeletonDefinition { struct Joint { @@ -48,7 +50,8 @@ struct DALI_SCENE_LOADER_API SkeletonDefinition std::vector mJoints; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_SKELETON_H +#endif //DALI_SCENE3D_LOADERER_SKELETON_H diff --git a/dali-scene-loader/public-api/skinning-details.cpp b/dali-scene3d/public-api/loader/skinning-details.cpp similarity index 81% rename from dali-scene-loader/public-api/skinning-details.cpp rename to dali-scene3d/public-api/loader/skinning-details.cpp index 0edb58b..128a19b 100644 --- a/dali-scene-loader/public-api/skinning-details.cpp +++ b/dali-scene3d/public-api/loader/skinning-details.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,18 +14,21 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/skinning-details.h" +#include "dali-scene3d/public-api/loader/skinning-details.h" #include "dali/public-api/animation/constraints.h" #include "dali/public-api/object/property.h" #include "dali/public-api/rendering/shader.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { const unsigned int Skinning::MAX_JOINTS = 64; const std::string Skinning::BONE_UNIFORM_NAME = "uBone"; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/skinning-details.h b/dali-scene3d/public-api/loader/skinning-details.h similarity index 72% rename from dali-scene-loader/public-api/skinning-details.h rename to dali-scene3d/public-api/loader/skinning-details.h index 4ad1676..78ba38c 100644 --- a/dali-scene-loader/public-api/skinning-details.h +++ b/dali-scene3d/public-api/loader/skinning-details.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_SKINNING_DETAILS_H_ -#define DALI_SCENE_LOADER_SKINNING_DETAILS_H_ +#ifndef DALI_SCENE3D_LOADER_SKINNING_DETAILS_H_ +#define DALI_SCENE3D_LOADER_SKINNING_DETAILS_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include @@ -26,9 +26,11 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D { -struct DALI_SCENE_LOADER_API Skinning +namespace Loader +{ +struct DALI_SCENE3D_API Skinning { /* * @brief Upper limit on the number of joints supported. @@ -43,7 +45,8 @@ struct DALI_SCENE_LOADER_API Skinning Skinning() = delete; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif // DALI_SCENE_LOADER_SKINNING_DETAILS_H_ +#endif // DALI_SCENE3D_LOADER_SKINNING_DETAILS_H_ diff --git a/dali-scene-loader/public-api/string-callback.cpp b/dali-scene3d/public-api/loader/string-callback.cpp similarity index 79% rename from dali-scene-loader/public-api/string-callback.cpp rename to dali-scene3d/public-api/loader/string-callback.cpp index 8bf02e6..5d46cb7 100644 --- a/dali-scene-loader/public-api/string-callback.cpp +++ b/dali-scene3d/public-api/loader/string-callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,20 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/string-callback.h" +#include "dali-scene3d/public-api/loader/string-callback.h" #include "dali/integration-api/debug.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { void DefaultErrorCallback(const std::string& message) { DALI_LOG_ERROR("%s", message.c_str()); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/string-callback.h b/dali-scene3d/public-api/loader/string-callback.h similarity index 69% rename from dali-scene-loader/public-api/string-callback.h rename to dali-scene3d/public-api/loader/string-callback.h index 5a1d289..4f00a10 100644 --- a/dali-scene-loader/public-api/string-callback.h +++ b/dali-scene3d/public-api/loader/string-callback.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_STRING_CALLBACK_H -#define DALI_SCENE_LOADER_STRING_CALLBACK_H +#ifndef DALI_SCENE3D_LOADER_STRING_CALLBACK_H +#define DALI_SCENE3D_LOADER_STRING_CALLBACK_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include @@ -26,7 +26,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /* * @brief A callback to post strings to. @@ -36,9 +38,10 @@ using StringCallback = std::function; /* * @brief Simply passes the formatted message to LOGE(). */ -DALI_SCENE_LOADER_API void DefaultErrorCallback(const std::string& message); +DALI_SCENE3D_API void DefaultErrorCallback(const std::string& message); -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_STRING_CALLBACK_H +#endif //DALI_SCENE3D_LOADER_STRING_CALLBACK_H diff --git a/dali-scene-loader/public-api/utils.cpp b/dali-scene3d/public-api/loader/utils.cpp similarity index 95% rename from dali-scene-loader/public-api/utils.cpp rename to dali-scene3d/public-api/loader/utils.cpp index 4d4396d..e4f3596 100644 --- a/dali-scene-loader/public-api/utils.cpp +++ b/dali-scene3d/public-api/loader/utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // INTERNAL -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/utils.h" // EXTERNAL #include @@ -28,7 +28,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { namespace { @@ -145,5 +147,6 @@ void ToUnixFileSeparators(std::string& path) std::replace(path.begin(), path.end(), '\\', '/'); } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/utils.h b/dali-scene3d/public-api/loader/utils.h similarity index 76% rename from dali-scene-loader/public-api/utils.h rename to dali-scene3d/public-api/loader/utils.h index f9213e1..05a2063 100644 --- a/dali-scene-loader/public-api/utils.h +++ b/dali-scene3d/public-api/loader/utils.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_UTILS_H_ -#define DALI_SCENE_LOADER_UTILS_H_ +#ifndef DALI_SCENE3D_LOADER_UTILS_H_ +#define DALI_SCENE3D_LOADER_UTILS_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include @@ -29,7 +29,9 @@ namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /* * @brief Fixed size backing buffer to use with std::ostreams where control over @@ -37,7 +39,7 @@ namespace SceneLoader * @note All stream insertions that would overflow the buffer that StreamBuffer * was created with, will fail. */ -class DALI_SCENE_LOADER_API StreamBuffer : public std::basic_streambuf +class DALI_SCENE3D_API StreamBuffer : public std::basic_streambuf { public: StreamBuffer(char* buffer, size_t size) noexcept(true); @@ -48,7 +50,7 @@ public: * which a message can be formatted into. Upon destruction, it throws a * DaliException with the message. */ -class DALI_SCENE_LOADER_API ExceptionFlinger +class DALI_SCENE3D_API ExceptionFlinger { public: enum @@ -85,12 +87,12 @@ private: /* * @brief Formats the given printf-style varargs into a std::string. */ -DALI_SCENE_LOADER_API std::string FormatString(const char* format, ...); +DALI_SCENE3D_API std::string FormatString(const char* format, ...); /* * @return The @n th bit in a bitmask. */ -DALI_SCENE_LOADER_API constexpr size_t NthBit(size_t n) +DALI_SCENE3D_API constexpr size_t NthBit(size_t n) { return 1 << n; } @@ -98,7 +100,7 @@ DALI_SCENE_LOADER_API constexpr size_t NthBit(size_t n) /* * @return Whether all of @a mask 's bits are set on @a value. */ -inline DALI_SCENE_LOADER_API bool MaskMatch(uint32_t value, uint32_t mask) +inline DALI_SCENE3D_API bool MaskMatch(uint32_t value, uint32_t mask) { return (value & mask) == mask; } @@ -106,7 +108,7 @@ inline DALI_SCENE_LOADER_API bool MaskMatch(uint32_t value, uint32_t mask) /* * @brief Convert a four-letter(, null-terminated) string literal into a uint32_t. */ -inline DALI_SCENE_LOADER_API constexpr uint32_t FourCC(const char (&fourCC)[5]) +inline DALI_SCENE3D_API constexpr uint32_t FourCC(const char (&fourCC)[5]) { return (fourCC[3] << 24) | (fourCC[2] << 16) | (fourCC[1] << 8) | fourCC[0]; } @@ -117,7 +119,7 @@ inline DALI_SCENE_LOADER_API constexpr uint32_t FourCC(const char (&fourCC)[5]) * @param[in] b, compare string * @return true if strings are equal */ -inline DALI_SCENE_LOADER_API bool CaseInsensitiveCharacterCompare(unsigned char a, unsigned char b) +inline DALI_SCENE3D_API bool CaseInsensitiveCharacterCompare(unsigned char a, unsigned char b) { // Converts to lower case in the current locale. return std::tolower(a) == std::tolower(b); @@ -128,7 +130,7 @@ inline DALI_SCENE_LOADER_API bool CaseInsensitiveCharacterCompare(unsigned char * @param[in] a, compare string * @param[in] b, compare string */ -inline DALI_SCENE_LOADER_API bool CaseInsensitiveStringCompare(const std::string& a, const std::string& b) +inline DALI_SCENE3D_API bool CaseInsensitiveStringCompare(const std::string& a, const std::string& b) { bool result = false; if(a.length() == b.length()) @@ -144,7 +146,7 @@ inline DALI_SCENE_LOADER_API bool CaseInsensitiveStringCompare(const std::string * to true in case of failure (should only be checked if the returned string * was empty()). */ -DALI_SCENE_LOADER_API std::string LoadTextFile(const char* path, bool* fail = nullptr); +DALI_SCENE3D_API std::string LoadTextFile(const char* path, bool* fail = nullptr); /* * @brief Makes a number of calls to @a fn, passing to each one the given @@ -154,7 +156,7 @@ DALI_SCENE_LOADER_API std::string LoadTextFile(const char* path, bool* fail = nu * for performance and stability reasons. */ template -inline DALI_SCENE_LOADER_API void VisitActor(Actor a, Func fn) +inline DALI_SCENE3D_API void VisitActor(Actor a, Func fn) { fn(a); @@ -169,7 +171,7 @@ inline DALI_SCENE_LOADER_API void VisitActor(Actor a, Func fn) * @brief Convenience function to set the given actor @a 's anchor point * and parent origin to center. */ -inline DALI_SCENE_LOADER_API void SetActorCentered(Actor a) +inline DALI_SCENE3D_API void SetActorCentered(Actor a) { a.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); a.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); @@ -179,7 +181,7 @@ namespace TexturedQuadOptions { using Type = uint32_t; -enum DALI_SCENE_LOADER_API Values : Type +enum DALI_SCENE3D_API Values : Type { NONE = 0x00, FLIP_VERTICAL = 0x01, @@ -189,15 +191,16 @@ enum DALI_SCENE_LOADER_API Values : Type /* * @brief Makes... geometry for a textured quad. */ -DALI_SCENE_LOADER_API Geometry MakeTexturedQuadGeometry(TexturedQuadOptions::Type options = TexturedQuadOptions::NONE); +DALI_SCENE3D_API Geometry MakeTexturedQuadGeometry(TexturedQuadOptions::Type options = TexturedQuadOptions::NONE); /* * @brief Fixes the path of a file. Replaces the '\\' separator by the '/' one. * @param[in,out] path The path to be fixed. */ -DALI_SCENE_LOADER_API void ToUnixFileSeparators(std::string& path); +DALI_SCENE3D_API void ToUnixFileSeparators(std::string& path); -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif /* DALI_SCENE_LOADER_UTILS_H_ */ +#endif /* DALI_SCENE3D_LOADER_UTILS_H_ */ diff --git a/dali-scene-loader/public-api/view-projection.cpp b/dali-scene3d/public-api/loader/view-projection.cpp similarity index 78% rename from dali-scene-loader/public-api/view-projection.cpp rename to dali-scene3d/public-api/loader/view-projection.cpp index ce2e6b0..ac970ca 100644 --- a/dali-scene-loader/public-api/view-projection.cpp +++ b/dali-scene3d/public-api/loader/view-projection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,14 @@ * limitations under the License. * */ -#include "dali-scene-loader/public-api/view-projection.h" -#include "dali-scene-loader/public-api/utils.h" +#include "dali-scene3d/public-api/loader/view-projection.h" +#include "dali-scene3d/public-api/loader/utils.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { void ViewProjection::Update() { @@ -32,5 +34,6 @@ void ViewProjection::Update() } } -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali diff --git a/dali-scene-loader/public-api/view-projection.h b/dali-scene3d/public-api/loader/view-projection.h similarity index 82% rename from dali-scene-loader/public-api/view-projection.h rename to dali-scene3d/public-api/loader/view-projection.h index 26ce908..db7be74 100644 --- a/dali-scene-loader/public-api/view-projection.h +++ b/dali-scene3d/public-api/loader/view-projection.h @@ -1,7 +1,7 @@ -#ifndef DALI_SCENE_LOADER_VIEW_PROJECTION_H_ -#define DALI_SCENE_LOADER_VIEW_PROJECTION_H_ +#ifndef DALI_SCENE3D_LOADER_VIEW_PROJECTION_H_ +#define DALI_SCENE3D_LOADER_VIEW_PROJECTION_H_ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,16 @@ */ // INTERNAL INCLUDES -#include "dali-scene-loader/public-api/api.h" +#include "dali-scene3d/public-api/api.h" // EXTERNAL INCLUDES #include "dali/public-api/math/matrix.h" namespace Dali { -namespace SceneLoader +namespace Scene3D +{ +namespace Loader { /** * @brief Contains view and projection matrices, also caching the view-projection @@ -72,7 +74,8 @@ private: Matrix mViewProjection; }; -} // namespace SceneLoader +} // namespace Loader +} // namespace Scene3D } // namespace Dali -#endif //DALI_SCENE_LOADER_VIEW_PROJECTION_H_ +#endif //DALI_SCENE3D_LOADER_VIEW_PROJECTION_H_ diff --git a/dali-scene-loader/third-party/.clang-format b/dali-scene3d/third-party/.clang-format similarity index 100% rename from dali-scene-loader/third-party/.clang-format rename to dali-scene3d/third-party/.clang-format diff --git a/dali-scene-loader/third-party/json.h b/dali-scene3d/third-party/json.h similarity index 100% rename from dali-scene-loader/third-party/json.h rename to dali-scene3d/third-party/json.h diff --git a/dali-toolkit/devel-api/controls/control-accessible.cpp b/dali-toolkit/devel-api/controls/control-accessible.cpp index 85b3c6a..a24e59d 100644 --- a/dali-toolkit/devel-api/controls/control-accessible.cpp +++ b/dali-toolkit/devel-api/controls/control-accessible.cpp @@ -265,6 +265,12 @@ Dali::Accessibility::Attributes ControlAccessible::GetAttributes() const } } + auto automationId = control.GetProperty(Dali::Toolkit::DevelControl::Property::AUTOMATION_ID); + if(!automationId.empty()) + { + attributeMap.emplace("automationId", std::move(automationId)); + } + return attributeMap; } diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index 34b733b..3a94e1b 100644 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -215,6 +215,14 @@ enum * */ COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, + + /** + * @brief Identifier that allows the automation framework to find and interact with this element. + * @details Name "automationId", type Property::STRING. + * @note This is a string identifier (compared to @c Actor::Property::ID which is an integer). + * It will also appear in the AT-SPI tree under the key "automationId". + */ + AUTOMATION_ID, }; } // namespace Property diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.cpp b/dali-toolkit/devel-api/controls/web-view/web-context.cpp deleted file mode 100755 index 128546b..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-context.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include - -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); -} - -std::string WebContext::GetProxyUri() const -{ - return mWebEngineContext.GetProxyUri(); -} - -void WebContext::SetProxyBypassRule(const std::string& proxy, const std::string& bypass) -{ - mWebEngineContext.SetProxyBypassRule(proxy, bypass); -} - -std::string WebContext::GetProxyBypassRule() const -{ - return mWebEngineContext.GetProxyBypassRule(); -} - -void WebContext::SetCertificateFilePath(const std::string& certificatePath) -{ - mWebEngineContext.SetCertificateFilePath(certificatePath); -} - -std::string WebContext::GetCertificateFilePath() const -{ - return mWebEngineContext.GetCertificateFilePath(); -} - -void WebContext::SetDefaultProxyAuth(const std::string& username, const std::string& password) -{ - mWebEngineContext.SetDefaultProxyAuth(username, password); -} - -void WebContext::DeleteAllWebDatabase() -{ - mWebEngineContext.DeleteAllWebDatabase(); -} - -bool WebContext::GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) -{ - return mWebEngineContext.GetWebDatabaseOrigins(callback); -} - -bool WebContext::DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin) -{ - return mWebEngineContext.DeleteWebDatabase(origin); -} - -bool WebContext::GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback) -{ - return mWebEngineContext.GetWebStorageOrigins(callback); -} - -bool WebContext::GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback) -{ - return mWebEngineContext.GetWebStorageUsageForOrigin(origin, callback); -} - -void WebContext::DeleteAllWebStorage() -{ - mWebEngineContext.DeleteAllWebStorage(); -} - -bool WebContext::DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin) -{ - return mWebEngineContext.DeleteWebStorage(origin); -} - -void WebContext::DeleteLocalFileSystem() -{ - mWebEngineContext.DeleteLocalFileSystem(); -} - -void WebContext::ClearCache() -{ - mWebEngineContext.ClearCache(); -} - -bool WebContext::DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin) -{ - return mWebEngineContext.DeleteApplicationCache(origin); -} - -void WebContext::GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback) -{ - mWebEngineContext.GetFormPasswordList(callback); -} - -void WebContext::RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback) -{ - mWebEngineContext.RegisterDownloadStartedCallback(callback); -} - -void WebContext::RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback) -{ - mWebEngineContext.RegisterMimeOverriddenCallback(callback); -} - -void WebContext::RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback) -{ - mWebEngineContext.RegisterRequestInterceptedCallback(callback); -} - -void WebContext::EnableCache(bool cacheEnabled) -{ - mWebEngineContext.EnableCache(cacheEnabled); -} - -bool WebContext::IsCacheEnabled() const -{ - return mWebEngineContext.IsCacheEnabled(); -} - -void WebContext::SetAppId(const std::string& appId) -{ - mWebEngineContext.SetAppId(appId); -} - -bool WebContext::SetAppVersion(const std::string& appVersion) -{ - return mWebEngineContext.SetAppVersion(appVersion); -} - -void WebContext::SetApplicationType(const Dali::WebEngineContext::ApplicationType applicationType) -{ - mWebEngineContext.SetApplicationType(applicationType); -} - -void WebContext::SetTimeOffset(float timeOffset) -{ - mWebEngineContext.SetTimeOffset(timeOffset); -} - -void WebContext::SetTimeZoneOffset(float timeZoneOffset, float daylightSavingTime) -{ - mWebEngineContext.SetTimeZoneOffset(timeZoneOffset, daylightSavingTime); -} - -void WebContext::SetDefaultZoomFactor(float zoomFactor) -{ - mWebEngineContext.SetDefaultZoomFactor(zoomFactor); -} - -float WebContext::GetDefaultZoomFactor() const -{ - return mWebEngineContext.GetDefaultZoomFactor(); -} - -void WebContext::RegisterUrlSchemesAsCorsEnabled(const std::vector& schemes) -{ - mWebEngineContext.RegisterUrlSchemesAsCorsEnabled(schemes); -} - -void WebContext::RegisterJsPluginMimeTypes(const std::vector& mimeTypes) -{ - mWebEngineContext.RegisterJsPluginMimeTypes(mimeTypes); -} - -bool WebContext::DeleteAllApplicationCache() -{ - return mWebEngineContext.DeleteAllApplicationCache(); -} - -bool WebContext::DeleteAllWebIndexedDatabase() -{ - return mWebEngineContext.DeleteAllWebIndexedDatabase(); -} - -void WebContext::DeleteFormPasswordDataList(const std::vector& list) -{ - mWebEngineContext.DeleteFormPasswordDataList(list); -} - -void WebContext::DeleteAllFormPasswordData() -{ - mWebEngineContext.DeleteAllFormPasswordData(); -} - -void WebContext::DeleteAllFormCandidateData() -{ - mWebEngineContext.DeleteAllFormCandidateData(); -} - -bool WebContext::FreeUnusedMemory() -{ - return mWebEngineContext.FreeUnusedMemory(); -} - -} // 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 deleted file mode 100755 index ebdbae0..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-context.h +++ /dev/null @@ -1,373 +0,0 @@ -#ifndef DALI_TOOLKIT_WEB_CONTEXT_H -#define DALI_TOOLKIT_WEB_CONTEXT_H - -/* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -class WebEngineSecurityOrigin; - -namespace Toolkit -{ -/** - * @addtogroup dali_toolkit_controls_web_view - * @{ - */ - -/** - * @brief WebContext is a control for context of WebView. - * - * For working WebContext, a WebEngineContext should be provided. - * - */ -class DALI_TOOLKIT_API WebContext -{ -public: - /** - * @brief Create a WebContext. - * - * @param[in] context The context of web engine. - */ - WebContext(Dali::WebEngineContext& context); - - /** - * @brief Destructor. - */ - virtual ~WebContext() final; - - /** - * @brief Return the cache model type. - * - * @return #Dali::WebEngineContext::CacheModel - */ - Dali::WebEngineContext::CacheModel GetCacheModel() const; - - /** - * @brief Request to set the cache model. - * - * @param[in] cacheModel The cache model - */ - void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel); - - /** - * @brief Set the given proxy URI to network backend of specific context. - * - * @param[in] uri The proxy URI to set - */ - void SetProxyUri(const std::string& uri); - - /** - * @brief Get the proxy URI from the network backend of specific context. - * - * @return current proxy URI or null string if it's not set - */ - std::string GetProxyUri() const; - - /** - * @brief Set the given proxy to network backend of specific context. - * - * @param[in] proxy URI to set - * @param[in] bypass rule to set - */ - void SetProxyBypassRule(const std::string& proxy, const std::string& bypass); - - /** - * @brief Get the proxy bypass rule from the network backend of specific context. - * - * @return current proxy bypass rule or null string if it's not set - */ - std::string GetProxyBypassRule() const; - - /** - * @brief Add 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); - - /** - * @brief Get CA certifcate file path - * - * It returns an internal string and should not be modified. - * - * @return certificate_file path which is set during ewk_context_certificate_file_set or null string otherwise - */ - std::string GetCertificateFilePath() const; - - /** - * @brief Set 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); - - /** - * @brief Requests for deleting all web databases. - */ - void DeleteAllWebDatabase(); - - /** - * @brief Request for getting web database origins. - * - * @param[in] callback callback called after getting web database origins - * - * @return true if succeeded, false otherwise - */ - bool GetWebDatabaseOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback); - - /** - * @brief Request for deleting web databases for origin. - * - * @param[in] origin database origin - * - * @return true if succeeded, false otherwise - */ - bool DeleteWebDatabase(Dali::WebEngineSecurityOrigin& origin); - - /** - * @brief Gets list of origins that is stored in web storage db. - * - * @param[in] callback callback called after getting web storage origins - * - * @return true if succeeded, false otherwise - */ - bool GetWebStorageOrigins(Dali::WebEngineContext::WebEngineSecurityOriginAcquiredCallback callback); - - /** - * @brief Get list of origins that is stored in web storage db. - * - * @param[in] origin storage origin - * @param[in] callback callback called after getting web storage origins - * - * @return true if succeeded, false otherwise - */ - bool GetWebStorageUsageForOrigin(Dali::WebEngineSecurityOrigin& origin, Dali::WebEngineContext::WebEngineStorageUsageAcquiredCallback callback); - - /** - * @brief Delete all web storage. - * - * @details This function does not ensure that all data will be removed. - * Should be used to extend free physical memory. - */ - void DeleteAllWebStorage(); - - /** - * @brief Delete web storage db. - * - * @param[in] origin origin of db - * - * @return true if succeeded, false otherwise - */ - bool DeleteWebStorage(Dali::WebEngineSecurityOrigin& origin); - - /** - * @brief Request for deleting all local file systems. - */ - void DeleteLocalFileSystem(); - - /** - * @brief Requests to clear cache - */ - void ClearCache(); - - /** - * @brief Request for deleting web application cache for origin. - * - * @param[in] origin application cache origin - * - * @return true if succeeded, false otherwise - */ - bool DeleteApplicationCache(Dali::WebEngineSecurityOrigin& origin); - - /** - * @brief Asynchronous request to get list of all password data. - * - * @param[in] callback callback called after getting form password - */ - void GetFormPasswordList(Dali::WebEngineContext::WebEngineFormPasswordAcquiredCallback callback); - - /** - * @brief Register callback for download started. - * - * @param[in] callback callback for download started - */ - void RegisterDownloadStartedCallback(Dali::WebEngineContext::WebEngineDownloadStartedCallback callback); - - /** - * @brief Register callback for mime overridden. - * - * @param[in] callback callback for mime overridden - */ - void RegisterMimeOverriddenCallback(Dali::WebEngineContext::WebEngineMimeOverriddenCallback callback); - - /** - * @brief Callback to be called when http request need be intercepted. - * - * @param[in] callback - */ - void RegisterRequestInterceptedCallback(Dali::WebEngineContext::WebEngineRequestInterceptedCallback callback); - - /** - * @brief Toggle the cache to be enabled or disabled - * - * @param[in] cacheEnabled enable or disable cache - */ - void EnableCache(bool cacheEnabled); - - /** - * @brief Query if the cache is enabled - * - * @return true is cache is enabled or false otherwise - */ - bool IsCacheEnabled() const; - - /** - * @brief Set application id for context. - * - * @param[in] appId application id - */ - void SetAppId(const std::string& appId); - - /** - * @brief Set application version for context. - * - * @param[in] appVersion application version - * - * @return true if successful, false otherwise - */ - bool SetAppVersion(const std::string& appVersion); - - /** - * @brief To declare application type - * - * @param[in] applicationType The Application_Type enum - * - */ - void SetApplicationType(const Dali::WebEngineContext::ApplicationType applicationType); - - /** - * @brief Set time offset - * - * @param[in] timeOffset The value will be added to system time as offset - */ - void SetTimeOffset(float timeOffset); - - /** - * @brief Set timezone offset - * - * @param[in] timeZoneOffset offset for time zone. - * @param[in] daylightSavingTime The value is for daylight saving time use. - */ - void SetTimeZoneOffset(float timeZoneOffset, float daylightSavingTime); - - /** - * @brief Set default zoom factor - * - * @param[in] zoomFactor default zoom factor - */ - void SetDefaultZoomFactor(float zoomFactor); - - /** - * @brief Get default zoom factor - * - * Gets default zoom factor for all pages opened with this context. - * - * @return default zoom factor or negative value on error - */ - float GetDefaultZoomFactor() const; - - /** - * @brief Register url schemes as CORS enabled - * - * @param[in] schemes The URL schemes list which will be added to web security policy - * - */ - void RegisterUrlSchemesAsCorsEnabled(const std::vector& schemes); - - /** - * @brief Register JS plugin mime types. - * - * @param[in] mimeTypes The MIME types will be checked by the renderer frame loader - * to skip creating default frame for the object tags with the registered MIME type. - */ - void RegisterJsPluginMimeTypes(const std::vector& mimeTypes); - - /** - * @brief Request for deleting all web application caches. - * - * @return @c true on success, otherwise @c false - */ - bool DeleteAllApplicationCache(); - - /** - * @brief Request for deleting all web indexed databases. - * - * @return @c true on success, otherwise @c false - */ - bool DeleteAllWebIndexedDatabase(); - - /** - * @brief Delete a given password data list - * - * @param[in] list List with Ewk_Password_Data - */ - void DeleteFormPasswordDataList(const std::vector& list); - - /** - * @brief Delete whole password data from DB - */ - void DeleteAllFormPasswordData(); - - /** - * @brief Delete all candidate form data from DB - */ - void DeleteAllFormCandidateData(); - - /** - * @brief Notify low memory to free unused memory. - * - * @return @c true on success or @c false otherwise. - */ - bool FreeUnusedMemory(); - -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 deleted file mode 100755 index 61529a8..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 - -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); -} - -void WebCookieManager::ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback) -{ - mWebEngineCookieManager.ChangesWatch(callback); -} - -} // 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 deleted file mode 100755 index b7b5bf1..0000000 --- a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef DALI_TOOLKIT_WEB_COOKIE_MANAGER_H -#define DALI_TOOLKIT_WEB_COOKIE_MANAGER_H - -/* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -class WebEngineCookieManager; - -namespace Toolkit -{ -/** - * @addtogroup dali_toolkit_controls_web_view - * @{ - */ - -/** - * @brief WebCookieManager is a control for cookie manager 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); - - /** - * @brief Watch for cookies' changes in @a manager. - * - * @param[in] callback cookies are added, removed or modified. - */ - void ChangesWatch(Dali::WebEngineCookieManager::WebEngineCookieManagerChangesWatchCallback callback); - -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-view.cpp b/dali-toolkit/devel-api/controls/web-view/web-view.cpp index 5b0f3d2..321b43f 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-view.cpp @@ -64,24 +64,24 @@ WebView WebView::New(uint32_t argc, char** argv) return Internal::WebView::New(argc, argv); } -WebView WebView::DownCast(BaseHandle handle) +Dali::WebEngineContext* WebView::GetContext() { - return Control::DownCast(handle); + return Internal::WebView::GetContext(); } -Dali::Toolkit::WebSettings* WebView::GetSettings() const +Dali::WebEngineCookieManager* WebView::GetCookieManager() { - return Dali::Toolkit::GetImpl(*this).GetSettings(); + return Internal::WebView::GetCookieManager(); } -Dali::Toolkit::WebContext* WebView::GetContext() const +WebView WebView::DownCast(BaseHandle handle) { - return Dali::Toolkit::GetImpl(*this).GetContext(); + return Control::DownCast(handle); } -Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const +Dali::Toolkit::WebSettings* WebView::GetSettings() const { - return Dali::Toolkit::GetImpl(*this).GetCookieManager(); + return Dali::Toolkit::GetImpl(*this).GetSettings(); } Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index 55908e8..4d90fbd 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -216,6 +216,16 @@ public: static WebView New(uint32_t argc, char** argv); /** + * @brief Get context of web engine. + */ + static Dali::WebEngineContext* GetContext(); + + /** + * @brief Get cookie manager of web engine. + */ + static Dali::WebEngineCookieManager* GetCookieManager(); + + /** * @brief Create an uninitialized WebView. */ WebView(); @@ -259,16 +269,6 @@ public: 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; diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 0a000bc..b501c9c 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -41,8 +41,6 @@ SET( devel_api_src_files ${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-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 @@ -260,8 +258,6 @@ 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-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/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index d4de79a..b967d14 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -485,6 +485,7 @@ const PropertyRegistration Control::Impl::PROPERTY_22(typeRegistration, "dispatc const PropertyRegistration Control::Impl::PROPERTY_23(typeRegistration, "accessibilityHidden", Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty); const PropertyRegistration Control::Impl::PROPERTY_24(typeRegistration, "clockwiseFocusableActorId", Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty); const PropertyRegistration Control::Impl::PROPERTY_25(typeRegistration, "counterClockwiseFocusableActorId", Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty); +const PropertyRegistration Control::Impl::PROPERTY_26(typeRegistration, "automationId", Toolkit::DevelControl::Property::AUTOMATION_ID, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty); // clang-format on @@ -1394,6 +1395,16 @@ void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const } break; } + + case Toolkit::DevelControl::Property::AUTOMATION_ID: + { + std::string automationId; + if(value.Get(automationId)) + { + controlImpl.mImpl->mAutomationId = automationId; + } + break; + } } } } @@ -1566,6 +1577,12 @@ Property::Value Control::Impl::GetProperty(BaseObject* object, Property::Index i value = controlImpl.mImpl->mCounterClockwiseFocusableActorId; break; } + + case Toolkit::DevelControl::Property::AUTOMATION_ID: + { + value = controlImpl.mImpl->mAutomationId; + break; + } } } diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 593ab7d..793fc22 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -537,6 +537,7 @@ public: std::string mAccessibilityName; std::string mAccessibilityDescription; std::string mAccessibilityTranslationDomain; + std::string mAutomationId; bool mAccessibilityHighlightable = false; bool mAccessibilityHidden = false; @@ -593,6 +594,7 @@ public: static const PropertyRegistration PROPERTY_23; static const PropertyRegistration PROPERTY_24; static const PropertyRegistration PROPERTY_25; + static const PropertyRegistration PROPERTY_26; private: // Accessibility - notification for highlighted object to check if it is showing. diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp index 4beea3f..5aeeabf 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -44,8 +44,6 @@ // INTERNAL INCLUDES #include #include -#include -#include #include #include #include @@ -178,6 +176,16 @@ Toolkit::WebView WebView::New(uint32_t argc, char** argv) return handle; } +Dali::WebEngineContext* WebView::GetContext() +{ + return Dali::WebEngine::GetContext(); +} + +Dali::WebEngineCookieManager* WebView::GetCookieManager() +{ + return Dali::WebEngine::GetCookieManager(); +} + void WebView::OnInitialize() { Actor self = Self(); @@ -199,8 +207,6 @@ void WebView::OnInitialize() if(mWebEngine) { mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered); - mWebContext = std::unique_ptr(new WebContext(mWebEngine.GetContext())); - mWebCookieManager = std::unique_ptr(new WebCookieManager(mWebEngine.GetCookieManager())); mWebSettings = std::unique_ptr(new WebSettings(mWebEngine.GetSettings())); mWebBackForwardList = std::unique_ptr(new WebBackForwardList(mWebEngine.GetBackForwardList())); } @@ -218,16 +224,6 @@ 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(); diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h index 6fe96ad..377ea61 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -40,8 +40,6 @@ namespace Toolkit class KeyEvent; class TouchEvent; class WebBackForwardList; -class WebContext; -class WebCookieManager; class WebSettings; class WebView; @@ -75,19 +73,19 @@ public: static Toolkit::WebView New(uint32_t argc, char** argv); /** - * @copydoc Dali::Toolkit::WebView::GetSettings() + * @copydoc Dali::Toolkit::WebView::GetContext() */ - Dali::Toolkit::WebSettings* GetSettings() const; + static Dali::WebEngineContext* GetContext(); /** - * @copydoc Dali::Toolkit::WebView::GetContext() + * @copydoc Dali::Toolkit::WebView::GetCookieManager() */ - Dali::Toolkit::WebContext* GetContext() const; + static Dali::WebEngineCookieManager* GetCookieManager(); /** - * @copydoc Dali::Toolkit::WebView::GetCookieManager() + * @copydoc Dali::Toolkit::WebView::GetSettings() */ - Dali::Toolkit::WebCookieManager* GetCookieManager() const; + Dali::Toolkit::WebSettings* GetSettings() const; /** * @copydoc Dali::Toolkit::WebView::GetBackForwardList() @@ -698,8 +696,6 @@ private: Dali::Size mWebViewSize; Dali::WebEngine mWebEngine; - std::unique_ptr mWebContext; - std::unique_ptr mWebCookieManager; std::unique_ptr mWebSettings; std::unique_ptr mWebBackForwardList; diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index 07dc86d..bcbddec 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -212,8 +212,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && - actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE) && - actor.GetProperty(Actor::Property::VISIBLE)) + actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) { // If the parent's KEYBOARD_FOCUSABLE_CHILDREN is false, it cannot have focus. Actor parent = actor.GetParent(); diff --git a/dali-toolkit/internal/text/emoji-helper.cpp b/dali-toolkit/internal/text/emoji-helper.cpp index c458fd0..35a7760 100644 --- a/dali-toolkit/internal/text/emoji-helper.cpp +++ b/dali-toolkit/internal/text/emoji-helper.cpp @@ -42,13 +42,14 @@ bool IsEmojiSequence(const TextAbstraction::Script& currentRunScript, const TextAbstraction::Character& character, const TextAbstraction::Script& characterScript) { - return (IsOneOfEmojiScripts(currentRunScript) && - (IsOneOfEmojiScripts(characterScript) || - TextAbstraction::IsZeroWidthJoiner(character) || - TextAbstraction::IsZeroWidthNonJoiner(character) || - TextAbstraction::IsEmojiItem(character) || - TextAbstraction::IsMiscellaneousSymbolsAndArrowsEmoji(character) || - TextAbstraction::IsDingbatsEmoji(character))); + return (!(TextAbstraction::IsNegativeSquaredLatinCapitalLetter(character)) && + (IsOneOfEmojiScripts(currentRunScript) && + (IsOneOfEmojiScripts(characterScript) || + TextAbstraction::IsZeroWidthJoiner(character) || + TextAbstraction::IsZeroWidthNonJoiner(character) || + TextAbstraction::IsEmojiItem(character) || + TextAbstraction::IsMiscellaneousSymbolsAndArrowsEmoji(character) || + TextAbstraction::IsDingbatsEmoji(character)))); } bool IsNewSequence(const Character* const textBuffer, diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 96210ca..f24d427 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -542,7 +542,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& } bool isCommonScript = false; - bool isEmojiScript = TextAbstraction::IsEmojiScript(script) || TextAbstraction::IsEmojiColorScript(script) || TextAbstraction::IsEmojiTextScript(script); + bool isEmojiScript = TextAbstraction::IsOneOfEmojiScripts(script); if(isEmojiScript && (previousScript == script)) { @@ -628,6 +628,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& { // Use the cached default font for the script if there is one. fontId = cachedDefaultFontId; + isValidFont = true; } else { @@ -660,6 +661,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& } } defaultFontsPerScript->Cache(currentFontDescription, fontId); + isValidFont = true; } } } // !isValidFont (3) @@ -729,6 +731,15 @@ void MultilanguageSupport::ValidateFonts(const Vector& description.path.c_str()); } #endif + if(!isValidFont && !isCommonScript) + { + Dali::TextAbstraction::FontDescription descriptionForLog; + fontClient.GetDescription(fontId, descriptionForLog); + DALI_LOG_RELEASE_INFO("Validated font set fail : Character : %x, Script : %s, Font : %s \n", + character, + Dali::TextAbstraction::ScriptName[script], + descriptionForLog.path.c_str()); + } // Whether bols style is required. isBoldRequired = (currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD); diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 9b10ffd..60efa05 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -581,22 +581,7 @@ void Control::OnPropertySet(Property::Index index, const Property::Value& proper } case Actor::Property::VISIBLE: { - const bool visible = propertyValue.Get(); - GetAccessibleObject()->EmitVisible(visible); - if(!visible) - { - Dali::Actor self = Self(); - Dali::Actor actor = Dali::Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor(); - while(actor) - { - if(self == actor) - { - Dali::Toolkit::KeyboardFocusManager::Get().ClearFocus(); - break; - } - actor = actor.GetParent(); - } - } + GetAccessibleObject()->EmitVisible(Self().GetProperty(Actor::Property::VISIBLE)); break; } case DevelActor::Property::USER_INTERACTION_ENABLED: diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 56a7313..9ae5216 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -29,7 +29,7 @@ namespace Toolkit { const unsigned int TOOLKIT_MAJOR_VERSION = 2; const unsigned int TOOLKIT_MINOR_VERSION = 1; -const unsigned int TOOLKIT_MICRO_VERSION = 31; +const unsigned int TOOLKIT_MICRO_VERSION = 32; const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 8619802..5caa1e1 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali2-toolkit Summary: Dali 3D engine Toolkit -Version: 2.1.31 +Version: 2.1.32 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT @@ -100,25 +100,25 @@ Requires: %{name} = %{version}-%{release} Application development package for Dali 3D engine toolkit - headers and package config ############################## -# dali-scene-loader +# dali-scene3d ############################## -%define dali2_scene_loader dali2-scene-loader -%package -n %{dali2_scene_loader} +%define dali2_scene3d dali2-scene3d +%package -n %{dali2_scene3d} Summary: DLI scene loading library Group: System/Libraries License: Apache-2.0 Requires: dali2-toolkit -%description -n %{dali2_scene_loader} +%description -n %{dali2_scene3d} Provides functionality for loading and displaying DLI format scenes. See README.md for more details. -%package -n %{dali2_scene_loader}-devel -Summary: Development components for dali-scene-loader +%package -n %{dali2_scene3d}-devel +Summary: Development components for dali-scene3d Group: Development/Building -Requires: %{dali2_scene_loader} = %{version}-%{release} +Requires: %{dali2_scene3d} = %{version}-%{release} -%description -n %{dali2_scene_loader}-devel -Development components for dali-scene-loader. +%description -n %{dali2_scene3d}-devel +Development components for dali-scene3d. %define dali_data_rw_dir %TZ_SYS_SHARE/dali/ %define dali_data_ro_dir %TZ_SYS_RO_SHARE/dali/ @@ -480,17 +480,17 @@ esac %{dali_toolkit_style_files}/default-feedback-theme.json %{_datadir}/locale/*/LC_MESSAGES/* -%files -n %{dali2_scene_loader} +%files -n %{dali2_scene3d} %if 0%{?enable_dali_smack_rules} -%manifest dali-scene-loader.manifest-smack +%manifest dali-scene3d.manifest-smack %else -%manifest dali-scene-loader.manifest +%manifest dali-scene3d.manifest %endif %defattr(-,root,root,-) -%{_libdir}/lib%{dali2_scene_loader}.so +%{_libdir}/lib%{dali2_scene3d}.so %license LICENSE -%files -n %{dali2_scene_loader}-devel +%files -n %{dali2_scene3d}-devel %defattr(-,root,root,-) -%{_includedir}/dali-scene-loader/public-api/* -%{_libdir}/pkgconfig/dali2-scene-loader.pc +%{_includedir}/dali-scene3d/public-api/* +%{_libdir}/pkgconfig/dali2-scene3d.pc