[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / atlas / atlas-glyph-manager.h
index 6a10947..f1a292b 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
-#define __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
+#ifndef DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H
+#define DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H
 
 /*
- * Copyright (c) 2015 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.
  */
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/atlas-manager/atlas-manager.h>
+#include <dali-toolkit/internal/text/rendering/atlas/atlas-manager.h>
 #include <dali-toolkit/internal/text/text-definitions.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal DALI_INTERNAL
 {
 class AtlasGlyphManager;
 }
 
-
 class AtlasGlyphManager : public BaseHandle
 {
 public:
-
   /**
    * Description of GlyphManager state
    */
   struct Metrics
   {
-    uint32_t mGlyphCount;                   // number of glyphs being managed
-    AtlasManager::Metrics mAtlasMetrics;    // metrics from the Atlas Manager
+    Metrics()
+    : mGlyphCount(0u)
+    {
+    }
+
+    ~Metrics()
+    {
+    }
+
+    uint32_t              mGlyphCount;         ///< number of glyphs being managed
+    std::string           mVerboseGlyphCounts; ///< a verbose list of the glyphs + ref counts
+    AtlasManager::Metrics mAtlasMetrics;       ///< metrics from the Atlas Manager
+  };
+
+  struct GlyphStyle
+  {
+    GlyphStyle()
+    : outline{0u},
+      isItalic{false},
+      isBold{false}
+    {
+    }
+
+    uint16_t outline;      ///< The outline width of this glyph
+    bool     isItalic : 1; ///< Whether the glyph is italic.
+    bool     isBold : 1;   ///< Whether the glyph is bold.
   };
 
   /**
@@ -72,12 +92,14 @@ public:
    * @brief Ask Atlas Manager to add a glyph
    *
    * @param[in] glyph glyph to add to an atlas
+   * @param[in] style The style of this glyph
    * @param[in] bitmap bitmap to use for glyph addition
    * @param[out] slot information returned by atlas manager for addition
    */
-  void Add( const Text::GlyphInfo& glyph,
-            const BufferImage& bitmap,
-            AtlasManager::AtlasSlot& slot );
+  void Add(const Text::GlyphInfo&   glyph,
+           const GlyphStyle&        style,
+           const PixelData&         bitmap,
+           AtlasManager::AtlasSlot& slot);
 
   /**
    * @brief Generate mesh data for an image contained in an atlas
@@ -86,29 +108,24 @@ public:
    * @param[in] position top left of image
    * @param[out] meshData generated MeshData
    */
-  void GenerateMeshData( uint32_t imageId,
-                         const Vector2& position,
-                         MeshData& meshData );
-
-  /**
-   * @brief Stitch Two Meshes together
-   *
-   * @param[in] first first mesh
-   * @param[in] second second mesh
-   */
-  void StitchMesh( MeshData& first,
-                   const MeshData& second );
+  void GenerateMeshData(uint32_t                       imageId,
+                        const Vector2&                 position,
+                        Toolkit::AtlasManager::Mesh2D& mesh);
 
   /**
    * @brief Check to see if a glyph is being cached
    *
    * @param[in] fontId The font that this glyph comes from
    * @param[in] index The GlyphIndex of this glyph
+   * @param[in] style The style of this glyph
    * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
+   *
+   * @return Whether glyph is cached or not ?
    */
-  void Cached( Text::FontId fontId,
-               Text::GlyphIndex index,
-               AtlasManager::AtlasSlot& slot );
+  bool IsCached(Text::FontId             fontId,
+                Text::GlyphIndex         index,
+                const GlyphStyle&        style,
+                AtlasManager::AtlasSlot& slot);
 
   /**
    * @brief Retrieve the size of an atlas
@@ -117,32 +134,35 @@ public:
    *
    * @return The pixel size of the atlas
    */
-  Vector2 GetAtlasSize( uint32_t atlasId );
+  Vector2 GetAtlasSize(uint32_t atlasId);
 
   /**
-   * @brief Set the Atlas size and block size for subsequent atlas generation
-   *
-   * @param[in] size size of the atlas in pixels
-   * @param[in] blockSize size of a block in this atlas in pixels
-   */
-  void SetNewAtlasSize( const Vector2& size,
-                        const Vector2& blockSize );
+    * @brief Set the atlas size and block size for subsequent Atlas generation
+    *
+    * @param[in] width width of atlas in pixels
+    * @param[in] height height of atlas in pixels
+    * @param[in] blockWidth width of a block in pixels
+    * @param[in] blockHeight height of a block in pixels
+    */
+  void SetNewAtlasSize(uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight);
 
   /**
-   * @brief Unreference an image from the atlas and remove from cache if no longer needed
+   * @brief Get the Pixel Format used by an atlas
+   *
+   * @param[in] atlasId Id of atlas to check
    *
-   * @param[in] imageId ID of the image
+   * @return The pixel format of the atlas
    */
-  void Remove( uint32_t imageId );
+  Pixel::Format GetPixelFormat(uint32_t atlasId);
 
   /**
-   * @brief Get the Pixel Format used by an atlas
+   * @brief Get the texture set used by an atlas
    *
-   * @param[in] atlasId Id of atlas to check
+   * @param[in] atlasId Id of an atlas
    *
-   * @return The pixel format of the atlas
+   * @return The texture set used by the atlas
    */
-  Pixel::Format GetPixelFormat( uint32_t atlasId );
+  TextureSet GetTextures(uint32_t atlasId) const;
 
   /**
    * @brief Get Glyph Manager metrics
@@ -151,14 +171,29 @@ public:
    */
   const Metrics& GetMetrics();
 
-private:
+  /**
+   * @brief Adjust the reference count for glyph
+   *
+   * @param[in] fontId The font this image came from
+   * @param[in] index The index of the glyph
+   * @param[in] style The style of this glyph
+   * @param[in] delta The adjustment to make to the reference count
+   */
+  void AdjustReferenceCount(Text::FontId fontId, Text::GlyphIndex index, const GlyphStyle& style, int32_t delta);
 
-  explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
+public:
+  // Default copy and move operator
+  AtlasGlyphManager(const AtlasGlyphManager& rhs) = default;
+  AtlasGlyphManager(AtlasGlyphManager&& rhs)      = default;
+  AtlasGlyphManager& operator=(const AtlasGlyphManager& rhs) = default;
+  AtlasGlyphManager& operator=(AtlasGlyphManager&& rhs) = default;
 
+private:
+  explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager* impl);
 };
 
 } // namespace Toolkit
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
+#endif // DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H