c4da1ba9413402d8ed732fca82442063e0d97153
[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 GlyphRecord
53   {
54     Text::FontId mFontId;
55     Text::GlyphIndex mIndex;
56     uint32_t mImageId;
57   };
58
59   AtlasGlyphManager();
60
61   virtual ~AtlasGlyphManager();
62
63 /**
64    * Create a new AtlasGlyphManager
65    */
66   static AtlasGlyphManagerPtr New();
67
68   /**
69    * @copydoc Toolkit::AtlasGlyphManager::Add
70    */
71   void Add( const Text::GlyphInfo& glyph,
72             const BufferImage& bitmap,
73             Dali::Toolkit::AtlasManager::AtlasSlot& slot );
74
75   /**
76    * @copydoc Toolkit::AtlasGlyphManager::GenerateMeshData
77    */
78   void GenerateMeshData( uint32_t imageId,
79                          const Vector2& position,
80                          MeshData& meshData );
81
82   /**
83    * @copydoc Toolkit::AtlasGlyphManager::StitchMesh
84    */
85   void StitchMesh( MeshData& first,
86                    const MeshData& second );
87
88   /**
89    * @copydoc Toolkit::AtlasGlyphManager::Cached
90    */
91   void Cached( Text::FontId fontId,
92                Text::GlyphIndex index,
93                Dali::Toolkit::AtlasManager::AtlasSlot& slot );
94
95   /**
96    * @copydoc Toolkit::AtlasGlyphManager::SetAtlasSize
97    */
98   void SetAtlasSize( const Vector2& size,
99                      const Vector2& blockSize );
100
101   /**
102    * @copydoc Toolkit::AtlasGlyphManager::Remove
103    */
104   void Remove( uint32_t imageId );
105
106   /**
107    * @copydoc toolkit::AtlasGlyphManager::GetPixelFormat
108    */
109   Pixel::Format GetPixelFormat( uint32_t atlasId );
110
111 private:
112
113   Dali::Toolkit::AtlasManager mAtlasManager;
114   Vector< GlyphRecord > mGlyphRecords;
115   uint32_t mCount;
116 };
117
118 } // namespace Internal
119
120 inline const Internal::AtlasGlyphManager& GetImplementation(const Toolkit::AtlasGlyphManager& manager)
121 {
122   DALI_ASSERT_ALWAYS( manager && "AtlasGlyphManager handle is empty" );
123
124   const BaseObject& handle = manager.GetBaseObject();
125
126   return static_cast<const Internal::AtlasGlyphManager&>(handle);
127 }
128
129 inline Internal::AtlasGlyphManager& GetImplementation(Toolkit::AtlasGlyphManager& manager)
130 {
131   DALI_ASSERT_ALWAYS( manager && "AtlasGlyphManager handle is empty" );
132
133   BaseObject& handle = manager.GetBaseObject();
134
135   return static_cast<Internal::AtlasGlyphManager&>(handle);
136 }
137
138 } // namespace Toolkit
139
140 } // namespace Dali
141
142
143  #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_IMPL_H__