From: Richard Huang Date: Fri, 24 Feb 2023 12:25:14 +0000 (+0000) Subject: [dali_2.2.15] Merge branch 'devel/master' X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=c70520ff81c009acafc2a2cfd1ac38adb64ffcae;hp=ec5fa07228a19206695cf552a84369bdf1cec9d7 [dali_2.2.15] Merge branch 'devel/master' Change-Id: I01efb5f098660428ccd3128136b121b2b97b71fa --- diff --git a/automated-tests/resources/AnimatedMorphCubeAnimateNonZeroFrame.gltf b/automated-tests/resources/AnimatedMorphCubeAnimateNonZeroFrame.gltf new file mode 100644 index 0000000..08c8daf --- /dev/null +++ b/automated-tests/resources/AnimatedMorphCubeAnimateNonZeroFrame.gltf @@ -0,0 +1,282 @@ +{ + "accessors": [ + { + "bufferView": 0, + "componentType": 5126, + "count": 24, + "type": "VEC3" + }, + { + "bufferView": 1, + "componentType": 5126, + "count": 24, + "type": "VEC4" + }, + { + "bufferView": 2, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "max": [ + 0.0100000035, + 0.0100000035, + 0.01 + ], + "min": [ + -0.0100000044, + -0.0100000054, + -0.01 + ] + }, + { + "bufferView": 3, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "name": "thin" + }, + { + "bufferView": 4, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "max": [ + 0.0, + 0.01893253, + 0.0 + ], + "min": [ + 0.0, + 0.0, + 0.0 + ], + "name": "thin" + }, + { + "bufferView": 5, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "name": "thin" + }, + { + "bufferView": 6, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "name": "angle" + }, + { + "bufferView": 7, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "max": [ + 0.0, + 0.0198908355, + 0.0 + ], + "min": [ + 0.0, + 0.0, + 0.0 + ], + "name": "angle" + }, + { + "bufferView": 8, + "componentType": 5126, + "count": 24, + "type": "VEC3", + "name": "angle" + }, + { + "bufferView": 9, + "componentType": 5123, + "count": 36, + "type": "SCALAR" + }, + { + "bufferView": 10, + "componentType": 5126, + "count": 127, + "type": "SCALAR", + "max": [ + 4.19999743 + ], + "min": [ + 0.03 + ] + }, + { + "bufferView": 11, + "componentType": 5126, + "count": 254, + "type": "SCALAR" + } + ], + "animations": [ + { + "channels": [ + { + "sampler": 0, + "target": { + "node": 0, + "path": "weights" + } + } + ], + "samplers": [ + { + "input": 10, + "interpolation": "LINEAR", + "output": 11 + } + ], + "name": "Square" + } + ], + "asset": { + "generator": "glTF Tools for Unity", + "version": "2.0" + }, + "bufferViews": [ + { + "buffer": 0, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 288, + "byteLength": 384 + }, + { + "buffer": 0, + "byteOffset": 672, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 960, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 1248, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 1536, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 1824, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 2112, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 2400, + "byteLength": 288 + }, + { + "buffer": 0, + "byteOffset": 2688, + "byteLength": 72 + }, + { + "buffer": 0, + "byteOffset": 2760, + "byteLength": 508 + }, + { + "buffer": 0, + "byteOffset": 3268, + "byteLength": 1016 + } + ], + "buffers": [ + { + "uri": "AnimatedMorphCube.bin", + "byteLength": 4284 + } + ], + "meshes": [ + { + "primitives": [ + { + "attributes": { + "NORMAL": 0, + "TANGENT": 1, + "POSITION": 2 + }, + "indices": 9, + "material": 0, + "targets": [ + { + "NORMAL": 3, + "POSITION": 4, + "TANGENT": 5 + }, + { + "NORMAL": 6, + "POSITION": 7, + "TANGENT": 8 + } + ] + } + ], + "weights": [ + 0.0, + 0.0 + ], + "name": "Cube" + } + ], + "materials": [ + { + "pbrMetallicRoughness": { + "baseColorFactor": [ + 0.6038274, + 0.6038274, + 0.6038274, + 1.0 + ], + "metallicFactor": 0.0, + "roughnessFactor": 0.5 + }, + "name": "Material" + } + ], + "nodes": [ + { + "mesh": 0, + "rotation": [ + 0.0, + 0.7071067, + -0.7071068, + 0.0 + ], + "scale": [ + 100.0, + 100.0, + 100.0 + ], + "name": "AnimatedMorphCube" + } + ], + "scene": 0, + "scenes": [ + { + "nodes": [ + 0 + ] + } + ] +} \ No newline at end of file diff --git a/automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp index 357d2a8..a485f0f 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Gltf2Loader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,8 +55,7 @@ namespace { struct Context { - ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) - { + ResourceBundle::PathProvider pathProvider = [](ResourceType::Value type) { return TEST_RESOURCE_DIR "/"; }; @@ -494,8 +493,7 @@ int UtcDaliGltfLoaderSuccessShort(void) TestApplication app; const std::string resourcePath = TEST_RESOURCE_DIR "/"; - auto pathProvider = [resourcePath](ResourceType::Value) - { + auto pathProvider = [resourcePath](ResourceType::Value) { return resourcePath; }; @@ -503,6 +501,7 @@ int UtcDaliGltfLoaderSuccessShort(void) for(auto modelName : { "2CylinderEngine", "AnimatedMorphCube", + "AnimatedMorphCubeAnimateNonZeroFrame", "AnimatedMorphSphere", "AnimatedTriangle", "BoxAnimated", diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index 00426ee..a8ec273 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -863,6 +863,19 @@ int UtcDaliTextControllerCheckBufferIndices(void) // Perform a relayout controller->Relayout(size); + // Set the text + controller->SetText(text); + + // Set the text size + controller->SetDefaultFontSize(10.f, Controller::POINT_SIZE); + + // Tweak some parameters to make the indices to access the text buffer invalid + mImpl.mTextUpdateInfo.Clear(); + + // Perform a relayout + controller->GetHeightForWidth(size.width / 2.f); + controller->Relayout(size); + tet_result(TET_PASS); END_TEST; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index 802f7b4..f332890 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -1774,7 +1774,69 @@ int UtcDaliBase64EncodingP(void) std::string output; DALI_TEST_CHECK(value.Get(output)); - DALI_TEST_EQUALS(output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8", TEST_LOCATION); + DALI_TEST_EQUALS(output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8=", TEST_LOCATION); + + std::cout << "Output data: " << output << std::endl; + + END_TEST; +} + +int UtcDaliBase64EncodingP2(void) +{ + std::vector data = {0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::min(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()}; + + Property::Value value; + EncodeBase64PropertyData(value, data); + + std::cout << "Input data: "; + std::ostream_iterator out_it(std::cout, ", "); + std::copy(data.begin(), data.end(), out_it); + std::cout << std::endl; + + std::string output; + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output, "AAAAAAEAAAACAAAAAwAAAAQAAAAFAAAAAAAAAP////8=", TEST_LOCATION); + + std::cout << "Output data: " << output << std::endl; + + END_TEST; +} + +int UtcDaliBase64EncodingP3(void) +{ + std::string originalData = "Something Longer than 64 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/== length is 106"; + originalData.push_back(-4); + originalData.push_back(-7); // some kind of non-ascii. + originalData.push_back(0); + originalData.push_back(0); + originalData.push_back(2); + originalData.push_back(2); + originalData.push_back(2); + + std::vector data(originalData.begin(), originalData.end()); + + Dali::Property::Value value; + EncodeBase64PropertyData(value, data); + + std::cout << "Input data: "; + std::ostream_iterator out_it(std::cout, ", "); + std::copy(data.begin(), data.end(), out_it); + std::cout << std::endl; + + std::string output; + Dali::Property::Array array; + DALI_TEST_CHECK(value.GetArray()); + array = *value.GetArray(); + DALI_TEST_EQUALS(array.Count(), 3, TEST_LOCATION); + DALI_TEST_CHECK(array[0].Get(output)); + std::cout << "first string : " << output << std::endl; + DALI_TEST_EQUALS(output, "U29tZXRoaW5nIExvbmdlciB0aGFuIDY0IEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZX", TEST_LOCATION); + DALI_TEST_CHECK(array[1].Get(output)); + std::cout << "second string : " << output << std::endl; + DALI_TEST_EQUALS(output, "WFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5Ky89PSAgbGVu", TEST_LOCATION); + DALI_TEST_CHECK(array[2].Get(output)); + std::cout << "third string : " << output << std::endl; + DALI_TEST_EQUALS(output, "Z3RoIGlzIDEwNvz5AAACAgI=", TEST_LOCATION); std::cout << "Output data: " << output << std::endl; @@ -1793,14 +1855,22 @@ int UtcDaliBase64EncodingN(void) DALI_TEST_CHECK(value.Get(output)); DALI_TEST_EQUALS(output.empty(), true, TEST_LOCATION); + std::vector data2; + EncodeBase64PropertyData(value, data2); + + DALI_TEST_CHECK(value.Get(output)); + DALI_TEST_EQUALS(output.empty(), true, TEST_LOCATION); + END_TEST; } template int b64l(std::vector& data) { - auto lengthInBytes = 4 * data.size(); - return ceil(lengthInBytes * 1.33333f); + auto lengthInBytes = sizeof(T) * data.size(); + // base64 encode each 3-byte as 4-byte. + // return ceil(lengthInBytes / 3) * 4 + return (lengthInBytes + 2) / 3 * 4; } int UtcDaliBase64EncodingP02(void) @@ -1969,6 +2039,10 @@ int UtcDaliBase64DecodingN01(void) std::vector outputData; DecodeBase64PropertyData(value, outputData); DALI_TEST_EQUALS(outputData.size(), 0, TEST_LOCATION); + + std::vector outputData2; + DecodeBase64PropertyData(value, outputData2); + DALI_TEST_EQUALS(outputData2.size(), 0, TEST_LOCATION); END_TEST; } @@ -1985,6 +2059,10 @@ int UtcDaliBase64DecodingN02(void) std::vector outputData; DecodeBase64PropertyData(value, outputData); DALI_TEST_EQUALS(outputData.size(), 0, TEST_LOCATION); + + std::vector outputData2; + DecodeBase64PropertyData(value, outputData2); + DALI_TEST_EQUALS(outputData2.size(), 0, TEST_LOCATION); END_TEST; } @@ -2002,3 +2080,33 @@ int UtcDaliBase64DecodingP01(void) END_TEST; } + +int UtcDaliBase64DecodingP02(void) +{ + tet_infoline("Test decoding string of known data gives expected result"); + + std::string testInput("//////7+/v4DAgEA"); + std::vector expectedResults = {0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0x03, 0x02, 0x01, 0x00}; + + std::vector outputData; + DecodeBase64PropertyData(Property::Value(testInput), outputData); + + DALI_TEST_EQUALS(std::equal(expectedResults.begin(), expectedResults.end(), outputData.begin()), true, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliBase64DecodingFromString(void) +{ + tet_infoline("Test decoding string of known data gives expected result"); + + std::string testInput("//////7+/v4DAgEA"); + std::vector expectedResults = {0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0x03, 0x02, 0x01, 0x00}; + + std::vector outputData; + DecodeBase64FromString(testInput, outputData); + + DALI_TEST_EQUALS(std::equal(expectedResults.begin(), expectedResults.end(), outputData.begin()), true, TEST_LOCATION); + + END_TEST; +} diff --git a/dali-scene3d/internal/common/environment-map-load-task.cpp b/dali-scene3d/internal/common/environment-map-load-task.cpp index d230e99..d847f46 100644 --- a/dali-scene3d/internal/common/environment-map-load-task.cpp +++ b/dali-scene3d/internal/common/environment-map-load-task.cpp @@ -58,9 +58,9 @@ bool EnvironmentMapLoadTask::HasSucceeded() const return mHasSucceeded; } -Dali::Scene3D::Loader::EnvironmentMapData& EnvironmentMapLoadTask::GetEnvironmentMap() +Dali::Texture EnvironmentMapLoadTask::GetLoadedTexture() { - return mEnvironmentMapData; + return (HasSucceeded()) ? mEnvironmentMapData.GetTexture() : Texture();; } } // namespace Internal diff --git a/dali-scene3d/internal/common/environment-map-load-task.h b/dali-scene3d/internal/common/environment-map-load-task.h index d9a936b..446665c 100644 --- a/dali-scene3d/internal/common/environment-map-load-task.h +++ b/dali-scene3d/internal/common/environment-map-load-task.h @@ -71,10 +71,11 @@ public: bool HasSucceeded() const; /** - * Retrieves loaded Environment Map - * @return EnvironmentMapData that is loaded from url. + * Retrieves loaded Ibl Texture + * @return Texture that is loaded from url. + * @note Do not call this method in worker thread. */ - Dali::Scene3D::Loader::EnvironmentMapData& GetEnvironmentMap(); + Dali::Texture GetLoadedTexture(); private: // Undefined diff --git a/dali-scene3d/internal/controls/model/model-impl.cpp b/dali-scene3d/internal/controls/model/model-impl.cpp index 3345bfc..31e75e5 100644 --- a/dali-scene3d/internal/controls/model/model-impl.cpp +++ b/dali-scene3d/internal/controls/model/model-impl.cpp @@ -23,11 +23,11 @@ #include #include #include +#include #include #include #include #include -#include #include // INTERNAL INCLUDES @@ -116,7 +116,8 @@ 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); }; + 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); @@ -251,13 +252,13 @@ bool Model::GetChildrenFocusable() const void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor) { bool needIblReset = false; - bool isOnScene = Self().GetProperty(Dali::Actor::Property::CONNECTED_TO_SCENE); + bool isOnScene = Self().GetProperty(Dali::Actor::Property::CONNECTED_TO_SCENE); if(mDiffuseIblUrl != diffuseUrl) { mDiffuseIblUrl = diffuseUrl; if(mDiffuseIblUrl.empty()) { - needIblReset = true; + needIblReset = true; } else { @@ -271,7 +272,7 @@ void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::s mSpecularIblUrl = specularUrl; if(mSpecularIblUrl.empty()) { - needIblReset = true; + needIblReset = true; } else { @@ -284,17 +285,8 @@ void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::s // we don't need to request to load texture. if(needIblReset) { - if(mIblDiffuseLoadTask) - { - Dali::AsyncTaskManager::Get().RemoveTask(mIblDiffuseLoadTask); - mIblDiffuseLoadTask.Reset(); - } - - if(mIblSpecularLoadTask) - { - Dali::AsyncTaskManager::Get().RemoveTask(mIblSpecularLoadTask); - mIblSpecularLoadTask.Reset(); - } + ResetResourceTask(mIblDiffuseLoadTask); + ResetResourceTask(mIblSpecularLoadTask); mIblDiffuseDirty = false; mIblSpecularDirty = false; @@ -309,11 +301,7 @@ void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::s { if(isOnScene && mIblDiffuseDirty) { - if(mIblDiffuseLoadTask) - { - Dali::AsyncTaskManager::Get().RemoveTask(mIblDiffuseLoadTask); - mIblDiffuseLoadTask.Reset(); - } + ResetResourceTask(mIblDiffuseLoadTask); mIblDiffuseLoadTask = new EnvironmentMapLoadTask(mDiffuseIblUrl, Scene3D::EnvironmentMapType::CUBEMAP, MakeCallback(this, &Model::OnIblDiffuseLoadComplete)); Dali::AsyncTaskManager::Get().AddTask(mIblDiffuseLoadTask); mIblDiffuseDirty = false; @@ -321,11 +309,7 @@ void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::s if(isOnScene && mIblSpecularDirty) { - if(mIblSpecularLoadTask) - { - Dali::AsyncTaskManager::Get().RemoveTask(mIblSpecularLoadTask); - mIblSpecularLoadTask.Reset(); - } + ResetResourceTask(mIblSpecularLoadTask); mIblSpecularLoadTask = new EnvironmentMapLoadTask(mSpecularIblUrl, Scene3D::EnvironmentMapType::CUBEMAP, MakeCallback(this, &Model::OnIblSpecularLoadComplete)); Dali::AsyncTaskManager::Get().AddTask(mIblSpecularLoadTask); mIblSpecularDirty = false; @@ -339,10 +323,7 @@ void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::s } // If diffuse and specular textures are already loaded, emits resource ready signal here. - if(IsResourceReady()) - { - Control::SetResourceReady(false); - } + NotifyResourceReady(); } void Model::SetImageBasedLightTexture(Dali::Texture diffuseTexture, Dali::Texture specularTexture, float scaleFactor) @@ -493,30 +474,33 @@ bool Model::IsResourceReady() const void Model::ScaleModel() { - if(mModelRoot) + if(!mModelRoot) { - float scale = 1.0f; - Vector3 size = Self().GetProperty(Dali::Actor::Property::SIZE); - if(size.x > 0.0f && size.y > 0.0f) - { - scale = MAXFLOAT; - scale = std::min(size.x / mNaturalSize.x, scale); - scale = std::min(size.y / mNaturalSize.y, scale); - } - // 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. - mModelRoot.SetProperty(Dali::Actor::Property::SCALE, Y_DIRECTION * scale); + return; } + + float scale = 1.0f; + Vector3 size = Self().GetProperty(Dali::Actor::Property::SIZE); + if(size.x > 0.0f && size.y > 0.0f) + { + scale = MAXFLOAT; + scale = std::min(size.x / mNaturalSize.x, scale); + scale = std::min(size.y / mNaturalSize.y, scale); + } + // 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. + mModelRoot.SetProperty(Dali::Actor::Property::SCALE, Y_DIRECTION * scale); } void Model::FitModelPosition() { - if(mModelRoot) + if(!mModelRoot) { - // 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); + return; } + // 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); } void Model::CollectRenderableActor(Actor actor) @@ -550,29 +534,33 @@ void Model::UpdateImageBasedLightTexture() for(auto&& actor : mRenderableActors) { Actor renderableActor = actor.GetHandle(); - if(renderableActor) + if(!renderableActor) + { + continue; + } + + uint32_t rendererCount = renderableActor.GetRendererCount(); + for(uint32_t i = 0; i < rendererCount; ++i) { - uint32_t rendererCount = renderableActor.GetRendererCount(); - for(uint32_t i = 0; i < rendererCount; ++i) + Dali::Renderer renderer = renderableActor.GetRendererAt(i); + if(!renderer) { - Dali::Renderer renderer = renderableActor.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, currentDiffuseTexture); - textures.SetTexture(textureCount - OFFSET_FOR_SPECULAR_CUBE_TEXTURE, currentSpecularTexture); - } - } - } + continue; + } + Dali::TextureSet textures = renderer.GetTextures(); + if(!textures) + { + continue; + } + 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, currentDiffuseTexture); + textures.SetTexture(textureCount - OFFSET_FOR_SPECULAR_CUBE_TEXTURE, currentSpecularTexture); } - renderableActor.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), currentIblScaleFactor); } + renderableActor.RegisterProperty(Dali::Scene3D::Loader::NodeDefinition::GetIblScaleFactorUniformName().data(), currentIblScaleFactor); } } @@ -627,154 +615,157 @@ void Model::OnModelLoadComplete() return; } - mModelRoot = Actor::New(); - mModelRoot.SetProperty(Actor::Property::COLOR_MODE, ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR); - - BoundingVolume AABB; - auto* resources = &(mModelLoadTask->mResources); - auto* scene = &(mModelLoadTask->mScene); - Dali::Scene3D::Loader::Transforms xforms{Dali::Scene3D::Loader::MatrixStack{}, Dali::Scene3D::Loader::ViewProjection{}}; - Dali::Scene3D::Loader::NodeDefinition::CreateParams nodeParams{*resources, xforms, {}, {}, {}}; - uint32_t rootCount = 0u; - for(auto iRoot : scene->GetRoots()) - { - resources->GenerateResources(mModelLoadTask->mResourceRefCounts[rootCount]); - - if(auto actor = scene->CreateNodes(iRoot, mModelLoadTask->mResourceChoices, 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, mModelLoadTask->mResourceChoices, iRoot, nodeParams, Matrix::IDENTITY); - rootCount++; - } + CreateModel(); + mRenderableActors.clear(); + CollectRenderableActor(mModelRoot); + auto* resources = &(mModelLoadTask->mResources); + auto* scene = &(mModelLoadTask->mScene); + CreateAnimations(*scene); if(!resources->mEnvironmentMaps.empty()) { mDefaultDiffuseTexture = resources->mEnvironmentMaps.front().second.mDiffuse; mDefaultSpecularTexture = resources->mEnvironmentMaps.front().second.mSpecular; } - if(!mModelLoadTask->mAnimations.empty()) - { - auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property) - { - Dali::Actor actor; - if(property.mNodeIndex != Scene3D::Loader::INVALID_INDEX) - { - auto* node = scene->GetNode(property.mNodeIndex); - if(node != nullptr) - { - actor = mModelRoot.FindChildById(node->mNodeId); - } - } - else - { - actor = mModelRoot.FindChildByName(property.mNodeName); - } - return actor; - }; - - mAnimations.clear(); - for(auto&& animation : mModelLoadTask->mAnimations) - { - Dali::Animation anim = animation.ReAnimate(getActor); - - mAnimations.push_back({animation.mName, anim}); - } - } - - mRenderableActors.clear(); - CollectRenderableActor(mModelRoot); - UpdateImageBasedLightTexture(); UpdateImageBasedLightScaleFactor(); - mNaturalSize = AABB.CalculateSize(); - mModelPivot = AABB.CalculatePivot(); - mModelRoot.SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); - Vector3 controlSize = Self().GetProperty(Dali::Actor::Property::SIZE); - if(Dali::EqualsZero(controlSize.x) || Dali::EqualsZero(controlSize.y)) - { - Self().SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); - } - - FitModelPosition(); - ScaleModel(); - mModelRoot.SetProperty(Dali::Actor::Property::SENSITIVE, mModelChildrenSensitive); mModelRoot.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, mModelChildrenFocusable); mModelRoot.SetProperty(Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, mModelChildrenFocusable); Self().Add(mModelRoot); - Self().SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3(mModelPivot.x, 1.0f - mModelPivot.y, mModelPivot.z)); mModelResourceReady = true; - - if(IsResourceReady()) - { - Control::SetResourceReady(false); - } - mModelLoadTask.Reset(); + NotifyResourceReady(); + ResetResourceTask(mModelLoadTask); } void Model::OnIblDiffuseLoadComplete() { - mDiffuseTexture = (mIblDiffuseLoadTask->HasSucceeded()) ? mIblDiffuseLoadTask->GetEnvironmentMap().GetTexture() : Texture(); + mDiffuseTexture = mIblDiffuseLoadTask->GetLoadedTexture(); + ResetResourceTask(mIblDiffuseLoadTask); mIblDiffuseResourceReady = true; if(mIblDiffuseResourceReady && mIblSpecularResourceReady) { OnIblLoadComplete(); } - mIblDiffuseLoadTask.Reset(); } void Model::OnIblSpecularLoadComplete() { - mSpecularTexture = (mIblSpecularLoadTask->HasSucceeded()) ? mIblSpecularLoadTask->GetEnvironmentMap().GetTexture() : Texture(); + mSpecularTexture = mIblSpecularLoadTask->GetLoadedTexture(); + ResetResourceTask(mIblSpecularLoadTask); mIblSpecularResourceReady = true; if(mIblDiffuseResourceReady && mIblSpecularResourceReady) { OnIblLoadComplete(); } - mIblSpecularLoadTask.Reset(); } void Model::OnIblLoadComplete() { UpdateImageBasedLightTexture(); + NotifyResourceReady(); +} - if(IsResourceReady()) +void Model::ResetResourceTasks() +{ + if(!Dali::Adaptor::IsAvailable()) { - Control::SetResourceReady(false); + return; } + ResetResourceTask(mModelLoadTask); + ResetResourceTask(mIblDiffuseLoadTask); + ResetResourceTask(mIblSpecularLoadTask); } -void Model::ResetResourceTasks() +void Model::ResetResourceTask(IntrusivePtr asyncTask) { - if(Dali::Adaptor::IsAvailable()) + if(!asyncTask) { - if(mModelLoadTask) + return; + } + Dali::AsyncTaskManager::Get().RemoveTask(asyncTask); + asyncTask.Reset(); +} + +void Model::NotifyResourceReady() +{ + if(!IsResourceReady()) + { + return; + } + Control::SetResourceReady(false); +} + +void Model::CreateModel() +{ + mModelRoot = Actor::New(); + mModelRoot.SetProperty(Actor::Property::COLOR_MODE, ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR); + + BoundingVolume AABB; + auto* resources = &(mModelLoadTask->mResources); + auto* scene = &(mModelLoadTask->mScene); + Dali::Scene3D::Loader::Transforms xforms{Dali::Scene3D::Loader::MatrixStack{}, Dali::Scene3D::Loader::ViewProjection{}}; + Dali::Scene3D::Loader::NodeDefinition::CreateParams nodeParams{*resources, xforms, {}, {}, {}}; + uint32_t rootCount = 0u; + for(auto iRoot : scene->GetRoots()) + { + resources->GenerateResources(mModelLoadTask->mResourceRefCounts[rootCount]); + + if(auto actor = scene->CreateNodes(iRoot, mModelLoadTask->mResourceChoices, nodeParams)) { - Dali::AsyncTaskManager::Get().RemoveTask(mModelLoadTask); - mModelLoadTask.Reset(); + 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); } - if(mIblDiffuseLoadTask) + + AddModelTreeToAABB(AABB, *scene, mModelLoadTask->mResourceChoices, iRoot, nodeParams, Matrix::IDENTITY); + rootCount++; + } + + mNaturalSize = AABB.CalculateSize(); + mModelPivot = AABB.CalculatePivot(); + mModelRoot.SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); + Vector3 controlSize = Self().GetProperty(Dali::Actor::Property::SIZE); + if(Dali::EqualsZero(controlSize.x) || Dali::EqualsZero(controlSize.y)) + { + Self().SetProperty(Dali::Actor::Property::SIZE, mNaturalSize); + } + FitModelPosition(); + ScaleModel(); +} + +void Model::CreateAnimations(Dali::Scene3D::Loader::SceneDefinition& scene) +{ + if(!mModelLoadTask->mAnimations.empty()) + { + auto getActor = [&](const Scene3D::Loader::AnimatedProperty& property) { - Dali::AsyncTaskManager::Get().RemoveTask(mIblDiffuseLoadTask); - mIblDiffuseLoadTask.Reset(); - } - if(mIblSpecularLoadTask) + if(property.mNodeIndex == Scene3D::Loader::INVALID_INDEX) + { + return mModelRoot.FindChildByName(property.mNodeName); + } + auto* node = scene.GetNode(property.mNodeIndex); + if(node == nullptr) + { + return Dali::Actor(); + } + return mModelRoot.FindChildById(node->mNodeId); + }; + + mAnimations.clear(); + for(auto&& animation : mModelLoadTask->mAnimations) { - Dali::AsyncTaskManager::Get().RemoveTask(mIblSpecularLoadTask); - mIblSpecularLoadTask.Reset(); + Dali::Animation anim = animation.ReAnimate(getActor); + mAnimations.push_back({animation.mName, anim}); } } } diff --git a/dali-scene3d/internal/controls/model/model-impl.h b/dali-scene3d/internal/controls/model/model-impl.h index e4f1f08..36e3a9a 100644 --- a/dali-scene3d/internal/controls/model/model-impl.h +++ b/dali-scene3d/internal/controls/model/model-impl.h @@ -229,6 +229,31 @@ private: */ void ResetResourceTasks(); + /** + * @brief Reset a Resource loading task. + */ + void ResetResourceTask(IntrusivePtr asyncTask); + + /** + * @brief Request to load a Ibl texture asynchronously + */ + void RequestLoadIblTexture(EnvironmentMapLoadTaskPtr asyncLoadTask, const std::string& url); + + /** + * @brief Notify Resource Ready signal. + */ + void NotifyResourceReady(); + + /** + * @brief Create Model from loaded SceneDefinition. + */ + void CreateModel(); + + /** + * @brief Create Dali::Animation from loaded AnimationDefinitions. + */ + void CreateAnimations(Dali::Scene3D::Loader::SceneDefinition& scene); + private: std::string mModelUrl; std::string mResourceDirectoryUrl; diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp index 86446d4..a4158e1 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp @@ -570,10 +570,9 @@ void SceneView::OnInitialize() mRootLayer.SetProperty(Dali::Actor::Property::INHERIT_SCALE, false); self.Add(mRootLayer); - mDefaultCamera = Dali::CameraActor::New(); + mDefaultCamera = Dali::CameraActor::New3DCamera(); mDefaultCamera.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); mDefaultCamera.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - mDefaultCamera.SetNearClippingPlane(1.0f); AddCamera(mDefaultCamera); UpdateCamera(mDefaultCamera); } @@ -790,7 +789,7 @@ void SceneView::OnSkyboxLoadComplete() Control::SetResourceReady(false); } - mSkyboxTexture = (mSkyboxLoadTask->HasSucceeded()) ? mSkyboxLoadTask->GetEnvironmentMap().GetTexture() : Texture(); + mSkyboxTexture = mSkyboxLoadTask->GetLoadedTexture(); Shader skyboxShader; if(mSkyboxEnvironmentMapType == Scene3D::EnvironmentMapType::CUBEMAP) { @@ -815,7 +814,7 @@ void SceneView::OnSkyboxLoadComplete() void SceneView::OnIblDiffuseLoadComplete() { - mDiffuseTexture = (mIblDiffuseLoadTask->HasSucceeded()) ? mIblDiffuseLoadTask->GetEnvironmentMap().GetTexture() : Texture(); + mDiffuseTexture = mIblDiffuseLoadTask->GetLoadedTexture(); mIblDiffuseResourceReady = true; if(mIblDiffuseResourceReady && mIblSpecularResourceReady) { @@ -826,7 +825,7 @@ void SceneView::OnIblDiffuseLoadComplete() void SceneView::OnIblSpecularLoadComplete() { - mSpecularTexture = (mIblSpecularLoadTask->HasSucceeded()) ? mIblSpecularLoadTask->GetEnvironmentMap().GetTexture() : Texture(); + mSpecularTexture = mIblSpecularLoadTask->GetLoadedTexture(); mIblSpecularResourceReady = true; if(mIblDiffuseResourceReady && mIblSpecularResourceReady) { diff --git a/dali-scene3d/public-api/loader/blend-shape-details.cpp b/dali-scene3d/public-api/loader/blend-shape-details.cpp index 01601f9..8e0353c 100644 --- a/dali-scene3d/public-api/loader/blend-shape-details.cpp +++ b/dali-scene3d/public-api/loader/blend-shape-details.cpp @@ -32,13 +32,13 @@ namespace Scene3D { namespace Loader { -const std::string BlendShapes::NUMBER_OF_BLEND_SHAPES("uNumberOfBlendShapes"); -const std::string BlendShapes::UNNORMALIZE_FACTOR("uBlendShapeUnnormalizeFactor"); -const std::string BlendShapes::COMPONENT_SIZE("uBlendShapeComponentSize"); +const char* BlendShapes::NUMBER_OF_BLEND_SHAPES("uNumberOfBlendShapes"); +const char* BlendShapes::UNNORMALIZE_FACTOR("uBlendShapeUnnormalizeFactor"); +const char* BlendShapes::COMPONENT_SIZE("uBlendShapeComponentSize"); -const std::string BlendShapes::COMPONENTS("blendShapeComponents"); +const char* BlendShapes::COMPONENTS("blendShapeComponents"); -const std::string BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight"); +const char* BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight"); void BlendShapes::ConfigureProperties(const std::pair& mesh, Shader shader, Actor actor) { @@ -46,8 +46,8 @@ void BlendShapes::ConfigureProperties(const std::pair(context, output.mBufferView->mBuffer.GetIndex(), inputDataBuffer, input.mBufferView->mByteOffset + input.mByteOffset, inputDataBufferSize); LoadDataFromAccessor(context, output.mBufferView->mBuffer.GetIndex(), outputDataBuffer, output.mBufferView->mByteOffset + output.mByteOffset, outputDataBufferSize); + ApplyAccessorMinMax(input, reinterpret_cast(inputDataBuffer.begin())); ApplyAccessorMinMax(output, reinterpret_cast(outputDataBuffer.begin())); return inputDataBuffer[input.mCount - 1u]; @@ -1004,6 +1005,12 @@ float LoadKeyFrames(ConversionContext& context, const gt::Animation::Channel& ch const float duration = std::max(LoadDataFromAccessors(context, input, output, inputDataBuffer, outputDataBuffer), AnimationDefinition::MIN_DURATION_SECONDS); + // Set first frame value as first keyframe (gltf animation spec) + if(input.mCount > 0 && !Dali::EqualsZero(inputDataBuffer[0])) + { + keyFrames.Add(0.0f, outputDataBuffer[0]); + } + for(uint32_t i = 0; i < input.mCount; ++i) { keyFrames.Add(inputDataBuffer[i] / duration, outputDataBuffer[i]); @@ -1020,10 +1027,10 @@ float LoadBlendShapeKeyFrames(ConversionContext& context, const gt::Animation::C Vector inputDataBuffer; Vector outputDataBuffer; - const float duration = LoadDataFromAccessors(context, input, output, inputDataBuffer, outputDataBuffer); + const float duration = std::max(LoadDataFromAccessors(context, input, output, inputDataBuffer, outputDataBuffer), AnimationDefinition::MIN_DURATION_SECONDS); char weightNameBuffer[32]; - auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str()); + auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM); char* const pWeightName = weightNameBuffer + prefixSize; const auto remainingSize = sizeof(weightNameBuffer) - prefixSize; for(uint32_t weightIndex = 0u, endWeightIndex = channel.mSampler->mOutput->mCount / channel.mSampler->mInput->mCount; weightIndex < endWeightIndex; ++weightIndex) @@ -1035,6 +1042,13 @@ float LoadBlendShapeKeyFrames(ConversionContext& context, const gt::Animation::C animatedProperty.mPropertyName = std::string(weightNameBuffer); animatedProperty.mKeyFrames = KeyFrames::New(); + + // Set first frame value as first keyframe (gltf animation spec) + if(input.mCount > 0 && !Dali::EqualsZero(inputDataBuffer[0])) + { + animatedProperty.mKeyFrames.Add(0.0f, outputDataBuffer[weightIndex]); + } + for(uint32_t i = 0; i < input.mCount; ++i) { animatedProperty.mKeyFrames.Add(inputDataBuffer[i] / duration, outputDataBuffer[i * endWeightIndex + weightIndex]); diff --git a/dali-scene3d/public-api/loader/material-definition.cpp b/dali-scene3d/public-api/loader/material-definition.cpp index bf764ff..58ab65d 100644 --- a/dali-scene3d/public-api/loader/material-definition.cpp +++ b/dali-scene3d/public-api/loader/material-definition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -91,9 +91,9 @@ Dali::PixelData LoadImageResource(const std::string& resourcePath, if(position != std::string::npos) { position += EMBEDDED_DATA_BASE64_ENCODING_TYPE.length(); - std::string data = textureDefinition.mImageUri.substr(position); + std::string_view data = std::string_view(textureDefinition.mImageUri).substr(position); std::vector buffer; - Dali::Toolkit::DecodeBase64PropertyData(data, buffer); + Dali::Toolkit::DecodeBase64FromString(data, buffer); uint32_t bufferSize = buffer.size(); Dali::Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromBuffer(reinterpret_cast(buffer.data()), bufferSize, textureDefinition.mMinImageDimensions, fittingMode, textureDefinition.mSamplingMode, orientationCorrection); @@ -187,8 +187,7 @@ MaterialDefinition::LoadRaw(const std::string& imagesPath) // Load textures auto iTexture = mTextureStages.begin(); - auto checkStage = [&](uint32_t flags) - { + auto checkStage = [&](uint32_t flags) { return iTexture != mTextureStages.end() && MaskMatch(iTexture->mSemantic, flags); }; @@ -323,7 +322,7 @@ TextureSet MaterialDefinition::Load(const EnvironmentDefinition::Vector& environ uint32_t n = 0; for(auto& tData : raw.mTextures) { - auto& pixels = tData.mPixels; + auto& pixels = tData.mPixels; Texture texture; if(pixels) { @@ -379,8 +378,7 @@ TextureSet MaterialDefinition::Load(const EnvironmentDefinition::Vector& environ bool MaterialDefinition::CheckTextures(uint32_t flags) const { - return std::find_if(mTextureStages.begin(), mTextureStages.end(), [flags](const TextureStage& ts) - { return MaskMatch(ts.mSemantic, flags); }) != mTextureStages.end(); + return std::find_if(mTextureStages.begin(), mTextureStages.end(), [flags](const TextureStage& ts) { return MaskMatch(ts.mSemantic, flags); }) != mTextureStages.end(); } } // namespace Loader diff --git a/dali-scene3d/public-api/loader/mesh-definition.cpp b/dali-scene3d/public-api/loader/mesh-definition.cpp index 3beaf83..b23140f 100644 --- a/dali-scene3d/public-api/loader/mesh-definition.cpp +++ b/dali-scene3d/public-api/loader/mesh-definition.cpp @@ -20,10 +20,12 @@ // EXTERNAL INCLUDES #include +#include #include +#include #include #include -#include "dali/devel-api/adaptor-framework/pixel-buffer.h" +#include namespace Dali { @@ -65,7 +67,7 @@ private: uint16_t (*mFunc)(uintptr_t&); }; -const std::string QUAD("quad"); +const char* QUAD("quad"); ///@brief Reads a blob from the given stream @a source into @a target, which must have /// at least @a descriptor.length bytes. @@ -247,83 +249,90 @@ void GenerateNormals(MeshDefinition::RawData& raw) attribs.push_back({"aNormal", Property::VECTOR3, attribs[0].mNumElements, std::move(buffer)}); } -void GenerateTangentsWithUvs(MeshDefinition::RawData& raw) +template, typename = std::enable_if_t<(std::is_same::value || std::is_same::value)>> +bool GenerateTangents(MeshDefinition::RawData& raw) { auto& attribs = raw.mAttribs; - DALI_ASSERT_DEBUG(attribs.size() > 2); // positions, normals, uvs - IndexProvider getIndex(raw.mIndices.data()); - - const uint32_t numIndices = raw.mIndices.empty() ? attribs[0].mNumElements : static_cast(raw.mIndices.size()); - - auto* positions = reinterpret_cast(attribs[0].mData.data()); - auto* uvs = reinterpret_cast(attribs[2].mData.data()); - - std::vector buffer(attribs[0].mNumElements * sizeof(Vector3)); - auto tangents = reinterpret_cast(buffer.data()); - - for(uint32_t i = 0; i < numIndices; i += 3) + // Required positions, normals, uvs (if we have). If not, skip generation + if(attribs.size() < (2 + static_cast(hasUvs))) { - uint16_t indices[]{getIndex(), getIndex(), getIndex()}; - Vector3 pos[]{positions[indices[0]], positions[indices[1]], positions[indices[2]]}; - Vector2 uv[]{uvs[indices[0]], uvs[indices[1]], uvs[indices[2]]}; - - float x0 = pos[1].x - pos[0].x; - float y0 = pos[1].y - pos[0].y; - float z0 = pos[1].z - pos[0].z; + return false; + } - float x1 = pos[2].x - pos[0].x; - float y1 = pos[2].y - pos[0].y; - float z1 = pos[2].z - pos[0].z; + std::vector buffer(attribs[0].mNumElements * sizeof(T)); + auto tangents = reinterpret_cast(buffer.data()); - float s0 = uv[1].x - uv[0].x; - float t0 = uv[1].y - uv[0].y; + if constexpr(hasUvs) + { + IndexProvider getIndex(raw.mIndices.data()); + const uint32_t numIndices = raw.mIndices.empty() ? attribs[0].mNumElements : static_cast(raw.mIndices.size()); - float s1 = uv[2].x - uv[0].x; - float t1 = uv[2].y - uv[0].y; + auto* positions = reinterpret_cast(attribs[0].mData.data()); + auto* uvs = reinterpret_cast(attribs[2].mData.data()); - float r = 1.f / (s0 * t1 - t0 * s1); - Vector3 tangent((x0 * t1 - t0 * x1) * r, (y0 * t1 - t0 * y1) * r, (z0 * t1 - t0 * z1) * r); - tangents[indices[0]] += tangent; - tangents[indices[1]] += tangent; - tangents[indices[2]] += tangent; + for(uint32_t i = 0; i < numIndices; i += 3) + { + uint16_t indices[]{getIndex(), getIndex(), getIndex()}; + Vector3 pos[]{positions[indices[0]], positions[indices[1]], positions[indices[2]]}; + Vector2 uv[]{uvs[indices[0]], uvs[indices[1]], uvs[indices[2]]}; + + float x0 = pos[1].x - pos[0].x; + float y0 = pos[1].y - pos[0].y; + float z0 = pos[1].z - pos[0].z; + + float x1 = pos[2].x - pos[0].x; + float y1 = pos[2].y - pos[0].y; + float z1 = pos[2].z - pos[0].z; + + float s0 = uv[1].x - uv[0].x; + float t0 = uv[1].y - uv[0].y; + + float s1 = uv[2].x - uv[0].x; + float t1 = uv[2].y - uv[0].y; + + float det = (s0 * t1 - t0 * s1); + float r = 1.f / ((std::abs(det) < Dali::Epsilon<1000>::value) ? (Dali::Epsilon<1000>::value * (det > 0.0f ? 1.f : -1.f)) : det); + Vector3 tangent((x0 * t1 - t0 * x1) * r, (y0 * t1 - t0 * y1) * r, (z0 * t1 - t0 * z1) * r); + tangents[indices[0]] += T(tangent); + tangents[indices[1]] += T(tangent); + tangents[indices[2]] += T(tangent); + } } auto* normals = reinterpret_cast(attribs[1].mData.data()); auto iEnd = normals + attribs[1].mNumElements; while(normals != iEnd) { - *tangents -= *normals * normals->Dot(*tangents); - tangents->Normalize(); - - ++tangents; - ++normals; - } - attribs.push_back({"aTangent", Property::VECTOR3, attribs[0].mNumElements, std::move(buffer)}); -} - -void GenerateTangents(MeshDefinition::RawData& raw) -{ - auto& attribs = raw.mAttribs; - DALI_ASSERT_DEBUG(attribs.size() > 1); // positions, normals - - auto* normals = reinterpret_cast(attribs[1].mData.data()); - - std::vector buffer(attribs[0].mNumElements * sizeof(Vector3)); - auto tangents = reinterpret_cast(buffer.data()); - - auto iEnd = normals + attribs[1].mNumElements; - while(normals != iEnd) - { - Vector3 t[]{normals->Cross(Vector3::XAXIS), normals->Cross(Vector3::YAXIS)}; + Vector3 tangentVec3; + if constexpr(hasUvs) + { + // Calculated by indexs + tangentVec3 = Vector3((*tangents).x, (*tangents).y, (*tangents).z); + } + else + { + // Only choiced by normal vector. by indexs + Vector3 t[]{normals->Cross(Vector3::XAXIS), normals->Cross(Vector3::YAXIS)}; + tangentVec3 = t[t[1].LengthSquared() > t[0].LengthSquared()]; + } - *tangents = t[t[1].LengthSquared() > t[0].LengthSquared()]; - *tangents -= *normals * normals->Dot(*tangents); - tangents->Normalize(); + tangentVec3 -= *normals * normals->Dot(tangentVec3); + tangentVec3.Normalize(); + if constexpr(useVec3) + { + *tangents = tangentVec3; + } + else + { + *tangents = Vector4(tangentVec3.x, tangentVec3.y, tangentVec3.z, 1.0f); + } ++tangents; ++normals; } - attribs.push_back({"aTangent", Property::VECTOR3, attribs[0].mNumElements, std::move(buffer)}); + attribs.push_back({"aTangent", useVec3 ? Property::VECTOR3 : Property::VECTOR4, attribs[0].mNumElements, std::move(buffer)}); + + return true; } void CalculateTextureSize(uint32_t totalTextureSize, uint32_t& textureWidth, uint32_t& textureHeight) @@ -833,7 +842,22 @@ MeshDefinition::LoadRaw(const std::string& modelsPath, BufferDefinition::Vector& else if(mTangents.mBlob.mLength != 0 && hasNormals && isTriangles) { DALI_ASSERT_DEBUG(mTangents.mBlob.mLength == mNormals.mBlob.GetBufferSize()); - hasUvs ? GenerateTangentsWithUvs(raw) : GenerateTangents(raw); + static const std::function GenerateTangentsFunction[2][2] = + { + { + GenerateTangents, + GenerateTangents, + }, + { + GenerateTangents, + GenerateTangents, + }, + }; + const bool generateSuccessed = GenerateTangentsFunction[mTangentType == Property::VECTOR3][hasUvs](raw); + if(!generateSuccessed) + { + DALI_LOG_ERROR("Failed to generate tangents\n"); + } } if(mColors.IsDefined()) diff --git a/dali-scene3d/public-api/loader/node-definition.cpp b/dali-scene3d/public-api/loader/node-definition.cpp index b47c203..98405d7 100644 --- a/dali-scene3d/public-api/loader/node-definition.cpp +++ b/dali-scene3d/public-api/loader/node-definition.cpp @@ -61,7 +61,7 @@ void NodeDefinition::Renderable::OnCreate(const NodeDefinition& node, CreatePara actor.AddRenderer(renderer); } -const std::string NodeDefinition::ORIGINAL_MATRIX_PROPERTY_NAME = "originalMatrix"; +const char* NodeDefinition::ORIGINAL_MATRIX_PROPERTY_NAME = "originalMatrix"; Actor NodeDefinition::CreateActor(CreateParams& params) { diff --git a/dali-scene3d/public-api/loader/node-definition.h b/dali-scene3d/public-api/loader/node-definition.h index d713ed5..0e9a5d7 100644 --- a/dali-scene3d/public-api/loader/node-definition.h +++ b/dali-scene3d/public-api/loader/node-definition.h @@ -250,7 +250,7 @@ public: // METHODS static std::string_view GetIblYDirectionUniformName(); public: // DATA - static const std::string ORIGINAL_MATRIX_PROPERTY_NAME; + static const char* ORIGINAL_MATRIX_PROPERTY_NAME; std::string mName; uint32_t mNodeId = INVALID_INDEX; diff --git a/dali-scene3d/public-api/loader/scene-definition.cpp b/dali-scene3d/public-api/loader/scene-definition.cpp index 3241769..f41422e 100644 --- a/dali-scene3d/public-api/loader/scene-definition.cpp +++ b/dali-scene3d/public-api/loader/scene-definition.cpp @@ -45,7 +45,7 @@ namespace Loader { namespace { -const std::string JOINT_MATRIX{"jointMatrix"}; +const char* JOINT_MATRIX{"jointMatrix"}; const std::map sConstraintFactory = { {Property::Type::BOOLEAN, @@ -305,7 +305,7 @@ void ConfigureBoneMatrix(const Matrix& ibm, Actor joint, Shader& shader, Index& { // Register bone transform on shader. char propertyNameBuffer[32]; - snprintf(propertyNameBuffer, sizeof(propertyNameBuffer), "%s[%d]", Skinning::BONE_UNIFORM_NAME.c_str(), boneIdx); + snprintf(propertyNameBuffer, sizeof(propertyNameBuffer), "%s[%d]", Skinning::BONE_UNIFORM_NAME, boneIdx); DALI_ASSERT_DEBUG(shader.GetPropertyIndex(propertyNameBuffer) == Property::INVALID_INDEX); auto propBoneXform = shader.RegisterProperty(propertyNameBuffer, Matrix{false}); diff --git a/dali-scene3d/public-api/loader/shader-definition.cpp b/dali-scene3d/public-api/loader/shader-definition.cpp index 729fa1d..a753155 100644 --- a/dali-scene3d/public-api/loader/shader-definition.cpp +++ b/dali-scene3d/public-api/loader/shader-definition.cpp @@ -28,9 +28,8 @@ namespace Loader { namespace { -const std::string SHADER_HINT_OUTPUT_IS_TRANSPARENT("OUTPUT_IS_TRANSPARENT"); ///< Might generate transparent alpha from opaque inputs. -const std::string SHADER_HINT_MODIFIES_GEOMETRY("MODIFIES_GEOMETRY"); ///< Might change position of vertices, this option disables any culling optimizations. - +const char* SHADER_HINT_OUTPUT_IS_TRANSPARENT("OUTPUT_IS_TRANSPARENT"); ///< Might generate transparent alpha from opaque inputs. +const char* SHADER_HINT_MODIFIES_GEOMETRY("MODIFIES_GEOMETRY"); ///< Might change position of vertices, this option disables any culling optimizations. } // namespace ShaderDefinition::ShaderDefinition(const ShaderDefinition& other) diff --git a/dali-scene3d/public-api/loader/skinning-details.cpp b/dali-scene3d/public-api/loader/skinning-details.cpp index 128a19b..e100151 100644 --- a/dali-scene3d/public-api/loader/skinning-details.cpp +++ b/dali-scene3d/public-api/loader/skinning-details.cpp @@ -27,8 +27,7 @@ namespace Loader { const unsigned int Skinning::MAX_JOINTS = 64; -const std::string Skinning::BONE_UNIFORM_NAME = "uBone"; - +const char* Skinning::BONE_UNIFORM_NAME = "uBone"; } // namespace Loader } // namespace Scene3D } // namespace Dali diff --git a/dali-scene3d/public-api/loader/skinning-details.h b/dali-scene3d/public-api/loader/skinning-details.h index 78ba38c..d754f0c 100644 --- a/dali-scene3d/public-api/loader/skinning-details.h +++ b/dali-scene3d/public-api/loader/skinning-details.h @@ -40,7 +40,7 @@ struct DALI_SCENE3D_API Skinning /* * @brief Name of bone matrix uniform (array). */ - static const std::string BONE_UNIFORM_NAME; + static const char* BONE_UNIFORM_NAME; Skinning() = delete; }; diff --git a/dali-toolkit/devel-api/builder/base64-encoding.cpp b/dali-toolkit/devel-api/builder/base64-encoding.cpp index 2de438a..17b823a 100644 --- a/dali-toolkit/devel-api/builder/base64-encoding.cpp +++ b/dali-toolkit/devel-api/builder/base64-encoding.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -75,12 +75,13 @@ bool DecodeBase64PropertyData(const Property::Value& value, std::vector outputTmpData; - outputTmpData.reserve(ceil(encodedString.size() * 0.75f)); + std::vector outputTmpData; + // Output required at least ceil(length * 3 / 4) + outputData.reserve((encodedString.size() * 3 + 3) / 4); bn::decode_b64(encodedString.begin(), encodedString.end(), std::back_inserter(outputTmpData)); outputData.clear(); - uint32_t outputSize = outputTmpData.size() / sizeof(uint32_t) + static_cast(!!(outputTmpData.size() % sizeof(uint32_t))); + uint32_t outputSize = (outputTmpData.size() + sizeof(uint32_t) - 1) / sizeof(uint32_t); outputData.resize(outputSize); // Treat as a block of data memcpy(&outputData[0], &outputTmpData[0], outputTmpData.size()); @@ -97,7 +98,8 @@ bool DecodeBase64PropertyData(const Property::Value& value, std::vector if(GetStringFromProperty(value, encodedString)) { - outputData.reserve(ceil(encodedString.size() * 0.75f)); + // Output required at least ceil(length * 3 / 4) + outputData.reserve((encodedString.size() * 3 + 3) / 4); bn::decode_b64(encodedString.begin(), encodedString.end(), std::back_inserter(outputData)); decoded = true; @@ -105,6 +107,15 @@ bool DecodeBase64PropertyData(const Property::Value& value, std::vector return decoded; } +bool DecodeBase64FromString(const std::string_view& encodedString, std::vector& outputData) +{ + // Output required at least ceil(length * 3 / 4) + outputData.reserve((encodedString.size() * 3 + 3) >> 2); + bn::decode_b64(encodedString.begin(), encodedString.end(), std::back_inserter(outputData)); + + return true; // Always success. +} + void EncodeBase64PropertyData(Property::Value& value, const std::vector& inputData) { std::ostringstream oss; @@ -114,11 +125,61 @@ void EncodeBase64PropertyData(Property::Value& value, const std::vector(oss, "")); std::string encodedString = oss.str(); + + // Add padding + int paddingLength = (4 - (encodedString.length() % 4)) % 4; + if(paddingLength > 0) + { + while(paddingLength--) + { + oss << '='; + } + encodedString = oss.str(); + } + + if(encodedString.length() > MAX_PROPERTY_STRING_LENGTH) + { + // cut string up into blocks of MAX_PROPERTY_STRING_LENGTH and store to an array + auto numStrings = (encodedString.length() + MAX_PROPERTY_STRING_LENGTH - 1) / MAX_PROPERTY_STRING_LENGTH; + + Property::Array array; + for(auto i = 0u; i < numStrings; ++i) + { + array.PushBack(encodedString.substr(i * MAX_PROPERTY_STRING_LENGTH, MAX_PROPERTY_STRING_LENGTH)); + } + value = array; + } + else + { + value = encodedString; + } +} + +void EncodeBase64PropertyData(Property::Value& value, const std::vector& inputData) +{ + std::ostringstream oss; + + bn::encode_b64(reinterpret_cast(&inputData[0]), + reinterpret_cast(&inputData[0] + inputData.size()), + std::ostream_iterator(oss, "")); + + std::string encodedString = oss.str(); + + // Add padding + int paddingLength = (4 - (encodedString.length() % 4)) % 4; + if(paddingLength > 0) + { + while(paddingLength--) + { + oss << '='; + } + encodedString = oss.str(); + } + if(encodedString.length() > MAX_PROPERTY_STRING_LENGTH) { // cut string up into blocks of MAX_PROPERTY_STRING_LENGTH and store to an array - auto numStrings = encodedString.length() / MAX_PROPERTY_STRING_LENGTH + - ((encodedString.length() % MAX_PROPERTY_STRING_LENGTH) != 0); + auto numStrings = (encodedString.length() + MAX_PROPERTY_STRING_LENGTH - 1) / MAX_PROPERTY_STRING_LENGTH; Property::Array array; for(auto i = 0u; i < numStrings; ++i) diff --git a/dali-toolkit/devel-api/builder/base64-encoding.h b/dali-toolkit/devel-api/builder/base64-encoding.h index c7067ed..566bded 100644 --- a/dali-toolkit/devel-api/builder/base64-encoding.h +++ b/dali-toolkit/devel-api/builder/base64-encoding.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_BASE64_ENCODING_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -56,6 +57,18 @@ DALI_TOOLKIT_API bool DecodeBase64PropertyData(const Property::Value& value, std DALI_TOOLKIT_API bool DecodeBase64PropertyData(const Property::Value& value, std::vector& outputData); /** + * @brief Parses a std::string_view to retrieve an array of uint8_t data. + * + * Data can be encoded using the base64 encoding scheme to allow it to be used + * in JSON (The property system maps to JSON types). + * + * @param[in] encodedString The input string to decode + * @param[out] outputData The output data block + * @return True if a data block was decoded successfully. + */ +DALI_TOOLKIT_API bool DecodeBase64FromString(const std::string_view& encodedString, std::vector& outputData); + +/** * @brief Convert a block of uint32_t data into a Property::STRING or ARRAY of STRINGs * encoded using base64. This allows the data to be mapped to JSON easily. * @@ -64,6 +77,15 @@ DALI_TOOLKIT_API bool DecodeBase64PropertyData(const Property::Value& value, std */ DALI_TOOLKIT_API void EncodeBase64PropertyData(Property::Value& value, const std::vector& inputData); +/** + * @brief Convert a block of uint8_t data into a Property::STRING or ARRAY of STRINGs + * encoded using base64. This allows the data to be mapped to JSON easily. + * + * @param[out] value The value to write data into (to avoid copying). + * @param[in] inputData The input + */ +DALI_TOOLKIT_API void EncodeBase64PropertyData(Property::Value& value, const std::vector& inputData); + } // namespace Toolkit } // namespace Dali diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 517d78f..8b69071 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -70,23 +70,22 @@ namespace { #define TOKEN_STRING(x) #x -const std::string KEYNAME_ACTORS = "actors"; -const std::string KEYNAME_ENTRY_TRANSITION = "entryTransition"; -const std::string KEYNAME_EXIT_TRANSITION = "exitTransition"; -const std::string KEYNAME_INCLUDES = "includes"; -const std::string KEYNAME_INHERIT = "inherit"; -const std::string KEYNAME_MAPPINGS = "mappings"; -const std::string KEYNAME_NAME = "name"; -const std::string KEYNAME_SIGNALS = "signals"; -const std::string KEYNAME_STATES = "states"; -const std::string KEYNAME_STYLES = "styles"; -const std::string KEYNAME_TEMPLATES = "templates"; -const std::string KEYNAME_TRANSITIONS = "transitions"; -const std::string KEYNAME_TYPE = "type"; -const std::string KEYNAME_VISUALS = "visuals"; - -const std::string PROPERTIES = "properties"; -const std::string ANIMATABLE_PROPERTIES = "animatableProperties"; +const char* KEYNAME_ACTORS = "actors"; +const char* KEYNAME_ENTRY_TRANSITION = "entryTransition"; +const char* KEYNAME_EXIT_TRANSITION = "exitTransition"; +const char* KEYNAME_INCLUDES = "includes"; +const char* KEYNAME_INHERIT = "inherit"; +const char* KEYNAME_MAPPINGS = "mappings"; +const char* KEYNAME_SIGNALS = "signals"; +const char* KEYNAME_STATES = "states"; +const char* KEYNAME_STYLES = "styles"; +const char* KEYNAME_TEMPLATES = "templates"; +const char* KEYNAME_TRANSITIONS = "transitions"; +const char* KEYNAME_TYPE = "type"; +const char* KEYNAME_VISUALS = "visuals"; + +const char* PROPERTIES = "properties"; +const char* ANIMATABLE_PROPERTIES = "animatableProperties"; typedef std::vector TreeNodeList; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 23f9204..76de885 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -52,12 +52,12 @@ namespace { -const std::string READING_INFO_TYPE_NAME = "name"; -const std::string READING_INFO_TYPE_ROLE = "role"; -const std::string READING_INFO_TYPE_DESCRIPTION = "description"; -const std::string READING_INFO_TYPE_STATE = "state"; -const std::string READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type"; -const std::string READING_INFO_TYPE_SEPARATOR = "|"; +const char* READING_INFO_TYPE_NAME = "name"; +const char* READING_INFO_TYPE_ROLE = "role"; +const char* READING_INFO_TYPE_DESCRIPTION = "description"; +const char* READING_INFO_TYPE_STATE = "state"; +const char* READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type"; +const char* READING_INFO_TYPE_SEPARATOR = "|"; } // namespace namespace Dali diff --git a/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp b/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp index 77eb533..e93057d 100644 --- a/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp +++ b/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp @@ -36,7 +36,7 @@ namespace const char* const IMAGE_BRDF_FILE_NAME = "brdfLUT.png"; // glTF file extension -const std::string GLTF_EXT(".gltf"); +const char* GLTF_EXT(".gltf"); /** * cube map face index diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 8d3c203..14d2de7 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -70,25 +70,25 @@ const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT * The alignment depends on the alignment value of the text label (Use Text::VerticalAlignment enumerations). */ const float VERTICAL_ALIGNMENT_TABLE[Text::VerticalAlignment::BOTTOM + 1] = - { +{ 0.0f, // VerticalAlignment::TOP 0.5f, // VerticalAlignment::CENTER 1.0f // VerticalAlignment::BOTTOM }; -const std::string TEXT_FIT_ENABLE_KEY("enable"); -const std::string TEXT_FIT_MIN_SIZE_KEY("minSize"); -const std::string TEXT_FIT_MAX_SIZE_KEY("maxSize"); -const std::string TEXT_FIT_STEP_SIZE_KEY("stepSize"); -const std::string TEXT_FIT_FONT_SIZE_KEY("fontSize"); -const std::string TEXT_FIT_FONT_SIZE_TYPE_KEY("fontSizeType"); +const char* TEXT_FIT_ENABLE_KEY("enable"); +const char* TEXT_FIT_MIN_SIZE_KEY("minSize"); +const char* TEXT_FIT_MAX_SIZE_KEY("maxSize"); +const char* TEXT_FIT_STEP_SIZE_KEY("stepSize"); +const char* TEXT_FIT_FONT_SIZE_KEY("fontSize"); +const char* TEXT_FIT_FONT_SIZE_TYPE_KEY("fontSizeType"); #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif const Scripting::StringEnum AUTO_SCROLL_STOP_MODE_TABLE[] = - { +{ {"IMMEDIATE", Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE}, {"FINISH_LOOP", Toolkit::TextLabel::AutoScrollStopMode::FINISH_LOOP}, }; diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index 862a69c..50d7d3d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -57,7 +57,7 @@ namespace #define GET_LOCALE_TEXT(string) dgettext("dali-toolkit", string) #endif -const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME("TextSelectionPopupButton"); +const char* TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME("TextSelectionPopupButton"); const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR(Dali::Vector4(0.24f, 0.72f, 0.8f, 1.0f)); const float DEFAULT_OPTION_PRESSED_CORNER_RADIUS = 0.0f; const Dali::Vector4 DEFAULT_LABEL_PADDING(Dali::Vector4(24.0f, 24.0f, 14.0f, 14.0f)); @@ -93,8 +93,8 @@ const char* const OPTION_COPY("optionCopy"); // "Copy" popup opt const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option. const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option. -const std::string IDS_LTR("IDS_LTR"); -const std::string RTL_DIRECTION("RTL"); +const char* IDS_LTR("IDS_LTR"); +const char* RTL_DIRECTION("RTL"); BaseHandle Create() { @@ -726,10 +726,10 @@ void TextSelectionPopup::AddPopupOptionsToToolbar(bool showIcons, bool showCapti // Whether to mirror the list of buttons (for right to left languages) bool mirror = false; #if defined(__GLIBC__) - char* idsLtr = GET_LOCALE_TEXT(IDS_LTR.c_str()); + char* idsLtr = GET_LOCALE_TEXT(IDS_LTR); if(NULL != idsLtr) { - mirror = (0 == strcmp(idsLtr, RTL_DIRECTION.c_str())); + mirror = (0 == strcmp(idsLtr, RTL_DIRECTION)); if(mirror) { 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 6321695..716a151 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -51,6 +51,7 @@ #include #include +#include namespace Dali { @@ -89,10 +90,13 @@ DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "loadProgressPercentage", FLOAT, DALI_TYPE_REGISTRATION_END() // clang-format on +std::unordered_map>& GetPluginWebViewTable() +{ + static std::unordered_map> pluginWebViewMap; + return pluginWebViewMap; +} } // namespace -std::unordered_map> WebView::mPluginWebViewMap; - WebView::WebView(const std::string& locale, const std::string& timezoneId) : Control(ControlBehaviour(ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)), mVisual(), @@ -144,10 +148,10 @@ WebView::~WebView() { if(mWebEngine) { - auto iter = mPluginWebViewMap.find(mWebEngine.GetPlugin()); - if (iter != mPluginWebViewMap.end()) + auto iter = GetPluginWebViewTable().find(mWebEngine.GetPlugin()); + if (iter != GetPluginWebViewTable().end()) { - mPluginWebViewMap.erase(iter); + GetPluginWebViewTable().erase(iter); } mWebEngine.Destroy(); } @@ -159,7 +163,7 @@ Toolkit::WebView WebView::New() Toolkit::WebView handle = Toolkit::WebView(*impl); if (impl->GetPlugin()) { - mPluginWebViewMap[impl->GetPlugin()] = handle; + GetPluginWebViewTable()[impl->GetPlugin()] = handle; } impl->Initialize(); return handle; @@ -171,7 +175,7 @@ Toolkit::WebView WebView::New(const std::string& locale, const std::string& time Toolkit::WebView handle = Toolkit::WebView(*impl); if (impl->GetPlugin()) { - mPluginWebViewMap[impl->GetPlugin()] = handle; + GetPluginWebViewTable()[impl->GetPlugin()] = handle; } impl->Initialize(); return handle; @@ -183,7 +187,7 @@ Toolkit::WebView WebView::New(uint32_t argc, char** argv) Toolkit::WebView handle = Toolkit::WebView(*impl); if (impl->GetPlugin()) { - mPluginWebViewMap[impl->GetPlugin()] = handle; + GetPluginWebViewTable()[impl->GetPlugin()] = handle; } impl->Initialize(); return handle; @@ -191,8 +195,8 @@ Toolkit::WebView WebView::New(uint32_t argc, char** argv) Toolkit::WebView WebView::FindWebView(Dali::WebEnginePlugin* plugin) { - auto iter = mPluginWebViewMap.find(plugin); - if (iter != mPluginWebViewMap.end()) + auto iter = GetPluginWebViewTable().find(plugin); + if (iter != GetPluginWebViewTable().end()) { return iter->second.GetHandle(); } 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 fc5d06a..61834a2 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -25,7 +25,6 @@ #include #include #include -#include // INTERNAL INCLUDES #include @@ -725,8 +724,6 @@ private: Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback mScreenshotCapturedCallback; Dali::WebEnginePlugin::WebEngineFrameRenderedCallback mFrameRenderedCallback; - - static std::unordered_map> mPluginWebViewMap; }; } // namespace Internal diff --git a/dali-toolkit/internal/feedback/feedback-style.cpp b/dali-toolkit/internal/feedback/feedback-style.cpp index 1e8607e..a5ed3b1 100644 --- a/dali-toolkit/internal/feedback/feedback-style.cpp +++ b/dali-toolkit/internal/feedback/feedback-style.cpp @@ -94,8 +94,6 @@ struct FeedbackStyleInfo SignalFeedbackInfoContainer mSignalFeedbackInfoList; }; -static const FeedbackStyleInfo DEFAULT_FEEDBACK_STYLE_INFO; - FeedbackStyle::FeedbackStyle() { mFeedback = Dali::FeedbackPlayer::Get(); @@ -180,6 +178,7 @@ const FeedbackStyleInfo& FeedbackStyle::GetStyleInfo(const std::string& type) co } else { + static const FeedbackStyleInfo DEFAULT_FEEDBACK_STYLE_INFO; return DEFAULT_FEEDBACK_STYLE_INFO; } } 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 707aa68..380da05 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -220,7 +220,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) { if(!parent.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN)) { - DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] Parent Actor has KEYBOARD_FOCUSABLE_CHILDREN false\n", __FUNCTION__, __LINE__); + DALI_LOG_DEBUG_INFO("Parent Actor has KEYBOARD_FOCUSABLE_CHILDREN false\n"); return false; } parent = parent.GetParent(); @@ -228,6 +228,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) // If developer set focus on same actor, doing nothing Actor currentFocusedActor = GetCurrentFocusActor(); + DALI_LOG_DEBUG_INFO("current focused actor : [%p] new focused actor : [%p]\n", currentFocusedActor.GetObjectPtr(), actor.GetObjectPtr()); if(actor == currentFocusedActor) { return true; @@ -1097,13 +1098,16 @@ void KeyboardFocusManager::OnWindowFocusChanged(Window window, bool focusIn) // Get Current Focused Actor from window Actor currentFocusedActor = GetFocusActorFromCurrentWindow(); - SetCurrentFocusActor(currentFocusedActor); - - if(currentFocusedActor && (mEnableFocusIndicator == ENABLE)) + if(currentFocusedActor) { - // Make sure the focused actor is highlighted - currentFocusedActor.Add(GetFocusIndicatorActor()); - mIsFocusIndicatorShown = SHOW; + SetCurrentFocusActor(currentFocusedActor); + + if(mEnableFocusIndicator == ENABLE) + { + // Make sure the focused actor is highlighted + currentFocusedActor.Add(GetFocusIndicatorActor()); + mIsFocusIndicatorShown = SHOW; + } } } } diff --git a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp index 5323d35..f7bd90a 100644 --- a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp @@ -39,11 +39,11 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_TEXT_PERFORMANCE_MARKER, false); -const std::string KEY_C_NAME = "c"; -const std::string KEY_V_NAME = "v"; -const std::string KEY_X_NAME = "x"; -const std::string KEY_A_NAME = "a"; -const std::string KEY_INSERT_NAME = "Insert"; +const char* KEY_C_NAME = "c"; +const char* KEY_V_NAME = "v"; +const char* KEY_X_NAME = "x"; +const char* KEY_A_NAME = "a"; +const char* KEY_INSERT_NAME = "Insert"; } // namespace diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index c483114..7752360 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -51,7 +51,7 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT constexpr float MAX_FLOAT = std::numeric_limits::max(); -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; } // namespace diff --git a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp index a1e6214..f2d49d2 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp @@ -131,7 +131,7 @@ void Controller::InputFontHandler::SetInputFontFamily(Controller& controller, co } } -const std::string& Controller::InputFontHandler::GetInputFontFamily(const Controller& controller) +std::string Controller::InputFontHandler::GetInputFontFamily(const Controller& controller) { if(NULL != controller.mImpl->mEventData) { diff --git a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h index 2ac7464..bf38a00 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h @@ -34,7 +34,7 @@ namespace Text struct Controller::InputFontHandler { static void SetInputFontFamily(Controller& controller, const std::string& fontFamily); - static const std::string& GetInputFontFamily(const Controller& controller); + static std::string GetInputFontFamily(const Controller& controller); static void SetInputFontWeight(const Controller& controller, FontWeight weight); static bool IsInputFontWeightDefined(const Controller& controller); static FontWeight GetInputFontWeight(const Controller& controller); diff --git a/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp b/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp index f410187..7842d05 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp @@ -38,7 +38,7 @@ namespace { -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; } namespace Dali::Toolkit::Text @@ -116,7 +116,7 @@ void Controller::InputProperties::SetInputShadowProperties(Controller& controlle } } -const std::string& Controller::InputProperties::GetInputShadowProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputShadowProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.shadowProperties : EMPTY_STRING; } @@ -129,7 +129,7 @@ void Controller::InputProperties::SetInputUnderlineProperties(Controller& contro } } -const std::string& Controller::InputProperties::GetInputUnderlineProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputUnderlineProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.underlineProperties : EMPTY_STRING; } @@ -142,7 +142,7 @@ void Controller::InputProperties::SetInputEmbossProperties(Controller& controlle } } -const std::string& Controller::InputProperties::GetInputEmbossProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputEmbossProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.embossProperties : controller.GetDefaultEmbossProperties(); } @@ -155,7 +155,7 @@ void Controller::InputProperties::SetInputOutlineProperties(Controller& controll } } -const std::string& Controller::InputProperties::GetInputOutlineProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputOutlineProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.outlineProperties : controller.GetDefaultOutlineProperties(); } diff --git a/dali-toolkit/internal/text/controller/text-controller-input-properties.h b/dali-toolkit/internal/text/controller/text-controller-input-properties.h index b0736f7..9b31d22 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-properties.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-properties.h @@ -39,19 +39,19 @@ struct Controller::InputProperties static void SetInputShadowProperties(Controller& controller, const std::string& shadowProperties); - static const std::string& GetInputShadowProperties(const Controller& controller); + static std::string GetInputShadowProperties(const Controller& controller); static void SetInputUnderlineProperties(Controller& controller, const std::string& underlineProperties); - static const std::string& GetInputUnderlineProperties(const Controller& controller); + static std::string GetInputUnderlineProperties(const Controller& controller); static void SetInputEmbossProperties(Controller& controller, const std::string& embossProperties); - static const std::string& GetInputEmbossProperties(const Controller& controller); + static std::string GetInputEmbossProperties(const Controller& controller); static void SetInputOutlineProperties(Controller& controller, const std::string& outlineProperties); - static const std::string& GetInputOutlineProperties(const Controller& controller); + static std::string GetInputOutlineProperties(const Controller& controller); static void SetInputModePassword(Controller& controller, bool passwordInput); diff --git a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp index da15a43..a0f03a6 100644 --- a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp @@ -33,7 +33,7 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; const char* const PLACEHOLDER_TEXT = "text"; const char* const PLACEHOLDER_TEXT_FOCUSED = "textFocused"; @@ -122,7 +122,7 @@ void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& contro } } -const std::string& Controller::PlaceholderHandler::GetPlaceholderFontFamily(const Controller& controller) +std::string Controller::PlaceholderHandler::GetPlaceholderFontFamily(const Controller& controller) { if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont)) { diff --git a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h index c7107c9..3bbf87b 100644 --- a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h @@ -39,7 +39,7 @@ struct Controller::PlaceholderHandler static void SetPlaceholderText(Controller& controller, PlaceholderType type, const std::string& text); static void GetPlaceholderText(const Controller& controller, PlaceholderType type, std::string& text); static void SetPlaceholderFontFamily(Controller& controller, const std::string& placeholderTextFontFamily); - static const std::string& GetPlaceholderFontFamily(const Controller& controller); + static std::string GetPlaceholderFontFamily(const Controller& controller); static void SetPlaceholderTextFontWeight(Controller& controller, FontWeight weight); static bool IsPlaceholderTextFontWeightDefined(const Controller& controller); static FontWeight GetPlaceholderTextFontWeight(const Controller& controller); diff --git a/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp index 8aba938..d323bd8 100644 --- a/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp @@ -99,6 +99,13 @@ Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Control if(!isEditable) { + if(NO_OPERATION != (VALIDATE_FONTS & operationsPending) && + textUpdateInfo.mCharacterIndex == static_cast(-1)) + { + impl.ClearFontData(); + updateInfoCharIndexBackup = textUpdateInfo.mCharacterIndex; + } + impl.UpdateModel(onlyOnceOperations); // Layout the text for the new width. diff --git a/dali-toolkit/internal/text/controller/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp index b66cd3c..810cd1a 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -45,7 +45,7 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; template void EnsureCreated(Type*& object) @@ -538,7 +538,7 @@ void Controller::SetDefaultFontFamily(const std::string& defaultFontFamily) } } -const std::string& Controller::GetDefaultFontFamily() const +std::string Controller::GetDefaultFontFamily() const { return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.family : EMPTY_STRING; } @@ -548,7 +548,7 @@ void Controller::SetPlaceholderFontFamily(const std::string& placeholderTextFont PlaceholderHandler::SetPlaceholderFontFamily(*this, placeholderTextFontFamily); } -const std::string& Controller::GetPlaceholderFontFamily() const +std::string Controller::GetPlaceholderFontFamily() const { return PlaceholderHandler::GetPlaceholderFontFamily(*this); } @@ -945,7 +945,7 @@ void Controller::SetDefaultEmbossProperties(const std::string& embossProperties) mImpl->mEmbossDefaults->properties = embossProperties; } -const std::string& Controller::GetDefaultEmbossProperties() const +std::string Controller::GetDefaultEmbossProperties() const { return mImpl->mEmbossDefaults ? mImpl->mEmbossDefaults->properties : EMPTY_STRING; } @@ -956,7 +956,7 @@ void Controller::SetDefaultOutlineProperties(const std::string& outlinePropertie mImpl->mOutlineDefaults->properties = outlineProperties; } -const std::string& Controller::GetDefaultOutlineProperties() const +std::string Controller::GetDefaultOutlineProperties() const { return mImpl->mOutlineDefaults ? mImpl->mOutlineDefaults->properties : EMPTY_STRING; } @@ -1006,7 +1006,7 @@ void Controller::SetInputFontFamily(const std::string& fontFamily) InputFontHandler::SetInputFontFamily(*this, fontFamily); } -const std::string& Controller::GetInputFontFamily() const +std::string Controller::GetInputFontFamily() const { return InputFontHandler::GetInputFontFamily(*this); } @@ -1081,7 +1081,7 @@ void Controller::SetInputShadowProperties(const std::string& shadowProperties) InputProperties::SetInputShadowProperties(*this, shadowProperties); } -const std::string& Controller::GetInputShadowProperties() const +std::string Controller::GetInputShadowProperties() const { return InputProperties::GetInputShadowProperties(*this); } @@ -1091,7 +1091,7 @@ void Controller::SetInputUnderlineProperties(const std::string& underlinePropert InputProperties::SetInputUnderlineProperties(*this, underlineProperties); } -const std::string& Controller::GetInputUnderlineProperties() const +std::string Controller::GetInputUnderlineProperties() const { return InputProperties::GetInputUnderlineProperties(*this); } @@ -1101,7 +1101,7 @@ void Controller::SetInputEmbossProperties(const std::string& embossProperties) InputProperties::SetInputEmbossProperties(*this, embossProperties); } -const std::string& Controller::GetInputEmbossProperties() const +std::string Controller::GetInputEmbossProperties() const { return InputProperties::GetInputEmbossProperties(*this); } @@ -1111,7 +1111,7 @@ void Controller::SetInputOutlineProperties(const std::string& outlineProperties) InputProperties::SetInputOutlineProperties(*this, outlineProperties); } -const std::string& Controller::GetInputOutlineProperties() const +std::string Controller::GetInputOutlineProperties() const { return InputProperties::GetInputOutlineProperties(*this); } @@ -1236,7 +1236,7 @@ void Controller::SetInputStrikethroughProperties(const std::string& strikethroug } } -const std::string& Controller::GetInputStrikethroughProperties() const +std::string Controller::GetInputStrikethroughProperties() const { return (NULL != mImpl->mEventData) ? mImpl->mEventData->mInputStyle.strikethroughProperties : EMPTY_STRING; } diff --git a/dali-toolkit/internal/text/controller/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h index 0a1b057..55953f4 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -829,7 +829,7 @@ public: // Default style & Input style * * @return The default font family. */ - const std::string& GetDefaultFontFamily() const; + std::string GetDefaultFontFamily() const; /** * @brief Sets the placeholder text font family. @@ -842,7 +842,7 @@ public: // Default style & Input style * * @return The placeholder text font family */ - const std::string& GetPlaceholderFontFamily() const; + std::string GetPlaceholderFontFamily() const; /** * @brief Sets the default font weight. @@ -1258,7 +1258,7 @@ public: // Default style & Input style * * @return The emboss's properties string. */ - const std::string& GetDefaultEmbossProperties() const; + std::string GetDefaultEmbossProperties() const; /** * @brief Sets the outline's properties string. @@ -1274,7 +1274,7 @@ public: // Default style & Input style * * @return The outline's properties string. */ - const std::string& GetDefaultOutlineProperties() const; + std::string GetDefaultOutlineProperties() const; /** * @brief Sets the default line spacing. @@ -1350,7 +1350,7 @@ public: // Default style & Input style * * @return The input text's font family name. */ - const std::string& GetInputFontFamily() const; + std::string GetInputFontFamily() const; /** * @brief Sets the input font's weight. @@ -1451,7 +1451,7 @@ public: // Default style & Input style * * @return The shadow's properties string. */ - const std::string& GetInputShadowProperties() const; + std::string GetInputShadowProperties() const; /** * @brief Sets the input underline's properties string. @@ -1467,7 +1467,7 @@ public: // Default style & Input style * * @return The underline's properties string. */ - const std::string& GetInputUnderlineProperties() const; + std::string GetInputUnderlineProperties() const; /** * @brief Sets the input emboss's properties string. @@ -1483,7 +1483,7 @@ public: // Default style & Input style * * @return The emboss's properties string. */ - const std::string& GetInputEmbossProperties() const; + std::string GetInputEmbossProperties() const; /** * @brief Sets input the outline's properties string. @@ -1499,7 +1499,7 @@ public: // Default style & Input style * * @return The outline's properties string. */ - const std::string& GetInputOutlineProperties() const; + std::string GetInputOutlineProperties() const; /** * @brief Sets the input strikethrough's properties string. @@ -1515,7 +1515,7 @@ public: // Default style & Input style * * @return The strikethrough's properties string. */ - const std::string& GetInputStrikethroughProperties() const; + std::string GetInputStrikethroughProperties() const; /** * @brief Set the control's interface. diff --git a/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp index 8e9ec06..f39afce 100644 --- a/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp @@ -35,8 +35,7 @@ namespace Text { namespace { -const std::string NONE("none"); -const std::string MULTIPLY("multiply"); +const char* MULTIPLY = "multiply"; } // namespace void ProcessEmbeddedItem(const Tag& tag, EmbeddedItem& embeddedItem) diff --git a/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp index 133d7fa..13afaa0 100644 --- a/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp @@ -37,9 +37,6 @@ namespace Text { namespace { -const std::string FONT_PREFIX("font-"); -const unsigned int FONT_PREFIX_LENGTH = 5u; -const unsigned int MIN_FONT_ATTRIBUTE_SIZE = 4u; ///< The minimum length of any of the possible 'weight', 'width' , 'slant' or 'size' values. const unsigned int MAX_FONT_ATTRIBUTE_SIZE = 15u; ///< The maximum length of any of the possible 'weight', 'width' or 'slant' values. const float PIXEL_FORMAT_64_FACTOR = 64.f; ///< 64.f is used to convert from point size to 26.6 pixel format. } // namespace diff --git a/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp index b0ac16b..f7ed507 100644 --- a/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp @@ -44,23 +44,23 @@ const char WEB_COLOR_TOKEN('#'); const char* const HEX_COLOR_TOKEN("0x"); const char* const ALPHA_ONE("FF"); -const std::string BLACK_COLOR("black"); -const std::string WHITE_COLOR("white"); -const std::string RED_COLOR("red"); -const std::string GREEN_COLOR("green"); -const std::string BLUE_COLOR("blue"); -const std::string YELLOW_COLOR("yellow"); -const std::string MAGENTA_COLOR("magenta"); -const std::string CYAN_COLOR("cyan"); -const std::string TRANSPARENT_COLOR("transparent"); - -const std::string SOLID_UNDERLINE("solid"); -const std::string DASHED_UNDERLINE("dashed"); -const std::string DOUBLE_UNDERLINE("double"); - -const std::string BEGIN_HORIZONTAL_ALIGNMENT("begin"); -const std::string CENTER_HORIZONTAL_ALIGNMENT("center"); -const std::string END_HORIZONTAL_ALIGNMENT("end"); +const char* BLACK_COLOR("black"); +const char* WHITE_COLOR("white"); +const char* RED_COLOR("red"); +const char* GREEN_COLOR("green"); +const char* BLUE_COLOR("blue"); +const char* YELLOW_COLOR("yellow"); +const char* MAGENTA_COLOR("magenta"); +const char* CYAN_COLOR("cyan"); +const char* TRANSPARENT_COLOR("transparent"); + +const char* SOLID_UNDERLINE("solid"); +const char* DASHED_UNDERLINE("dashed"); +const char* DOUBLE_UNDERLINE("double"); + +const char* BEGIN_HORIZONTAL_ALIGNMENT("begin"); +const char* CENTER_HORIZONTAL_ALIGNMENT("center"); +const char* END_HORIZONTAL_ALIGNMENT("end"); } // namespace diff --git a/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.cpp b/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.cpp index b166c99..a65a4f2 100644 --- a/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.cpp +++ b/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.cpp @@ -24,10 +24,6 @@ namespace Toolkit { namespace Text { -namespace -{ -static const Vector EMPTY_CHARACTER_SPACING_GLYPH_RUNS; -} float GetGlyphCharacterSpacing(const GlyphIndex& index, const Vector& characterSpacingGlyphRuns, const float modelCharacterSpacing) @@ -50,14 +46,8 @@ float GetGlyphCharacterSpacing(const GlyphIndex& index, return characterSpacing; } - -const Vector& GetEmptyCharacterSpacingGlyphRuns() -{ - // This is needed to return a common empty vector for CharacterSpacingGlyphRun - return EMPTY_CHARACTER_SPACING_GLYPH_RUNS; -} } // namespace Text } // namespace Toolkit -} // namespace Dali \ No newline at end of file +} // namespace Dali diff --git a/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h b/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h index 3865b97..a15aa5e 100644 --- a/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h +++ b/dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h @@ -44,18 +44,10 @@ namespace Text float GetGlyphCharacterSpacing(const GlyphIndex& index, const Vector& characterSpacingGlyphRuns, const float modelCharacterSpacing); - -/** - * @brief Create static empty vector and retrun it. - * - * @return The reference for the empty character-spacing glyph runs. - */ -const Vector& GetEmptyCharacterSpacingGlyphRuns(); - } // namespace Text } // namespace Toolkit } // namespace Dali -#endif // DALI_TOOLKIT_TEXT_RENDERING_STYLES_CHARACTER_SPACING_HELPER_FUNCTIONS_H \ No newline at end of file +#endif // DALI_TOOLKIT_TEXT_RENDERING_STYLES_CHARACTER_SPACING_HELPER_FUNCTIONS_H diff --git a/dali-toolkit/internal/text/text-effects-style.cpp b/dali-toolkit/internal/text/text-effects-style.cpp index 1428b95..2bf1398 100644 --- a/dali-toolkit/internal/text/text-effects-style.cpp +++ b/dali-toolkit/internal/text/text-effects-style.cpp @@ -35,17 +35,16 @@ namespace Text { namespace { -const std::string COLOR_KEY("color"); -const std::string OFFSET_KEY("offset"); -const std::string BLUR_RADIUS_KEY("blurRadius"); -const std::string WIDTH_KEY("width"); -const std::string HEIGHT_KEY("height"); -const std::string ENABLE_KEY("enable"); -const std::string TYPE_KEY("type"); -const std::string DASH_WIDTH_KEY("dashWidth"); -const std::string DASH_GAP_KEY("dashGap"); -const std::string TRUE_TOKEN("true"); -const std::string FALSE_TOKEN("false"); +const char* COLOR_KEY = "color"; +const char* OFFSET_KEY = "offset"; +const char* BLUR_RADIUS_KEY = "blurRadius"; +const char* WIDTH_KEY = "width"; +const char* HEIGHT_KEY = "height"; +const char* ENABLE_KEY = "enable"; +const char* TYPE_KEY = "type"; +const char* DASH_WIDTH_KEY = "dashWidth"; +const char* DASH_GAP_KEY = "dashGap"; +const char* TRUE_TOKEN = "true"; } // namespace bool ParseShadowProperties(const Property::Map& shadowPropertiesMap, diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index ce5e860..f087a1e 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -33,14 +33,13 @@ namespace Text { namespace { -const std::string STYLE_KEY("style"); -const std::string WEIGHT_KEY("weight"); -const std::string WIDTH_KEY("width"); -const std::string SLANT_KEY("slant"); -const std::string FAMILY_KEY("family"); -const std::string TYPE_KEY("type"); - -const std::string SYSTEM_TOKEN("system"); +const char* WEIGHT_KEY = "weight"; +const char* WIDTH_KEY = "width"; +const char* SLANT_KEY = "slant"; +const char* FAMILY_KEY = "family"; +const char* TYPE_KEY = "type"; + +const char* SYSTEM_TOKEN = "system"; } // namespace diff --git a/dali-toolkit/internal/text/text-view-interface.h b/dali-toolkit/internal/text/text-view-interface.h index 8a23485..24fcfff 100644 --- a/dali-toolkit/internal/text/text-view-interface.h +++ b/dali-toolkit/internal/text/text-view-interface.h @@ -353,20 +353,6 @@ public: virtual const Vector& GetBoundedParagraphRuns() const = 0; /** - * @brief Retrieves the number of character-spacing glyph runs. - * - * @return The number of character-spacing glyph runs. - */ - virtual Length GetNumberOfCharacterSpacingGlyphRuns() const = 0; - - /** - * @brief Retrieves the reference for character-spacing glyph runs. - * - * @return The reference for character-spacing glyph runs. - */ - virtual const Vector& GetCharacterSpacingGlyphRuns() const = 0; - - /** * @brief Retrieves the strikethrough runs. * * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied. diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp index e89d434..334d922 100644 --- a/dali-toolkit/internal/text/text-view.cpp +++ b/dali-toolkit/internal/text/text-view.cpp @@ -917,24 +917,14 @@ const Vector& View::GetBoundedParagraphRuns() const return mImpl->mLogicalModel->GetBoundedParagraphRuns(); } -Length View::GetNumberOfCharacterSpacingGlyphRuns() const -{ - return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetNumberOfCharacterSpacingGlyphRuns() : 0u; -} - -const Vector& View::GetCharacterSpacingGlyphRuns() const -{ - return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacingGlyphRuns() : GetEmptyCharacterSpacingGlyphRuns(); -} - float View::GetCharacterSpacing() const { - return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacing() : 0.f; + return mImpl->mVisualModel->GetCharacterSpacing(); } const Character* View::GetTextBuffer() const { - return (mImpl->mVisualModel) ? mImpl->mLogicalModel->mText.Begin() : nullptr; + return mImpl->mLogicalModel->mText.Begin(); } const Vector& View::GetGlyphsToCharacters() const diff --git a/dali-toolkit/internal/text/text-view.h b/dali-toolkit/internal/text/text-view.h index 893c802..5bf55e1 100644 --- a/dali-toolkit/internal/text/text-view.h +++ b/dali-toolkit/internal/text/text-view.h @@ -269,16 +269,6 @@ public: virtual const Vector& GetBoundedParagraphRuns() const; /** - * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfCharacterSpacingGlyphRuns() - */ - Length GetNumberOfCharacterSpacingGlyphRuns() const override; - - /** - * @copydoc Dali::Toolkit::Text::ViewInterface::GetCharacterSpacingGlyphRuns() - */ - const Vector& GetCharacterSpacingGlyphRuns() const override; - - /** * @copydoc Dali::Toolkit::Text::ViewInterface::GetCharacterSpacing() */ float GetCharacterSpacing() const override; diff --git a/dali-toolkit/internal/transition/transition-base-impl.cpp b/dali-toolkit/internal/transition/transition-base-impl.cpp old mode 100644 new mode 100755 index 5a88901..1c3ca66 --- a/dali-toolkit/internal/transition/transition-base-impl.cpp +++ b/dali-toolkit/internal/transition/transition-base-impl.cpp @@ -36,20 +36,6 @@ namespace Internal { namespace { -static constexpr float OPACITY_TRANSPARENT = 0.0f; - -const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION(Dali::AlphaFunction::DEFAULT); - -const Property::Map PROPERTY_MAP_INDEPENDENT_CONTROL{ - {Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER}, - {Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER}, - {Dali::Actor::Property::POSITION_USES_ANCHOR_POINT, true}, - {Dali::Actor::Property::INHERIT_POSITION, false}, - {Dali::Actor::Property::INHERIT_ORIENTATION, false}, - {Dali::Actor::Property::INHERIT_SCALE, false}, - {Dali::Actor::Property::COLOR_MODE, Dali::ColorMode::USE_OWN_COLOR}, -}; - Property::Map GetOriginalProperties(Dali::Toolkit::Control control) { Property::Map propertyMap; @@ -69,7 +55,6 @@ Property::Map GetOriginalProperties(Dali::Toolkit::Control control) return propertyMap; } - } // anonymous namespace TransitionBasePtr TransitionBase::New() @@ -83,7 +68,7 @@ TransitionBasePtr TransitionBase::New() } TransitionBase::TransitionBase() -: mAlphaFunction(DEFAULT_ALPHA_FUNCTION), +: mAlphaFunction(Dali::AlphaFunction::DEFAULT), mTimePeriod(TimePeriod(0.0f)), mTransitionWithChild(false), mMoveTargetChildren(false), @@ -159,7 +144,14 @@ void TransitionBase::Play() targetWorldTransform.GetTransformComponents(targetPosition, targetOrientation, targetScale); Vector4 targetColor = DevelActor::GetWorldColor(mTarget); - mTarget.SetProperties(PROPERTY_MAP_INDEPENDENT_CONTROL); + mTarget[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER; + mTarget[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + mTarget[Dali::Actor::Property::POSITION_USES_ANCHOR_POINT] = true; + mTarget[Dali::Actor::Property::INHERIT_POSITION] = false; + mTarget[Dali::Actor::Property::INHERIT_ORIENTATION] = false; + mTarget[Dali::Actor::Property::INHERIT_SCALE] = false; + mTarget[Dali::Actor::Property::COLOR_MODE] = Dali::ColorMode::USE_OWN_COLOR; + mTarget[Dali::Actor::Property::POSITION] = targetPosition; mTarget[Dali::Actor::Property::SCALE] = targetScale; mTarget[Dali::Actor::Property::ORIENTATION] = targetOrientation; diff --git a/dali-toolkit/internal/transition/transition-impl.cpp b/dali-toolkit/internal/transition/transition-impl.cpp index 3f78a6f..332c9e0 100644 --- a/dali-toolkit/internal/transition/transition-impl.cpp +++ b/dali-toolkit/internal/transition/transition-impl.cpp @@ -35,11 +35,6 @@ namespace Toolkit { namespace Internal { -namespace -{ -const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION(Dali::AlphaFunction::DEFAULT); -} // anonymous namespace - TransitionPtr Transition::New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, bool useDestinationTarget, TimePeriod timePeriod) { float delaySeconds = timePeriod.delaySeconds; diff --git a/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp index f23456c..b6a9ae8 100644 --- a/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp +++ b/dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp @@ -43,9 +43,6 @@ Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, " #else #define LOG_CACHE #endif - -static constexpr bool ENABLE_ORIENTATION_CORRECTION(true); - } // namespace namespace Dali diff --git a/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp b/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp index 728c219..2c98a4f 100644 --- a/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp +++ b/dali-toolkit/internal/visuals/image-visual-shader-factory.cpp @@ -35,12 +35,6 @@ namespace { const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f); -// global string variable to caching complate vertex shader -static std::string gVertexShader; - -// global string variable to caching complate fragment shader (no atlas) -static std::string gFragmentShaderNoAtlas; - const int NATIVE_SHADER_TYPE_OFFSET = VisualFactoryCache::ShaderType::NATIVE_IMAGE_SHADER - VisualFactoryCache::ShaderType::IMAGE_SHADER; // enum of required list when we select shader @@ -279,6 +273,8 @@ Shader ImageVisualShaderFactory::GetShader(VisualFactoryCache& factoryCache, con std::string_view ImageVisualShaderFactory::GetVertexShaderSource() { + // static string variable to cache complete vertex shader + static std::string gVertexShader; if(gVertexShader.empty()) { gVertexShader = Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(); @@ -289,6 +285,8 @@ std::string_view ImageVisualShaderFactory::GetVertexShaderSource() std::string_view ImageVisualShaderFactory::GetFragmentShaderSource() { + // static string variable to cache complete fragment shader (no atlas) + static std::string gFragmentShaderNoAtlas; if(gFragmentShaderNoAtlas.empty()) { gFragmentShaderNoAtlas = Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_FRAG.data(); diff --git a/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp b/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp index 5a2eba8..5f9b04b 100644 --- a/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp +++ b/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp @@ -30,12 +30,6 @@ namespace Internal { namespace { -// global string variable to caching complate vertex shader -static std::string gVertexShader; - -// global string variable to caching complate fragment shader (no atlas) -static std::string gFragmentShaderNoAtlas; - // enum of required list when we select shader enum class TextVisualRequireFlag : uint32_t { diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 7b52284..3b6a6fc 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 = 2; -const unsigned int TOOLKIT_MICRO_VERSION = 14; +const unsigned int TOOLKIT_MICRO_VERSION = 15; const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 38e80df..f6ebe63 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.2.14 +Version: 2.2.15 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT