1 #ifndef DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H
2 #define DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H
5 * Copyright (c) 2021 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>
29 namespace Internal DALI_INTERNAL
31 class AtlasGlyphManager;
34 class AtlasGlyphManager : public BaseHandle
38 * Description of GlyphManager state
51 uint32_t mGlyphCount; ///< number of glyphs being managed
52 std::string mVerboseGlyphCounts; ///< a verbose list of the glyphs + ref counts
53 AtlasManager::Metrics mAtlasMetrics; ///< metrics from the Atlas Manager
65 uint16_t outline; ///< The outline width of this glyph
66 bool isItalic : 1; ///< Whether the glyph is italic.
67 bool isBold : 1; ///< Whether the glyph is bold.
71 * @brief Create a AtlasGlyphManager handle.
73 * Calling member functions with an uninitialised handle is not allowed.
80 * This is non-virtual since derived Handle types must not contain data or virtual methods.
85 * @brief Create or retrieve AtlasGlyphManager singleton.
87 * @return A handle to the AtlasGlyphManager control.
89 static AtlasGlyphManager Get();
92 * @brief Ask Atlas Manager to add a glyph
94 * @param[in] glyph glyph to add to an atlas
95 * @param[in] style The style of this glyph
96 * @param[in] bitmap bitmap to use for glyph addition
97 * @param[out] slot information returned by atlas manager for addition
99 void Add(const Text::GlyphInfo& glyph,
100 const GlyphStyle& style,
101 const PixelData& bitmap,
102 AtlasManager::AtlasSlot& slot);
105 * @brief Generate mesh data for an image contained in an atlas
107 * @param[in] imageId ID of image to generate geometry for
108 * @param[in] position top left of image
109 * @param[out] meshData generated MeshData
111 void GenerateMeshData(uint32_t imageId,
112 const Vector2& position,
113 Toolkit::AtlasManager::Mesh2D& mesh);
116 * @brief Check to see if a glyph is being cached
118 * @param[in] fontId The font that this glyph comes from
119 * @param[in] index The GlyphIndex of this glyph
120 * @param[in] style The style of this glyph
121 * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
123 * @return Whether glyph is cached or not ?
125 bool IsCached(Text::FontId fontId,
126 Text::GlyphIndex index,
127 const GlyphStyle& style,
128 AtlasManager::AtlasSlot& slot);
131 * @brief Retrieve the size of an atlas
133 * @param[in] atlasId Id of the atlas to interrogate
135 * @return The pixel size of the atlas
137 Vector2 GetAtlasSize(uint32_t atlasId);
140 * @brief Set the atlas size and block size for subsequent Atlas generation
142 * @param[in] width width of atlas in pixels
143 * @param[in] height height of atlas in pixels
144 * @param[in] blockWidth width of a block in pixels
145 * @param[in] blockHeight height of a block in pixels
147 void SetNewAtlasSize(uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight);
150 * @brief Get the Pixel Format used by an atlas
152 * @param[in] atlasId Id of atlas to check
154 * @return The pixel format of the atlas
156 Pixel::Format GetPixelFormat(uint32_t atlasId);
159 * @brief Get the texture set used by an atlas
161 * @param[in] atlasId Id of an atlas
163 * @return The texture set used by the atlas
165 TextureSet GetTextures(uint32_t atlasId) const;
168 * @brief Get Glyph Manager metrics
170 * @return const reference to glyph manager metrics
172 const Metrics& GetMetrics();
175 * @brief Adjust the reference count for glyph
177 * @param[in] fontId The font this image came from
178 * @param[in] index The index of the glyph
179 * @param[in] style The style of this glyph
180 * @param[in] delta The adjustment to make to the reference count
182 void AdjustReferenceCount(Text::FontId fontId, Text::GlyphIndex index, const GlyphStyle& style, int32_t delta);
185 explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager* impl);
188 } // namespace Toolkit
192 #endif // DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H