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( const Text::GlyphInfo& glyph,
73 const BufferImage& bitmap,
74 AtlasManager::AtlasSlot& slot )
76 GetImplementation(*this).Add( glyph, bitmap, slot );
79 void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
80 const Vector2& position,
81 Toolkit::AtlasManager::Mesh2D& mesh )
83 GetImplementation(*this).GenerateMeshData( imageId,
88 void AtlasGlyphManager::StitchMesh( Toolkit::AtlasManager::Mesh2D& first,
89 const Toolkit::AtlasManager::Mesh2D& second )
91 GetImplementation(*this).StitchMesh( first, second );
94 bool AtlasGlyphManager::Cached( Text::FontId fontId,
95 Text::GlyphIndex index,
96 AtlasManager::AtlasSlot& slot )
98 return GetImplementation(*this).Cached( fontId, index, slot );
101 void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
103 GetImplementation(*this).SetNewAtlasSize( width, height, blockWidth, blockHeight );
106 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
108 return GetImplementation(*this).GetAtlasSize( atlasId );
111 Pixel::Format AtlasGlyphManager::GetPixelFormat( uint32_t atlasId )
113 return GetImplementation(*this).GetPixelFormat( atlasId );
116 Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
118 return GetImplementation(*this).GetMaterial( atlasId );
121 Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
123 return GetImplementation(*this).GetSampler( atlasId );
126 const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
128 return GetImplementation(*this).GetMetrics();
131 void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta )
133 GetImplementation(*this).AdjustReferenceCount( fontId, imageId, delta );
136 Shader AtlasGlyphManager::GetEffectBufferShader() const
138 return GetImplementation(*this).GetEffectBufferShader();
141 Shader AtlasGlyphManager::GetGlyphShadowShader() const
143 return GetImplementation(*this).GetGlyphShadowShader();
146 } // namespace Toolkit