2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
22 #include <dali/devel-api/adaptor-framework/singleton-service.h>
25 #include <dali-toolkit/internal/atlas-manager/atlas-manager-impl.h>
26 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h>
34 AtlasGlyphManager::AtlasGlyphManager()
38 AtlasGlyphManager::~AtlasGlyphManager()
42 AtlasGlyphManager AtlasGlyphManager::Get()
44 AtlasGlyphManager manager;
46 // Check whether the AtlasGlyphManager is already created
47 SingletonService singletonService( SingletonService::Get() );
48 if ( singletonService )
50 Dali::BaseHandle handle = singletonService.GetSingleton(typeid(AtlasGlyphManager));
53 // If so, downcast the handle of singleton to AtlasGlyphManager
54 manager = AtlasGlyphManager(dynamic_cast<Internal::AtlasGlyphManager*>(handle.GetObjectPtr()));
59 // If not, create the AtlasGlyphManager and register it as a singleton
60 manager = AtlasGlyphManager(new Internal::AtlasGlyphManager());
61 singletonService.Register(typeid(manager), manager);
67 AtlasGlyphManager::AtlasGlyphManager(Internal::AtlasGlyphManager *impl)
72 void AtlasGlyphManager::Add( Text::FontId fontId,
73 const Text::GlyphInfo& glyph,
74 const BufferImage& bitmap,
75 AtlasManager::AtlasSlot& slot )
77 GetImplementation(*this).Add( fontId, glyph, bitmap, slot );
80 void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
81 const Vector2& position,
82 Toolkit::AtlasManager::Mesh2D& mesh )
84 GetImplementation(*this).GenerateMeshData( imageId,
89 void AtlasGlyphManager::StitchMesh( Toolkit::AtlasManager::Mesh2D& first,
90 const Toolkit::AtlasManager::Mesh2D& second )
92 GetImplementation(*this).StitchMesh( first, second );
95 bool AtlasGlyphManager::Cached( Text::FontId fontId,
96 Text::GlyphIndex index,
97 AtlasManager::AtlasSlot& slot )
99 return GetImplementation(*this).Cached( fontId, index, slot );
102 void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
104 GetImplementation(*this).SetNewAtlasSize( width, height, blockWidth, blockHeight );
107 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
109 return GetImplementation(*this).GetAtlasSize( atlasId );
112 Pixel::Format AtlasGlyphManager::GetPixelFormat( uint32_t atlasId )
114 return GetImplementation(*this).GetPixelFormat( atlasId );
117 Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
119 return GetImplementation(*this).GetMaterial( atlasId );
122 Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
124 return GetImplementation(*this).GetSampler( atlasId );
127 const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
129 return GetImplementation(*this).GetMetrics();
132 void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta )
134 GetImplementation(*this).AdjustReferenceCount( fontId, imageId, delta );
137 Shader AtlasGlyphManager::GetEffectBufferShader() const
139 return GetImplementation(*this).GetEffectBufferShader();
142 Shader AtlasGlyphManager::GetGlyphShadowShader() const
144 return GetImplementation(*this).GetGlyphShadowShader();
147 } // namespace Toolkit