Revert "[Tizen] Clear cached font data if appended too much"
authorTaehyub Kim <taehyub.kim@samsung.com>
Thu, 8 Jun 2023 04:22:19 +0000 (13:22 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Thu, 8 Jun 2023 04:22:19 +0000 (13:22 +0900)
This reverts commit af27120e57e2b6b6cc28d45fe5375a0450a9e5f9.

dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/multi-language-support-impl.h

index b2ad241..79de1e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 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.
@@ -41,13 +41,6 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_MULT
 DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FONT_PERFORMANCE_MARKER, false);
 
 const Dali::Toolkit::Text::Character UTF32_A = 0x0041;
-
-// TODO : Customization required for these values.
-constexpr std::size_t MAX_VALIDATE_FONTS_PER_SCRIPT_CACHE_SIZE = 63;
-constexpr std::size_t MAX_DEFAULT_FONTS_CACHE_SIZE             = 15;
-
-constexpr int VALIDATE_FONTS_PER_SCRIPT_REMAIN_COUNT = 8;
-constexpr int DEFAULT_FONTS_REMAIN_COUNT             = 2;
 } // namespace
 
 namespace Text
@@ -69,20 +62,6 @@ bool ValidateFontsPerScript::IsValidFont(FontId fontId) const
 
   return false;
 }
-void ValidateFontsPerScript::Cache(FontId fontId)
-{
-  mValidFonts.PushBack(fontId);
-  if(MAX_VALIDATE_FONTS_PER_SCRIPT_CACHE_SIZE < mValidFonts.Count())
-  {
-    // Clear cache but remaind some last items.
-    const auto offset = mValidFonts.Count() - VALIDATE_FONTS_PER_SCRIPT_REMAIN_COUNT;
-    for(int i = 0; i < VALIDATE_FONTS_PER_SCRIPT_REMAIN_COUNT; ++i)
-    {
-      mValidFonts[i] = std::move(mValidFonts[offset + i]);
-    }
-    mValidFonts.Resize(VALIDATE_FONTS_PER_SCRIPT_REMAIN_COUNT);
-  }
-}
 
 FontId DefaultFonts::FindFont(TextAbstraction::FontClient&            fontClient,
                               const TextAbstraction::FontDescription& description,
@@ -114,16 +93,6 @@ void DefaultFonts::Cache(const TextAbstraction::FontDescription& description, Fo
   item.description = description;
   item.fontId      = fontId;
   mFonts.push_back(item);
-  if(MAX_DEFAULT_FONTS_CACHE_SIZE < mFonts.size())
-  {
-    // Clear cache but remaind some last items.
-    const auto offset = mFonts.size() - DEFAULT_FONTS_REMAIN_COUNT;
-    for(int i = 0; i < DEFAULT_FONTS_REMAIN_COUNT; ++i)
-    {
-      mFonts[i] = std::move(mFonts[offset + i]);
-    }
-    mFonts.resize(DEFAULT_FONTS_REMAIN_COUNT);
-  }
 }
 
 MultilanguageSupport::MultilanguageSupport()
@@ -504,10 +473,10 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
   Vector<ScriptRun>::ConstIterator scriptRunEndIt          = scripts.End();
   bool                             isNewParagraphCharacter = false;
 
-  FontId                  previousEmojiFontId = 0u;
-  FontId                  currentFontId       = 0u;
-  FontId                  previousFontId      = 0u;
-  TextAbstraction::Script previousScript      = TextAbstraction::UNKNOWN;
+  FontId previousEmojiFontId = 0u;
+  FontId currentFontId       = 0u;
+  FontId previousFontId      = 0u;
+  TextAbstraction::Script previousScript = TextAbstraction::UNKNOWN;
 
   CharacterIndex lastCharacter = startIndex + numberOfCharacters - 1u;
   for(Length index = startIndex; index <= lastCharacter; ++index)
@@ -658,7 +627,7 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
             *(validFontsPerScriptCacheBuffer + script) = validateFontsPerScript;
           }
 
-          validateFontsPerScript->Cache(fontId);
+          validateFontsPerScript->mValidFonts.PushBack(fontId);
         }
 
         if(!isValidFont && (fontId != cachedDefaultFontId) && (!TextAbstraction::IsNewParagraph(character))) // (3)
@@ -675,7 +644,7 @@ void MultilanguageSupport::ValidateFonts(const Vector<Character>&
           if(isValidCachedFont)
           {
             // Use the cached default font for the script if there is one.
-            fontId      = cachedDefaultFontId;
+            fontId = cachedDefaultFontId;
             isValidFont = true;
           }
           else
index 25a1c1c..cda767a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -67,14 +67,6 @@ struct ValidateFontsPerScript
    */
   bool IsValidFont(FontId fontId) const;
 
-  /**
-   * @brief Cache the given @p fontId in the vector of valid fonts.
-   * @note If cache size is big enough, we might remove some caches.
-   *
-   * @param[in] fontId The font id.
-   */
-  void Cache(FontId fontId);
-
   Vector<FontId> mValidFonts;
 };
 
@@ -117,13 +109,6 @@ struct DefaultFonts
                   const TextAbstraction::FontDescription& description,
                   PointSize26Dot6                         size) const;
 
-  /**
-   * @brief Cache a default font for the given @p size.
-   * @note If cache size is big enough, we might remove some caches.
-   *
-   * @param[in] description The font's description.
-   * @param[in] fontId The font id.
-   */
   void Cache(const TextAbstraction::FontDescription& description, FontId fontId);
 
   std::vector<CacheItem> mFonts;