Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / atlas / atlas-glyph-manager.h
1 #ifndef __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
2 #define __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/atlas-manager/atlas-manager.h>
23 #include <dali-toolkit/internal/text/text-definitions.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class AtlasGlyphManager;
34 }
35
36
37 class DALI_IMPORT_API AtlasGlyphManager : public BaseHandle
38 {
39 public:
40
41   /**
42    * @brief Create a AtlasGlyphManager handle.
43    *
44    * Calling member functions with an uninitialised handle is not allowed.
45    */
46   AtlasGlyphManager();
47
48   /**
49    * @brief Destructor
50    *
51    * This is non-virtual since derived Handle types must not contain data or virtual methods.
52    */
53   ~AtlasGlyphManager();
54
55   /**
56    * @brief Create or retrieve AtlasGlyphManager singleton.
57    *
58    * @return A handle to the AtlasGlyphManager control.
59    */
60   static AtlasGlyphManager Get();
61
62   /**
63    * @brief Ask Atlas Manager to add a glyph
64    *
65    * @param[in] glyph glyph to add to an atlas
66    * @param[in] bitmap bitmap to use for glyph addition
67    * @param[out] slot information returned by atlas manager for addition
68    */
69   void Add( const Text::GlyphInfo& glyph,
70             const BufferImage& bitmap,
71             AtlasManager::AtlasSlot& slot );
72
73   /**
74    * @brief Generate mesh data for an image contained in an atlas
75    *
76    * @param[in] imageId ID of image to generate geometry for
77    * @param[in] position top left of image
78    * @param[out] meshData generated MeshData
79    */
80   void GenerateMeshData( uint32_t imageId,
81                          const Vector2& position,
82                          MeshData& meshData );
83
84   /**
85    * @brief Stitch Two Meshes together
86    *
87    * @param[in] first first mesh
88    * @param[in] second second mesh
89    */
90   void StitchMesh( MeshData& first,
91                    const MeshData& second );
92
93   /**
94    * @brief Check to see if a glyph is being cached
95    *
96    * @param[in] fontId The font that this glyph comes from
97    * @param[in] index The GlyphIndex of this glyph
98    * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
99    */
100   void Cached( Text::FontId fontId,
101                Text::GlyphIndex index,
102                AtlasManager::AtlasSlot& slot );
103
104   /**
105    * @brief Set the Atlas size and block size for subsequent atlas generation
106    *
107    * @param[in] size size of the atlas in pixels
108    * @param[in] blockSize size of a block in this atlas in pixels
109    */
110   void SetAtlasSize( const Vector2& size,
111                      const Vector2& blockSize );
112
113   /**
114    * @brief Unreference an image from the atlas and remove from cache if no longer needed
115    *
116    * @param[in] imageId ID of the image
117    */
118   void Remove( uint32_t imageId );
119
120   /**
121    * @brief Get the Pixel Format used by an atlas
122    *
123    * @param atlasId Id of atlas to check
124    * @return The pixel format of the atlas
125    */
126   Pixel::Format GetPixelFormat( uint32_t atlasId );
127
128 private:
129
130   explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
131
132 };
133
134 } // namespace Toolkit
135
136 } // namespace Dali
137
138 #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__