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
46 uint32_t mGlyphCount; // number of glyphs being managed
47 AtlasManager::Metrics mAtlasMetrics; // metrics from the Atlas Manager
51 * @brief Create a AtlasGlyphManager handle.
53 * Calling member functions with an uninitialised handle is not allowed.
60 * This is non-virtual since derived Handle types must not contain data or virtual methods.
65 * @brief Create or retrieve AtlasGlyphManager singleton.
67 * @return A handle to the AtlasGlyphManager control.
69 static AtlasGlyphManager Get();
72 * @brief Ask Atlas Manager to add a glyph
74 * @param[in] fontId fontId glyph comes from
75 * @param[in] glyph glyph to add to an atlas
76 * @param[in] bitmap bitmap to use for glyph addition
77 * @param[out] slot information returned by atlas manager for addition
79 void Add( Text::FontId fontId,
80 const Text::GlyphInfo& glyph,
81 const BufferImage& bitmap,
82 AtlasManager::AtlasSlot& slot );
85 * @brief Generate mesh data for an image contained in an atlas
87 * @param[in] imageId ID of image to generate geometry for
88 * @param[in] position top left of image
89 * @param[out] meshData generated MeshData
91 void GenerateMeshData( uint32_t imageId,
92 const Vector2& position,
96 * @brief Stitch Two Meshes together
98 * @param[in] first first mesh
99 * @param[in] second second mesh
101 void StitchMesh( MeshData& first,
102 const MeshData& second );
105 * @brief Check to see if a glyph is being cached
107 * @param[in] fontId The font that this glyph comes from
108 * @param[in] index The GlyphIndex of this glyph
109 * @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
111 * @return Whether glyph is cached or not ?
113 bool Cached( Text::FontId fontId,
114 Text::GlyphIndex index,
115 AtlasManager::AtlasSlot& slot );
118 * @brief Retrieve the size of an atlas
120 * @param[in] atlasId Id of the atlas to interrogate
122 * @return The pixel size of the atlas
124 Vector2 GetAtlasSize( uint32_t atlasId );
127 * @brief Set the atlas size and block size for subsequent Atlas generation
129 * @param[in] width width of atlas in pixels
130 * @param[in] height height of atlas in pixels
131 * @param[in] blockWidth width of a block in pixels
132 * @param[in] blockHeight height of a block in pixels
134 void SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight );
137 * @brief Get the Pixel Format used by an atlas
139 * @param[in] atlasId Id of atlas to check
141 * @return The pixel format of the atlas
143 Pixel::Format GetPixelFormat( uint32_t atlasId );
146 * @brief Get Glyph Manager metrics
148 * @return const reference to glyph manager metrics
150 const Metrics& GetMetrics();
153 * @brief Adjust the reference count for an imageId and remove cache entry if it becomes free
155 * @param[in] fontId the font this image came from
156 * @param[in] imageId The imageId
157 * @param[in] delta adjustment to make to reference count
159 void AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta );
163 explicit DALI_INTERNAL AtlasGlyphManager(Internal::AtlasGlyphManager *impl);
167 } // namespace Toolkit
171 #endif // __DALI_TOOLKIT_ATLAS_GLYPH_MANAGER_H__