[dali_2.3.22] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / atlas / atlas-glyph-manager-impl.h
index cbbe732..26bd6e3 100644 (file)
@@ -1,9 +1,8 @@
-
-#ifndef __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
-#define __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
+#ifndef DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H
+#define DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H
 
 /*
- * Copyright (c) 2015 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.
@@ -18,7 +17,6 @@
  * limitations under the License.
  */
 
-
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/base-object.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 class AtlasGlyphManager;
 
 } // namespace Toolkit
 
 namespace Toolkit
 {
-
 namespace Internal
 {
-
 class AtlasGlyphManager;
 typedef IntrusivePtr<AtlasGlyphManager> AtlasGlyphManagerPtr;
 
 class AtlasGlyphManager : public Dali::BaseObject
 {
 public:
-
-  struct GlyphRecord
+  struct GlyphRecordEntry
   {
-    Text::FontId mFontId;
     Text::GlyphIndex mIndex;
-    uint32_t mImageId;
+    uint32_t         mImageId;
+    int32_t          mCount;
+    uint16_t         mOutlineWidth;
+    bool             isItalic : 1;
+    bool             isBold : 1;
   };
 
-  AtlasGlyphManager();
-
-  virtual ~AtlasGlyphManager();
+  struct FontGlyphRecord
+  {
+    Text::FontId             mFontId;
+    Vector<GlyphRecordEntry> mGlyphRecords;
+  };
 
-/**
-   * Create a new AtlasGlyphManager
+  /**
+   * @brief Constructor
    */
-  static AtlasGlyphManagerPtr New();
+  AtlasGlyphManager();
 
   /**
    * @copydoc Toolkit::AtlasGlyphManager::Add
    */
-  void Add( const Text::GlyphInfo& glyph,
-            const BufferImage& bitmap,
-            Dali::Toolkit::AtlasManager::AtlasSlot& slot );
+  void Add(const Text::GlyphInfo&                        glyph,
+           const Toolkit::AtlasGlyphManager::GlyphStyle& style,
+           const PixelData&                              bitmap,
+           Dali::Toolkit::AtlasManager::AtlasSlot&       slot);
 
   /**
    * @copydoc Toolkit::AtlasGlyphManager::GenerateMeshData
    */
-  void GenerateMeshData( uint32_t imageId,
-                         const Vector2& position,
-                         MeshData& meshData );
+  void GenerateMeshData(uint32_t                       imageId,
+                        const Vector2&                 position,
+                        Toolkit::AtlasManager::Mesh2D& mesh);
 
   /**
-   * @copydoc Toolkit::AtlasGlyphManager::StitchMesh
+   * @copydoc Toolkit::AtlasGlyphManager::IsCached
    */
-  void StitchMesh( MeshData& first,
-                   const MeshData& second );
+  bool IsCached(Text::FontId                                  fontId,
+                Text::GlyphIndex                              index,
+                const Toolkit::AtlasGlyphManager::GlyphStyle& style,
+                Dali::Toolkit::AtlasManager::AtlasSlot&       slot);
 
   /**
-   * @copydoc Toolkit::AtlasGlyphManager::Cached
+   * @copydoc Toolkit::AtlasGlyphManager::GetAtlasSize
    */
-  void Cached( Text::FontId fontId,
-               Text::GlyphIndex index,
-               Dali::Toolkit::AtlasManager::AtlasSlot& slot );
+  Vector2 GetAtlasSize(uint32_t atlasId);
 
   /**
-   * @copydoc Toolkit::AtlasGlyphManager::GetAtlasSize
+   * @copydoc Toolkit::AtlasGlyphManager::SetNewAtlasSize
    */
-  Vector2 GetAtlasSize( uint32_t atlasId );
+  void SetNewAtlasSize(uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight);
 
   /**
-   * @copydoc Toolkit::AtlasGlyphManager::SetNewAtlasSize
+   * @copydoc Toolkit::AtlasGlyphManager::GetPixelFormat
    */
-  void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
+  Pixel::Format GetPixelFormat(uint32_t atlasId);
 
   /**
-   * @copydoc Toolkit::AtlasGlyphManager::Remove
+   * @copydoc toolkit::AtlasGlyphManager::AdjustReferenceCount
    */
-  void Remove( uint32_t imageId );
+  void AdjustReferenceCount(Text::FontId fontId, Text::GlyphIndex index, const Toolkit::AtlasGlyphManager::GlyphStyle& style, int32_t delta);
 
   /**
-   * @copydoc toolkit::AtlasGlyphManager::GetPixelFormat
+   * @copydoc Toolkit::AtlasGlyphManager::GetTextures
    */
-  Pixel::Format GetPixelFormat( uint32_t atlasId );
+  TextureSet GetTextures(uint32_t atlasId) const;
 
   /**
-   * @copydoc toolkit::AtlasGlyphManager::GetMetrics
+   * @copydoc Toolkit::AtlasGlyphManager::GetMetrics
    */
   const Toolkit::AtlasGlyphManager::Metrics& GetMetrics();
 
-private:
+protected:
+  /**
+   * A reference counted object may only be deleted by calling Unreference()
+   */
+  virtual ~AtlasGlyphManager();
 
-  Dali::Toolkit::AtlasManager mAtlasManager;
-  Vector< GlyphRecord > mGlyphRecords;
-  uint32_t mCount;
-  Toolkit::AtlasGlyphManager::Metrics mMetrics;
+private:
+  Dali::Toolkit::AtlasManager         mAtlasManager; ///> Atlas Manager created by GlyphManager
+  std::vector<FontGlyphRecord>        mFontGlyphRecords;
+  Toolkit::AtlasGlyphManager::Metrics mMetrics; ///> Metrics to pass back on GlyphManager status
+  Sampler                             mSampler;
 };
 
 } // namespace Internal
 
 inline const Internal::AtlasGlyphManager& GetImplementation(const Toolkit::AtlasGlyphManager& manager)
 {
-  DALI_ASSERT_ALWAYS( manager && "AtlasGlyphManager handle is empty" );
+  DALI_ASSERT_ALWAYS(manager && "AtlasGlyphManager handle is empty");
 
   const BaseObject& handle = manager.GetBaseObject();
 
@@ -138,7 +142,7 @@ inline const Internal::AtlasGlyphManager& GetImplementation(const Toolkit::Atlas
 
 inline Internal::AtlasGlyphManager& GetImplementation(Toolkit::AtlasGlyphManager& manager)
 {
-  DALI_ASSERT_ALWAYS( manager && "AtlasGlyphManager handle is empty" );
+  DALI_ASSERT_ALWAYS(manager && "AtlasGlyphManager handle is empty");
 
   BaseObject& handle = manager.GetBaseObject();
 
@@ -149,5 +153,4 @@ inline Internal::AtlasGlyphManager& GetImplementation(Toolkit::AtlasGlyphManager
 
 } // namespace Dali
 
-
- #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
\ No newline at end of file
+#endif // DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H