From: Richard Huang Date: Fri, 15 Jul 2022 12:17:32 +0000 (+0100) Subject: [dali_2.1.31] Merge branch 'devel/master' X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=020b07151378db83ab8e12eb3e2d51db0ed69996;hp=21f841ba0703a6fbf442ab097451560b7b6efe1b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [dali_2.1.31] Merge branch 'devel/master' Change-Id: I8f5db813c2fde9e94473dbe70f32a889543d76b8 --- diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h index e44aa56..d3f4e25 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h @@ -125,6 +125,8 @@ struct DBusWrapper virtual ObjectPtr eldbus_object_get_impl( const ConnectionPtr &conn, const std::string &bus, const std::string &path ) = 0; virtual ProxyPtr eldbus_proxy_get_impl( const ObjectPtr &obj, const std::string &interface ) = 0; virtual ProxyPtr eldbus_proxy_copy_impl( const ProxyPtr &ptr) = 0; + virtual void eldbus_name_request_impl(const ConnectionPtr&, const std::string&) {} // no-op + virtual void eldbus_name_release_impl(const ConnectionPtr&, const std::string&) {} // no-op class StringStorage { diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index 5b8469d..5fc9349 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -28,11 +28,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include namespace Dali { diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h index 00bf3d5..b064bfa 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp index e2ff409..d9fe5b7 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp @@ -43,6 +43,7 @@ const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg"; const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif"; const std::string DEFAULT_FONT_DIR("/resources/fonts"); +const char* const DALI_DEBUG_RENDERING("DALI_DEBUG_RENDERING"); void TestDebugVisual(Integration::Scene scene, Visual::Base& visual, DevelVisual::Type actualType, Vector2 expectedNaturalSize) { @@ -96,7 +97,7 @@ void dali_debug_rendering_cleanup(void) int UtcDaliDebugRenderingGetVisual1(void) { - EnvironmentVariable::SetTestingEnvironmentVariable(true); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "1"); ToolkitTestApplication application; tet_infoline("UtcDaliDebugRenderingGetVisual1: Request visual with a Property::Map"); @@ -213,13 +214,13 @@ int UtcDaliDebugRenderingGetVisual1(void) DALI_TEST_CHECK(nPatchVisual); TestDebugVisual(application.GetScene(), nPatchVisual, Visual::N_PATCH, Vector2::ZERO); - EnvironmentVariable::SetTestingEnvironmentVariable(false); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "0"); END_TEST; } int UtcDaliDebugRenderingGetVisual2(void) { - EnvironmentVariable::SetTestingEnvironmentVariable(true); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "1"); ToolkitTestApplication application; tet_infoline("UtcDaliDebugRenderingGetVisual2: Request visual with various parameters"); @@ -257,13 +258,13 @@ int UtcDaliDebugRenderingGetVisual2(void) DALI_TEST_CHECK(nPatchVisual); TestDebugVisual(application.GetScene(), nPatchVisual, Visual::N_PATCH, Vector2::ZERO); - EnvironmentVariable::SetTestingEnvironmentVariable(false); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "0"); END_TEST; } int UtcDaliDebugRenderingGetVisual3(void) { - EnvironmentVariable::SetTestingEnvironmentVariable(true); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "1"); ToolkitTestApplication application; tet_infoline("UtcDaliDebugRenderingGetVisual3: Request visual with various parameters"); @@ -322,13 +323,13 @@ int UtcDaliDebugRenderingGetVisual3(void) DALI_TEST_EQUALS(imageView2.GetRendererCount(), 0u, TEST_LOCATION); DALI_TEST_EQUALS(imageView3.GetRendererCount(), 0u, TEST_LOCATION); - EnvironmentVariable::SetTestingEnvironmentVariable(false); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "0"); END_TEST; } int UtcDaliDebugRenderingGetVisual4(void) { - EnvironmentVariable::SetTestingEnvironmentVariable(true); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "1"); ToolkitTestApplication application; tet_infoline("UtcDaliDebugRenderingGetVisual4: Request visual with empty URL and empty Array"); @@ -372,13 +373,13 @@ int UtcDaliDebugRenderingGetVisual4(void) DALI_TEST_CHECK(emptyVisual.GetObjectPtr() == &visualImpl); } - EnvironmentVariable::SetTestingEnvironmentVariable(false); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "0"); END_TEST; } int UtcDaliDebugRenderingGetVisualObject01(void) { - EnvironmentVariable::SetTestingEnvironmentVariable(true); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "1"); ToolkitTestApplication application; VisualFactory factory = VisualFactory::Get(); @@ -400,7 +401,7 @@ int UtcDaliDebugRenderingGetVisualObject01(void) tet_infoline("Compare the returned TextVisual with the visual implementation, should differ"); DALI_TEST_CHECK(textVisual.GetObjectPtr() != &visualImpl); - EnvironmentVariable::SetTestingEnvironmentVariable(false); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "0"); END_TEST; } @@ -457,7 +458,7 @@ int UtcDaliDebugRenderingGetVisualObject03(void) int UtcDaliDebugRenderingRenderText(void) { - EnvironmentVariable::SetTestingEnvironmentVariable(true); + EnvironmentVariable::SetTestEnvironmentVariable(DALI_DEBUG_RENDERING, "1"); ToolkitTestApplication application; tet_infoline("Ensure we can render text when in debug mode"); diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-LineHelperFunctions.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-LineHelperFunctions.cpp index 2930c6d..92113fc 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-LineHelperFunctions.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-LineHelperFunctions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ #include #include #include +#include #include #include -#include #include using namespace Dali; 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 b079ce3..53b45f2 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,10 @@ #include #include #include -#include +#include +#include #include #include -#include using namespace Dali; using namespace Toolkit; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp index 75d8bb4..a0a27c9 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Ellipsis.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp index 36117f7..3efd9aa 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Markup.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp index 462a883..c64458a 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Typesetter.cpp @@ -25,9 +25,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp index a3ad901..daabc0b 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-ViewModel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ #include #include #include +#include #include #include -#include using namespace Dali; using namespace Toolkit; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp index f768255..16dfc51 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include using namespace Dali; using namespace Toolkit; @@ -1441,4 +1441,4 @@ int UtcDaliTextEditorMarkupSpanCharacterSpacing(void) } END_TEST; -} \ No newline at end of file +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp index da3ffc3..06eefbc 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp @@ -22,9 +22,9 @@ #include #include +#include +#include #include -#include -#include using namespace Dali; using namespace Toolkit; @@ -1350,4 +1350,4 @@ int UtcDaliTextFieldMarkupSpanCharacterSpacing(void) } END_TEST; -} \ No newline at end of file +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp index d9a3c04..4f15239 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp @@ -22,10 +22,10 @@ #include #include +#include +#include #include #include -#include -#include using namespace Dali; using namespace Toolkit; @@ -1337,4 +1337,4 @@ int UtcDaliTextLabelMarkupSpanCharacterSpacing(void) } END_TEST; -} \ No newline at end of file +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp index 6999ffa..9f4cd73 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Visuals-internal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,59 +21,60 @@ #include #include -#include #include +#include + #include -#include +#include #include #include -#include +#include + #include <../dali-toolkit/dali-toolkit-test-utils/dummy-control.h> -#include +#include using namespace Dali; using namespace Toolkit; namespace { - -const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json"; +const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json"; } int UtcDaliVisualAction(void) { ToolkitTestApplication application; - tet_infoline( "Register an ImageVisual and and perform an Action on Visual directly" ); - Vector2 controlSize( 20.f, 30.f ); + tet_infoline("Register an ImageVisual and and perform an Action on Visual directly"); + Vector2 controlSize(20.f, 30.f); //Created DummyVisual - Property::Map settings; - Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New( settings ); + Property::Map settings; + Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New(settings); - DummyControl dummyControl = DummyControl::New( true ); - Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); - tet_infoline( "Register visual and stage control" ); + tet_infoline("Register visual and stage control"); - Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base( dummyVisualPtr.Get() ); - dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visualBaseHandle ); - dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - application.GetScene().Add( dummyControl ); + Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base(dummyVisualPtr.Get()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visualBaseHandle); + dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + application.GetScene().Add(dummyControl); application.SendNotification(); application.Render(); - tet_infoline( "Check action counter is 0 before DoAction" ); - DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 0, TEST_LOCATION ); + tet_infoline("Check action counter is 0 before DoAction"); + DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION); - tet_infoline( "Perform TEST_ACTION action on Visual. Should increase the action counter" ); + tet_infoline("Perform TEST_ACTION action on Visual. Should increase the action counter"); - Property::Map attributes; - Toolkit::Internal::Visual::Base& internalVisualBase = GetImplementation( visualBaseHandle ); - internalVisualBase.DoAction( Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes ); + Property::Map attributes; + Toolkit::Internal::Visual::Base& internalVisualBase = GetImplementation(visualBaseHandle); + internalVisualBase.DoAction(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes); application.SendNotification(); - DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 1, TEST_LOCATION ); + DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 1, TEST_LOCATION); END_TEST; } @@ -81,39 +82,39 @@ int UtcDaliVisualAction(void) int UtcDaliVisualActionNotImplemented(void) { ToolkitTestApplication application; - tet_infoline( "Register an ImageVisual and and perform an Action on a Visual which does not support any Actions" ); - Vector2 controlSize( 20.f, 30.f ); + tet_infoline("Register an ImageVisual and and perform an Action on a Visual which does not support any Actions"); + Vector2 controlSize(20.f, 30.f); //Created DummyVisual - Property::Map settings; - Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New( settings ); + Property::Map settings; + Toolkit::Internal::DummyVisualPtr dummyVisualPtr = Toolkit::Internal::DummyVisual::New(settings); - DummyControl dummyControl = DummyControl::New( true ); - Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); - tet_infoline( "Register visual and stage control" ); + tet_infoline("Register visual and stage control"); VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; - propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); - propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); - Visual::Base visual = factory.CreateVisual( propertyMap ); + propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE); + Visual::Base visual = factory.CreateVisual(propertyMap); - dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - application.GetScene().Add( dummyControl ); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + application.GetScene().Add(dummyControl); application.SendNotification(); application.Render(); - tet_infoline( "Check action counter is 0 before DoAction" ); - DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 0, TEST_LOCATION ); + tet_infoline("Check action counter is 0 before DoAction"); + DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION); - tet_infoline( "Perform TEST_ACTION action on Color Visual which does not support it.. Should not increment the action counter" ); + tet_infoline("Perform TEST_ACTION action on Color Visual which does not support it.. Should not increment the action counter"); Property::Map attributes; - GetImplementation( visual ).DoAction( Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes ); + GetImplementation(visual).DoAction(Dali::Toolkit::Internal::DummyVisual::TEST_ACTION, attributes); application.SendNotification(); - DALI_TEST_EQUALS( dummyVisualPtr->GetActionCounter() , 0, TEST_LOCATION ); + DALI_TEST_EQUALS(dummyVisualPtr->GetActionCounter(), 0, TEST_LOCATION); END_TEST; } @@ -121,40 +122,40 @@ int UtcDaliVisualActionNotImplemented(void) int UtcDaliVisualSetProperties(void) { ToolkitTestApplication application; - tet_infoline( "Register a visual and SetProperties" ); + tet_infoline("Register a visual and SetProperties"); Toolkit::Internal::VisualFactoryCache* factoryCache = new Toolkit::Internal::VisualFactoryCache(false); //Created ColorVisual Property::Map propertyMap1; - propertyMap1.Insert(Visual::Property::TYPE, Visual::COLOR); - propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, Color::RED); - Toolkit::Internal::ColorVisualPtr colorVisualPtr = Toolkit::Internal::ColorVisual::New( *factoryCache, propertyMap1 ); + propertyMap1.Insert(Visual::Property::TYPE, Visual::COLOR); + propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, Color::RED); + Toolkit::Internal::ColorVisualPtr colorVisualPtr = Toolkit::Internal::ColorVisual::New(*factoryCache, propertyMap1); - DummyControl dummyControl = DummyControl::New( true ); - Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummyControl.GetImplementation() ); + DummyControl dummyControl = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); - Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base( colorVisualPtr.Get() ); - dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visualBaseHandle ); - dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - application.GetScene().Add( dummyControl ); + Toolkit::Visual::Base visualBaseHandle = Toolkit::Visual::Base(colorVisualPtr.Get()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visualBaseHandle); + dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f)); + application.GetScene().Add(dummyControl); application.SendNotification(); application.Render(); Property::Map propertyMap; - propertyMap.Insert( Visual::Property::MIX_COLOR, Color::BLUE ); + propertyMap.Insert(Visual::Property::MIX_COLOR, Color::BLUE); - colorVisualPtr->SetProperties( propertyMap ); + colorVisualPtr->SetProperties(propertyMap); application.SendNotification(); application.Render(); Property::Map resultMap; - visualBaseHandle.CreatePropertyMap( resultMap ); + visualBaseHandle.CreatePropertyMap(resultMap); - Property::Value* colorValue = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 ); - DALI_TEST_CHECK( colorValue ); - DALI_TEST_CHECK( colorValue->Get< Vector4 >() == Color::BLUE ); + Property::Value* colorValue = resultMap.Find(Visual::Property::MIX_COLOR, Property::VECTOR4); + DALI_TEST_CHECK(colorValue); + DALI_TEST_CHECK(colorValue->Get() == Color::BLUE); delete factoryCache; @@ -164,22 +165,22 @@ int UtcDaliVisualSetProperties(void) int UtcDaliAnimatedVectorImageVisualCreateInstancePropertyMap(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliAnimatedVectorImageVisualCreateInstancePropertyMap" ); + tet_infoline("UtcDaliAnimatedVectorImageVisualCreateInstancePropertyMap"); Property::Map propertyMap; - propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) - .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ); + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME); // request AnimatedVectorImageVisual with a property map - VisualFactory factory = VisualFactory::Get(); - Visual::Base visual = factory.CreateVisual( propertyMap ); - Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( visual ); + VisualFactory factory = VisualFactory::Get(); + Visual::Base visual = factory.CreateVisual(propertyMap); + Toolkit::Internal::Visual::Base& visualImpl = GetImplementation(visual); Property::Map resultMap; - visualImpl.CreateInstancePropertyMap( resultMap ); + visualImpl.CreateInstancePropertyMap(resultMap); // check the property values from the returned map from a visual - DALI_TEST_CHECK( resultMap.Empty() ); // Now the map is empty + DALI_TEST_CHECK(resultMap.Empty()); // Now the map is empty END_TEST; } @@ -187,47 +188,50 @@ int UtcDaliAnimatedVectorImageVisualCreateInstancePropertyMap(void) int UtcDaliAnimatedVectorImageVisualSetProperties(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliAnimatedVectorImageVisualSetProperties" ); + tet_infoline("UtcDaliAnimatedVectorImageVisualSetProperties"); Property::Map propertyMap; - propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) - .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) - .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) - .Add( DevelImageVisual::Property::PLAY_RANGE, Vector2( 0.2f, 0.8f ) ); + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) + .Add(DevelImageVisual::Property::LOOP_COUNT, 3) + .Add(DevelImageVisual::Property::PLAY_RANGE, Vector2(0.2f, 0.8f)); - Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); - Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( visual ); - DALI_TEST_CHECK( visual ); + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + Toolkit::Internal::Visual::Base& visualImpl = GetImplementation(visual); + DALI_TEST_CHECK(visual); - DummyControl actor = DummyControl::New( true ); - DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() ); - dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) ); - application.GetScene().Add( actor ); + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f)); + application.GetScene().Add(actor); application.SendNotification(); application.Render(); + // Trigger count is 2 - load, resource ready + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // renderer is added to actor - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); - Renderer renderer = actor.GetRendererAt( 0u ); - DALI_TEST_CHECK( renderer ); + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); Property::Map propertyMap1; - propertyMap1.Add( DevelImageVisual::Property::LOOP_COUNT, 1 ) - .Add( DevelImageVisual::Property::PLAY_RANGE, Vector2( 0.4f, 0.6f ) ); + propertyMap1.Add(DevelImageVisual::Property::LOOP_COUNT, 1) + .Add(DevelImageVisual::Property::PLAY_RANGE, Vector2(0.4f, 0.6f)); - visualImpl.SetProperties( propertyMap1 ); + visualImpl.SetProperties(propertyMap1); application.SendNotification(); application.Render(); - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); - renderer = actor.GetRendererAt( 0u ); - DALI_TEST_CHECK( renderer ); + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); - actor.Unparent( ); - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + actor.Unparent(); + DALI_TEST_CHECK(actor.GetRendererCount() == 0u); END_TEST; } @@ -235,29 +239,29 @@ int UtcDaliAnimatedVectorImageVisualSetProperties(void) int UtcDaliArcVisualCreateInstancePropertyMap(void) { ToolkitTestApplication application; - tet_infoline( "UtcDaliArcVisualCreateInstancePropertyMap" ); + tet_infoline("UtcDaliArcVisualCreateInstancePropertyMap"); Property::Map propertyMap; - propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ARC ) - .Add( DevelArcVisual::Property::THICKNESS, 20.0f ); + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ARC) + .Add(DevelArcVisual::Property::THICKNESS, 20.0f); // request ArcVisual with a property map - VisualFactory factory = VisualFactory::Get(); - Visual::Base visual = factory.CreateVisual( propertyMap ); - Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( visual ); + VisualFactory factory = VisualFactory::Get(); + Visual::Base visual = factory.CreateVisual(propertyMap); + Toolkit::Internal::Visual::Base& visualImpl = GetImplementation(visual); Property::Map resultMap; - visualImpl.CreateInstancePropertyMap( resultMap ); + visualImpl.CreateInstancePropertyMap(resultMap); // check the property values from the returned map from a visual - DALI_TEST_CHECK( resultMap.Empty() ); // Now the map is empty + DALI_TEST_CHECK(resultMap.Empty()); // Now the map is empty END_TEST; } int UtcDaliVisualUpdateBrokenImageRenderer(void) { ToolkitTestApplication application; - tet_infoline( "UpdateBrokenImageRenderer Test" ); + tet_infoline("UpdateBrokenImageRenderer Test"); Toolkit::Internal::VisualFactoryCache* factoryCache = new Toolkit::Internal::VisualFactoryCache(false); @@ -268,7 +272,7 @@ int UtcDaliVisualUpdateBrokenImageRenderer(void) //Created dummy renderer Geometry geometry = factoryCache->GetGeometry(Toolkit::Internal::VisualFactoryCache::QUAD_GEOMETRY); - Shader shader = Shader::New("foo","bar"); + Shader shader = Shader::New("foo", "bar"); Renderer renderer = Renderer::New(geometry, shader); DALI_TEST_CHECK(renderer); diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h index d917107..fcadd6f 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h @@ -2,7 +2,7 @@ #define DALI_TEST_COMPARE_TYPES_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,109 +111,4 @@ inline bool CompareType(Extents extents1, Extents extents2, float epsil (extents1.bottom == extents2.bottom); } -template<> -inline bool CompareType(Property::Value q1, Property::Value q2, float epsilon) -{ - Property::Type type = q1.GetType(); - if(type != q2.GetType()) - { - return false; - } - - bool result = false; - switch(type) - { - case Property::BOOLEAN: - { - bool a, b; - q1.Get(a); - q2.Get(b); - result = a == b; - break; - } - case Property::INTEGER: - { - int a, b; - q1.Get(a); - q2.Get(b); - result = a == b; - break; - } - case Property::FLOAT: - { - float a, b; - q1.Get(a); - q2.Get(b); - result = CompareType(a, b, epsilon); - break; - } - case Property::VECTOR2: - { - Vector2 a, b; - q1.Get(a); - q2.Get(b); - result = CompareType(a, b, epsilon); - break; - } - case Property::VECTOR3: - { - Vector3 a, b; - q1.Get(a); - q2.Get(b); - result = CompareType(a, b, epsilon); - break; - } - case Property::RECTANGLE: - case Property::VECTOR4: - { - Vector4 a, b; - q1.Get(a); - q2.Get(b); - result = CompareType(a, b, epsilon); - break; - } - case Property::ROTATION: - { - Quaternion a, b; - q1.Get(a); - q2.Get(b); - result = CompareType(a, b, epsilon); - break; - } - case Property::STRING: - { - std::string a, b; - q1.Get(a); - q2.Get(b); - result = (a.compare(b) == 0); - break; - } - case Property::MATRIX: - case Property::MATRIX3: - case Property::ARRAY: - case Property::MAP: - { - //TODO: Implement this? - DALI_ASSERT_ALWAYS(0 && "Not implemented"); - result = false; - break; - } - case Property::EXTENTS: - { - Extents a, b; - q1.Get(a); - q2.Get(b); - result = CompareType(a, b, epsilon); - break; - } - case Property::NONE: - { - result = false; - break; - } - } - - return result; -} - #endif diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp index 43aa8ce..726648a 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ * */ -#include -#include +#include +#include #include #include #include diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp index 5d8d143..4fc6cf2 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,7 @@ #include "toolkit-environment-variable.h" // EXTERNAL INCLUDE -#include -#include +#include namespace Dali { @@ -27,36 +26,22 @@ namespace EnvironmentVariable { namespace { -const char* gReturnValue = NULL; -std::string gEnvironmentVariableName; -std::string gEnvironmentVariableValue; +std::map gEnvironmentVariables; } // namespace const char* GetEnvironmentVariable(const char* variable) { - if(gEnvironmentVariableName == variable) + auto value = gEnvironmentVariables.find(variable); + if(value != gEnvironmentVariables.end()) { - return gEnvironmentVariableValue.c_str(); - } - return gReturnValue; -} - -void SetTestingEnvironmentVariable(bool testing) -{ - if(testing) - { - gReturnValue = "1"; - } - else - { - gReturnValue = NULL; + return value->second.c_str(); } + return nullptr; } void SetTestEnvironmentVariable(const char* variable, const char* value) { - gEnvironmentVariableName = variable; - gEnvironmentVariableValue = value; + gEnvironmentVariables[variable] = value; } } // namespace EnvironmentVariable diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.h index 43b0758..96c9c88 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-environment-variable.h @@ -27,8 +27,6 @@ namespace EnvironmentVariable { const char* GetEnvironmentVariable(const char* variable); -void SetTestingEnvironmentVariable(bool); - void SetTestEnvironmentVariable(const char* variable, const char* value); } // namespace EnvironmentVariable diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp old mode 100755 new mode 100644 index 2ccf2c1..e6456ec --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,50 +15,50 @@ * */ +#include #include +#include #include #include -#include #include +#include +#include #include #include -#include namespace Dali { - namespace Internal { - namespace Adaptor { - namespace { Dali::Internal::Adaptor::VectorAnimationRenderer* gVectorAnimationRenderer = nullptr; } -class VectorAnimationRenderer: public Dali::BaseObject +class VectorAnimationRenderer : public Dali::BaseObject { public: - VectorAnimationRenderer() : mUrl(), mRenderer(), - mWidth( 0 ), - mHeight( 0 ), + mWidth(0), + mHeight(0), + mDefaultWidth(0), + mDefaultHeight(0), mTotalFrameNumber(VECTOR_ANIMATION_TOTAL_FRAME_NUMBER), - mPreviousFrame( 0 ), + mPreviousFrame(0), mDelayTime(0), mDroppedFrames(0), - mFrameRate( 60.0f ), + mFrameRate(60.0f), mTestFrameDrop(false), mNeedDroppedFrames(false), - mEventThreadCallback( new EventThreadCallback( MakeCallback( this, &VectorAnimationRenderer::OnTriggered ) ) ) + mEventThreadCallback(new EventThreadCallback(MakeCallback(this, &VectorAnimationRenderer::OnTriggered))) { mCount++; - if( mCount == 2 ) + if(mCount == 2) { mFrameRate = 0.1f; } @@ -71,69 +71,71 @@ public: bool Load(const std::string& url) { + Dali::Mutex::ScopedLock lock(mMutex); mUrl = url; if(mUrl == "invalid.json") { + mLoadFailed = true; return false; } else if(mUrl == "framedrop.json") { // Change total frame number for test mTotalFrameNumber = 200; - mTestFrameDrop = true; } + + mDefaultWidth = 100; + mDefaultHeight = 100; + return true; } - void SetRenderer( Dali::Renderer renderer ) + void SetRenderer(Dali::Renderer renderer) { mRenderer = renderer; - - if( mWidth != 0 && mHeight != 0 ) - { - Dali::TextureSet textureSet = mRenderer.GetTextures(); - Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight ); - textureSet.SetTexture( 0, texture ); - mUploadCompletedSignal.Emit(); - } } - void SetSize( uint32_t width, uint32_t height ) + void SetSize(uint32_t width, uint32_t height) { - mWidth = width; + Dali::Mutex::ScopedLock lock(mMutex); + mWidth = width; mHeight = height; - if( mRenderer ) + if(!mLoadFailed) { - Dali::TextureSet textureSet = mRenderer.GetTextures(); - Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight ); - textureSet.SetTexture( 0, texture ); - mUploadCompletedSignal.Emit(); + mNeedTrigger = true; + mResourceReady = false; } } - bool Render( uint32_t frameNumber ) + bool Render(uint32_t frameNumber) { + Dali::Mutex::ScopedLock lock(mMutex); + if(mWidth == 0 || mHeight == 0) + { + return false; + } + if(mTestFrameDrop) { std::this_thread::sleep_for(std::chrono::milliseconds(static_cast(mDelayTime))); - mTestFrameDrop = false; + mTestFrameDrop = false; mNeedDroppedFrames = true; } else if(mNeedDroppedFrames) { - mDroppedFrames = (frameNumber > mPreviousFrame) ? frameNumber - mPreviousFrame - 1: frameNumber + (mTotalFrameNumber - mPreviousFrame) - 1; - mNeedTrigger = true; + mDroppedFrames = (frameNumber > mPreviousFrame) ? frameNumber - mPreviousFrame - 1 : frameNumber + (mTotalFrameNumber - mPreviousFrame) - 1; + mNeedTrigger = true; mNeedDroppedFrames = false; } - if( mNeedTrigger ) + if(mNeedTrigger) { mEventThreadCallback->Trigger(); mNeedTrigger = false; } - if( frameNumber == 1 && mPreviousFrame != frameNumber ) + if(frameNumber == 1 && mPreviousFrame != frameNumber) { mPreviousFrame = frameNumber; // For test corverage @@ -153,23 +155,23 @@ public: return mFrameRate; } - void GetDefaultSize( uint32_t& width, uint32_t& height ) const + void GetDefaultSize(uint32_t& width, uint32_t& height) const { - width = 100; - height = 100; + width = mDefaultWidth; + height = mDefaultHeight; } - bool GetMarkerInfo( const std::string& marker, uint32_t& startFrame, uint32_t& endFrame ) const + bool GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const { - if( marker.compare( VECTOR_ANIMATION_MARKER_NAME_1 ) == 0 ) + if(marker.compare(VECTOR_ANIMATION_MARKER_NAME_1) == 0) { startFrame = VECTOR_ANIMATION_MARKER_START_FRAME_1; - endFrame = VECTOR_ANIMATION_MARKER_END_FRAME_1; + endFrame = VECTOR_ANIMATION_MARKER_END_FRAME_1; } - else if( marker.compare( VECTOR_ANIMATION_MARKER_NAME_2 ) == 0 ) + else if(marker.compare(VECTOR_ANIMATION_MARKER_NAME_2) == 0) { startFrame = VECTOR_ANIMATION_MARKER_START_FRAME_2; - endFrame = VECTOR_ANIMATION_MARKER_END_FRAME_2; + endFrame = VECTOR_ANIMATION_MARKER_END_FRAME_2; } else { @@ -178,6 +180,16 @@ public: return true; } + void InvalidateBuffer() + { + Dali::Mutex::ScopedLock lock(mMutex); + if(mResourceReady) + { + mNeedTrigger = true; + mResourceReady = false; + } + } + Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal() { return mUploadCompletedSignal; @@ -185,50 +197,67 @@ public: void OnTriggered() { + if(!mResourceReady) + { + mResourceReady = true; + + Dali::TextureSet textureSet = mRenderer.GetTextures(); + Dali::Texture texture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight); + textureSet.SetTexture(0, texture); + + Devel::PixelBuffer pixelBuffer = Devel::PixelBuffer::New(mWidth, mHeight, Pixel::RGBA8888); + Dali::PixelData pixelData = Devel::PixelBuffer::Convert(pixelBuffer); + texture.Upload(pixelData); + + mUploadCompletedSignal.Emit(); + } } public: - static uint32_t mCount; - static bool mNeedTrigger; - std::string mUrl; + std::string mUrl; Dali::Renderer mRenderer; - uint32_t mWidth; - uint32_t mHeight; - uint32_t mTotalFrameNumber; - uint32_t mPreviousFrame; - uint32_t mDelayTime; - uint32_t mDroppedFrames; - float mFrameRate; - bool mTestFrameDrop; - bool mNeedDroppedFrames; + Dali::Mutex mMutex; + uint32_t mWidth; + uint32_t mHeight; + uint32_t mDefaultWidth; + uint32_t mDefaultHeight; + uint32_t mTotalFrameNumber; + uint32_t mPreviousFrame; + uint32_t mDelayTime; + uint32_t mDroppedFrames; + float mFrameRate; + bool mTestFrameDrop; + bool mNeedDroppedFrames; + bool mLoadFailed{false}; + bool mResourceReady{false}; + bool mNeedTrigger{true}; + Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal; - std::unique_ptr< EventThreadCallback > mEventThreadCallback; + std::unique_ptr mEventThreadCallback; }; uint32_t VectorAnimationRenderer::mCount = 0; -bool VectorAnimationRenderer::mNeedTrigger = true; -inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer ) +inline VectorAnimationRenderer& GetImplementation(Dali::VectorAnimationRenderer& renderer) { - DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." ); + DALI_ASSERT_ALWAYS(renderer && "VectorAnimationRenderer handle is empty."); BaseObject& handle = renderer.GetBaseObject(); - return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle ); + return static_cast(handle); } -inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer ) +inline const VectorAnimationRenderer& GetImplementation(const Dali::VectorAnimationRenderer& renderer) { - DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." ); + DALI_ASSERT_ALWAYS(renderer && "VectorAnimationRenderer handle is empty."); const BaseObject& handle = renderer.GetBaseObject(); - return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle ); + return static_cast(handle); } } // namespace Adaptor } // namespace Internal - /********************************************************************************/ /********************************* PUBLIC CLASS *******************************/ /********************************************************************************/ @@ -239,7 +268,7 @@ VectorAnimationRenderer VectorAnimationRenderer::New() Internal::Adaptor::gVectorAnimationRenderer = animationRenderer; - return VectorAnimationRenderer( animationRenderer ); + return VectorAnimationRenderer(animationRenderer); } VectorAnimationRenderer::VectorAnimationRenderer() @@ -250,19 +279,19 @@ VectorAnimationRenderer::~VectorAnimationRenderer() { } -VectorAnimationRenderer::VectorAnimationRenderer( Internal::Adaptor::VectorAnimationRenderer* internal ) -: BaseHandle( internal ) +VectorAnimationRenderer::VectorAnimationRenderer(Internal::Adaptor::VectorAnimationRenderer* internal) +: BaseHandle(internal) { } -VectorAnimationRenderer::VectorAnimationRenderer( const VectorAnimationRenderer& handle ) -: BaseHandle( handle ) +VectorAnimationRenderer::VectorAnimationRenderer(const VectorAnimationRenderer& handle) +: BaseHandle(handle) { } -VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimationRenderer& rhs ) +VectorAnimationRenderer& VectorAnimationRenderer::operator=(const VectorAnimationRenderer& rhs) { - BaseHandle::operator=( rhs ); + BaseHandle::operator=(rhs); return *this; } @@ -272,51 +301,56 @@ void VectorAnimationRenderer::Finalize() bool VectorAnimationRenderer::Load(const std::string& url) { - return Internal::Adaptor::GetImplementation( *this ).Load(url); + return Internal::Adaptor::GetImplementation(*this).Load(url); } -void VectorAnimationRenderer::SetRenderer( Renderer renderer ) +void VectorAnimationRenderer::SetRenderer(Renderer renderer) { - Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer ); + Internal::Adaptor::GetImplementation(*this).SetRenderer(renderer); } -void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height ) +void VectorAnimationRenderer::SetSize(uint32_t width, uint32_t height) { - Internal::Adaptor::GetImplementation( *this ).SetSize( width, height ); + Internal::Adaptor::GetImplementation(*this).SetSize(width, height); } -bool VectorAnimationRenderer::Render( uint32_t frameNumber ) +bool VectorAnimationRenderer::Render(uint32_t frameNumber) { - return Internal::Adaptor::GetImplementation( *this ).Render( frameNumber ); + return Internal::Adaptor::GetImplementation(*this).Render(frameNumber); } uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const { - return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber(); + return Internal::Adaptor::GetImplementation(*this).GetTotalFrameNumber(); } float VectorAnimationRenderer::GetFrameRate() const { - return Internal::Adaptor::GetImplementation( *this ).GetFrameRate(); + return Internal::Adaptor::GetImplementation(*this).GetFrameRate(); +} + +void VectorAnimationRenderer::GetDefaultSize(uint32_t& width, uint32_t& height) const +{ + Internal::Adaptor::GetImplementation(*this).GetDefaultSize(width, height); } -void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const +void VectorAnimationRenderer::GetLayerInfo(Property::Map& map) const { - Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height ); } -void VectorAnimationRenderer::GetLayerInfo( Property::Map& map ) const +bool VectorAnimationRenderer::GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const { + return Internal::Adaptor::GetImplementation(*this).GetMarkerInfo(marker, startFrame, endFrame); } -bool VectorAnimationRenderer::GetMarkerInfo( const std::string& marker, uint32_t& startFrame, uint32_t& endFrame ) const +void VectorAnimationRenderer::InvalidateBuffer() { - return Internal::Adaptor::GetImplementation( *this ).GetMarkerInfo( marker, startFrame, endFrame ); + return Internal::Adaptor::GetImplementation(*this).InvalidateBuffer(); } VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal() { - return Internal::Adaptor::GetImplementation( *this ).UploadCompletedSignal(); + return Internal::Adaptor::GetImplementation(*this).UploadCompletedSignal(); } } // namespace Dali @@ -325,15 +359,10 @@ namespace Test { namespace VectorAnimationRenderer { - -void RequestTrigger() -{ - Dali::Internal::Adaptor::VectorAnimationRenderer::mNeedTrigger = true; -} - void DelayRendering(uint32_t delay) { - Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime = delay; + Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime = delay; + Dali::Internal::Adaptor::gVectorAnimationRenderer->mTestFrameDrop = true; } uint32_t GetDroppedFrames() @@ -341,6 +370,5 @@ uint32_t GetDroppedFrames() return Dali::Internal::Adaptor::gVectorAnimationRenderer->mDroppedFrames; } -} // VectorAnimationRenderer -} // Test - +} // namespace VectorAnimationRenderer +} // namespace Test diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.h old mode 100755 new mode 100644 index a1ea51b..bc241f1 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEST_VECTOR_ANIMATION_RENDERER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ namespace Test { namespace VectorAnimationRenderer { - #define VECTOR_ANIMATION_TOTAL_FRAME_NUMBER 5 #define VECTOR_ANIMATION_MARKER_NAME_1 "marker1" #define VECTOR_ANIMATION_MARKER_NAME_2 "marker2" @@ -31,12 +30,10 @@ namespace VectorAnimationRenderer #define VECTOR_ANIMATION_MARKER_START_FRAME_2 2 #define VECTOR_ANIMATION_MARKER_END_FRAME_2 3 -void RequestTrigger(); -void DelayRendering(uint32_t delay); +void DelayRendering(uint32_t delay); uint32_t GetDroppedFrames(); -} // VectorAnimationRenderer -} // Test - +} // namespace VectorAnimationRenderer +} // namespace Test #endif // DALI_TOOLKIT_TEST_VECTOR_ANIMATION_RENDERER_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 000bfa7..075cf2a 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,24 +17,24 @@ #include "toolkit-timer.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 41028c1..0529655 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -86,6 +86,9 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); Renderer renderer = actor.GetRendererAt(0u); @@ -119,6 +122,9 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); Renderer renderer = actor.GetRendererAt(0u); @@ -160,6 +166,9 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); Renderer renderer = actor.GetRendererAt(0u); @@ -210,8 +219,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) application.SendNotification(); application.Render(); - // Trigger count is 1 - render a frame - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); @@ -319,7 +328,8 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); Property::Map resultMap; resultMap = actor.GetProperty(DummyControl::Property::TEST_VISUAL); @@ -558,6 +568,9 @@ int UtcDaliAnimatedVectorImageVisualCustomShader(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + Renderer renderer = dummy.GetRendererAt(0); Shader shader2 = renderer.GetShader(); Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM); @@ -597,6 +610,9 @@ int UtcDaliAnimatedVectorImageVisualNaturalSize(void) application.SendNotification(); application.Render(); + // Trigger count is 1 - load + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + visual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS(naturalSize, Vector2(100.0f, 100.0f), TEST_LOCATION); // 100x100 is the content default size. @@ -641,8 +657,8 @@ int UtcDaliAnimatedVectorImageVisualLoopCount(void) application.SendNotification(); application.Render(); - // Trigger count is 1 - render a frame - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); @@ -685,7 +701,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); @@ -712,10 +729,13 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array); DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::PLAY_RANGE); @@ -734,10 +754,13 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -751,10 +774,13 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array); DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::PLAY_RANGE); @@ -803,7 +829,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); // renderer is added to actor DALI_TEST_CHECK(actor.GetRendererCount() == 1u); @@ -830,10 +857,13 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array); DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::PLAY_RANGE); @@ -854,10 +884,13 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array); DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::PLAY_RANGE); @@ -902,8 +935,8 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) application.SendNotification(); application.Render(); - // Wait for animation finish - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // Wait for animation finish - load, render, finish + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::PLAY_STATE); @@ -921,7 +954,8 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) Property::Map propertyMap; propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) - .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME); + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME) + .Add(DevelImageVisual::Property::LOOP_COUNT, 3); Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); DALI_TEST_CHECK(visual); @@ -940,12 +974,18 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -963,10 +1003,13 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -990,15 +1033,19 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) application.SendNotification(); application.Render(); - // Stop and jump to 3 - DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes); + // Wait for animation finish + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Jump to 3 DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1009,10 +1056,13 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) // Jump to the same position DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1054,7 +1104,8 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::LOOP_COUNT); @@ -1079,10 +1130,13 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::LOOP_COUNT); @@ -1105,10 +1159,13 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); // wait for next rasterize thread run + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::PLAY_RANGE); @@ -1169,8 +1226,8 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) application.SendNotification(); application.Render(); - // Trigger count is 1 - animation finished - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // Trigger count is 3 - load, render, animation finished + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1217,6 +1274,14 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) // Pause DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); int currentFrameNumber = value->Get(); @@ -1224,8 +1289,13 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) // Stop DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes); + // To make event trigger + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + application.SendNotification(); - application.Render(16); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1264,8 +1334,8 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void) application.SendNotification(); application.Render(); - // Trigger count is 1 - animation finished - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // Trigger count is 3 - load, render, animation finished + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION); Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); @@ -1328,13 +1398,21 @@ int UtcDaliAnimatedVectorImageVisualPropertyNotification(void) DummyControl actor = DummyControl::New(true); DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); Vector2 controlSize(20.f, 30.f); - Vector3 controlScale(2.0f, 2.0f, 1.0f); actor.SetProperty(Actor::Property::SIZE, controlSize); - actor.SetProperty(Actor::Property::SCALE, controlScale); - - application.GetScene().Add(actor); application.SendNotification(); application.Render(); @@ -1342,19 +1420,17 @@ int UtcDaliAnimatedVectorImageVisualPropertyNotification(void) application.SendNotification(); application.Render(); - Renderer renderer = actor.GetRendererAt(0u); - DALI_TEST_CHECK(renderer); + // Trigger count is 1 - render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); auto textureSet = renderer.GetTextures(); auto texture = textureSet.GetTexture(0); - DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION); - DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION); + DALI_TEST_EQUALS(controlSize.width, texture.GetWidth(), TEST_LOCATION); + DALI_TEST_EQUALS(controlSize.height, texture.GetHeight(), TEST_LOCATION); - // Change scale and size - controlSize = Vector2(50.f, 40.f); - controlScale = Vector3(0.5f, 0.5f, 1.0f); - actor.SetProperty(Actor::Property::SIZE, controlSize); + // Change scale + Vector3 controlScale(2.0f, 2.0f, 1.0f); actor.SetProperty(Actor::Property::SCALE, controlScale); application.SendNotification(); @@ -1363,6 +1439,33 @@ int UtcDaliAnimatedVectorImageVisualPropertyNotification(void) application.SendNotification(); application.Render(); + // Trigger count is 1 - render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + textureSet = renderer.GetTextures(); + texture = textureSet.GetTexture(0); + + DALI_TEST_EQUALS(controlSize.width * controlScale.width, texture.GetWidth(), TEST_LOCATION); + DALI_TEST_EQUALS(controlSize.height * controlScale.height, texture.GetHeight(), TEST_LOCATION); + + // Size animation + controlSize = Vector2(50.0f, 100.0f); + Animation animation = Animation::New(1.0); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), Vector3(controlSize.x, controlSize.y, 0.0f)); + animation.Play(); + + application.SendNotification(); + application.Render(1100); // After the animation + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + renderer = actor.GetRendererAt(0u); DALI_TEST_CHECK(renderer); @@ -1411,12 +1514,21 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) application.GetScene().Add(actor2); + application.SendNotification(); + application.Render(); + + // Trigger count is 4 - load & render a frame for each instance + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION); + DevelControl::DoAction(actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map()); + // To make event trigger + actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + application.SendNotification(); application.Render(); - std::this_thread::sleep_for(std::chrono::milliseconds(200)); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); Property::Map attributes; attributes.Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::LAST_FRAME); @@ -1463,6 +1575,9 @@ int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + Property::Map attributes; DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); @@ -1510,6 +1625,9 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void) application.SendNotification(); application.Render(); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + Property::Map attributes; DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); @@ -1534,7 +1652,7 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void) END_TEST; } -int UtcDaliAnimatedVectorImageVisualInvalidFile(void) +int UtcDaliAnimatedVectorImageVisualInvalidFile01(void) { ToolkitTestApplication application; tet_infoline("Request loading with invalid file - should draw broken image"); @@ -1561,6 +1679,99 @@ int UtcDaliAnimatedVectorImageVisualInvalidFile(void) application.SendNotification(); application.Render(); + // Trigger count is 1 - load + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + // Check resource status + Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL); + DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION); + + // The broken image should be shown. + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualInvalidFile02(void) +{ + ToolkitTestApplication application; + tet_infoline("Request loading with invalid file - should draw broken image"); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME); + + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - load + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + // Add to the Scene after loading + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Check resource status + Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL); + DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION); + + // The broken image should be shown. + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualInvalidFile03(void) +{ + ToolkitTestApplication application; + tet_infoline("Request loading with invalid file without size set - should draw broken image"); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME); + + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - load + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + // Check resource status Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL); DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION); @@ -1593,6 +1804,12 @@ int UtcDaliAnimatedVectorImageVisualFrameDrops(void) application.GetScene().Add(actor); + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load, render the first frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + Property::Map map = actor.GetProperty(DummyControl::Property::TEST_VISUAL); Property::Value* value = map.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER); int totalFrameNumber = value->Get(); @@ -1606,8 +1823,8 @@ int UtcDaliAnimatedVectorImageVisualFrameDrops(void) application.SendNotification(); application.Render(); - // Trigger count is 2 - render the first frame & calculating frame drops - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + // Trigger count is 1 - calculating frame drops + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); // Check dropped frame uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames(); @@ -1616,3 +1833,61 @@ int UtcDaliAnimatedVectorImageVisualFrameDrops(void) END_TEST; } + +int UtcDaliAnimatedVectorImageVisualSize(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualSize"); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + + VisualFactory factory = VisualFactory::Get(); + Visual::Base visual = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions()); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + application.GetScene().Add(actor); + + application.SendNotification(); + + // Trigger count is 2 - load, resource ready + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + textureTrace.Enable(true); + + application.SendNotification(); + application.Render(); + + { + int width = 100, height = 100; // 100x100 is the content default size. + std::stringstream out; + out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height; + DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); + } + + actor.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 200.0f)); + + application.SendNotification(); + application.Render(); + + // Trigger count is 1 - resource ready + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + textureTrace.Reset(); + + application.SendNotification(); + application.Render(); + + { + int width = 200, height = 200; + std::stringstream out; + out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height; + DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); + } + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-CanvasView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-CanvasView.cpp index b6458d3..b55622f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-CanvasView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-CanvasView.cpp @@ -28,8 +28,8 @@ #include #include #include -#include -#include +#include +#include #include using namespace Dali; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index 95c6abd..7a7bf26 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -3703,7 +3703,7 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void) tet_printf("test %s [sync:%d] signal fired\n", url.c_str(), isSynchronous ? 1 : 0); DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, location); - DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION); + DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(Toolkit::ImageView::Property::IMAGE), loadSuccess ? Toolkit::Visual::ResourceStatus::READY : Toolkit::Visual::ResourceStatus::FAILED, location); imageView.Unparent(); }; @@ -3750,7 +3750,7 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void) TestResourceReadyUrl(1, 0, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION); TestResourceReadyUrl(2, 0, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // 2 image loading - batch size - TestResourceReadyUrl(1, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // 1 rasterize + TestResourceReadyUrl(2, 0, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // load & rasterize TestResourceReadyUrl(3, 0, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); // 2 image loading + 1 applymask @@ -3761,7 +3761,7 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void) TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION); TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION); TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading - TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize + TestResourceReadyUrl(1, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize TestResourceReadyUrl(2, 0, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); // 2 image loading TestResourceReadyUrl(2, 0, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); // 2 image loading @@ -3779,8 +3779,7 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void) TestResourceReadyUrl(0, 1, 1, TEST_SVG_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize TestResourceReadyUrl(0, 1, 1, TEST_BROKEN_IMAGE_L, "", TEST_LOCATION); - TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async - TestResourceReadyUrl(0, 1, 1, TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, "", TEST_LOCATION); // synchronous rasterize + TestResourceReadyUrl(1, 1, 1, TEST_GIF_FILE_NAME, "", TEST_LOCATION); // first frame image loading sync + second frame image loading async TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, gImage_34_RGBA, TEST_LOCATION); @@ -3791,7 +3790,6 @@ int UtcDaliImageViewCheckVariousCaseSendOnResourceReadySignal(void) TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION); TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION); - TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "invalid.png", TEST_LOCATION); TestResourceReadyUrl(0, 1, 1, gImage_600_RGB, "invalid.png", TEST_LOCATION); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp index ba39604..2bfef0a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp @@ -64,7 +64,8 @@ const char* TEST_ROTATED_IMAGE = TEST_RESOURCE_DIR "/keyboard-Landsca const char* TEST_YUV420_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1-yuv420.jpg"; const char* TEST_N_PATCH_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/heartsframe.9.png"; -constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES_ENV"; +constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES"; +constexpr auto ENABLE_DECODE_JPEG_TO_YUV_420_ENV = "DALI_ENABLE_DECODE_JPEG_TO_YUV_420"; bool gResourceReadySignalFired = false; std::vector gReadyIds = {}; @@ -2989,6 +2990,7 @@ int UtcDaliImageVisualLoadReady01(void) int UtcDaliImageVisualLoadImagePlanes01(void) { EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1"); + EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1"); ToolkitTestApplication application; @@ -3034,6 +3036,7 @@ int UtcDaliImageVisualLoadImagePlanes01(void) int UtcDaliImageVisualLoadImagePlanes02(void) { EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1"); + EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1"); ToolkitTestApplication application; @@ -3077,6 +3080,7 @@ int UtcDaliImageVisualLoadImagePlanes02(void) int UtcDaliImageVisualLoadImagePlanes03(void) { EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1"); + EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1"); ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index f54a7f0..dae8540 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -4197,7 +4197,8 @@ int UtcDaliVisualRoundedCorner(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -4573,7 +4574,8 @@ int UtcDaliVisualBorderline(void) application.SendNotification(); application.Render(); - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -5605,8 +5607,8 @@ int UtcDaliVisualGetVisualProperty07(void) application.SendNotification(); application.Render(); - // Wait for image loading - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); application.SendNotification(); application.Render(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index 48edaf8..442d75d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -29,19 +29,19 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/dali-toolkit/devel-api/controls/canvas-view/canvas-view.h b/dali-toolkit/devel-api/controls/canvas-view/canvas-view.h index 64e1397..390cabd 100644 --- a/dali-toolkit/devel-api/controls/canvas-view/canvas-view.h +++ b/dali-toolkit/devel-api/controls/canvas-view/canvas-view.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_CANVAS_VIEW_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ #include // EXTERNAL INCLUDES -#include -#include +#include +#include namespace Dali { diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp index 8b3d8e1..9881636 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include // EXTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h index 0b015bc..1c0ca6e 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h +++ b/dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // EXTERNAL INCLUDES -#include +#include #include #include diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.cpp b/dali-toolkit/devel-api/controls/web-view/web-context.cpp index bba91c6..128546b 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-context.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include // EXTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/devel-api/controls/web-view/web-context.h b/dali-toolkit/devel-api/controls/web-view/web-context.h index 69e723b..ebdbae0 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-context.h +++ b/dali-toolkit/devel-api/controls/web-view/web-context.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_WEB_CONTEXT_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // EXTERNAL INCLUDES -#include +#include #include // INTERNAL INCLUDES diff --git a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h index 421db32..b7b5bf1 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h +++ b/dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_WEB_COOKIE_MANAGER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // EXTERNAL INCLUDES -#include +#include #include // INTERNAL INCLUDES diff --git a/dali-toolkit/devel-api/controls/web-view/web-settings.cpp b/dali-toolkit/devel-api/controls/web-view/web-settings.cpp index b17f48d..385ecc6 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-settings.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-settings.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include // EXTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index af7a058..55908e8 100755 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_WEB_VIEW_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include -#include +#include namespace Dali { diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index d1d6900..401b82f 100644 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/canvas-view/canvas-view-impl.h b/dali-toolkit/internal/controls/canvas-view/canvas-view-impl.h index 4e492eb..92110f0 100644 --- a/dali-toolkit/internal/controls/canvas-view/canvas-view-impl.h +++ b/dali-toolkit/internal/controls/canvas-view/canvas-view-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ */ // EXTERNAL INCLUDES -#include -#include -#include +#include +#include +#include #include #include diff --git a/dali-toolkit/internal/controls/canvas-view/canvas-view-rasterize-thread.h b/dali-toolkit/internal/controls/canvas-view/canvas-view-rasterize-thread.h index f89bb91..8e96367 100644 --- a/dali-toolkit/internal/controls/canvas-view/canvas-view-rasterize-thread.h +++ b/dali-toolkit/internal/controls/canvas-view/canvas-view-rasterize-thread.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_CANVAS_VIEW_RASTERIZE_THREAD_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ */ // EXTERNAL INCLUDES -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/common-text-utils.h b/dali-toolkit/internal/controls/text-controls/common-text-utils.h index a0d0ad4..a21dc86 100644 --- a/dali-toolkit/internal/controls/text-controls/common-text-utils.h +++ b/dali-toolkit/internal/controls/text-controls/common-text-utils.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_TEXT_CONTROLS_COMMON_TEXT_UTILS_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h index c62988a..aaa58f7 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp index 403f777..067023a 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index 6c4faa6..bed947d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp index f1247f9..45af9b7 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h index 49f9197..f4dac1d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include 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 09bea45..4beea3f 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,19 +19,19 @@ #include "web-view-impl.h" // EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include 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 6a0da6e..6fe96ad 100755 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_WEB_VIEW_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ // EXTERNAL INCLUDES #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index d80bffe..2d71f4b 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -44,6 +44,7 @@ SET( toolkit_src_files ${toolkit_src_dir}/visuals/primitive/primitive-visual.cpp ${toolkit_src_dir}/visuals/svg/svg-rasterize-thread.cpp ${toolkit_src_dir}/visuals/svg/svg-visual.cpp + ${toolkit_src_dir}/visuals/text-visual-shader-factory.cpp ${toolkit_src_dir}/visuals/text/text-visual.cpp ${toolkit_src_dir}/visuals/transition-data-impl.cpp ${toolkit_src_dir}/visuals/image-visual-shader-factory.cpp @@ -149,19 +150,6 @@ SET( toolkit_src_files ${toolkit_src_dir}/text/cursor-helper-functions.cpp ${toolkit_src_dir}/text/glyph-metrics-helper.cpp ${toolkit_src_dir}/text/logical-model-impl.cpp - ${toolkit_src_dir}/text/markup-processor.cpp - ${toolkit_src_dir}/text/markup-processor-color.cpp - ${toolkit_src_dir}/text/markup-processor-embedded-item.cpp - ${toolkit_src_dir}/text/markup-processor-anchor.cpp - ${toolkit_src_dir}/text/markup-processor-font.cpp - ${toolkit_src_dir}/text/markup-processor-background.cpp - ${toolkit_src_dir}/text/markup-processor-paragraph.cpp - ${toolkit_src_dir}/text/markup-processor-span.cpp - ${toolkit_src_dir}/text/markup-processor-strikethrough.cpp - ${toolkit_src_dir}/text/markup-processor-underline.cpp - ${toolkit_src_dir}/text/markup-processor-character-spacing.cpp - ${toolkit_src_dir}/text/markup-processor-helper-functions.cpp - ${toolkit_src_dir}/text/markup-processor-attribute-helper-functions.cpp ${toolkit_src_dir}/text/multi-language-support.cpp ${toolkit_src_dir}/text/hidden-text.cpp ${toolkit_src_dir}/text/input-filter.cpp @@ -171,18 +159,6 @@ SET( toolkit_src_files ${toolkit_src_dir}/text/shaper.cpp ${toolkit_src_dir}/text/hyphenator.cpp ${toolkit_src_dir}/text/text-enumerations-impl.cpp - ${toolkit_src_dir}/text/text-controller.cpp - ${toolkit_src_dir}/text/text-controller-background-actor.cpp - ${toolkit_src_dir}/text/text-controller-event-handler.cpp - ${toolkit_src_dir}/text/text-controller-impl.cpp - ${toolkit_src_dir}/text/text-controller-impl-data-clearer.cpp - ${toolkit_src_dir}/text/text-controller-impl-event-handler.cpp - ${toolkit_src_dir}/text/text-controller-impl-model-updater.cpp - ${toolkit_src_dir}/text/text-controller-input-font-handler.cpp - ${toolkit_src_dir}/text/text-controller-input-properties.cpp - ${toolkit_src_dir}/text/text-controller-placeholder-handler.cpp - ${toolkit_src_dir}/text/text-controller-relayouter.cpp - ${toolkit_src_dir}/text/text-controller-text-updater.cpp ${toolkit_src_dir}/text/text-effects-style.cpp ${toolkit_src_dir}/text/text-font-style.cpp ${toolkit_src_dir}/text/text-io.cpp @@ -194,8 +170,33 @@ SET( toolkit_src_files ${toolkit_src_dir}/text/text-view-interface.cpp ${toolkit_src_dir}/text/visual-model-impl.cpp ${toolkit_src_dir}/text/decorator/text-decorator.cpp + ${toolkit_src_dir}/text/controller/text-controller.cpp + ${toolkit_src_dir}/text/controller/text-controller-background-actor.cpp + ${toolkit_src_dir}/text/controller/text-controller-event-handler.cpp + ${toolkit_src_dir}/text/controller/text-controller-impl.cpp + ${toolkit_src_dir}/text/controller/text-controller-impl-data-clearer.cpp + ${toolkit_src_dir}/text/controller/text-controller-impl-event-handler.cpp + ${toolkit_src_dir}/text/controller/text-controller-impl-model-updater.cpp + ${toolkit_src_dir}/text/controller/text-controller-input-font-handler.cpp + ${toolkit_src_dir}/text/controller/text-controller-input-properties.cpp + ${toolkit_src_dir}/text/controller/text-controller-placeholder-handler.cpp + ${toolkit_src_dir}/text/controller/text-controller-relayouter.cpp + ${toolkit_src_dir}/text/controller/text-controller-text-updater.cpp ${toolkit_src_dir}/text/layouts/layout-engine-helper-functions.cpp ${toolkit_src_dir}/text/layouts/layout-engine.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-color.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-embedded-item.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-anchor.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-font.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-background.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-paragraph.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-span.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-strikethrough.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-underline.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-character-spacing.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-helper-functions.cpp + ${toolkit_src_dir}/text/markup-processor/markup-processor-attribute-helper-functions.cpp ${toolkit_src_dir}/text/multi-language-helper-functions.cpp ${toolkit_src_dir}/text/multi-language-support-impl.cpp ${toolkit_src_dir}/text/rendering/text-backend.cpp diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-shader.frag deleted file mode 100644 index e9e1069..0000000 --- a/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-shader.frag +++ /dev/null @@ -1,11 +0,0 @@ -varying mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform lowp vec4 uColor; -uniform lowp vec3 mixColor; - -void main() -{ - mediump vec4 textTexture = texture2D( sTexture, vTexCoord ); - - gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 ); -} diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-with-style-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-with-style-shader.frag deleted file mode 100644 index ca42ca6..0000000 --- a/dali-toolkit/internal/graphics/shaders/text-visual-multi-color-text-with-style-shader.frag +++ /dev/null @@ -1,16 +0,0 @@ -varying mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform sampler2D sStyle; -uniform sampler2D sOverlayStyle; -uniform lowp vec4 uColor; -uniform lowp vec3 mixColor; - -void main() -{ - mediump vec4 textTexture = texture2D( sTexture, vTexCoord ); - mediump vec4 styleTexture = texture2D( sStyle, vTexCoord ); - mediump vec4 overlayStyleTexture = texture2D( sOverlayStyle, vTexCoord ); - - // Draw the text as overlay above the style - gl_FragColor = ( overlayStyleTexture + textTexture * (1.0 - overlayStyleTexture.a) + styleTexture * ( 1.0 - textTexture.a ) * (1.0 - overlayStyleTexture.a) ) * uColor * vec4( mixColor, 1.0 ); -} diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-shader.frag new file mode 100644 index 0000000..0fc642e --- /dev/null +++ b/dali-toolkit/internal/graphics/shaders/text-visual-shader.frag @@ -0,0 +1,63 @@ +INPUT mediump vec2 vTexCoord; +uniform sampler2D sTexture; +#ifdef IS_REQUIRED_STYLE +uniform sampler2D sStyle; +#endif +#ifdef IS_REQUIRED_OVERLAY +uniform sampler2D sOverlayStyle; +#endif +#ifdef IS_REQUIRED_MULTI_COLOR +#elif defined(IS_REQUIRED_EMOJI) +// Single color with emoji. +uniform sampler2D sMask; +uniform lowp float uHasMultipleTextColors; +#endif +uniform lowp vec4 uTextColorAnimatable; +uniform lowp vec4 uColor; +uniform lowp vec3 mixColor; + +void main() +{ +#ifdef IS_REQUIRED_STYLE + mediump vec4 styleTexture = TEXTURE( sStyle, vTexCoord ); +#endif + +#ifdef IS_REQUIRED_OVERLAY + mediump vec4 overlayStyleTexture = TEXTURE( sOverlayStyle, vTexCoord ); +#endif + +#if defined(IS_REQUIRED_MULTI_COLOR) || defined(IS_REQUIRED_EMOJI) + // Multiple color or use emoji. + mediump vec4 textColor = TEXTURE(sTexture, vTexCoord); + +#ifdef IS_REQUIRED_MULTI_COLOR +#elif defined(IS_REQUIRED_EMOJI) + // Single color with emoji. + mediump float maskTexture = TEXTURE(sMask, vTexCoord).r; + + // Set the color of non-transparent pixel in text to what it is animated to. + // Markup text with multiple text colors are not animated (but can be supported later on if required). + // Emoji color are not animated. + mediump float vstep = step( 0.0001, textColor.a ); + textColor.rgb = mix(textColor.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * (1.0 - uHasMultipleTextColors)); +#endif +#else + // Single color without emoji. + mediump float textTexture = TEXTURE(sTexture, vTexCoord).r; + mediump vec4 textColor = uTextColorAnimatable * textTexture; +#endif + + // Draw the text as overlay above the style + OUT_COLOR = uColor * vec4(mixColor, 1.0) * ( +#ifdef IS_REQUIRED_OVERLAY + ( +#endif + textColor +#ifdef IS_REQUIRED_STYLE + + styleTexture * (1.0 - textColor.a) +#endif +#ifdef IS_REQUIRED_OVERLAY + ) * (1.0 - overlayStyleTexture.a) + overlayStyleTexture +#endif + ); +} diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-shader.vert b/dali-toolkit/internal/graphics/shaders/text-visual-shader.vert index 4cc1212..6e90fe9 100644 --- a/dali-toolkit/internal/graphics/shaders/text-visual-shader.vert +++ b/dali-toolkit/internal/graphics/shaders/text-visual-shader.vert @@ -1,9 +1,9 @@ -attribute mediump vec2 aPosition; +INPUT mediump vec2 aPosition; uniform highp mat4 uMvpMatrix; uniform highp vec3 uSize; uniform mediump vec4 pixelArea; -varying mediump vec2 vTexCoord; +OUTPUT mediump vec2 vTexCoord; //Visual size and offset uniform mediump vec2 offset; diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-shader.frag deleted file mode 100644 index ab44460..0000000 --- a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-shader.frag +++ /dev/null @@ -1,13 +0,0 @@ -varying mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform lowp vec4 uTextColorAnimatable; -uniform lowp vec4 uColor; -uniform lowp vec3 mixColor; - -void main() -{ - mediump float textTexture = texture2D( sTexture, vTexCoord ).r; - - // Set the color of the text to what it is animated to. - gl_FragColor = uTextColorAnimatable * textTexture * uColor * vec4( mixColor, 1.0 ); -} diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-emoji-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-emoji-shader.frag deleted file mode 100644 index 544f0be..0000000 --- a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-emoji-shader.frag +++ /dev/null @@ -1,21 +0,0 @@ -varying mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform sampler2D sMask; -uniform lowp vec4 uTextColorAnimatable; -uniform lowp vec4 uColor; -uniform lowp vec3 mixColor; - -void main() -{ - mediump vec4 textTexture = texture2D( sTexture, vTexCoord ); - mediump float maskTexture = texture2D( sMask, vTexCoord ).r; - - // Set the color of non-transparent pixel in text to what it is animated to. - // Markup text with multiple text colors are not animated (but can be supported later on if required). - // Emoji color are not animated. - mediump float vstep = step( 0.0001, textTexture.a ); - textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture ); - - // Draw the text as overlay above the style - gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 ); -} diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-and-emoji-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-and-emoji-shader.frag deleted file mode 100644 index 0d82aa7..0000000 --- a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-and-emoji-shader.frag +++ /dev/null @@ -1,26 +0,0 @@ -varying mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform sampler2D sStyle; -uniform sampler2D sOverlayStyle; -uniform sampler2D sMask; -uniform lowp float uHasMultipleTextColors; -uniform lowp vec4 uTextColorAnimatable; -uniform lowp vec4 uColor; -uniform lowp vec3 mixColor; - -void main() -{ - mediump vec4 textTexture = texture2D( sTexture, vTexCoord ); - mediump vec4 styleTexture = texture2D( sStyle, vTexCoord ); - mediump vec4 overlayStyleTexture = texture2D( sOverlayStyle, vTexCoord ); - mediump float maskTexture = texture2D( sMask, vTexCoord ).r; - - // Set the color of non-transparent pixel in text to what it is animated to. - // Markup text with multiple text colors are not animated (but can be supported later on if required). - // Emoji color are not animated. - mediump float vstep = step( 0.0001, textTexture.a ); - textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) ); - - // Draw the text as overlay above the style - gl_FragColor = ( overlayStyleTexture + textTexture * (1.0 - overlayStyleTexture.a) + styleTexture * ( 1.0 - textTexture.a ) * (1.0 - overlayStyleTexture.a) ) * uColor * vec4( mixColor, 1.0 ); -} diff --git a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-shader.frag b/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-shader.frag deleted file mode 100644 index cf93f15..0000000 --- a/dali-toolkit/internal/graphics/shaders/text-visual-single-color-text-with-style-shader.frag +++ /dev/null @@ -1,17 +0,0 @@ -varying mediump vec2 vTexCoord; -uniform sampler2D sTexture; -uniform sampler2D sStyle; -uniform sampler2D sOverlayStyle; -uniform lowp vec4 uTextColorAnimatable; -uniform lowp vec4 uColor; -uniform lowp vec3 mixColor; - -void main() -{ - mediump float textTexture = texture2D( sTexture, vTexCoord ).r; - mediump vec4 styleTexture = texture2D( sStyle, vTexCoord ); - mediump vec4 overlayStyleTexture = texture2D( sOverlayStyle, vTexCoord ); - - // Draw the text as overlay above the style - gl_FragColor = ( overlayStyleTexture + uTextColorAnimatable * textTexture * (1.0 - overlayStyleTexture.a) + styleTexture * ( 1.0 - uTextColorAnimatable.a * textTexture ) * (1.0 - overlayStyleTexture.a) ) * uColor * vec4( mixColor, 1.0 ); -} \ No newline at end of file diff --git a/dali-toolkit/internal/text/text-controller-background-actor.cpp b/dali-toolkit/internal/text/controller/text-controller-background-actor.cpp similarity index 99% rename from dali-toolkit/internal/text/text-controller-background-actor.cpp rename to dali-toolkit/internal/text/controller/text-controller-background-actor.cpp index bc7c79b..666d794 100644 --- a/dali-toolkit/internal/text/text-controller-background-actor.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-background-actor.cpp @@ -16,7 +16,7 @@ */ // HEADER -#include +#include // EXTERNAL INCLUDES #include diff --git a/dali-toolkit/internal/text/text-controller-background-actor.h b/dali-toolkit/internal/text/controller/text-controller-background-actor.h similarity index 100% rename from dali-toolkit/internal/text/text-controller-background-actor.h rename to dali-toolkit/internal/text/controller/text-controller-background-actor.h diff --git a/dali-toolkit/internal/text/text-controller-event-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp similarity index 98% rename from dali-toolkit/internal/text/text-controller-event-handler.cpp rename to dali-toolkit/internal/text/controller/text-controller-event-handler.cpp index 59f0b8d..e351342 100644 --- a/dali-toolkit/internal/text/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -25,9 +25,9 @@ // INTERNAL INCLUDES #include -#include -#include -#include +#include +#include +#include #include namespace diff --git a/dali-toolkit/internal/text/text-controller-event-handler.h b/dali-toolkit/internal/text/controller/text-controller-event-handler.h similarity index 97% rename from dali-toolkit/internal/text/text-controller-event-handler.h rename to dali-toolkit/internal/text/controller/text-controller-event-handler.h index 0028890..3be57c2 100644 --- a/dali-toolkit/internal/text/text-controller-event-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-event-handler.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_EVENT_HANDLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ // INTERNAL INCLUDES #include +#include #include -#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-controller-impl-data-clearer.cpp b/dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.cpp similarity index 98% rename from dali-toolkit/internal/text/text-controller-impl-data-clearer.cpp rename to dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.cpp index 87099da..3822fb3 100644 --- a/dali-toolkit/internal/text/text-controller-impl-data-clearer.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,10 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES -#include +#include #include namespace Dali::Toolkit::Text diff --git a/dali-toolkit/internal/text/text-controller-impl-data-clearer.h b/dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.h similarity index 96% rename from dali-toolkit/internal/text/text-controller-impl-data-clearer.h rename to dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.h index 87d6e24..878b285 100644 --- a/dali-toolkit/internal/text/text-controller-impl-data-clearer.h +++ b/dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_DATA_CLEARER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include namespace Dali::Toolkit::Text { diff --git a/dali-toolkit/internal/text/text-controller-impl-event-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-impl-event-handler.cpp similarity index 99% rename from dali-toolkit/internal/text/text-controller-impl-event-handler.cpp rename to dali-toolkit/internal/text/controller/text-controller-impl-event-handler.cpp index 1ed8c7f..9dcf07a 100644 --- a/dali-toolkit/internal/text/text-controller-impl-event-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl-event-handler.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include diff --git a/dali-toolkit/internal/text/text-controller-impl-event-handler.h b/dali-toolkit/internal/text/controller/text-controller-impl-event-handler.h similarity index 97% rename from dali-toolkit/internal/text/text-controller-impl-event-handler.h rename to dali-toolkit/internal/text/controller/text-controller-impl-event-handler.h index 82e5c78..ca93586 100644 --- a/dali-toolkit/internal/text/text-controller-impl-event-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-impl-event-handler.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_EVENT_HANDLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp similarity index 99% rename from dali-toolkit/internal/text/text-controller-impl-model-updater.cpp rename to dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp index de18e85..8b6b639 100644 --- a/dali-toolkit/internal/text/text-controller-impl-model-updater.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include diff --git a/dali-toolkit/internal/text/text-controller-impl-model-updater.h b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.h similarity index 91% rename from dali-toolkit/internal/text/text-controller-impl-model-updater.h rename to dali-toolkit/internal/text/controller/text-controller-impl-model-updater.h index 2c5dd8c..928d8c5 100644 --- a/dali-toolkit/internal/text/text-controller-impl-model-updater.h +++ b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_MODEL_UPDATER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include namespace Dali::Toolkit::Text { diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp similarity index 99% rename from dali-toolkit/internal/text/text-controller-impl.cpp rename to dali-toolkit/internal/text/controller/text-controller-impl.cpp index 7fac661..e5086d6 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -30,11 +30,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/controller/text-controller-impl.h similarity index 99% rename from dali-toolkit/internal/text/text-controller-impl.h rename to dali-toolkit/internal/text/controller/text-controller-impl.h index 23b020c..faa8772 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/controller/text-controller-impl.h @@ -26,7 +26,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include #include diff --git a/dali-toolkit/internal/text/text-controller-input-font-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp similarity index 99% rename from dali-toolkit/internal/text/text-controller-input-font-handler.cpp rename to dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp index 988ddd1..a1e6214 100644 --- a/dali-toolkit/internal/text/text-controller-input-font-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp @@ -16,13 +16,13 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-controller-input-font-handler.h b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h similarity index 94% rename from dali-toolkit/internal/text/text-controller-input-font-handler.h rename to dali-toolkit/internal/text/controller/text-controller-input-font-handler.h index f76bc41..2ac7464 100644 --- a/dali-toolkit/internal/text/text-controller-input-font-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_INPUT_FONT_HANDLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/text-controller-input-properties.cpp b/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp similarity index 91% rename from dali-toolkit/internal/text/text-controller-input-properties.cpp rename to dali-toolkit/internal/text/controller/text-controller-input-properties.cpp index 99ef15a..f410187 100644 --- a/dali-toolkit/internal/text/text-controller-input-properties.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES //#include @@ -28,12 +28,12 @@ // INTERNAL INCLUDES #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include namespace diff --git a/dali-toolkit/internal/text/text-controller-input-properties.h b/dali-toolkit/internal/text/controller/text-controller-input-properties.h similarity index 71% rename from dali-toolkit/internal/text/text-controller-input-properties.h rename to dali-toolkit/internal/text/controller/text-controller-input-properties.h index d453b5f..b0736f7 100644 --- a/dali-toolkit/internal/text/text-controller-input-properties.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-properties.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_INPUT_PROPERTIES_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,18 +23,7 @@ #include // INTERNAL INCLUDES -#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include +#include namespace Dali::Toolkit::Text { diff --git a/dali-toolkit/internal/text/text-controller-placeholder-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp similarity index 98% rename from dali-toolkit/internal/text/text-controller-placeholder-handler.cpp rename to dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp index 312ecb5..da15a43 100644 --- a/dali-toolkit/internal/text/text-controller-placeholder-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,14 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES #include -#include +#include #include #include diff --git a/dali-toolkit/internal/text/text-controller-placeholder-handler.h b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h similarity index 96% rename from dali-toolkit/internal/text/text-controller-placeholder-handler.h rename to dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h index 9c81eb1..c7107c9 100644 --- a/dali-toolkit/internal/text/text-controller-placeholder-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_PLACEHOLDER_HANDLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include // INTERNAL INCLUDES -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/text-controller-relayouter.cpp b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp similarity index 99% rename from dali-toolkit/internal/text/text-controller-relayouter.cpp rename to dali-toolkit/internal/text/controller/text-controller-relayouter.cpp index 527bb99..3b0c4c3 100644 --- a/dali-toolkit/internal/text/text-controller-relayouter.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-relayouter.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -24,8 +24,8 @@ // INTERNAL INCLUDES #include -#include -#include +#include +#include namespace { diff --git a/dali-toolkit/internal/text/text-controller-relayouter.h b/dali-toolkit/internal/text/controller/text-controller-relayouter.h similarity index 97% rename from dali-toolkit/internal/text/text-controller-relayouter.h rename to dali-toolkit/internal/text/controller/text-controller-relayouter.h index a98ed53..ca4e666 100644 --- a/dali-toolkit/internal/text/text-controller-relayouter.h +++ b/dali-toolkit/internal/text/controller/text-controller-relayouter.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_RELAYOUTER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ #include // INTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-controller-text-updater.cpp b/dali-toolkit/internal/text/controller/text-controller-text-updater.cpp similarity index 97% rename from dali-toolkit/internal/text/text-controller-text-updater.cpp rename to dali-toolkit/internal/text/controller/text-controller-text-updater.cpp index 35408da..addb91a 100644 --- a/dali-toolkit/internal/text/text-controller-text-updater.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-text-updater.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -26,9 +26,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include namespace @@ -473,6 +473,7 @@ bool Controller::TextUpdater::RemoveText( UpdateInputStyleType type) { bool removed = false; + bool removeAll = false; Controller::Impl& impl = *controller.mImpl; EventData*& eventData = impl.mEventData; @@ -526,9 +527,14 @@ bool Controller::TextUpdater::RemoveText( numberOfCharacters = currentText.Count() - cursorIndex; } + if((cursorIndex == 0) && (currentText.Count() - numberOfCharacters == 0)) + { + removeAll = true; + } + TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo; - if(eventData->mPreEditFlag || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time. + if(eventData->mPreEditFlag || removeAll || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time. ((cursorIndex + numberOfCharacters) <= textUpdateInfo.mPreviousNumberOfCharacters)) { // Mark the paragraphs to be updated. @@ -574,7 +580,7 @@ bool Controller::TextUpdater::RemoveText( // If the number of current text and the number of characters to be deleted are same, // it means all texts should be removed and all Preedit variables should be initialized. - if((currentText.Count() - numberOfCharacters == 0) && (cursorIndex == 0)) + if(removeAll) { impl.ClearPreEditFlag(); textUpdateInfo.mNumberOfCharactersToAdd = 0; @@ -617,6 +623,7 @@ bool Controller::TextUpdater::RemoveText( } DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", &controller, numberOfCharacters); + removeAll = false; removed = true; } } diff --git a/dali-toolkit/internal/text/text-controller-text-updater.h b/dali-toolkit/internal/text/controller/text-controller-text-updater.h similarity index 96% rename from dali-toolkit/internal/text/text-controller-text-updater.h rename to dali-toolkit/internal/text/controller/text-controller-text-updater.h index 1070966..47403f6 100644 --- a/dali-toolkit/internal/text/text-controller-text-updater.h +++ b/dali-toolkit/internal/text/controller/text-controller-text-updater.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_UPDATER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp similarity index 98% rename from dali-toolkit/internal/text/text-controller.cpp rename to dali-toolkit/internal/text/controller/text-controller.cpp index 1a07af5..5f775f7 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -28,14 +28,14 @@ // INTERNAL INCLUDES #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h similarity index 100% rename from dali-toolkit/internal/text/text-controller.h rename to dali-toolkit/internal/text/controller/text-controller.h diff --git a/dali-toolkit/internal/text/markup-processor-anchor.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-anchor.cpp similarity index 85% rename from dali-toolkit/internal/text/markup-processor-anchor.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-anchor.cpp index 771ff4e..87789e3 100644 --- a/dali-toolkit/internal/text/markup-processor-anchor.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-anchor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-anchor.h b/dali-toolkit/internal/text/markup-processor/markup-processor-anchor.h similarity index 90% rename from dali-toolkit/internal/text/markup-processor-anchor.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-anchor.h index 7c1d181..5559e0a 100644 --- a/dali-toolkit/internal/text/markup-processor-anchor.h +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-anchor.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_ANCHOR_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dali-toolkit/internal/text/markup-processor-attribute-helper-functions.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-attribute-helper-functions.cpp similarity index 86% rename from dali-toolkit/internal/text/markup-processor-attribute-helper-functions.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-attribute-helper-functions.cpp index da00996..5554c22 100644 --- a/dali-toolkit/internal/text/markup-processor-attribute-helper-functions.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-attribute-helper-functions.cpp @@ -16,10 +16,10 @@ */ // FILE HEADER -#include +#include // INTERNAL INCLUDES -#include +#include // EXTERNAL INCLUDES #include diff --git a/dali-toolkit/internal/text/markup-processor-attribute-helper-functions.h b/dali-toolkit/internal/text/markup-processor/markup-processor-attribute-helper-functions.h similarity index 98% rename from dali-toolkit/internal/text/markup-processor-attribute-helper-functions.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-attribute-helper-functions.h index 52771b5..ab7e07e 100644 --- a/dali-toolkit/internal/text/markup-processor-attribute-helper-functions.h +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-attribute-helper-functions.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_ATTRIBUTE_HELPER_FUNCTIONS_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dali-toolkit/internal/text/markup-processor-background.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-background.cpp similarity index 83% rename from dali-toolkit/internal/text/markup-processor-background.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-background.cpp index 7f0e8ae..303fff7 100644 --- a/dali-toolkit/internal/text/markup-processor-background.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-background.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-background.h b/dali-toolkit/internal/text/markup-processor/markup-processor-background.h similarity index 90% rename from dali-toolkit/internal/text/markup-processor-background.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-background.h index 331d2c8..9420dac 100644 --- a/dali-toolkit/internal/text/markup-processor-background.h +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-background.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_BACKGROUND_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dali-toolkit/internal/text/markup-processor-character-spacing.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-character-spacing.cpp similarity index 85% rename from dali-toolkit/internal/text/markup-processor-character-spacing.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-character-spacing.cpp index cce30dd..f18efe3 100644 --- a/dali-toolkit/internal/text/markup-processor-character-spacing.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-character-spacing.cpp @@ -16,15 +16,15 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES #include -#include -#include +#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-character-spacing.h b/dali-toolkit/internal/text/markup-processor/markup-processor-character-spacing.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor-character-spacing.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-character-spacing.h diff --git a/dali-toolkit/internal/text/markup-processor-color.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-color.cpp similarity index 90% rename from dali-toolkit/internal/text/markup-processor-color.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-color.cpp index 4fb95ef..1a5ce73 100644 --- a/dali-toolkit/internal/text/markup-processor-color.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-color.cpp @@ -16,14 +16,14 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-color.h b/dali-toolkit/internal/text/markup-processor/markup-processor-color.h similarity index 96% rename from dali-toolkit/internal/text/markup-processor-color.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-color.h index 02210fb..2d8be1e 100644 --- a/dali-toolkit/internal/text/markup-processor-color.h +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-color.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_COLOR_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dali-toolkit/internal/text/markup-processor-embedded-item.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp similarity index 91% rename from dali-toolkit/internal/text/markup-processor-embedded-item.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp index 94d6fd4..8e9ec06 100644 --- a/dali-toolkit/internal/text/markup-processor-embedded-item.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-embedded-item.h b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.h similarity index 95% rename from dali-toolkit/internal/text/markup-processor-embedded-item.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.h index 1677244..ed6a371 100644 --- a/dali-toolkit/internal/text/markup-processor-embedded-item.h +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_EMBEDDED_ITEM_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dali-toolkit/internal/text/markup-processor-font.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp similarity index 93% rename from dali-toolkit/internal/text/markup-processor-font.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp index 802f9e9..133d7fa 100644 --- a/dali-toolkit/internal/text/markup-processor-font.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -24,8 +24,8 @@ // INTERNAL INCLUDES #include -#include -#include +#include +#include #include #include diff --git a/dali-toolkit/internal/text/markup-processor-font.h b/dali-toolkit/internal/text/markup-processor/markup-processor-font.h similarity index 97% rename from dali-toolkit/internal/text/markup-processor-font.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-font.h index 6461451..cc2b561 100644 --- a/dali-toolkit/internal/text/markup-processor-font.h +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-font.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_MARKUP_PROCESSOR_FONT_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dali-toolkit/internal/text/markup-processor-helper-functions.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp similarity index 99% rename from dali-toolkit/internal/text/markup-processor-helper-functions.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp index 9f4c34d..b0ac16b 100644 --- a/dali-toolkit/internal/text/markup-processor-helper-functions.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include diff --git a/dali-toolkit/internal/text/markup-processor-helper-functions.h b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor-helper-functions.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.h diff --git a/dali-toolkit/internal/text/markup-processor-paragraph.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-paragraph.cpp similarity index 93% rename from dali-toolkit/internal/text/markup-processor-paragraph.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-paragraph.cpp index e470bec..8676198 100644 --- a/dali-toolkit/internal/text/markup-processor-paragraph.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-paragraph.cpp @@ -16,14 +16,14 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES #include -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-paragraph.h b/dali-toolkit/internal/text/markup-processor/markup-processor-paragraph.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor-paragraph.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-paragraph.h diff --git a/dali-toolkit/internal/text/markup-processor-span.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-span.cpp similarity index 91% rename from dali-toolkit/internal/text/markup-processor-span.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-span.cpp index 3e20c6f..5f8dfa2 100644 --- a/dali-toolkit/internal/text/markup-processor-span.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-span.cpp @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -24,11 +24,11 @@ // INTERNAL INCLUDES #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/markup-processor-span.h b/dali-toolkit/internal/text/markup-processor/markup-processor-span.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor-span.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-span.h diff --git a/dali-toolkit/internal/text/markup-processor-strikethrough.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-strikethrough.cpp similarity index 93% rename from dali-toolkit/internal/text/markup-processor-strikethrough.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-strikethrough.cpp index 10e104c..5d08c93 100644 --- a/dali-toolkit/internal/text/markup-processor-strikethrough.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-strikethrough.cpp @@ -16,14 +16,14 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES -#include -#include +#include +#include #include #include diff --git a/dali-toolkit/internal/text/markup-processor-strikethrough.h b/dali-toolkit/internal/text/markup-processor/markup-processor-strikethrough.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor-strikethrough.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-strikethrough.h diff --git a/dali-toolkit/internal/text/markup-processor-underline.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-underline.cpp similarity index 95% rename from dali-toolkit/internal/text/markup-processor-underline.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor-underline.cpp index 08b9f1e..ac1b0ae 100644 --- a/dali-toolkit/internal/text/markup-processor-underline.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-underline.cpp @@ -16,14 +16,14 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include // INTERNAL INCLUDES -#include -#include +#include +#include #include #include #include diff --git a/dali-toolkit/internal/text/markup-processor-underline.h b/dali-toolkit/internal/text/markup-processor/markup-processor-underline.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor-underline.h rename to dali-toolkit/internal/text/markup-processor/markup-processor-underline.h diff --git a/dali-toolkit/internal/text/markup-processor.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor.cpp similarity index 96% rename from dali-toolkit/internal/text/markup-processor.cpp rename to dali-toolkit/internal/text/markup-processor/markup-processor.cpp index 1047411..b19cdb1 100644 --- a/dali-toolkit/internal/text/markup-processor.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor.cpp @@ -16,7 +16,7 @@ */ // FILE HEADER -#include +#include // EXTERNAL INCLUDES #include @@ -25,17 +25,17 @@ // INTERNAL INCLUDES #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -941,10 +941,13 @@ void ResizeModelVectors(MarkupProcessData& markupProcessData, markupProcessData.characterSpacingCharacterRuns.Resize(characterSpacingCharacterRunIndex); #ifdef DEBUG_ENABLED - for(uint32_t i = 0; gLogFilter->IsEnabledFor(Debug::Verbose) && i < colorRunIndex; ++i) + if(gLogFilter->IsEnabledFor(Debug::Verbose)) { - ColorRun& run = markupProcessData.colorRuns[i]; - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "run[%d] index: %d, length: %d, color %f,%f,%f,%f\n", i, run.characterRun.characterIndex, run.characterRun.numberOfCharacters, run.color.r, run.color.g, run.color.b, run.color.a); + for(uint32_t i = 0; i < colorRunIndex; ++i) + { + ColorRun& run = markupProcessData.colorRuns[i]; + DALI_LOG_INFO(gLogFilter, Debug::Verbose, "run[%d] index: %d, length: %d, color %f,%f,%f,%f\n", i, run.characterRun.characterIndex, run.characterRun.numberOfCharacters, run.color.r, run.color.g, run.color.b, run.color.a); + } } #endif } diff --git a/dali-toolkit/internal/text/markup-processor.h b/dali-toolkit/internal/text/markup-processor/markup-processor.h similarity index 100% rename from dali-toolkit/internal/text/markup-processor.h rename to dali-toolkit/internal/text/markup-processor/markup-processor.h diff --git a/dali-toolkit/internal/text/property-string-parser.cpp b/dali-toolkit/internal/text/property-string-parser.cpp index ec0fc94..9265472 100644 --- a/dali-toolkit/internal/text/property-string-parser.cpp +++ b/dali-toolkit/internal/text/property-string-parser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp index 1a1063c..1d8731d 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -802,11 +802,14 @@ struct AtlasRenderer::Impl Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics(); DALI_LOG_INFO(gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n", metrics.mGlyphCount, metrics.mAtlasMetrics.mAtlasCount, metrics.mAtlasMetrics.mTextureMemoryUsed / 1024); - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "%s\n", metrics.mVerboseGlyphCounts.c_str()); - - for(uint32_t i = 0; gLogFilter->IsEnabledFor(Debug::Verbose) && i < metrics.mAtlasMetrics.mAtlasCount; ++i) + if(gLogFilter->IsEnabledFor(Debug::Verbose)) { - DALI_LOG_INFO(gLogFilter, Debug::Verbose, " Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n", i + 1, i > 8 ? "" : " ", metrics.mAtlasMetrics.mAtlasMetrics[i].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA", metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mBlocksUsed, metrics.mAtlasMetrics.mAtlasMetrics[i].mTotalBlocks); + DALI_LOG_INFO(gLogFilter, Debug::Verbose, "%s\n", metrics.mVerboseGlyphCounts.c_str()); + + for(uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i) + { + DALI_LOG_INFO(gLogFilter, Debug::Verbose, " Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n", i + 1, i > 8 ? "" : " ", metrics.mAtlasMetrics.mAtlasMetrics[i].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA", metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mBlocksUsed, metrics.mAtlasMetrics.mAtlasMetrics[i].mTotalBlocks); + } } #endif } diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp index 14f3da7..5543d79 100644 --- a/dali-toolkit/internal/text/rendering/text-typesetter.cpp +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -983,7 +983,7 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect CombineImageBuffer(imageBuffer, outlineImageBuffer, bufferWidth, bufferHeight, true); } - // @todo. Support shadow and underline for partial text later on. + // @todo. Support shadow for partial text later on. // Generate the shadow if enabled const Vector2& shadowOffset = mModel->GetShadowOffset(); @@ -1004,17 +1004,6 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect CombineImageBuffer(imageBuffer, shadowImageBuffer, bufferWidth, bufferHeight, true); } - // Generate the underline if enabled - const bool underlineEnabled = mModel->IsUnderlineEnabled(); - if(underlineEnabled && RENDER_OVERLAY_STYLE == behaviour) - { - // Create the image buffer for underline - Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, penX, penY, startIndexOfGlyphs, endIndexOfGlyphs); - - // Combine the two buffers - CombineImageBuffer(imageBuffer, underlineImageBuffer, bufferWidth, bufferHeight, true); - } - // Generate the background if enabled const bool backgroundEnabled = mModel->IsBackgroundEnabled(); const bool backgroundMarkupSet = mModel->IsMarkupBackgroundColorSet(); @@ -1040,20 +1029,40 @@ PixelData Typesetter::Render(const Vector2& size, Toolkit::DevelText::TextDirect CombineImageBuffer(imageBuffer, backgroundImageBuffer, bufferWidth, bufferHeight, true); } - // Generate the strikethrough if enabled - const bool strikethroughEnabled = mModel->IsStrikethroughEnabled(); - if(strikethroughEnabled && RENDER_OVERLAY_STYLE == behaviour) + if(RENDER_OVERLAY_STYLE == behaviour) { - // Create the image buffer for strikethrough - Devel::PixelBuffer strikethroughImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_STRIKETHROUGH, ignoreHorizontalAlignment, pixelFormat, penX, penY, 0u, endIndexOfGlyphs); + if(mModel->IsUnderlineEnabled()) + { + // Create the image buffer for underline + Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, penX, penY, startIndexOfGlyphs, endIndexOfGlyphs); - // Combine the two buffers - CombineImageBuffer(imageBuffer, strikethroughImageBuffer, bufferWidth, bufferHeight, true); - } + // Combine the two buffers + CombineImageBuffer(imageBuffer, underlineImageBuffer, bufferWidth, bufferHeight, true); + } + + if(mModel->IsStrikethroughEnabled()) + { + // Create the image buffer for strikethrough + Devel::PixelBuffer strikethroughImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_STRIKETHROUGH, ignoreHorizontalAlignment, pixelFormat, penX, penY, 0u, endIndexOfGlyphs); - // Markup-Processor + // Combine the two buffers + CombineImageBuffer(imageBuffer, strikethroughImageBuffer, bufferWidth, bufferHeight, true); + } + + // Markup-Processor for overlay styles + if(mModel->IsMarkupProcessorEnabled()) + { + if(mModel->IsMarkupUnderlineSet()) + { + imageBuffer = ApplyUnderlineMarkupImageBuffer(imageBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, penX, penY); + } - imageBuffer = ApplyMarkupProcessorOnPixelBuffer(imageBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, penX, penY); + if(mModel->IsMarkupStrikethroughSet()) + { + imageBuffer = ApplyStrikethroughMarkupImageBuffer(imageBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, penX, penY); + } + } + } } // Create the final PixelData for the combined image buffer @@ -1490,20 +1499,6 @@ Devel::PixelBuffer Typesetter::ApplyStrikethroughMarkupImageBuffer(Devel::PixelB return topPixelBuffer; } -Devel::PixelBuffer Typesetter::ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t bufferWidth, const uint32_t bufferHeight, const bool ignoreHorizontalAlignment, const Pixel::Format pixelFormat, const int32_t horizontalOffset, const int32_t verticalOffset) -{ - // Apply the markup-Processor if enabled - const bool markupProcessorEnabled = mModel->IsMarkupProcessorEnabled(); - if(markupProcessorEnabled) - { - topPixelBuffer = ApplyUnderlineMarkupImageBuffer(topPixelBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset); - - topPixelBuffer = ApplyStrikethroughMarkupImageBuffer(topPixelBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset); - } - - return topPixelBuffer; -} - Typesetter::Typesetter(const ModelInterface* const model) : mModel(new ViewModel(model)) { diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.h b/dali-toolkit/internal/text/rendering/text-typesetter.h index 3a71c31..296126e 100644 --- a/dali-toolkit/internal/text/rendering/text-typesetter.h +++ b/dali-toolkit/internal/text/rendering/text-typesetter.h @@ -147,21 +147,6 @@ private: Devel::PixelBuffer CreateImageBuffer(const uint32_t bufferWidth, const uint32_t bufferHeight, const Typesetter::Style style, const bool ignoreHorizontalAlignment, const Pixel::Format pixelFormat, const int32_t horizontalOffset, const int32_t verticalOffset, const TextAbstraction::GlyphIndex fromGlyphIndex, const TextAbstraction::GlyphIndex toGlyphIndex); /** - * @brief Apply behaviour of tags if the markup-processor is enabled. - * - * @param[in] topPixelBuffer The top layer buffer. - * @param[in] bufferWidth The width of the image buffer. - * @param[in] bufferHeight The height of the image buffer. - * @param[in] ignoreHorizontalAlignment Whether to ignore the horizontal alignment, not ignored by default. - * @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8). - * @param[in] horizontalOffset The horizontal offset to be added to the glyph's position. - * @param[in] verticalOffset The vertical offset to be added to the glyph's position. - * - * @return The image buffer with the markup. - */ - Devel::PixelBuffer ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const uint32_t bufferWidth, const uint32_t bufferHeight, const bool ignoreHorizontalAlignment, const Pixel::Format pixelFormat, const int32_t horizontalOffset, const int32_t verticalOffset); - - /** * @brief Apply markup underline tags. * * The properties on TextLabel override the behavior of Markup. diff --git a/dali-toolkit/internal/text/rendering/view-model.cpp b/dali-toolkit/internal/text/rendering/view-model.cpp index 9cfba93..0c4aeb3 100644 --- a/dali-toolkit/internal/text/rendering/view-model.cpp +++ b/dali-toolkit/internal/text/rendering/view-model.cpp @@ -245,6 +245,11 @@ bool ViewModel::IsUnderlineEnabled() const return mModel->IsUnderlineEnabled(); } +bool const ViewModel::IsMarkupUnderlineSet() const +{ + return mModel->IsMarkupUnderlineSet(); +} + float ViewModel::GetUnderlineHeight() const { return mModel->GetUnderlineHeight(); @@ -699,6 +704,11 @@ bool ViewModel::IsStrikethroughEnabled() const return mModel->IsStrikethroughEnabled(); } +bool const ViewModel::IsMarkupStrikethroughSet() const +{ + return mModel->IsMarkupStrikethroughSet(); +} + Length ViewModel::GetNumberOfStrikethroughRuns() const { return mModel->GetNumberOfStrikethroughRuns(); diff --git a/dali-toolkit/internal/text/rendering/view-model.h b/dali-toolkit/internal/text/rendering/view-model.h index c7b0b18..c127ebb 100644 --- a/dali-toolkit/internal/text/rendering/view-model.h +++ b/dali-toolkit/internal/text/rendering/view-model.h @@ -207,6 +207,11 @@ public: bool IsUnderlineEnabled() const override; /** + * @copydoc ModelInterface::IsMarkupUnderlineSet() + */ + bool const IsMarkupUnderlineSet() const override; + + /** * @copydoc ModelInterface::GetUnderlineHeight() */ float GetUnderlineHeight() const override; @@ -303,13 +308,27 @@ public: */ void ElideGlyphs(); + /** + * @copydoc ModelInterface::GetStrikethroughHeight() + */ float GetStrikethroughHeight() const override; + /** + * @copydoc ModelInterface::GetStrikethroughColor() + */ const Vector4& GetStrikethroughColor() const override; + /** + * @copydoc ModelInterface::IsStrikethroughEnabled() + */ bool IsStrikethroughEnabled() const override; /** + * @copydoc ModelInterface::IsMarkupStrikethroughSet() + */ + bool const IsMarkupStrikethroughSet() const override; + + /** * @copydoc ModelInterface::GetNumberOfStrikethroughRuns() */ Length GetNumberOfStrikethroughRuns() const override; diff --git a/dali-toolkit/internal/text/text-effects-style.cpp b/dali-toolkit/internal/text/text-effects-style.cpp index 90c570a..c15a11d 100644 --- a/dali-toolkit/internal/text/text-effects-style.cpp +++ b/dali-toolkit/internal/text/text-effects-style.cpp @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include #include #include diff --git a/dali-toolkit/internal/text/text-effects-style.h b/dali-toolkit/internal/text/text-effects-style.h index d87e810..0ceeab3 100644 --- a/dali-toolkit/internal/text/text-effects-style.h +++ b/dali-toolkit/internal/text/text-effects-style.h @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include #include #include diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index 117268a..ce5e860 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include #include namespace Dali diff --git a/dali-toolkit/internal/text/text-font-style.h b/dali-toolkit/internal/text/text-font-style.h index c85ec58..e2955c7 100644 --- a/dali-toolkit/internal/text/text-font-style.h +++ b/dali-toolkit/internal/text/text-font-style.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_TEXT_FONT_STYLE_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include // INTERNAL INCLUDES -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-model-interface.h b/dali-toolkit/internal/text/text-model-interface.h index 0f2bd7b..0ccbb45 100644 --- a/dali-toolkit/internal/text/text-model-interface.h +++ b/dali-toolkit/internal/text/text-model-interface.h @@ -262,6 +262,13 @@ public: virtual bool IsUnderlineEnabled() const = 0; /** + * @brief checks if there is underline set using markup. + * + * @return boolean if there is underline set using markup. + */ + virtual bool const IsMarkupUnderlineSet() const = 0; + + /** * @brief Retrieves the underline height override * * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height @@ -376,6 +383,13 @@ public: virtual bool IsStrikethroughEnabled() const = 0; /** + * @brief checks if there is strikethrough set using markup. + * + * @return boolean if there is strikethrough set using markup. + */ + virtual bool const IsMarkupStrikethroughSet() const = 0; + + /** * @brief Retrieves the strikethrough height override * * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height diff --git a/dali-toolkit/internal/text/text-model.cpp b/dali-toolkit/internal/text/text-model.cpp index 0ac67ca..ba6dbcf 100644 --- a/dali-toolkit/internal/text/text-model.cpp +++ b/dali-toolkit/internal/text/text-model.cpp @@ -187,6 +187,11 @@ bool Model::IsUnderlineEnabled() const return mVisualModel->IsUnderlineEnabled(); } +bool const Model::IsMarkupUnderlineSet() const +{ + return (mVisualModel->mUnderlineRuns.Count() > 0u); +} + float Model::GetUnderlineHeight() const { return mVisualModel->GetUnderlineHeight(); @@ -266,6 +271,11 @@ bool Model::IsStrikethroughEnabled() const return mVisualModel->IsStrikethroughEnabled(); } +bool const Model::IsMarkupStrikethroughSet() const +{ + return (mVisualModel->mStrikethroughRuns.Count() > 0u); +} + float Model::GetStrikethroughHeight() const { return mVisualModel->GetStrikethroughHeight(); diff --git a/dali-toolkit/internal/text/text-model.h b/dali-toolkit/internal/text/text-model.h index 416df17..a3a42a2 100644 --- a/dali-toolkit/internal/text/text-model.h +++ b/dali-toolkit/internal/text/text-model.h @@ -205,6 +205,11 @@ public: bool IsUnderlineEnabled() const override; /** + * @copydoc ModelInterface::IsMarkupUnderlineSet() + */ + bool const IsMarkupUnderlineSet() const override; + + /** * @copydoc ModelInterface::GetUnderlineHeight() */ float GetUnderlineHeight() const override; @@ -274,11 +279,26 @@ public: */ Length GetHyphensCount() const override; + /** + * @copydoc ModelInterface::GetStrikethroughHeight() + */ float GetStrikethroughHeight() const override; + /** + * @copydoc ModelInterface::GetStrikethroughColor() + */ const Vector4& GetStrikethroughColor() const override; + /** + * @copydoc ModelInterface::IsStrikethroughEnabled() + */ bool IsStrikethroughEnabled() const override; + + /** + * @copydoc ModelInterface::IsMarkupStrikethroughSet() + */ + bool const IsMarkupStrikethroughSet() const override; + /** * @copydoc ModelInterface::GetCharacterSpacing() */ diff --git a/dali-toolkit/internal/text/text-selection-handle-controller.cpp b/dali-toolkit/internal/text/text-selection-handle-controller.cpp index e4bf91c..fef3baa 100644 --- a/dali-toolkit/internal/text/text-selection-handle-controller.cpp +++ b/dali-toolkit/internal/text/text-selection-handle-controller.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include using namespace Dali; diff --git a/dali-toolkit/internal/text/text-selection-handle-controller.h b/dali-toolkit/internal/text/text-selection-handle-controller.h index 62032fd..a021009 100644 --- a/dali-toolkit/internal/text/text-selection-handle-controller.h +++ b/dali-toolkit/internal/text/text-selection-handle-controller.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_SELECTION_HANDLE_CONTROLLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali { diff --git a/dali-toolkit/internal/text/text-view-interface.h b/dali-toolkit/internal/text/text-view-interface.h index 98b420d..2fcf548 100644 --- a/dali-toolkit/internal/text/text-view-interface.h +++ b/dali-toolkit/internal/text/text-view-interface.h @@ -175,6 +175,13 @@ public: virtual bool IsUnderlineEnabled() const = 0; /** + * @brief checks if there is underline set using markup. + * + * @return boolean if there is underline set using markup. + */ + virtual bool const IsMarkupUnderlineSet() const = 0; + + /** * @brief Returns the hyphens glyph info. * * @return hyphens glyph info. @@ -311,6 +318,13 @@ public: virtual bool IsStrikethroughEnabled() const = 0; /** + * @brief checks if there is strikethrough set using markup. + * + * @return boolean if there is strikethrough set using markup. + */ + virtual bool const IsMarkupStrikethroughSet() const = 0; + + /** * @brief Retrieves the strikethrough height override * * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height diff --git a/dali-toolkit/internal/text/text-view.cpp b/dali-toolkit/internal/text/text-view.cpp index 0be5ac6..0b81484 100644 --- a/dali-toolkit/internal/text/text-view.cpp +++ b/dali-toolkit/internal/text/text-view.cpp @@ -670,6 +670,11 @@ bool View::IsUnderlineEnabled() const return false; } +bool const View::IsMarkupUnderlineSet() const +{ + return (GetNumberOfUnderlineRuns() > 0u); +} + const GlyphInfo* View::GetHyphens() const { if(mImpl->mVisualModel) @@ -865,6 +870,11 @@ bool View::IsStrikethroughEnabled() const return (mImpl->mVisualModel) ? mImpl->mVisualModel->IsStrikethroughEnabled() : false; } +bool const View::IsMarkupStrikethroughSet() const +{ + return (GetNumberOfStrikethroughRuns() > 0u); +} + float View::GetStrikethroughHeight() const { return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughHeight() : 0.0f; diff --git a/dali-toolkit/internal/text/text-view.h b/dali-toolkit/internal/text/text-view.h index 93542cc..7cccf19 100644 --- a/dali-toolkit/internal/text/text-view.h +++ b/dali-toolkit/internal/text/text-view.h @@ -135,6 +135,11 @@ public: bool IsUnderlineEnabled() const override; /** + * @copydoc Dali::Toolkit::Text::ViewInterface::IsMarkupUnderlineSet() + */ + bool const IsMarkupUnderlineSet() const; + + /** * @copydoc Dali::Toolkit::Text::ViewInterface::GetHyphens() */ const GlyphInfo* GetHyphens() const override; @@ -232,6 +237,11 @@ public: bool IsStrikethroughEnabled() const override; /** + * @copydoc Dali::Toolkit::Text::ViewInterface::IsMarkupStrikethroughSet() + */ + bool const IsMarkupStrikethroughSet() const; + + /** * @copydoc Dali::Toolkit::Text::ViewInterface::GetStrikethroughHeight() */ float GetStrikethroughHeight() const override; diff --git a/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp b/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp index 223208a..e23ee49 100644 --- a/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp +++ b/dali-toolkit/internal/texture-manager/texture-manager-impl.cpp @@ -39,7 +39,7 @@ constexpr auto DEFAULT_NUMBER_OF_REMOTE_LOADER_THREADS = size_t{8u}; constexpr auto NUMBER_OF_LOCAL_LOADER_THREADS_ENV = "DALI_TEXTURE_LOCAL_THREADS"; constexpr auto NUMBER_OF_REMOTE_LOADER_THREADS_ENV = "DALI_TEXTURE_REMOTE_THREADS"; -constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES_ENV"; +constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES"; size_t GetNumberOfThreads(const char* environmentVariable, size_t defaultValue) { diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp index 1017ae0..4b547b4 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp @@ -102,12 +102,9 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual(VisualFactoryCache& factory // the rasterized image is with pre-multiplied alpha format mImpl->mFlags |= Visual::Base::Impl::IS_PREMULTIPLIED_ALPHA; - if(!mVectorAnimationTask->Load(mUrl.GetUrl())) - { - mLoadFailed = true; - } + mVectorAnimationTask->RequestLoad(mUrl.GetUrl()); - mVectorAnimationTask->UploadCompletedSignal().Connect(this, &AnimatedVectorImageVisual::OnUploadCompleted); + mVectorAnimationTask->ResourceReadySignal().Connect(this, &AnimatedVectorImageVisual::OnResourceReady); mVectorAnimationTask->SetAnimationFinishedCallback(new EventThreadCallback(MakeCallback(this, &AnimatedVectorImageVisual::OnAnimationFinished))); auto& vectorAnimationManager = mFactoryCache.GetVectorAnimationManager(); @@ -127,7 +124,7 @@ AnimatedVectorImageVisual::~AnimatedVectorImageVisual() } // Finalize animation task and disconnect the signal in the main thread - mVectorAnimationTask->UploadCompletedSignal().Disconnect(this, &AnimatedVectorImageVisual::OnUploadCompleted); + mVectorAnimationTask->ResourceReadySignal().Disconnect(this, &AnimatedVectorImageVisual::OnResourceReady); mVectorAnimationTask->Finalize(); } } @@ -146,10 +143,28 @@ void AnimatedVectorImageVisual::GetNaturalSize(Vector2& naturalSize) } else { - uint32_t width, height; - mVectorAnimationTask->GetDefaultSize(width, height); - naturalSize.x = width; - naturalSize.y = height; + if(mLoadFailed && mImpl->mRenderer) + { + // Load failed, use broken image size + auto textureSet = mImpl->mRenderer.GetTextures(); + if(textureSet && textureSet.GetTextureCount()) + { + auto texture = textureSet.GetTexture(0); + if(texture) + { + naturalSize.x = texture.GetWidth(); + naturalSize.y = texture.GetHeight(); + return; + } + } + } + else + { + uint32_t width, height; + mVectorAnimationTask->GetDefaultSize(width, height); + naturalSize.x = width; + naturalSize.y = height; + } } DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::GetNaturalSize: w = %f, h = %f [%p]\n", naturalSize.width, naturalSize.height, this); @@ -308,6 +323,8 @@ void AnimatedVectorImageVisual::OnInitialize(void) // Register transform properties mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + + mVectorAnimationTask->SetRenderer(mImpl->mRenderer); } void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor) @@ -319,16 +336,13 @@ void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor) if(mLoadFailed) { - Vector2 imageSize = Vector2::ZERO; - imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); + Vector2 imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); actor.AddRenderer(mImpl->mRenderer); ResourceReady(Toolkit::Visual::ResourceStatus::FAILED); } else { - mVectorAnimationTask->SetRenderer(mImpl->mRenderer); - // Add property notification for scaling & size mScaleNotification = actor.AddPropertyNotification(Actor::Property::WORLD_SCALE, StepCondition(0.1f, 1.0f)); mScaleNotification.NotifySignal().Connect(this, &AnimatedVectorImageVisual::OnScaleNotification); @@ -343,6 +357,15 @@ void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor) { DevelWindow::VisibilityChangedSignal(window).Connect(this, &AnimatedVectorImageVisual::OnWindowVisibilityChanged); } + + if(mImpl->mEventObserver) + { + // The visual needs it's size set before it can be rasterized hence request relayout once on stage + mImpl->mEventObserver->RelayoutRequest(*this); + } + + mAnimationData.resendFlag |= VectorAnimationTask::RESEND_NEED_RESOURCE_READY; + TriggerVectorRasterization(); } DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOnScene [%p]\n", this); @@ -351,7 +374,7 @@ void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor) void AnimatedVectorImageVisual::DoSetOffScene(Actor& actor) { StopAnimation(); - SendAnimationData(); + TriggerVectorRasterization(); if(mImpl->mRenderer) { @@ -374,8 +397,10 @@ void AnimatedVectorImageVisual::DoSetOffScene(Actor& actor) mPlacementActor.Reset(); // Reset the visual size to zero so that when adding the actor back to stage the rasterization is forced - mVisualSize = Vector2::ZERO; - mVisualScale = Vector2::ONE; + mVisualSize = Vector2::ZERO; + mVisualScale = Vector2::ONE; + mAnimationData.width = 0; + mAnimationData.height = 0; DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::DoSetOffScene [%p]\n", this); } @@ -398,7 +423,7 @@ void AnimatedVectorImageVisual::OnSetTransform() mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE; } - SendAnimationData(); + TriggerVectorRasterization(); } } @@ -464,19 +489,41 @@ void AnimatedVectorImageVisual::OnDoAction(const Property::Index actionId, const TriggerVectorRasterization(); } -void AnimatedVectorImageVisual::OnUploadCompleted() +void AnimatedVectorImageVisual::OnResourceReady(VectorAnimationTask::ResourceStatus status) { - // If weak handle is holding a placement actor, it is the time to add the renderer to actor. - Actor actor = mPlacementActor.GetHandle(); - if(actor && !mRendererAdded) + if(status == VectorAnimationTask::ResourceStatus::LOADED) { - actor.AddRenderer(mImpl->mRenderer); - mRendererAdded = true; + if(mImpl->mEventObserver) + { + mImpl->mEventObserver->RelayoutRequest(*this); + } + } + else + { + mLoadFailed = status == VectorAnimationTask::ResourceStatus::FAILED ? true : false; - ResourceReady(Toolkit::Visual::ResourceStatus::READY); + // If weak handle is holding a placement actor, it is the time to add the renderer to actor. + Actor actor = mPlacementActor.GetHandle(); + if(actor && !mRendererAdded) + { + if(!mLoadFailed) + { + actor.AddRenderer(mImpl->mRenderer); + ResourceReady(Toolkit::Visual::ResourceStatus::READY); + } + else + { + Vector2 imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); + mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); + actor.AddRenderer(mImpl->mRenderer); + ResourceReady(Toolkit::Visual::ResourceStatus::FAILED); + } - DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this); + mRendererAdded = true; + } } + + DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "Renderer is added (status = %d) [%p]\n", status, this); } void AnimatedVectorImageVisual::OnAnimationFinished() @@ -528,9 +575,12 @@ void AnimatedVectorImageVisual::SetVectorImageSize() uint32_t width = static_cast(mVisualSize.width * mVisualScale.width); uint32_t height = static_cast(mVisualSize.height * mVisualScale.height); - mAnimationData.width = width; - mAnimationData.height = height; - mAnimationData.resendFlag |= VectorAnimationTask::RESEND_SIZE; + if(mAnimationData.width != width || mAnimationData.height != height) + { + mAnimationData.width = width; + mAnimationData.height = height; + mAnimationData.resendFlag |= VectorAnimationTask::RESEND_SIZE; + } } void AnimatedVectorImageVisual::StopAnimation() @@ -562,7 +612,7 @@ void AnimatedVectorImageVisual::OnScaleNotification(PropertyNotification& source { Vector3 scale = actor.GetProperty(Actor::Property::WORLD_SCALE); - if(mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f) + if((mVisualScale.width != scale.width || mVisualScale.height != scale.height) && (mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f)) { mVisualScale.width = scale.width; mVisualScale.height = scale.height; @@ -582,16 +632,20 @@ void AnimatedVectorImageVisual::OnSizeNotification(PropertyNotification& source) Actor actor = mPlacementActor.GetHandle(); if(actor) { - Vector3 size = actor.GetCurrentProperty(Actor::Property::SIZE); - mVisualSize.width = size.width; - mVisualSize.height = size.height; + Vector3 size = actor.GetCurrentProperty(Actor::Property::SIZE); - DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSizeNotification: size = %f, %f [%p]\n", mVisualSize.width, mVisualSize.height, this); + if(mVisualSize.width != size.width || mVisualSize.height != size.height) + { + mVisualSize.width = size.width; + mVisualSize.height = size.height; - SetVectorImageSize(); - SendAnimationData(); + DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSizeNotification: size = %f, %f [%p]\n", mVisualSize.width, mVisualSize.height, this); - Stage::GetCurrent().KeepRendering(0.0f); // Trigger event processing + SetVectorImageSize(); + SendAnimationData(); + + Stage::GetCurrent().KeepRendering(0.0f); // Trigger event processing + } } } diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h index 4b14fc3..221cf23 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h @@ -168,9 +168,10 @@ private: void DoSetProperty(Property::Index index, const Property::Value& value); /** - * @brief Called when the texture upload is completed. + * @brief Called when the resource is ready. + * @param[in] status The resource status */ - void OnUploadCompleted(); + void OnResourceReady(VectorAnimationTask::ResourceStatus status); /** * @brief Event callback from rasterize thread. This is called after the animation is finished. diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-manager.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-manager.cpp index f23439d..7971b4d 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-manager.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ VectorAnimationManager::~VectorAnimationManager() if(mProcessorRegistered) { - Adaptor::Get().UnregisterProcessor(*this); + Adaptor::Get().UnregisterProcessor(*this, true); } for(auto observer : mLifecycleObservers) @@ -97,7 +97,7 @@ void VectorAnimationManager::RegisterEventCallback(CallbackBase* callback) if(!mProcessorRegistered) { - Adaptor::Get().RegisterProcessor(*this); + Adaptor::Get().RegisterProcessor(*this, true); // Use post processor to trigger after layoutting mProcessorRegistered = true; } } @@ -113,7 +113,7 @@ void VectorAnimationManager::UnregisterEventCallback(CallbackBase* callback) { if(Adaptor::IsAvailable()) { - Adaptor::Get().UnregisterProcessor(*this); + Adaptor::Get().UnregisterProcessor(*this, true); mProcessorRegistered = false; } } @@ -129,7 +129,7 @@ void VectorAnimationManager::Process(bool postProcessor) } mEventCallbacks.clear(); - Adaptor::Get().UnregisterProcessor(*this); + Adaptor::Get().UnregisterProcessor(*this, true); mProcessorRegistered = false; } diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index 86a37ab..b79f422 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,9 @@ VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache) mAnimationData(), mVectorAnimationThread(factoryCache.GetVectorAnimationManager().GetVectorAnimationThread()), mConditionalWait(), + mResourceReadySignal(), mAnimationFinishedTrigger(), + mLoadCompletedTrigger(new EventThreadCallback(MakeCallback(this, &VectorAnimationTask::OnLoadCompleted))), mPlayState(PlayState::STOPPED), mStopBehavior(DevelImageVisual::StopBehavior::CURRENT_FRAME), mLoopingMode(DevelImageVisual::LoopingMode::RESTART), @@ -72,8 +74,11 @@ VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache) mUpdateFrameNumber(false), mNeedAnimationFinishedTrigger(true), mAnimationDataUpdated(false), - mDestroyTask(false) + mDestroyTask(false), + mLoadRequest(false), + mLoadFailed(false) { + mVectorRenderer.UploadCompletedSignal().Connect(this, &VectorAnimationTask::OnUploadCompleted); } VectorAnimationTask::~VectorAnimationTask() @@ -96,13 +101,14 @@ void VectorAnimationTask::Finalize() mDestroyTask = true; } -bool VectorAnimationTask::Load(const std::string& url) +bool VectorAnimationTask::Load() { - mUrl = url; - if(!mVectorRenderer.Load(mUrl)) { DALI_LOG_ERROR("VectorAnimationTask::Load: Load failed [%s]\n", mUrl.c_str()); + mLoadRequest = false; + mLoadFailed = true; + mLoadCompletedTrigger->Trigger(); return false; } @@ -113,10 +119,8 @@ bool VectorAnimationTask::Load(const std::string& url) mFrameRate = mVectorRenderer.GetFrameRate(); mFrameDurationMicroSeconds = MICROSECONDS_PER_SECOND / mFrameRate; - uint32_t width, height; - mVectorRenderer.GetDefaultSize(width, height); - - SetSize(width, height); + mLoadRequest = false; + mLoadCompletedTrigger->Trigger(); DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Load: file = %s [%d frames, %f fps] [%p]\n", mUrl.c_str(), mTotalFrame, mFrameRate, this); @@ -132,6 +136,14 @@ void VectorAnimationTask::SetRenderer(Renderer renderer) DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this); } +void VectorAnimationTask::RequestLoad(const std::string& url) +{ + mUrl = url; + mLoadRequest = true; + + mVectorAnimationThread.AddTask(this); +} + void VectorAnimationTask::SetAnimationData(const AnimationData& data) { ConditionalWait::ScopedLock lock(mConditionalWait); @@ -293,12 +305,12 @@ void VectorAnimationTask::SetPlayRange(const Property::Array& playRange) mCurrentFrame = mEndFrame; } - DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%p]\n", mStartFrame, mEndFrame, this); + DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetPlayRange: [%d, %d] [%s] [%p]\n", mStartFrame, mEndFrame, mUrl.c_str(), this); } } else { - DALI_LOG_ERROR("VectorAnimationTask::SetPlayRange: Invalid range (%d, %d) [%p]\n", startFrame, endFrame, this); + DALI_LOG_ERROR("VectorAnimationTask::SetPlayRange: Invalid range (%d, %d) [%s] [%p]\n", startFrame, endFrame, mUrl.c_str(), this); return; } } @@ -326,7 +338,7 @@ void VectorAnimationTask::SetCurrentFrameNumber(uint32_t frameNumber) } else { - DALI_LOG_ERROR("Invalid frame number [%d (%d, %d)]\n", frameNumber, mStartFrame, mEndFrame); + DALI_LOG_ERROR("Invalid frame number [%d (%d, %d)] [%p]\n", frameNumber, mStartFrame, mEndFrame, this); } } @@ -364,15 +376,16 @@ void VectorAnimationTask::GetLayerInfo(Property::Map& map) const mVectorRenderer.GetLayerInfo(map); } -VectorAnimationTask::UploadCompletedSignalType& VectorAnimationTask::UploadCompletedSignal() +VectorAnimationTask::ResourceReadySignalType& VectorAnimationTask::ResourceReadySignal() { - return mVectorRenderer.UploadCompletedSignal(); + return mResourceReadySignal; } -bool VectorAnimationTask::Rasterize() +bool VectorAnimationTask::Rasterize(bool& keepAnimation) { bool stopped = false; uint32_t currentFrame; + keepAnimation = false; { ConditionalWait::ScopedLock lock(mConditionalWait); @@ -381,13 +394,23 @@ bool VectorAnimationTask::Rasterize() // The task will be destroyed. We don't need rasterization. return false; } + + if(mLoadRequest) + { + return Load(); + } + } + + if(mLoadFailed) + { + return false; } ApplyAnimationData(); if(mPlayState == PlayState::PLAYING && mUpdateFrameNumber) { - mCurrentFrame = mForward ? mCurrentFrame + mDroppedFrames + 1 : mCurrentFrame - mDroppedFrames - 1; + mCurrentFrame = mForward ? mCurrentFrame + mDroppedFrames + 1 : (mCurrentFrame > mDroppedFrames ? mCurrentFrame - mDroppedFrames - 1 : 0); Dali::ClampInPlace(mCurrentFrame, mStartFrame, mEndFrame); } @@ -479,13 +502,12 @@ bool VectorAnimationTask::Rasterize() DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Animation is finished [current = %d] [%p]\n", currentFrame, this); } - bool keepAnimation = true; - if(mPlayState == PlayState::PAUSED || mPlayState == PlayState::STOPPED) + if(mPlayState != PlayState::PAUSED && mPlayState != PlayState::STOPPED) { - keepAnimation = false; + keepAnimation = true; } - return keepAnimation; + return true; } uint32_t VectorAnimationTask::GetStoppedFrame(uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame) @@ -600,6 +622,11 @@ void VectorAnimationTask::ApplyAnimationData() SetCurrentFrameNumber(mAnimationData[index].currentFrame); } + if(mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_NEED_RESOURCE_READY) + { + mVectorRenderer.InvalidateBuffer(); + } + if(mAnimationData[index].resendFlag & VectorAnimationTask::RESEND_PLAY_STATE) { if(mAnimationData[index].playState == DevelImageVisual::PlayState::PLAYING) @@ -619,6 +646,22 @@ void VectorAnimationTask::ApplyAnimationData() mAnimationData[index].resendFlag = 0; } +void VectorAnimationTask::OnUploadCompleted() +{ + mResourceReadySignal.Emit(ResourceStatus::READY); +} + +void VectorAnimationTask::OnLoadCompleted() +{ + if(!mLoadFailed) + { + mResourceReadySignal.Emit(ResourceStatus::LOADED); + } + else + { + mResourceReadySignal.Emit(ResourceStatus::FAILED); + } +} } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h index 3c0b8e3..1e4ff4c 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VECTOR_ANIMATION_TASK_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,10 +42,17 @@ typedef IntrusivePtr VectorAnimationTaskPtr; /** * The task of the vector animation. */ -class VectorAnimationTask : public RefObject +class VectorAnimationTask : public RefObject, public ConnectionTracker { public: - using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType; + enum class ResourceStatus + { + LOADED, /// Resource is loaded + READY, /// Resource is ready + FAILED /// Resource is fail to load + }; + + using ResourceReadySignalType = Signal; using TimePoint = std::chrono::time_point; @@ -54,13 +61,14 @@ public: */ enum ResendFlags { - RESEND_PLAY_RANGE = 1 << 0, - RESEND_LOOP_COUNT = 1 << 1, - RESEND_STOP_BEHAVIOR = 1 << 2, - RESEND_LOOPING_MODE = 1 << 3, - RESEND_CURRENT_FRAME = 1 << 4, - RESEND_SIZE = 1 << 5, - RESEND_PLAY_STATE = 1 << 6 + RESEND_PLAY_RANGE = 1 << 0, + RESEND_LOOP_COUNT = 1 << 1, + RESEND_STOP_BEHAVIOR = 1 << 2, + RESEND_LOOPING_MODE = 1 << 3, + RESEND_CURRENT_FRAME = 1 << 4, + RESEND_SIZE = 1 << 5, + RESEND_PLAY_STATE = 1 << 6, + RESEND_NEED_RESOURCE_READY = 1 << 7 }; /** @@ -124,19 +132,18 @@ public: void Finalize(); /** - * @brief Loads the animation file. + * @brief Sets the renderer used to display the result image. * - * @param[in] url The url of the vector animation file - * @return True if loading success, false otherwise. + * @param[in] renderer The renderer used to display the result image */ - bool Load(const std::string& url); + void SetRenderer(Renderer renderer); /** - * @brief Sets the renderer used to display the result image. + * @brief Request to load the animation file. * - * @param[in] renderer The renderer used to display the result image + * @param[in] url The url of the vector animation file */ - void SetRenderer(Renderer renderer); + void RequestLoad(const std::string& url); /** * @brief Sets data to specify animation playback. @@ -182,16 +189,17 @@ public: void GetLayerInfo(Property::Map& map) const; /** - * @brief Connect to this signal to be notified when the texture upload is completed. + * @brief Connect to this signal to be notified when the resource is ready. * @return The signal to connect to. */ - UploadCompletedSignalType& UploadCompletedSignal(); + ResourceReadySignalType& ResourceReadySignal(); /** * @brief Rasterizes the current frame. - * @return true if the animation is running, false otherwise. + * @param[out] keepAnimation true if the animation is running, false otherwise. + * @return true if the rasterization succeeded, false otherwise. */ - bool Rasterize(); + bool Rasterize(bool& keepAnimation); /** * @brief Calculates the time for the next frame rasterization. @@ -207,6 +215,13 @@ public: private: /** + * @brief Loads the animation file. + * + * @return True if loading succeeded, false otherwise. + */ + bool Load(); + + /** * @brief Play the vector animation. */ void PlayAnimation(); @@ -271,6 +286,16 @@ private: */ void ApplyAnimationData(); + /** + * @brief Called when the texture upload is completed. + */ + void OnUploadCompleted(); + + /** + * @brief Event callback from rasterize thread. This is called when the file loading is completed. + */ + void OnLoadCompleted(); + // Undefined VectorAnimationTask(const VectorAnimationTask& task) = delete; @@ -291,7 +316,9 @@ private: AnimationData mAnimationData[2]; VectorAnimationThread& mVectorAnimationThread; ConditionalWait mConditionalWait; + ResourceReadySignalType mResourceReadySignal; std::unique_ptr mAnimationFinishedTrigger; + std::unique_ptr mLoadCompletedTrigger; PlayState mPlayState; DevelImageVisual::StopBehavior::Type mStopBehavior; DevelImageVisual::LoopingMode::Type mLoopingMode; @@ -313,6 +340,8 @@ private: bool mNeedAnimationFinishedTrigger; bool mAnimationDataUpdated; bool mDestroyTask; + bool mLoadRequest; + bool mLoadFailed; }; } // namespace Internal diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp index 97634f6..7e505c9 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ void VectorAnimationThread::AddTask(VectorAnimationTaskPtr task) } } -void VectorAnimationThread::OnTaskCompleted(VectorAnimationTaskPtr task, bool keepAnimation) +void VectorAnimationThread::OnTaskCompleted(VectorAnimationTaskPtr task, bool success, bool keepAnimation) { if(!mDestroyThread) { @@ -131,7 +131,7 @@ void VectorAnimationThread::OnTaskCompleted(VectorAnimationTaskPtr task, bool ke needRasterize = true; } - if(keepAnimation) + if(keepAnimation && success) { if(mCompletedTasks.end() == std::find(mCompletedTasks.begin(), mCompletedTasks.end(), task)) { @@ -220,9 +220,9 @@ void VectorAnimationThread::Rasterize() auto nextFrameTime = nextTask->GetNextFrameTime(); #if defined(DEBUG_ENABLED) - auto duration = std::chrono::duration_cast(nextFrameTime - currentTime); +// auto duration = std::chrono::duration_cast(nextFrameTime - currentTime); - DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationThread::Rasterize: [next time = %lld]\n", duration.count()); +// DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationThread::Rasterize: [next time = %lld]\n", duration.count()); #endif if(nextFrameTime <= currentTime) @@ -330,9 +330,9 @@ void VectorAnimationThread::SleepThread::Run() if(needToSleep) { #if defined(DEBUG_ENABLED) - auto sleepDuration = std::chrono::duration_cast(mSleepTimePoint - std::chrono::steady_clock::now()); +// auto sleepDuration = std::chrono::duration_cast(mSleepTimePoint - std::chrono::steady_clock::now()); - DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationThread::SleepThread::Run: [sleep duration = %lld]\n", sleepDuration.count()); +// DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationThread::SleepThread::Run: [sleep duration = %lld]\n", sleepDuration.count()); #endif std::this_thread::sleep_until(sleepTimePoint); diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h index 8190e7b..b752105 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VECTOR_ANIMATION_THREAD_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,9 +60,11 @@ public: /** * @brief Called when the rasterization is completed from the rasterize thread. - * @param task The completed task + * @param[in] task The completed task + * @param[in] success true if the task succeeded, false otherwise. + * @param[in] keepAnimation true if the animation is running, false otherwise. */ - void OnTaskCompleted(VectorAnimationTaskPtr task, bool stopped); + void OnTaskCompleted(VectorAnimationTaskPtr task, bool success, bool keepAnimation); /** * @brief Called when the sleep thread is awaken. diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.cpp index 9a3f909..0ba9f52 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,11 +125,12 @@ void VectorRasterizeThread::Rasterize() if(nextTask) { - bool keepAnimation = nextTask->Rasterize(); + bool keepAnimation; + bool success = nextTask->Rasterize(keepAnimation); if(mCompletedCallback) { - CallbackBase::Execute(*mCompletedCallback, nextTask, keepAnimation); + CallbackBase::Execute(*mCompletedCallback, nextTask, success, keepAnimation); } } } diff --git a/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp b/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp new file mode 100644 index 0000000..5a2eba8 --- /dev/null +++ b/dali-toolkit/internal/visuals/text-visual-shader-factory.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ +namespace Toolkit +{ +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 +{ + DEFAULT = 0, + STYLES = 1 << 0, + OVERLAY = 1 << 1, + EMOJI = 1 << 2, + MULTI_COLOR = 1 << 3, +}; + +const VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[] = + { + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_OVERLAY, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_OVERLAY, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_OVERLAY_AND_EMOJI, + VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_OVERLAY_AND_EMOJI, + VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT, + VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, + VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_OVERLAY, + VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE_AND_OVERLAY, +}; + +} // unnamed namespace + +namespace TextVisualShaderFeature +{ +FeatureBuilder& FeatureBuilder::EnableMultiColor(bool enableMultiColor) +{ + mTextMultiColor = enableMultiColor ? TextMultiColor::MULTI_COLOR_TEXT : TextMultiColor::SINGLE_COLOR_TEXT; + return *this; +} +FeatureBuilder& FeatureBuilder::EnableEmoji(bool enableEmoji) +{ + mTextEmoji = enableEmoji ? TextEmoji::HAS_EMOJI : TextEmoji::NO_EMOJI; + return *this; +} +FeatureBuilder& FeatureBuilder::EnableStyle(bool enableStyle) +{ + mTextStyle = enableStyle ? TextStyle::HAS_STYLES : TextStyle::NO_STYLES; + return *this; +} +FeatureBuilder& FeatureBuilder::EnableOverlay(bool enableOverlay) +{ + mTextOverlay = enableOverlay ? TextOverlay::HAS_OVERLAY : TextOverlay::NO_OVERLAY; + return *this; +} +} // namespace TextVisualShaderFeature + +TextVisualShaderFactory::TextVisualShaderFactory() +{ +} + +TextVisualShaderFactory::~TextVisualShaderFactory() +{ +} + +Shader TextVisualShaderFactory::GetShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder) +{ + Shader shader; + uint32_t shaderTypeFlag = static_cast(TextVisualRequireFlag::DEFAULT); + VisualFactoryCache::ShaderType shaderType = VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT; + + const auto& multiColor = featureBuilder.mTextMultiColor; + const auto& emoji = featureBuilder.mTextEmoji; + const auto& style = featureBuilder.mTextStyle; + const auto& overlay = featureBuilder.mTextOverlay; + + if(style == TextVisualShaderFeature::TextStyle::HAS_STYLES) + { + shaderTypeFlag |= static_cast(TextVisualRequireFlag::STYLES); + } + if(overlay == TextVisualShaderFeature::TextOverlay::HAS_OVERLAY) + { + shaderTypeFlag |= static_cast(TextVisualRequireFlag::OVERLAY); + } + // multi color can also render emoji. If multi color text, dont consider emoji + if(multiColor != TextVisualShaderFeature::TextMultiColor::MULTI_COLOR_TEXT && emoji == TextVisualShaderFeature::TextEmoji::HAS_EMOJI) + { + shaderTypeFlag |= static_cast(TextVisualRequireFlag::EMOJI); + } + if(multiColor == TextVisualShaderFeature::TextMultiColor::MULTI_COLOR_TEXT) + { + shaderTypeFlag |= static_cast(TextVisualRequireFlag::MULTI_COLOR); + } + + shaderType = SHADER_TYPE_TABLE[shaderTypeFlag]; + shader = factoryCache.GetShader(shaderType); + + if(!shader) + { + std::string vertexShaderPrefixList; + std::string fragmentShaderPrefixList; + + if(style == TextVisualShaderFeature::TextStyle::HAS_STYLES) + { + fragmentShaderPrefixList += "#define IS_REQUIRED_STYLE\n"; + } + if(overlay == TextVisualShaderFeature::TextOverlay::HAS_OVERLAY) + { + fragmentShaderPrefixList += "#define IS_REQUIRED_OVERLAY\n"; + } + // multi color can also render emoji. If multi color text, dont consider emoji + if(multiColor != TextVisualShaderFeature::TextMultiColor::MULTI_COLOR_TEXT && emoji == TextVisualShaderFeature::TextEmoji::HAS_EMOJI) + { + fragmentShaderPrefixList += "#define IS_REQUIRED_EMOJI\n"; + } + if(multiColor == TextVisualShaderFeature::TextMultiColor::MULTI_COLOR_TEXT) + { + fragmentShaderPrefixList += "#define IS_REQUIRED_MULTI_COLOR\n"; + } + + std::string vertexShader = std::string(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_TEXT_VISUAL_SHADER_VERT.data()); + std::string fragmentShader = std::string(Dali::Shader::GetFragmentShaderPrefix() + fragmentShaderPrefixList + SHADER_TEXT_VISUAL_SHADER_FRAG.data()); + + shader = Shader::New(vertexShader, fragmentShader); + factoryCache.SaveShader(shaderType, shader); + } + return shader; +} + +} // namespace Internal + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/internal/visuals/text-visual-shader-factory.h b/dali-toolkit/internal/visuals/text-visual-shader-factory.h new file mode 100644 index 0000000..4a9969b --- /dev/null +++ b/dali-toolkit/internal/visuals/text-visual-shader-factory.h @@ -0,0 +1,172 @@ +#ifndef DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H +#define DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H + +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Toolkit +{ +namespace Internal +{ +/** + * TextVisualShaderFeature contains feature lists what text visual shader need to know. + */ +namespace TextVisualShaderFeature +{ +namespace TextMultiColor +{ +/** + * @brief Whether text contains single color or not. + */ +enum Type +{ + SINGLE_COLOR_TEXT = 0, ///< The text contains single color only. + MULTI_COLOR_TEXT ///< The text contains multiple colors. +}; +} // namespace TextMultiColor + +namespace TextEmoji +{ +/** + * @brief Whether text contains emoji or not. + */ +enum Type +{ + NO_EMOJI = 0, ///< The text contains no emoji. + HAS_EMOJI ///< The text contains emoji. +}; +} // namespace TextEmoji + +namespace TextStyle +{ +/** + * @brief Whether text contains styles (like shadow or background color) or not. + */ +enum Type +{ + NO_STYLES = 0, ///< The text contains contains no styles. + HAS_STYLES ///< The text contains contains styles. +}; +} // namespace TextStyle + +namespace TextOverlay +{ +/** + * @brief Whether text contains overlay styles (like markdown) or not. + */ +enum Type +{ + NO_OVERLAY = 0, ///< The text contains contains no overlay. + HAS_OVERLAY ///< The text contains contains overlay. +}; +} // namespace TextOverlay + +/** + * @brief Collection of current text visual feature. + */ +struct FeatureBuilder +{ + FeatureBuilder() + : mTextMultiColor(TextMultiColor::SINGLE_COLOR_TEXT), + mTextEmoji(TextEmoji::NO_EMOJI), + mTextStyle(TextStyle::NO_STYLES), + mTextOverlay(TextOverlay::NO_OVERLAY) + { + } + + FeatureBuilder& EnableMultiColor(bool enableMultiColor); + FeatureBuilder& EnableEmoji(bool enableEmoji); + FeatureBuilder& EnableStyle(bool enableStyle); + FeatureBuilder& EnableOverlay(bool enableOverlay); + + bool IsEnabledMultiColor() const + { + return mTextMultiColor == TextMultiColor::MULTI_COLOR_TEXT; + } + bool IsEnabledEmoji() const + { + return mTextEmoji == TextEmoji::HAS_EMOJI; + } + bool IsEnabledStyle() const + { + return mTextStyle == TextStyle::HAS_STYLES; + } + bool IsEnabledOverlay() const + { + return mTextOverlay == TextOverlay::HAS_OVERLAY; + } + + TextMultiColor::Type mTextMultiColor : 2; ///< Whether text has multiple color, or not. default as TextMultiColor::SINGLE_COLOR_TEXT + TextEmoji::Type mTextEmoji : 2; ///< Whether text has emoji, or not. default as TextEmoji::NO_EMOJI + TextStyle::Type mTextStyle : 2; ///< Whether text has style, or not. default as TextStyle::NO_STYLES + TextOverlay::Type mTextOverlay : 2; ///< Whether text has overlay style, or not. default as TextOverlay::NO_OVERLAY +}; + +} // namespace TextVisualShaderFeature + +/** + * TextVisualShaderFactory is an object that provides and shares shaders for text visuals + */ +class TextVisualShaderFactory +{ +public: + /** + * @brief Constructor + */ + TextVisualShaderFactory(); + + /** + * @brief Destructor + */ + ~TextVisualShaderFactory(); + + /** + * @brief Get the standard text rendering shader. + * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object + * @param[in] featureBuilder Collection of current text shader's features + * @return The standard text rendering shader with features. + */ + Shader GetShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder); + +protected: + /** + * Undefined copy constructor. + */ + TextVisualShaderFactory(const TextVisualShaderFactory&); + + /** + * Undefined assignment operator. + */ + TextVisualShaderFactory& operator=(const TextVisualShaderFactory& rhs); + +private: +}; + +} // namespace Internal + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index 777e48f..aa205cf 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -148,9 +148,9 @@ void OpacityConstraint(float& current, const PropertyInputContainer& inputs) } // unnamed namespace -TextVisualPtr TextVisual::New(VisualFactoryCache& factoryCache, const Property::Map& properties) +TextVisualPtr TextVisual::New(VisualFactoryCache& factoryCache, TextVisualShaderFactory& shaderFactory, const Property::Map& properties) { - TextVisualPtr textVisualPtr(new TextVisual(factoryCache)); + TextVisualPtr textVisualPtr(new TextVisual(factoryCache, shaderFactory)); textVisualPtr->SetProperties(properties); textVisualPtr->Initialize(); return textVisualPtr; @@ -249,10 +249,12 @@ void TextVisual::EnablePreMultipliedAlpha(bool preMultiplied) } } -TextVisual::TextVisual(VisualFactoryCache& factoryCache) +TextVisual::TextVisual(VisualFactoryCache& factoryCache, TextVisualShaderFactory& shaderFactory) : Visual::Base(factoryCache, Visual::FittingMode::FIT_KEEP_ASPECT_RATIO, Toolkit::Visual::TEXT), mController(Text::Controller::New()), mTypesetter(Text::Typesetter::New(mController->GetTextModel())), + mTextVisualShaderFactory(shaderFactory), + mTextShaderFeatureCache(), mAnimatableTextColorPropertyIndex(Property::INVALID_INDEX), mTextColorAnimatableIndex(Property::INVALID_INDEX), mRendererUpdateNeeded(false) @@ -268,7 +270,7 @@ TextVisual::~TextVisual() void TextVisual::OnInitialize() { Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY); - Shader shader = GetTextShader(mFactoryCache, TextType::SINGLE_COLOR_TEXT, TextType::NO_EMOJI, TextType::NO_STYLES); + Shader shader = GetTextShader(mFactoryCache, TextVisualShaderFeature::FeatureBuilder()); mImpl->mRenderer = VisualRenderer::New(geometry, shader); mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); @@ -560,13 +562,14 @@ void TextVisual::UpdateRenderer() shadowEnabled = true; } - const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled(); - const bool outlineEnabled = (mController->GetTextModel()->GetOutlineWidth() > Math::MACHINE_EPSILON_1); - const bool backgroundEnabled = mController->GetTextModel()->IsBackgroundEnabled(); - const bool markupProcessorEnabled = mController->IsMarkupProcessorEnabled(); - const bool strikethroughEnabled = mController->GetTextModel()->IsStrikethroughEnabled(); - - const bool styleEnabled = (shadowEnabled || underlineEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled || strikethroughEnabled); + const bool outlineEnabled = (mController->GetTextModel()->GetOutlineWidth() > Math::MACHINE_EPSILON_1); + const bool backgroundEnabled = mController->GetTextModel()->IsBackgroundEnabled(); + const bool markupProcessorEnabled = mController->IsMarkupProcessorEnabled(); + const bool markupUnderlineEnabled = markupProcessorEnabled && mController->GetTextModel()->IsMarkupUnderlineSet(); + const bool markupStrikethroughEnabled = markupProcessorEnabled && mController->GetTextModel()->IsMarkupStrikethroughSet(); + const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled() || markupUnderlineEnabled; + const bool strikethroughEnabled = mController->GetTextModel()->IsStrikethroughEnabled() || markupStrikethroughEnabled; + const bool styleEnabled = (shadowEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled); const bool isOverlayStyle = underlineEnabled || strikethroughEnabled; AddRenderer(control, relayoutSize, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle); @@ -604,7 +607,7 @@ PixelData TextVisual::ConvertToPixelData(unsigned char* buffer, int width, int h return pixelData; } -void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle) +void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler) { TextureSet textureSet = TextureSet::New(); unsigned int textureSetIndex = 0u; @@ -618,21 +621,21 @@ void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sa ++textureSetIndex; } - if(styleEnabled && info.styleBuffer && info.overlayStyleBuffer) + if(mTextShaderFeatureCache.IsEnabledStyle() && info.styleBuffer) { PixelData styleData = ConvertToPixelData(info.styleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888); AddTexture(textureSet, styleData, sampler, textureSetIndex); ++textureSetIndex; + } - // TODO : We need to seperate whether use overlayStyle or not. - // Current text visual shader required both of them. - + if(mTextShaderFeatureCache.IsEnabledOverlay() && info.overlayStyleBuffer) + { PixelData overlayStyleData = ConvertToPixelData(info.overlayStyleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888); AddTexture(textureSet, overlayStyleData, sampler, textureSetIndex); ++textureSetIndex; } - if(containsColorGlyph && !hasMultipleTextColors && info.maskBuffer) + if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor() && info.maskBuffer) { PixelData maskData = ConvertToPixelData(info.maskBuffer, info.width, info.height, info.offsetPosition, Pixel::L8); AddTexture(textureSet, maskData, sampler, textureSetIndex); @@ -651,14 +654,14 @@ void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sa renderer.SetProperty(VisualRenderer::Property::TRANSFORM_SIZE, Vector2(info.width, info.height)); renderer.SetProperty(VisualRenderer::Property::TRANSFORM_OFFSET, Vector2(info.offSet.x, info.offSet.y)); renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); - renderer.RegisterProperty("uHasMultipleTextColors", static_cast(hasMultipleTextColors)); + renderer.RegisterProperty("uHasMultipleTextColors", static_cast(mTextShaderFeatureCache.IsEnabledMultiColor())); mRendererList.push_back(renderer); } void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle) { - Shader shader = GetTextShader(mFactoryCache, hasMultipleTextColors, containsColorGlyph, styleEnabled); + Shader shader = GetTextShader(mFactoryCache, TextVisualShaderFeature::FeatureBuilder().EnableMultiColor(hasMultipleTextColors).EnableEmoji(containsColorGlyph).EnableStyle(styleEnabled).EnableOverlay(isOverlayStyle)); mImpl->mRenderer.SetShader(shader); // Get the maximum size. @@ -667,7 +670,7 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple // No tiling required. Use the default renderer. if(size.height < maxTextureSize) { - TextureSet textureSet = GetTextTexture(size, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle); + TextureSet textureSet = GetTextTexture(size); mImpl->mRenderer.SetTextures(textureSet); //Register transform properties @@ -703,23 +706,23 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple Dali::DevelPixelData::PixelDataBuffer textPixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(data); info.textBuffer = textPixelData.buffer; - if(styleEnabled) + if(mTextShaderFeatureCache.IsEnabledStyle()) { // Create RGBA texture for all the text styles (without the text itself) PixelData styleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888); Dali::DevelPixelData::PixelDataBuffer stylePixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(styleData); info.styleBuffer = stylePixelData.buffer; + } - // TODO : We need to seperate whether use overlayStyle or not. - // Current text visual shader required both of them. - + if(mTextShaderFeatureCache.IsEnabledOverlay()) + { // Create RGBA texture for all the overlay styles PixelData overlayStyleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_OVERLAY_STYLE, false, Pixel::RGBA8888); Dali::DevelPixelData::PixelDataBuffer overlayStylePixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(overlayStyleData); info.overlayStyleBuffer = overlayStylePixelData.buffer; } - if(containsColorGlyph && !hasMultipleTextColors) + if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor()) { // Create a L8 texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation PixelData maskData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_MASK, false, Pixel::L8); @@ -737,7 +740,7 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple } // Create a textureset in the default renderer. - CreateTextureSet(info, mImpl->mRenderer, sampler, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle); + CreateTextureSet(info, mImpl->mRenderer, sampler); verifiedHeight -= maxTextureSize; @@ -756,7 +759,7 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple // New offset for tiling. info.offSet.y += maxTextureSize; // Create a textureset int the new tiling renderer. - CreateTextureSet(info, tilingRenderer, sampler, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle); + CreateTextureSet(info, tilingRenderer, sampler); verifiedHeight -= maxTextureSize; } @@ -800,7 +803,7 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple } } -TextureSet TextVisual::GetTextTexture(const Vector2& size, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle) +TextureSet TextVisual::GetTextTexture(const Vector2& size) { // Filter mode needs to be set to linear to produce better quality while scaling. Sampler sampler = Sampler::New(); @@ -809,7 +812,7 @@ TextureSet TextVisual::GetTextTexture(const Vector2& size, bool hasMultipleTextC TextureSet textureSet = TextureSet::New(); // Create RGBA texture if the text contains emojis or multiple text colors, otherwise L8 texture - Pixel::Format textPixelFormat = (containsColorGlyph || hasMultipleTextColors) ? Pixel::RGBA8888 : Pixel::L8; + Pixel::Format textPixelFormat = (mTextShaderFeatureCache.IsEnabledEmoji() || mTextShaderFeatureCache.IsEnabledMultiColor()) ? Pixel::RGBA8888 : Pixel::L8; // Check the text direction Toolkit::DevelText::TextDirection::Type textDirection = mController->GetTextDirection(); @@ -823,23 +826,23 @@ TextureSet TextVisual::GetTextTexture(const Vector2& size, bool hasMultipleTextC AddTexture(textureSet, data, sampler, textureSetIndex); ++textureSetIndex; - if(styleEnabled) + if(mTextShaderFeatureCache.IsEnabledStyle()) { // Create RGBA texture for all the text styles that render in the background (without the text itself) PixelData styleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888); AddTexture(textureSet, styleData, sampler, textureSetIndex); ++textureSetIndex; + } - // TODO : We need to seperate whether use overlayStyle or not. - // Current text visual shader required both of them. - + if(mTextShaderFeatureCache.IsEnabledOverlay()) + { // Create RGBA texture for overlay styles such as underline and strikethrough (without the text itself) PixelData overlayStyleData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_OVERLAY_STYLE, false, Pixel::RGBA8888); AddTexture(textureSet, overlayStyleData, sampler, textureSetIndex); ++textureSetIndex; } - if(containsColorGlyph && !hasMultipleTextColors) + if(mTextShaderFeatureCache.IsEnabledEmoji() && !mTextShaderFeatureCache.IsEnabledMultiColor()) { // Create a L8 texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation PixelData maskData = mTypesetter->Render(size, textDirection, Text::Typesetter::RENDER_MASK, false, Pixel::L8); @@ -850,73 +853,13 @@ TextureSet TextVisual::GetTextTexture(const Vector2& size, bool hasMultipleTextC return textureSet; } -Shader TextVisual::GetTextShader(VisualFactoryCache& factoryCache, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled) +Shader TextVisual::GetTextShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder) { - Shader shader; - - if(hasMultipleTextColors && !styleEnabled) - { - // We don't animate text color if the text contains multiple colors - shader = factoryCache.GetShader(VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT); - if(!shader) - { - shader = Shader::New(SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_MULTI_COLOR_TEXT_SHADER_FRAG); - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - factoryCache.SaveShader(VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT, shader); - } - } - else if(hasMultipleTextColors && styleEnabled) - { - // We don't animate text color if the text contains multiple colors - shader = factoryCache.GetShader(VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE); - if(!shader) - { - shader = Shader::New(SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_MULTI_COLOR_TEXT_WITH_STYLE_SHADER_FRAG); - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - factoryCache.SaveShader(VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, shader); - } - } - else if(!hasMultipleTextColors && !containsColorGlyph && !styleEnabled) - { - shader = factoryCache.GetShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT); - if(!shader) - { - shader = Shader::New(SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_SHADER_FRAG); - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - factoryCache.SaveShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT, shader); - } - } - else if(!hasMultipleTextColors && !containsColorGlyph && styleEnabled) - { - shader = factoryCache.GetShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE); - if(!shader) - { - shader = Shader::New(SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_STYLE_SHADER_FRAG); - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - factoryCache.SaveShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE, shader); - } - } - else if(!hasMultipleTextColors && containsColorGlyph && !styleEnabled) - { - shader = factoryCache.GetShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI); - if(!shader) - { - shader = Shader::New(SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_EMOJI_SHADER_FRAG); - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - factoryCache.SaveShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI, shader); - } - } - else // if( !hasMultipleTextColors && containsColorGlyph && styleEnabled ) - { - shader = factoryCache.GetShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI); - if(!shader) - { - shader = Shader::New(SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI_SHADER_FRAG); - shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); - factoryCache.SaveShader(VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI, shader); - } - } + // Cache feature builder informations. + mTextShaderFeatureCache = featureBuilder; + Shader shader = mTextVisualShaderFactory.GetShader(factoryCache, mTextShaderFeatureCache); + shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT); return shader; } diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index c79c254..c81fbce 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -25,8 +25,9 @@ #include // INTERNAL INCLUDES +#include #include -#include +#include #include namespace Dali @@ -72,10 +73,11 @@ public: * @brief Create a new text visual. * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object + * @param[in] shaderFactory The TextVisualShaderFactory object * @param[in] properties A Property::Map containing settings for this visual * @return A smart-pointer to the newly allocated visual. */ - static TextVisualPtr New(VisualFactoryCache& factoryCache, const Property::Map& properties); + static TextVisualPtr New(VisualFactoryCache& factoryCache, TextVisualShaderFactory& shaderFactory, const Property::Map& properties); /** * @brief Converts all strings keys in property map to index keys. Property Map can then be merged correctly. @@ -153,8 +155,9 @@ protected: * @brief Constructor. * * @param[in] factoryCache The VisualFactoryCache object + * @param[in] shaderFactory The TextVisualShaderFactory object */ - TextVisual(VisualFactoryCache& factoryCache); + TextVisual(VisualFactoryCache& factoryCache, TextVisualShaderFactory& shaderFactory); /** * @brief A reference counted object may only be deleted by calling Unreference(). @@ -274,16 +277,12 @@ private: PixelData ConvertToPixelData(unsigned char* buffer, int width, int height, int offsetPosition, const Pixel::Format textPixelFormat); /** - * @brief Create the text's texture. + * @brief Create the text's texture. It will use cached shader feature for text visual. * @param[in] info This is the information you need to create a Tiling. * @param[in] renderer The renderer to which the TextureSet will be added. * @param[in] sampler The sampler. - * @param[in] hasMultipleTextColors Whether the text contains multiple colors. - * @param[in] containsColorGlyph Whether the text contains color glyph. - * @param[in] styleEnabled Whether the text contains any styles (e.g. shadow, underline, etc.). - * @param[in] isOverlayStyle Whether the style needs to overlay on the text (e.g. strikethrough, underline, etc.). */ - void CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle); + void CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler); /** * Create renderer of the text for rendering. @@ -297,23 +296,17 @@ private: void AddRenderer(Actor& actor, const Vector2& size, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle); /** - * Get the texture of the text for rendering. + * Get the texture of the text for rendering. It will use cached shader feature for text visual. * @param[in] size The texture size. - * @param[in] hasMultipleTextColors Whether the text contains multiple colors. - * @param[in] containsColorGlyph Whether the text contains color glyph. - * @param[in] styleEnabled Whether the text contains any styles (e.g. shadow, underline, etc.). - * @param[in] isOverlayStyle Whether the style needs to overlay on the text (e.g. strikethrough, underline, etc.). */ - TextureSet GetTextTexture(const Vector2& size, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle); + TextureSet GetTextTexture(const Vector2& size); /** * Get the text rendering shader. * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object - * @param[in] hasMultipleTextColors Whether the text contains multiple colors. - * @param[in] containsColorGlyph Whether the text contains color glyph. - * @param[in] styleEnabled Whether the text contains any styles (e.g. shadow, underline, etc.). + * @param[in] featureBuilder Collection of current text shader's features. It will be cached as text visual. */ - Shader GetTextShader(VisualFactoryCache& factoryCache, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled); + Shader GetTextShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder); /** * @brief Retrieve the TextVisual object. @@ -328,32 +321,20 @@ private: private: typedef std::vector RendererContainer; - /** - * Used as an alternative to boolean so that it is obvious whether the text contains single or multiple text colors, and emoji and styles. - */ - struct TextType - { - enum Type - { - SINGLE_COLOR_TEXT = 0, ///< The text contains single color only. - MULTI_COLOR_TEXT = 1, ///< The text contains multiple colors. - NO_EMOJI = 0, ///< The text contains no emoji. - HAS_EMOJI = 1, ///< The text contains emoji. - NO_STYLES = 0, ///< The text contains contains no styles. - HAS_SYLES = 1 ///< The text contains contains styles. - }; - }; - private: - Text::ControllerPtr mController; ///< The text's controller. - Text::TypesetterPtr mTypesetter; ///< The text's typesetter. - WeakHandle mControl; ///< The control where the renderer is added. - Constraint mColorConstraint{}; ///< Color constraint - Constraint mOpacityConstraint{}; ///< Opacity constraint - Property::Index mAnimatableTextColorPropertyIndex; ///< The index of animatable text color property registered by the control. - Property::Index mTextColorAnimatableIndex; ///< The index of uTextColorAnimatable property. - bool mRendererUpdateNeeded : 1; ///< The flag to indicate whether the renderer needs to be updated. - RendererContainer mRendererList; + Text::ControllerPtr mController; ///< The text's controller. + Text::TypesetterPtr mTypesetter; ///< The text's typesetter. + + TextVisualShaderFactory& mTextVisualShaderFactory; ///< The shader factory for text visual. + TextVisualShaderFeature::FeatureBuilder mTextShaderFeatureCache; ///< The cached shader feature for text visual. + + WeakHandle mControl; ///< The control where the renderer is added. + Constraint mColorConstraint{}; ///< Color constraint + Constraint mOpacityConstraint{}; ///< Opacity constraint + Property::Index mAnimatableTextColorPropertyIndex; ///< The index of animatable text color property registered by the control. + Property::Index mTextColorAnimatableIndex; ///< The index of uTextColorAnimatable property. + bool mRendererUpdateNeeded : 1; ///< The flag to indicate whether the renderer needs to be updated. + RendererContainer mRendererList; }; } // namespace Internal diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.h b/dali-toolkit/internal/visuals/visual-factory-cache.h index 6d9f28c..0edda01 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.h +++ b/dali-toolkit/internal/visuals/visual-factory-cache.h @@ -104,12 +104,18 @@ public: NATIVE_IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING, NINE_PATCH_SHADER, NINE_PATCH_MASK_SHADER, - TEXT_SHADER_MULTI_COLOR_TEXT, - TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, TEXT_SHADER_SINGLE_COLOR_TEXT, TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_OVERLAY, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_OVERLAY, TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI, TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_OVERLAY_AND_EMOJI, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_OVERLAY_AND_EMOJI, + TEXT_SHADER_MULTI_COLOR_TEXT, + TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, + TEXT_SHADER_MULTI_COLOR_TEXT_WITH_OVERLAY, + TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE_AND_OVERLAY, ANIMATED_GRADIENT_SHADER_LINEAR_BOUNDING_REFLECT, ANIMATED_GRADIENT_SHADER_LINEAR_BOUNDING_REPEAT, ANIMATED_GRADIENT_SHADER_LINEAR_BOUNDING_CLAMP, diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index a4b0a0a..57290a1 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,7 @@ const char* const BROKEN_IMAGE_FILE_NAME = "broken.png"; ///< The file name of t VisualFactory::VisualFactory(bool debugEnabled) : mFactoryCache(), mImageVisualShaderFactory(), + mTextVisualShaderFactory(), mSlotDelegate(this), mDebugEnabled(debugEnabled), mPreMultiplyOnLoad(true) @@ -207,7 +209,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM case Toolkit::Visual::TEXT: { - visualPtr = TextVisual::New(GetFactoryCache(), propertyMap); + visualPtr = TextVisual::New(GetFactoryCache(), GetTextVisualShaderFactory(), propertyMap); break; } @@ -426,6 +428,15 @@ ImageVisualShaderFactory& VisualFactory::GetImageVisualShaderFactory() return *mImageVisualShaderFactory; } +TextVisualShaderFactory& VisualFactory::GetTextVisualShaderFactory() +{ + if(!mTextVisualShaderFactory) + { + mTextVisualShaderFactory = std::unique_ptr(new TextVisualShaderFactory()); + } + return *mTextVisualShaderFactory; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.h b/dali-toolkit/internal/visuals/visual-factory-impl.h index a5ecda8..616b8d0 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.h +++ b/dali-toolkit/internal/visuals/visual-factory-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ namespace Internal { class VisualFactoryCache; class ImageVisualShaderFactory; +class TextVisualShaderFactory; /** * @copydoc Toolkit::VisualFactory @@ -112,6 +113,11 @@ private: */ ImageVisualShaderFactory& GetImageVisualShaderFactory(); + /** + * Get the text visual shader factory, creating it if necessary. + */ + TextVisualShaderFactory& GetTextVisualShaderFactory(); + VisualFactory(const VisualFactory&) = delete; VisualFactory& operator=(const VisualFactory& rhs) = delete; @@ -119,6 +125,7 @@ private: private: std::unique_ptr mFactoryCache; std::unique_ptr mImageVisualShaderFactory; + std::unique_ptr mTextVisualShaderFactory; SlotDelegate mSlotDelegate; bool mDebugEnabled : 1; bool mPreMultiplyOnLoad : 1; ///< Local store for this flag diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index f04adf2..56a7313 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -29,7 +29,7 @@ namespace Toolkit { const unsigned int TOOLKIT_MAJOR_VERSION = 2; const unsigned int TOOLKIT_MINOR_VERSION = 1; -const unsigned int TOOLKIT_MICRO_VERSION = 30; +const unsigned int TOOLKIT_MICRO_VERSION = 31; const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index a643452..8619802 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali2-toolkit Summary: Dali 3D engine Toolkit -Version: 2.1.30 +Version: 2.1.31 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT