Refactored font-client-plugin-impl
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / plugin / font-client-plugin-impl.h
index a8de931..6274cdf 100644 (file)
 #include <dali/devel-api/text-abstraction/font-metrics.h>
 #include <dali/devel-api/text-abstraction/glyph-info.h>
 #include <dali/internal/text/text-abstraction/font-client-impl.h>
+#include <dali/internal/text/text-abstraction/plugin/bitmap-font-cache-item.h>
+#include <dali/internal/text/text-abstraction/plugin/embedded-item.h>
+#include <dali/internal/text/text-abstraction/plugin/font-face-cache-item.h>
+#include <dali/internal/text/text-abstraction/plugin/pixel-buffer-cache-item.h>
 
 #ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
 #include <third-party/glyphy/vector-font-cache.h>
@@ -55,11 +59,6 @@ namespace Internal
 typedef uint32_t FontDescriptionId;
 
 /**
- * @brief Type used for indices addressing the vector with pixel buffers.
- */
-typedef uint32_t PixelBufferId;
-
-/**
  * @brief Vector of character sets.
  */
 typedef Vector<_FcCharSet*> CharacterSetList;
@@ -115,42 +114,6 @@ struct FontClient::Plugin
     FontId            fontId;             ///< The font identifier.
   };
 
-  /**
-   * @brief Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'.
-   */
-  struct FontFaceCacheItem
-  {
-    FontFaceCacheItem(FT_Face            ftFace,
-                      const FontPath&    path,
-                      PointSize26Dot6    requestedPointSize,
-                      FaceIndex          face,
-                      const FontMetrics& metrics);
-
-    FontFaceCacheItem(FT_Face            ftFace,
-                      const FontPath&    path,
-                      PointSize26Dot6    requestedPointSize,
-                      FaceIndex          face,
-                      const FontMetrics& metrics,
-                      int                fixedSizeIndex,
-                      float              fixedWidth,
-                      float              fixedHeight,
-                      bool               hasColorTables);
-
-    FT_Face         mFreeTypeFace;          ///< The FreeType face.
-    FontPath        mPath;                  ///< The path to the font file name.
-    PointSize26Dot6 mRequestedPointSize;    ///< The font point size.
-    FaceIndex       mFaceIndex;             ///< The face index.
-    FontMetrics     mMetrics;               ///< The font metrics.
-    _FcCharSet*     mCharacterSet;          ///< Pointer with the range of characters.
-    int             mFixedSizeIndex;        ///< Index to the fixed size table for the requested size.
-    float           mFixedWidthPixels;      ///< The height in pixels (fixed size bitmaps only)
-    float           mFixedHeightPixels;     ///< The height in pixels (fixed size bitmaps only)
-    unsigned int    mVectorFontId;          ///< The ID of the equivalent vector-based font
-    FontId          mFontId;                ///< Index to the vector with the cache of font's ids.
-    bool            mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps.
-    bool            mHasColorTables : 1;    ///< Whether the font has color tables.
-  };
-
   struct EllipsisItem
   {
     PointSize26Dot6 requestedPointSize;
@@ -158,35 +121,6 @@ struct FontClient::Plugin
   };
 
   /**
-   * @brief Caches pixel buffers.
-   */
-  struct PixelBufferCacheItem
-  {
-    Devel::PixelBuffer pixelBuffer; ///< The pixel buffer loaded from the url.
-    std::string        url;         ///< The url.
-  };
-
-  /**
-   * @brief Caches embedded items.
-   */
-  struct EmbeddedItem
-  {
-    PixelBufferId pixelBufferId; ///< Index to the vector of pixel buffers
-    unsigned int  width;         ///< The desired width.
-    unsigned int  height;        ///< The desired height.
-  };
-
-  /**
-   * @brief Stores a bitmap font and its pixel buffers per glyph.
-   */
-  struct BitmapFontCacheItem
-  {
-    BitmapFont                      font;         ///< The bitmap font.
-    std::vector<Devel::PixelBuffer> pixelBuffers; ///< The pixel buffers of the glyphs.
-    FontId                          id;           ///< Index to the vector with the cache of font's ids.
-  };
-
-  /**
    * Constructor.
    *
    * Initializes the FreeType library.
@@ -255,6 +189,13 @@ struct FontClient::Plugin
   bool IsCharacterSupportedByFont(FontId fontId, Character character);
 
   /**
+   * Get the cached font item for the given font
+   * @param[in] id The font id to search for
+   * @return the matching cached font item
+   */
+  const FontCacheItemInterface* GetCachedFontItem(FontId id) const;
+
+  /**
    * @brief Finds within the @p fontList a font which support the @p carcode.
    *
    * @param[in] fontList A list of font paths, family, width, weight and slant.
@@ -608,10 +549,8 @@ private:
   void ClearCharacterSetFromFontFaceCache();
 
 private:
-  // Declared private and left undefined to avoid copies.
-  Plugin(const Plugin&);
-  // Declared private and left undefined to avoid copies.
-  Plugin& operator=(const Plugin&);
+  Plugin(const Plugin&) = delete;
+  Plugin& operator=(const Plugin&) = delete;
 
 private:
   FT_Library mFreeTypeLibrary; ///< A handle to a FreeType library instance.