1 #ifndef __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_H__
2 #define __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_H__
5 * Copyright (c) 2014 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/internal/common/text-array.h>
23 #include <dali/internal/common/owner-container.h>
24 #include <dali/internal/event/text/font-metrics-interface.h>
25 #include <dali/internal/event/text/atlas/glyph-atlas.h>
26 #include <dali/internal/event/text/resource/glyph-texture-observer.h>
27 #include <dali/internal/event/text/resource/glyph-resource-manager.h>
28 #include <dali/internal/event/text/atlas/glyph-atlas-manager-interface.h>
38 * Glyph atlas manager does the following:
41 * - Finds the best atlas given a string of text
43 * GlyphAtlasManagerInterface provides:
45 * - Text Vertex creation from a string of text
46 * - Allows observers to watch for text load events
47 * - Allows observers to watch for texture resize events.
49 class GlyphAtlasManager: public GlyphAtlasManagerInterface
55 * @param[in] fontLookup font lookup interface
57 GlyphAtlasManager( const FontLookupInterface& fontLookup );
62 virtual ~GlyphAtlasManager();
65 public: // for GlyphAtlasManagerInterface
68 * @copydoc GlyphAtlasManagerInterface::TextRequired()
70 virtual TextVertexBuffer* TextRequired( const TextArray& text,
71 const TextFormat& format,
72 FontMetricsInterface& metrics );
75 * @copydoc GlyphAtlasManagerInterface::TextNotRequired()
77 virtual void TextNotRequired( const TextArray& text,
78 const TextFormat& format,
80 unsigned int textureId );
83 * @copydoc GlyphAtlasManagerInterface::IsTextLoaded()
85 virtual bool IsTextLoaded( const TextArray& text,
86 const TextFormat& format,
88 unsigned int textureId) const;
91 * @copydoc GlyphAtlasManagerInterface::AddTextObserver()
93 virtual void AddTextObserver( TextObserver& observer );
96 * @copydoc GlyphAtlasManagerInterface::RemoveTextObserver()
98 virtual void RemoveTextObserver( TextObserver& observer );
101 * @copydoc GlyphAtlasManagerInterface::AddObserver()
103 virtual void AddTextureObserver( GlyphTextureObserver& observer);
106 * @copydoc GlyphAtlasManagerInterface::RemoveObserver()
108 virtual void RemoveTextureObserver( GlyphTextureObserver& observer);
113 * Send any pending glyph load requests held in each atlas to the resource manager.
115 void SendTextRequests();
118 * @return glyph load observer interface
120 GlyphLoadObserver& GetLoadObserver();
124 // Undefined copy constructor.
125 GlyphAtlasManager( const GlyphAtlasManager& );
127 // Undefined assignment operator.
128 GlyphAtlasManager& operator=( const GlyphAtlasManager& );
131 * Creates a new atlas
132 * @param[in] size the atlas size in pixels (size = width = height)
135 GlyphAtlas* CreateAtlas( unsigned int size );
138 * Find the most suitable atlas for a string of text
139 * @param[in] text text array
140 * @param[in] format text format
142 * @param[in,out] the ranking for the atlas that is found
145 GlyphAtlas* FindAtlas( const TextArray& text ,
146 const TextFormat& format,
148 AtlasRanking& bestRank);
152 * @param[in] atlas to add
154 void AddAtlas( GlyphAtlas* atlas);
158 * @param[in] atlas the atlas to remove
160 void RemoveAtlas( GlyphAtlas* atlas );
163 * Get an atlas given a texture id
164 * @param[in] textureId
167 GlyphAtlas& GetAtlas( unsigned int textureId ) const;
170 * Takes an atlas and returns a bigger version.
171 * The old atlas is deleted.
172 * @param atlas the atlas to make bigger
173 * @returns a bigger atlas
175 GlyphAtlas* CreateLargerAtlas( GlyphAtlas* atlas );
178 * Notify atlas observers that the texture has changed. Note, this no longer means
179 * that the glyphs are present.
181 void NotifyAtlasObservers();
184 typedef OwnerContainer< GlyphAtlas* > AtlasList; ///< atlas list typedef
185 typedef Dali::Vector< GlyphTextureObserver* > TextureObserverList; ///< list of observers that get informed when an atlas is resized / split
187 AtlasList mAtlasList; ///< List of atlases
188 GlyphResourceManager mGlyphResourceManager; ///< glyph resource manager
189 TextureObserverList mTextureObservers; ///< unique set of observers that watch texture resize / split changes
190 bool mAtlasesChanged; ///< Set to true if any atlas is resized, used to notify observers at end of event cycle
193 } // namespace Internal
197 #endif // __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_H__