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/text/rendering/atlas/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 std::string mVerboseGlyphCounts; ///< a verbose list of the glyphs + ref counts
55 AtlasManager::Metrics mAtlasMetrics; ///< metrics from the Atlas Manager
59 * @brief Create a AtlasGlyphManager handle.
61 * Calling member functions with an uninitialised handle is not allowed.
68 * This is non-virtual since derived Handle types must not contain data or virtual methods.
73 * @brief Create or retrieve AtlasGlyphManager singleton.
75 * @return A handle to the AtlasGlyphManager control.
77 static AtlasGlyphManager Get();
80 * @brief Ask Atlas Manager to add a glyph
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( const Text::GlyphInfo& glyph,
87 const PixelData& bitmap,
88 AtlasManager::AtlasSlot& slot );
91 * @brief Generate mesh data for an image contained in an atlas
93 * @param[in] imageId ID of image to generate geometry for
94 * @param[in] position top left of image
95 * @param[out] meshData generated MeshData
97 void GenerateMeshData( uint32_t imageId,
98 const Vector2& position,
99 Toolkit::AtlasManager::Mesh2D& mesh );
102 * @brief Check to see if a glyph is being cached
104 * @param[in] fontId The font that this glyph comes from
105 * @param[in] index The GlyphIndex of this glyph
106 * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
108 * @return Whether glyph is cached or not ?
110 bool IsCached( Text::FontId fontId,
111 Text::GlyphIndex index,
112 AtlasManager::AtlasSlot& slot );
115 * @brief Retrieve the size of an atlas
117 * @param[in] atlasId Id of the atlas to interrogate
119 * @return The pixel size of the atlas
121 Vector2 GetAtlasSize( uint32_t atlasId );
124 * @brief Set the atlas size and block size for subsequent Atlas generation
126 * @param[in] width width of atlas in pixels
127 * @param[in] height height of atlas in pixels
128 * @param[in] blockWidth width of a block in pixels
129 * @param[in] blockHeight height of a block in pixels
131 void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
134 * @brief Get the Pixel Format used by an atlas
136 * @param[in] atlasId Id of atlas to check
138 * @return The pixel format of the atlas
140 Pixel::Format GetPixelFormat( uint32_t atlasId );
143 * @brief Get the texture set used by an atlas
145 * @param[in] atlasId Id of an atlas
147 * @return The texture set used by the atlas
149 TextureSet GetTextures( uint32_t atlasId ) const;
152 * @brief Get the shader used by an atlas
154 * @param[in] atlasId Id of an atlas
156 * @return The shader used by the atlas
158 Shader GetShader( uint32_t atlasId ) const;
161 * @brief Get Glyph Manager metrics
163 * @return const reference to glyph manager metrics
165 const Metrics& GetMetrics();
168 * @brief Adjust the reference count for glyph
170 * @param[in] fontId The font this image came from
171 * @param[in] index The index of the glyph
172 * @param[in] delta The adjustment to make to the reference count
174 void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
178 explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
182 } // namespace Toolkit
186 #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__