// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
#include <fontconfig/fontconfig.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/internal/text/text-abstraction/font-client-impl.h>
#include <dali/internal/text/text-abstraction/plugin/font-client-plugin-impl.h>
namespace
{
+
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FONT_PERFORMANCE_MARKER, false);
+
+/**
+ * @brief Maximum size of glyph cache per each font face.
+ */
+constexpr std::size_t DEFAULT_GLYPH_CACHE_MAX = 128;
+constexpr std::size_t MINIMUM_SIZE_OF_GLYPH_CACHE_MAX = 3u;
+
+constexpr auto MAX_NUMBER_OF_GLYPH_CACHE_ENV = "DALI_GLYPH_CACHE_MAX";
+
+/**
+ * @brief Get maximum size of glyph cache size from environment.
+ * If not settuped, default as 128.
+ * @note This value fixed when we call it first time.
+ * @return The max size of glyph cache.
+ */
+inline size_t GetMaxNumberOfGlyphCache()
+{
+ using Dali::EnvironmentVariable::GetEnvironmentVariable;
+ static auto numberString = GetEnvironmentVariable(MAX_NUMBER_OF_GLYPH_CACHE_ENV);
+ static auto number = numberString ? std::strtoul(numberString, nullptr, 10) : DEFAULT_GLYPH_CACHE_MAX;
+ return (number < MINIMUM_SIZE_OF_GLYPH_CACHE_MAX) ? MINIMUM_SIZE_OF_GLYPH_CACHE_MAX : number;
+}
+
} // namespace
namespace Dali::TextAbstraction::Internal
mFontDescriptionSizeCache(),
mEllipsisCache(),
mEmbeddedItemCache(),
+ mGlyphCacheManager(new GlyphCacheManager(GetMaxNumberOfGlyphCache())),
mLatestFoundFontDescription(),
mLatestFoundFontDescriptionId(0u),
mLatestFoundCacheKey(0, 0),
void FontClient::Plugin::CacheHandler::ClearCache()
{
+ // delete cached glyph informations before clear mFontFaceCache.
+ mGlyphCacheManager->ClearCache();
+
mDefaultFontDescription = FontDescription();
mSystemFonts.clear();
mFontDescriptionCache.push_back(tempFontDescription);
// Set the index to the vector of paths to font file names.
- const FontDescriptionId fontDescriptionId = mFontDescriptionCache.size();
+ const FontDescriptionId fontDescriptionId = static_cast<FontDescriptionId>(mFontDescriptionCache.size());
FONT_LOG_DESCRIPTION(tempFontDescription, "default platform font");
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " default font fontDescriptionId : %d\n", fontDescriptionId);
FontDescriptionId& fontDescriptionId)
{
DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
- DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of validated fonts in the cache : %d\n", mValidatedFontCache.size());
+ DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of validated fonts in the cache : %zu\n", mValidatedFontCache.size());
fontDescriptionId = 0u;
DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
FONT_LOG_DESCRIPTION(fontDescription, "");
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_VALIDATE_FONT");
+
// Create a font pattern.
FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription);
if(matched && (nullptr != characterSet))
{
+ #if defined(TRACE_ENABLED)
+ if(gTraceFilter && gTraceFilter->IsTraceEnabled())
+ {
+ DALI_LOG_DEBUG_INFO("DALI_TEXT_VALIDATE_FONT : FcFontMatch : %s, style : %s, %s, %s\n", fontDescription.family.c_str(), FontWidth::Name[fontDescription.width], FontWeight::Name[fontDescription.weight], FontSlant::Name[fontDescription.slant]);
+ }
+ #endif
+
// Add the path to the cache.
description.type = FontDescription::FACE_FONT;
mFontDescriptionCache.push_back(description);
// Set the index to the vector of paths to font file names.
- fontDescriptionId = mFontDescriptionCache.size();
+ fontDescriptionId = static_cast<FontDescriptionId>(mFontDescriptionCache.size());
FONT_LOG_DESCRIPTION(description, "matched");
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " fontDescriptionId : %d\n", fontDescriptionId);
CharacterSetList*& characterSetList) const
{
DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
- DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of fallback font lists in the cache : %d\n", mFallbackCache.size());
+ DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of fallback font lists in the cache : %zu\n", mFallbackCache.size());
fontList = nullptr;
{
DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_FALLBACK_FONTLIST");
+
+ #if defined(TRACE_ENABLED)
+ if(gTraceFilter && gTraceFilter->IsTraceEnabled())
+ {
+ DALI_LOG_DEBUG_INFO("DALI_TEXT_FALLBACK_FONTLIST : FcFontSort : %s\n", fontDescription.family.c_str());
+ }
+ #endif
+
fontList = new FontList;
characterSetList = new CharacterSetList;
DALI_LOG_TRACE_METHOD(gFontClientLogFilter);
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " path : [%s]\n", path.c_str());
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
- DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of fonts in the cache : %d\n", mFontFaceCache.size());
+ DALI_LOG_INFO(gFontClientLogFilter, Debug::Verbose, " number of fonts in the cache : %zu\n", mFontFaceCache.size());
fontId = 0u;
for(const auto& cacheItem : mFontFaceCache)
mFontDescriptionCache.push_back(description);
// Set the index to the vector of paths to font file names.
- fontDescriptionId = mFontDescriptionCache.size();
+ fontDescriptionId = static_cast<FontDescriptionId>(mFontDescriptionCache.size());
// Increase the reference counter and add the character set to the cache.
mCharacterSetCache.PushBack(FcCharSetCopy(characterSet));
FontId FontClient::Plugin::CacheHandler::CacheFontFaceCacheItem(FontFaceCacheItem&& fontFaceCacheItem)
{
// Set the index to the font's id cache.
- fontFaceCacheItem.mFontId = mFontIdCache.size();
+ fontFaceCacheItem.mFontId = static_cast<FontId>(mFontIdCache.size());
// Create the font id item to cache.
FontIdCacheItem fontIdCacheItem;
fontIdCacheItem.type = FontDescription::FACE_FONT;
// Set the index to the FreeType font face cache.
- fontIdCacheItem.index = mFontFaceCache.size();
+ fontIdCacheItem.index = static_cast<FontCacheIndex>(mFontFaceCache.size());
// Cache the items.
mFontFaceCache.emplace_back(std::move(fontFaceCacheItem));
mFontIdCache.emplace_back(std::move(fontIdCacheItem));
// Set the font id to be returned.
- FontId fontId = mFontIdCache.size();
+ FontId fontId = static_cast<FontId>(mFontIdCache.size());
return fontId;
}
FontClient::Plugin::CacheHandler::EllipsisCacheIndex FontClient::Plugin::CacheHandler::CacheEllipsis(EllipsisItem&& ellipsisItem)
{
- EllipsisCacheIndex ellipsisCacheIndex = mEllipsisCache.size();
+ EllipsisCacheIndex ellipsisCacheIndex = static_cast<EllipsisCacheIndex>(mEllipsisCache.size());
mEllipsisCache.emplace_back(std::move(ellipsisItem));
FontId FontClient::Plugin::CacheHandler::CacheBitmapFontCacheItem(BitmapFontCacheItem&& bitmapFontCacheItem)
{
// Set the index to the font's id cache.
- bitmapFontCacheItem.id = mFontIdCache.size();
+ bitmapFontCacheItem.id = static_cast<FontId>(mFontIdCache.size());
// Create the font id item to cache.
CacheHandler::FontIdCacheItem fontIdCacheItem;
fontIdCacheItem.type = FontDescription::BITMAP_FONT;
// Set the index to the Bitmap font face cache.
- fontIdCacheItem.index = mBitmapFontCache.size();
+ fontIdCacheItem.index = static_cast<FontCacheIndex>(mBitmapFontCache.size());
// Cache the items.
mBitmapFontCache.emplace_back(std::move(bitmapFontCacheItem));
mFontIdCache.emplace_back(std::move(fontIdCacheItem));
// Set the font id to be returned.
- FontId fontId = mFontIdCache.size();
+ FontId fontId = static_cast<FontId>(mFontIdCache.size());
return fontId;
}
PixelBufferCacheItem pixelBufferCacheItem;
pixelBufferCacheItem.pixelBuffer = pixelBuffer;
pixelBufferCacheItem.url = url;
- pixelBufferCacheItem.id = mPixelBufferCache.size() + 1u;
+ pixelBufferCacheItem.id = static_cast<PixelBufferId>(mPixelBufferCache.size() + 1u);
// Store the cache item in the cache.
mPixelBufferCache.emplace_back(std::move(pixelBufferCacheItem));
// Set the pixel buffer id to be returned.
- pixelBufferId = mPixelBufferCache.size();
+ pixelBufferId = static_cast<PixelBufferId>(mPixelBufferCache.size());
}
return pixelBufferId;
}
GlyphIndex FontClient::Plugin::CacheHandler::CacheEmbeddedItem(EmbeddedItem&& embeddedItem)
{
- embeddedItem.index = mEmbeddedItemCache.size() + 1u;
+ embeddedItem.index = static_cast<GlyphIndex>(mEmbeddedItemCache.size() + 1u);
// Cache the embedded item.
mEmbeddedItemCache.emplace_back(std::move(embeddedItem));
// Set the font id to be returned.
- GlyphIndex index = mEmbeddedItemCache.size();
+ GlyphIndex index = static_cast<GlyphIndex>(mEmbeddedItemCache.size());
return index;
}