mVectorFontCache(nullptr),
mEllipsisCache(),
mEmbeddedItemCache(),
+ mLatestFoundFontDescription(),
+ mLatestFoundCacheKey(0, 0),
mDefaultFontDescriptionCached(false),
mIsAtlasLimitationEnabled(TextAbstraction::FontClient::DEFAULT_ATLAS_LIMITATION_ENABLED),
mCurrentMaximumBlockSizeFitInAtlas(TextAbstraction::FontClient::MAX_SIZE_FIT_IN_ATLAS)
mEmbeddedItemCache.Clear();
mBitmapFontCache.clear();
+ mLatestFoundFontDescription.family.clear();
+ mLatestFoundCacheKey = FontDescriptionSizeCacheKey(0, 0);
+
mDefaultFontDescriptionCached = false;
}
fontDescriptionId = 0u;
+ // Fast cut if inputed family is empty.
+ if(DALI_UNLIKELY(fontDescription.family.empty()))
+ {
+ DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " validated font description not found / fontDescription.family is empty!\n");
+ return false;
+ }
+
+ // Heuristic optimize code : Compare with latest found item.
+ if((fontDescription.width == mLatestFoundFontDescription.width) &&
+ (fontDescription.weight == mLatestFoundFontDescription.weight) &&
+ (fontDescription.slant == mLatestFoundFontDescription.slant) &&
+ (fontDescription.family == mLatestFoundFontDescription.family))
+ {
+ fontDescriptionId = mLatestFoundFontDescriptionId;
+
+ DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " validated font description same as latest, id : %d\n", fontDescriptionId);
+ return true;
+ }
+
for(const auto& item : mValidatedFontCache)
{
- if(!fontDescription.family.empty() &&
- (fontDescription.family == item.fontDescription.family) &&
- (fontDescription.width == item.fontDescription.width) &&
+ if((fontDescription.width == item.fontDescription.width) &&
(fontDescription.weight == item.fontDescription.weight) &&
- (fontDescription.slant == item.fontDescription.slant))
+ (fontDescription.slant == item.fontDescription.slant) &&
+ (fontDescription.family == item.fontDescription.family))
{
fontDescriptionId = item.index;
+ mLatestFoundFontDescription = fontDescription;
+ mLatestFoundFontDescriptionId = fontDescriptionId;
+
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " validated font description found, id : %d\n", fontDescriptionId);
return true;
}
fontCacheIndex = 0u;
- FontDescriptionSizeCacheKey key(fontDescriptionId, requestedPointSize);
+ const FontDescriptionSizeCacheKey key(fontDescriptionId, requestedPointSize);
+
+ // Heuristic optimize code : Compare with latest found item.
+ if(key == mLatestFoundCacheKey)
+ {
+ fontCacheIndex = mLatestFoundCacheIndex;
+
+ DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font same as latest, index of font cache : %d\n", fontCacheIndex);
+ return true;
+ }
const auto& iter = mFontDescriptionSizeCache.find(key);
if(iter != mFontDescriptionSizeCache.cend())
{
fontCacheIndex = iter->second;
+ mLatestFoundCacheKey = key;
+ mLatestFoundCacheIndex = fontCacheIndex;
+
DALI_LOG_INFO(gFontClientLogFilter, Debug::General, " font found, index of font cache : %d\n", fontCacheIndex);
return true;
}