1 #ifndef __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
2 #define __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/internal/atlas-manager/atlas-manager.h>
23 #include <dali-toolkit/internal/text/text-definitions.h>
31 namespace Internal DALI_INTERNAL
33 class AtlasGlyphManager;
37 class AtlasGlyphManager : public BaseHandle
42 * Description of GlyphManager state
53 uint32_t mGlyphCount; // number of glyphs being managed
54 AtlasManager::Metrics mAtlasMetrics; // metrics from the Atlas Manager
58 * @brief Create a AtlasGlyphManager handle.
60 * Calling member functions with an uninitialised handle is not allowed.
67 * This is non-virtual since derived Handle types must not contain data or virtual methods.
72 * @brief Create or retrieve AtlasGlyphManager singleton.
74 * @return A handle to the AtlasGlyphManager control.
76 static AtlasGlyphManager Get();
79 * @brief Ask Atlas Manager to add a glyph
81 * @param[in] fontId fontId glyph comes from
82 * @param[in] glyph glyph to add to an atlas
83 * @param[in] bitmap bitmap to use for glyph addition
84 * @param[out] slot information returned by atlas manager for addition
86 void Add( Text::FontId fontId,
87 const Text::GlyphInfo& glyph,
88 const BufferImage& bitmap,
89 AtlasManager::AtlasSlot& slot );
92 * @brief Generate mesh data for an image contained in an atlas
94 * @param[in] imageId ID of image to generate geometry for
95 * @param[in] position top left of image
96 * @param[out] meshData generated MeshData
98 void GenerateMeshData( uint32_t imageId,
99 const Vector2& position,
100 Toolkit::AtlasManager::Mesh2D& mesh );
103 * @brief Stitch Two Meshes together
105 * @param[in] first first mesh
106 * @param[in] second second mesh
108 void StitchMesh( Toolkit::AtlasManager::Mesh2D& first,
109 const Toolkit::AtlasManager::Mesh2D& second );
112 * @brief Check to see if a glyph is being cached
114 * @param[in] fontId The font that this glyph comes from
115 * @param[in] index The GlyphIndex of this glyph
116 * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
118 * @return Whether glyph is cached or not ?
120 bool Cached( Text::FontId fontId,
121 Text::GlyphIndex index,
122 AtlasManager::AtlasSlot& slot );
125 * @brief Retrieve the size of an atlas
127 * @param[in] atlasId Id of the atlas to interrogate
129 * @return The pixel size of the atlas
131 Vector2 GetAtlasSize( uint32_t atlasId );
134 * @brief Set the atlas size and block size for subsequent Atlas generation
136 * @param[in] width width of atlas in pixels
137 * @param[in] height height of atlas in pixels
138 * @param[in] blockWidth width of a block in pixels
139 * @param[in] blockHeight height of a block in pixels
141 void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
144 * @brief Get the Pixel Format used by an atlas
146 * @param[in] atlasId Id of atlas to check
148 * @return The pixel format of the atlas
150 Pixel::Format GetPixelFormat( uint32_t atlasId );
153 * @brief Get the material used by an atlas
155 * @param[in] atlasId Id of an atlas
157 * @return The material used by the atlas
159 Material GetMaterial( uint32_t atlasId ) const;
162 * @brief Get the sampler used by an atlas
164 * @param[in] atlasId Id of an atlas
166 * @return The sampler used by the atlas
168 Sampler GetSampler( uint32_t atlasId ) const;
171 * @brief Get Glyph Manager metrics
173 * @return const reference to glyph manager metrics
175 const Metrics& GetMetrics();
178 * @brief Adjust the reference count for an imageId and remove cache entry if it becomes free
180 * @param[in] fontId the font this image came from
181 * @param[in] imageId The imageId
182 * @param[in] delta adjustment to make to reference count
184 void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
187 * @brief Get Shader used for rendering glyph effect buffers
189 * @return Handle of shader needed
191 Shader GetEffectBufferShader() const;
194 * @brief Get Shader used rendering Glyph Shadows
196 * @return Handle of shader needed
198 Shader GetGlyphShadowShader() const;
202 explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
206 } // namespace Toolkit
210 #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__