From 6bb8b87587658b23fc7f1d55019fac83ddacef0b Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Wed, 1 Apr 2020 20:57:44 +0100 Subject: [PATCH] Fix for PreInitialize, including FontClient Change-Id: I00b464e8936731e85bb9daefd0eeb16a853dc929 --- dali/devel-api/text-abstraction/font-client.cpp | 5 +++++ dali/devel-api/text-abstraction/font-client.h | 7 +++++++ dali/internal/adaptor/common/application-impl.cpp | 2 ++ .../text/text-abstraction/font-client-impl.cpp | 24 +++++++++++++++++++++- .../text/text-abstraction/font-client-impl.h | 9 ++++++++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/dali/devel-api/text-abstraction/font-client.cpp b/dali/devel-api/text-abstraction/font-client.cpp index 8484200..7fed0ab 100755 --- a/dali/devel-api/text-abstraction/font-client.cpp +++ b/dali/devel-api/text-abstraction/font-client.cpp @@ -242,6 +242,11 @@ FontClient::FontClient( Internal::FontClient* internal ) { } +FontClient FontClientPreInitialize() +{ + return Internal::FontClient::PreInitialize(); +} + } // namespace TextAbstraction } // namespace Dali diff --git a/dali/devel-api/text-abstraction/font-client.h b/dali/devel-api/text-abstraction/font-client.h index b0219c0..0c3c646 100755 --- a/dali/devel-api/text-abstraction/font-client.h +++ b/dali/devel-api/text-abstraction/font-client.h @@ -482,6 +482,13 @@ public: // Not intended for application developers explicit DALI_INTERNAL FontClient( Internal::FontClient* fontClient ); }; +/** + * @brief This is used to improve application launch performance + * + * @return A pre-initialized FontClient + */ +DALI_ADAPTOR_API FontClient FontClientPreInitialize(); + } // namespace TextAbstraction } // namespace Dali diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index 8e38ca5..3f4ed25 100755 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -80,6 +80,8 @@ void Application::PreInitialize( int* argc, char** argv[] ) { if( !gPreInitializedApplication ) { + Dali::TextAbstraction::FontClientPreInitialize(); + gPreInitializedApplication = new Application ( argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL ); gPreInitializedApplication->CreateWindow(); // Only create window gPreInitializedApplication->mLaunchpadState = Launchpad::PRE_INITIALIZED; diff --git a/dali/internal/text/text-abstraction/font-client-impl.cpp b/dali/internal/text/text-abstraction/font-client-impl.cpp index 1a653d6..4e82a54 100755 --- a/dali/internal/text/text-abstraction/font-client-impl.cpp +++ b/dali/internal/text/text-abstraction/font-client-impl.cpp @@ -38,6 +38,8 @@ namespace TextAbstraction namespace Internal { +Dali::TextAbstraction::FontClient FontClient::gPreInitializedFontClient( NULL ); + FontClient::FontClient() : mPlugin( nullptr ), mDpiHorizontal( 0 ), @@ -67,7 +69,16 @@ Dali::TextAbstraction::FontClient FontClient::Get() } else // create and register the object { - fontClientHandle = Dali::TextAbstraction::FontClient( new FontClient ); + if( gPreInitializedFontClient ) + { + fontClientHandle = gPreInitializedFontClient; + gPreInitializedFontClient.Reset(); // No longer needed + } + else + { + fontClientHandle = Dali::TextAbstraction::FontClient( new FontClient ); + } + service.Register( typeid( fontClientHandle ), fontClientHandle ); } } @@ -75,6 +86,17 @@ Dali::TextAbstraction::FontClient FontClient::Get() return fontClientHandle; } +Dali::TextAbstraction::FontClient FontClient::PreInitialize() +{ + gPreInitializedFontClient = Dali::TextAbstraction::FontClient( new FontClient ); + + // Make DefaultFontDescription cached + Dali::TextAbstraction::FontDescription defaultFontDescription; + gPreInitializedFontClient.GetDefaultPlatformFontDescription( defaultFontDescription ); + + return gPreInitializedFontClient; +} + void FontClient::ClearCache() { if( mPlugin ) diff --git a/dali/internal/text/text-abstraction/font-client-impl.h b/dali/internal/text/text-abstraction/font-client-impl.h index 62cd300..def0799 100755 --- a/dali/internal/text/text-abstraction/font-client-impl.h +++ b/dali/internal/text/text-abstraction/font-client-impl.h @@ -59,6 +59,13 @@ public: static Dali::TextAbstraction::FontClient Get(); /** + * @brief This is used to improve application launch performance + * + * @return A pre-initialized FontClient + */ + static Dali::TextAbstraction::FontClient PreInitialize(); + + /** * @copydoc Dali::TextAbstraction::FontClient::ClearCache() */ void ClearCache(); @@ -261,6 +268,8 @@ private: unsigned int mDpiHorizontal; unsigned int mDpiVertical; + static Dali::TextAbstraction::FontClient gPreInitializedFontClient; + }; // class FontClient } // namespace Internal -- 2.7.4