1 #ifndef DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H
2 #define DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H
5 * Copyright (c) 2019 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
66 uint16_t outline; ///< The outline width of this glyph
67 bool isItalic:1; ///< Whether the glyph is italic.
68 bool isBold:1; ///< Whether the glyph is bold.
72 * @brief Create a AtlasGlyphManager handle.
74 * Calling member functions with an uninitialised handle is not allowed.
81 * This is non-virtual since derived Handle types must not contain data or virtual methods.
86 * @brief Create or retrieve AtlasGlyphManager singleton.
88 * @return A handle to the AtlasGlyphManager control.
90 static AtlasGlyphManager Get();
93 * @brief Ask Atlas Manager to add a glyph
95 * @param[in] glyph glyph to add to an atlas
96 * @param[in] style The style of this glyph
97 * @param[in] bitmap bitmap to use for glyph addition
98 * @param[out] slot information returned by atlas manager for addition
100 void Add( const Text::GlyphInfo& glyph,
101 const GlyphStyle& style,
102 const PixelData& bitmap,
103 AtlasManager::AtlasSlot& slot );
106 * @brief Generate mesh data for an image contained in an atlas
108 * @param[in] imageId ID of image to generate geometry for
109 * @param[in] position top left of image
110 * @param[out] meshData generated MeshData
112 void GenerateMeshData( uint32_t imageId,
113 const Vector2& position,
114 Toolkit::AtlasManager::Mesh2D& mesh );
117 * @brief Check to see if a glyph is being cached
119 * @param[in] fontId The font that this glyph comes from
120 * @param[in] index The GlyphIndex of this glyph
121 * @param[in] style The style of this glyph
122 * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
124 * @return Whether glyph is cached or not ?
126 bool IsCached( Text::FontId fontId,
127 Text::GlyphIndex index,
128 const GlyphStyle& style,
129 AtlasManager::AtlasSlot& slot );
132 * @brief Retrieve the size of an atlas
134 * @param[in] atlasId Id of the atlas to interrogate
136 * @return The pixel size of the atlas
138 Vector2 GetAtlasSize( uint32_t atlasId );
141 * @brief Set the atlas size and block size for subsequent Atlas generation
143 * @param[in] width width of atlas in pixels
144 * @param[in] height height of atlas in pixels
145 * @param[in] blockWidth width of a block in pixels
146 * @param[in] blockHeight height of a block in pixels
148 void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
151 * @brief Get the Pixel Format used by an atlas
153 * @param[in] atlasId Id of atlas to check
155 * @return The pixel format of the atlas
157 Pixel::Format GetPixelFormat( uint32_t atlasId );
160 * @brief Get the texture set used by an atlas
162 * @param[in] atlasId Id of an atlas
164 * @return The texture set used by the atlas
166 TextureSet GetTextures( uint32_t atlasId ) const;
169 * @brief Get Glyph Manager metrics
171 * @return const reference to glyph manager metrics
173 const Metrics& GetMetrics();
176 * @brief Adjust the reference count for glyph
178 * @param[in] fontId The font this image came from
179 * @param[in] index The index of the glyph
180 * @param[in] style The style of this glyph
181 * @param[in] delta The adjustment to make to the reference count
183 void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, const GlyphStyle& style, int32_t delta );
187 explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
191 } // namespace Toolkit
195 #endif // DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H