Merge "Text clean." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / atlas / atlas-glyph-manager.cpp
1  /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/singleton-service.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 AtlasGlyphManager::AtlasGlyphManager()
34 {
35 }
36
37 AtlasGlyphManager::~AtlasGlyphManager()
38 {
39 }
40
41 AtlasGlyphManager AtlasGlyphManager::Get()
42 {
43   AtlasGlyphManager manager;
44
45   // Check whether the AtlasGlyphManager is already created
46   SingletonService singletonService( SingletonService::Get() );
47   if ( singletonService )
48   {
49     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(AtlasGlyphManager));
50     if(handle)
51     {
52       // If so, downcast the handle of singleton to AtlasGlyphManager
53       manager = AtlasGlyphManager(dynamic_cast<Internal::AtlasGlyphManager*>(handle.GetObjectPtr()));
54     }
55
56     if(!manager)
57     {
58       // If not, create the AtlasGlyphManager and register it as a singleton
59       manager = AtlasGlyphManager(new Internal::AtlasGlyphManager());
60       singletonService.Register(typeid(manager), manager);
61     }
62   }
63   return manager;
64 }
65
66 AtlasGlyphManager::AtlasGlyphManager(Internal::AtlasGlyphManager *impl)
67   : BaseHandle(impl)
68 {
69 }
70
71 void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
72                              const BufferImage& bitmap,
73                              AtlasManager::AtlasSlot& slot )
74 {
75   GetImplementation(*this).Add( glyph, bitmap, slot );
76 }
77
78 void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
79                                           const Vector2& position,
80                                           Toolkit::AtlasManager::Mesh2D& mesh )
81 {
82   GetImplementation(*this).GenerateMeshData( imageId,
83                                              position,
84                                              mesh );
85 }
86
87 void AtlasGlyphManager::StitchMesh( Toolkit::AtlasManager::Mesh2D& first,
88                                     const Toolkit::AtlasManager::Mesh2D& second )
89 {
90   GetImplementation(*this).StitchMesh( first, second );
91 }
92
93 bool AtlasGlyphManager::Cached( Text::FontId fontId,
94                                 Text::GlyphIndex index,
95                                 AtlasManager::AtlasSlot& slot )
96 {
97   return GetImplementation(*this).Cached( fontId, index, slot );
98 }
99
100 void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
101 {
102   GetImplementation(*this).SetNewAtlasSize( width, height, blockWidth, blockHeight );
103 }
104
105 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
106 {
107   return GetImplementation(*this).GetAtlasSize( atlasId );
108 }
109
110 Pixel::Format AtlasGlyphManager::GetPixelFormat( uint32_t atlasId )
111 {
112   return GetImplementation(*this).GetPixelFormat( atlasId );
113 }
114
115 Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
116 {
117   return GetImplementation(*this).GetMaterial( atlasId );
118 }
119
120 Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
121 {
122   return GetImplementation(*this).GetSampler( atlasId );
123 }
124
125 const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
126 {
127   return GetImplementation(*this).GetMetrics();
128 }
129
130 void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
131 {
132   GetImplementation(*this).AdjustReferenceCount( fontId, index, delta );
133 }
134
135 Shader AtlasGlyphManager::GetEffectBufferShader() const
136 {
137   return GetImplementation(*this).GetEffectBufferShader();
138 }
139
140 Shader AtlasGlyphManager::GetGlyphShadowShader() const
141 {
142   return GetImplementation(*this).GetGlyphShadowShader();
143 }
144
145 } // namespace Toolkit
146
147 } // namespace Dali