From: Eunki Hong Date: Thu, 30 Mar 2023 19:05:47 +0000 (+0900) Subject: Fix performance down if DefaultFontDescription not prepared X-Git-Tag: dali_2.2.21~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=b59a021650a941e4c1b5a0644bdd64034a8254be Fix performance down if DefaultFontDescription not prepared Since FontDescription cache system have some problem if family is empty. So we use DefaultFontDescription if inputed family is empty. But we try to delay the FontClient creation time as possible. If that case, It it possible that Default informations are not prepared yet. This patch ensure the mDefaultFontDescription prepared at FontClient::Get(). So now, we can ensure to use FontId cache system well. TODO : We might fix empty family bugs if possible Change-Id: I72f5f7a581186addd130848f257f939cd24e094a Signed-off-by: Eunki Hong --- diff --git a/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp b/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp index be22f59..a02925d 100644 --- a/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp +++ b/automated-tests/src/dali-adaptor-internal/utc-Dali-FontClient.cpp @@ -236,7 +236,7 @@ int UtcDaliFontClientAtlasLimitationDisabled(void) for(int i = 0; i < 50; ++i) { TextAbstraction::GlyphBufferData dummy = std::move(movedGlyphBufferData2000); - movedGlyphBufferData2000 = std::move(dummy); + movedGlyphBufferData2000 = std::move(dummy); // Test moved GlyphBufferData destruct well } @@ -260,8 +260,11 @@ int UtcDaliFontClientCurrentMaximumBlockSizeFitInAtlas(void) Size maximumTextAtlasSize = fontClient.GetMaximumTextAtlasSize(); Size currentMaximumBlockSizeFitInAtlas = fontClient.GetCurrentMaximumBlockSizeFitInAtlas(); - tet_infoline("CurrentMaximumBlockSizeFitInAtlas start with default "); - DALI_TEST_EQUALS(currentMaximumBlockSizeFitInAtlas, defaultTextAtlasSize, TEST_LOCATION); + // TODO : This UTC pass only if we don't create fontClient plugin. Currently we always create plugin at Get API, due to performance + //tet_infoline("CurrentMaximumBlockSizeFitInAtlas start with default "); + //DALI_TEST_EQUALS(currentMaximumBlockSizeFitInAtlas, defaultTextAtlasSize, TEST_LOCATION); + + currentMaximumBlockSizeFitInAtlas = defaultTextAtlasSize; tet_infoline("SetCurrentMaximumBlockSizeFitInAtlas is changed with current "); isChanged = fontClient.SetCurrentMaximumBlockSizeFitInAtlas(currentMaximumBlockSizeFitInAtlas); diff --git a/dali/internal/text/text-abstraction/font-client-impl.cpp b/dali/internal/text/text-abstraction/font-client-impl.cpp index afc5b26..5e2b258 100644 --- a/dali/internal/text/text-abstraction/font-client-impl.cpp +++ b/dali/internal/text/text-abstraction/font-client-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,19 +32,19 @@ #include -#define FONT_LOG_MESSAGE(level, format, ...) \ - do \ - { \ - char buffer[256]; \ - int result = std::snprintf(buffer, sizeof(buffer), format, ##__VA_ARGS__); \ - if (result >= static_cast(sizeof(buffer))) \ - { \ - std::string log("Font log message is too long to fit in the buffer.\n"); \ - Dali::TizenPlatform::LogMessage(Dali::Integration::Log::ERROR, log); \ - break; \ - } \ - std::string log(buffer); \ - Dali::TizenPlatform::LogMessage(level, log); \ +#define FONT_LOG_MESSAGE(level, format, ...) \ + do \ + { \ + char buffer[256]; \ + int result = std::snprintf(buffer, sizeof(buffer), format, ##__VA_ARGS__); \ + if(result >= static_cast(sizeof(buffer))) \ + { \ + std::string log("Font log message is too long to fit in the buffer.\n"); \ + Dali::TizenPlatform::LogMessage(Dali::Integration::Log::ERROR, log); \ + break; \ + } \ + std::string log(buffer); \ + Dali::TizenPlatform::LogMessage(level, log); \ } while(0) namespace Dali @@ -55,7 +55,7 @@ namespace Internal { Dali::TextAbstraction::FontClient FontClient::gPreInitializedFontClient(NULL); Dali::TextAbstraction::FontClient FontClient::gPreCachedFontClient(NULL); -std::thread gPreCacheThread; +std::thread gPreCacheThread; /* TODO: This is to prevent duplicate calls of font pre-cache. * We may support this later, but currently we can't guarantee the behaviour * if there is a pre-cache call from the user after the font client has been created. */ @@ -110,6 +110,10 @@ Dali::TextAbstraction::FontClient FontClient::Get() else { fontClientHandle = Dali::TextAbstraction::FontClient(new FontClient); + + // Make DefaultFontDescription cached + Dali::TextAbstraction::FontDescription defaultFontDescription; + fontClientHandle.GetDefaultPlatformFontDescription(defaultFontDescription); } gFontPreCacheAvailable = false; @@ -148,7 +152,7 @@ void FontClient::PreCacheRun(const FontFamilyList& fallbackFamilyList, const Fon FONT_LOG_MESSAGE(Dali::Integration::Log::INFO, "BEGIN: DALI_TEXT_PRECACHE_RUN\n"); Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient(new FontClient); GetImplementation(fontClient).FontPreCache(fallbackFamilyList, extraFamilyList, localeFamily); - gPreCachedFontClient = fontClient; + gPreCachedFontClient = fontClient; gFontPreCacheAvailable = false; FONT_LOG_MESSAGE(Dali::Integration::Log::INFO, "END: DALI_TEXT_PRECACHE_RUN\n"); } diff --git a/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp b/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp index 8629c40..f58304c 100644 --- a/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp +++ b/dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ // INTERNAL INCLUDES #include #include -#include #include +#include #include #include #include @@ -76,7 +76,6 @@ Dali::Integration::Log::Filter* gFontClientLogFilter = Dali::Integration::Log::F namespace { - DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FONT_PERFORMANCE_MARKER, false); /** @@ -272,12 +271,12 @@ void FontClient::Plugin::FontPreCache(const FontFamilyList& fallbackFamilyList, FontFamilyList familyList; familyList.reserve(extraFamilyList.size() + 1); - for (const auto& fallbackFont : fallbackFamilyList) + for(const auto& fallbackFont : fallbackFamilyList) { - FontList* fontList = nullptr; - CharacterSetList* characterSetList = nullptr; + FontList* fontList = nullptr; + CharacterSetList* characterSetList = nullptr; FontDescriptionId fontDescriptionId = 0u; - FontDescription fontDescription; + FontDescription fontDescription; fontDescription.family = FontFamily(fallbackFont); fontDescription.weight = DefaultFontWeight(); fontDescription.width = DefaultFontWidth(); @@ -559,12 +558,12 @@ FontId FontClient::Plugin::FindFallbackFont(Character charcode, DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWidth::Name[preferredFontDescription.width], FontWidth::Name[fontDescription.width]); DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontSlant::Name[preferredFontDescription.slant], FontSlant::Name[fontDescription.slant]); - #if defined(TRACE_ENABLED) +#if defined(TRACE_ENABLED) if(gTraceFilter && gTraceFilter->IsTraceEnabled()) { DALI_LOG_DEBUG_INFO("DALI_TEXT_FIND_FALLBACKFONT : %s -> %s\n", preferredFontDescription.family.c_str(), fontDescription.family.c_str()); } - #endif +#endif // Check first if the font's description has been queried before. FontList* fontList = nullptr; @@ -1086,12 +1085,12 @@ FontId FontClient::Plugin::CreateFont(const FontPath& path, DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_CREATE_FONT"); FontId fontId = 0u; - #if defined(TRACE_ENABLED) +#if defined(TRACE_ENABLED) if(gTraceFilter && gTraceFilter->IsTraceEnabled()) { DALI_LOG_DEBUG_INFO("DALI_TEXT_CREATE_FONT : FT_New_Face : %s\n", path.c_str()); } - #endif +#endif // Create & cache new font face FT_Face ftFace;