[dali_1.0.44] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / atlas / atlas-glyph-manager-impl.h
1
2 #ifndef __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
3 #define __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__
4
5 /*
6  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21
22 // EXTERNAL INCLUDES
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/object/base-object.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 class AtlasGlyphManager;
36
37 } // namespace Toolkit
38
39 namespace Toolkit
40 {
41
42 namespace Internal
43 {
44
45 class AtlasGlyphManager;
46 typedef IntrusivePtr<AtlasGlyphManager> AtlasGlyphManagerPtr;
47
48 class AtlasGlyphManager : public Dali::BaseObject
49 {
50 public:
51
52   struct GlyphRecordEntry
53   {
54     Text::GlyphIndex mIndex;
55     uint32_t mImageId;
56     int32_t mCount;
57   };
58
59   struct FontGlyphRecord
60   {
61     Text::FontId mFontId;
62     Vector< GlyphRecordEntry > mGlyphRecords;
63   };
64
65   AtlasGlyphManager();
66
67   virtual ~AtlasGlyphManager();
68
69 /**
70    * Create a new AtlasGlyphManager
71    */
72   static AtlasGlyphManagerPtr New();
73
74   /**
75    * @copydoc Toolkit::AtlasGlyphManager::Add
76    */
77   void Add( Text::FontId fontId,
78             const Text::GlyphInfo& glyph,
79             const BufferImage& bitmap,
80             Dali::Toolkit::AtlasManager::AtlasSlot& slot );
81
82   /**
83    * @copydoc Toolkit::AtlasGlyphManager::GenerateMeshData
84    */
85   void GenerateMeshData( uint32_t imageId,
86                          const Vector2& position,
87                          MeshData& meshData );
88
89   /**
90    * @copydoc Toolkit::AtlasGlyphManager::StitchMesh
91    */
92   void StitchMesh( MeshData& first,
93                    const MeshData& second );
94
95   /**
96    * @copydoc Toolkit::AtlasGlyphManager::Cached
97    */
98   bool Cached( Text::FontId fontId,
99                Text::GlyphIndex index,
100                Dali::Toolkit::AtlasManager::AtlasSlot& slot );
101
102   /**
103    * @copydoc Toolkit::AtlasGlyphManager::GetAtlasSize
104    */
105   Vector2 GetAtlasSize( uint32_t atlasId );
106
107   /**
108    * @copydoc Toolkit::AtlasGlyphManager::SetNewAtlasSize
109    */
110   void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
111
112   /**
113    * @copydoc toolkit::AtlasGlyphManager::GetPixelFormat
114    */
115   Pixel::Format GetPixelFormat( uint32_t atlasId );
116
117   /**
118    * @copydoc toolkit::AtlasGlyphManager::GetMetrics
119    */
120   const Toolkit::AtlasGlyphManager::Metrics& GetMetrics();
121
122   /**
123    * @copydoc toolkit::AtlasGlyphManager::AdjustReferenceCount
124    */
125   void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
126
127 private:
128
129   Dali::Toolkit::AtlasManager mAtlasManager;
130   std::vector< FontGlyphRecord > mFontGlyphRecords;
131   uint32_t mCount;
132   Toolkit::AtlasGlyphManager::Metrics mMetrics;
133 };
134
135 } // namespace Internal
136
137 inline const Internal::AtlasGlyphManager& GetImplementation(const Toolkit::AtlasGlyphManager& manager)
138 {
139   DALI_ASSERT_ALWAYS( manager && "AtlasGlyphManager handle is empty" );
140
141   const BaseObject& handle = manager.GetBaseObject();
142
143   return static_cast<const Internal::AtlasGlyphManager&>(handle);
144 }
145
146 inline Internal::AtlasGlyphManager& GetImplementation(Toolkit::AtlasGlyphManager& manager)
147 {
148   DALI_ASSERT_ALWAYS( manager && "AtlasGlyphManager handle is empty" );
149
150   BaseObject& handle = manager.GetBaseObject();
151
152   return static_cast<Internal::AtlasGlyphManager&>(handle);
153 }
154
155 } // namespace Toolkit
156
157 } // namespace Dali
158
159
160  #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__