Added support for including headers from devel folder
[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/atlas-manager/atlas-manager-impl.h>
26 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 AtlasGlyphManager::AtlasGlyphManager()
35 {
36 }
37
38 AtlasGlyphManager::~AtlasGlyphManager()
39 {
40 }
41
42 AtlasGlyphManager AtlasGlyphManager::Get()
43 {
44   AtlasGlyphManager manager;
45
46   // Check whether the AtlasGlyphManager is already created
47   SingletonService singletonService( SingletonService::Get() );
48   if ( singletonService )
49   {
50     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(AtlasGlyphManager));
51     if(handle)
52     {
53       // If so, downcast the handle of singleton to AtlasGlyphManager
54       manager = AtlasGlyphManager(dynamic_cast<Internal::AtlasGlyphManager*>(handle.GetObjectPtr()));
55     }
56
57     if(!manager)
58     {
59       // If not, create the AtlasGlyphManager and register it as a singleton
60       manager = AtlasGlyphManager(new Internal::AtlasGlyphManager());
61       singletonService.Register(typeid(manager), manager);
62     }
63   }
64   return manager;
65 }
66
67 AtlasGlyphManager::AtlasGlyphManager(Internal::AtlasGlyphManager *impl)
68   : BaseHandle(impl)
69 {
70 }
71
72 void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
73                              const BufferImage& bitmap,
74                              AtlasManager::AtlasSlot& slot )
75 {
76   GetImplementation(*this).Add( glyph, bitmap, slot );
77 }
78
79 void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
80                                           const Vector2& position,
81                                           MeshData& meshData )
82 {
83   GetImplementation(*this).GenerateMeshData( imageId,
84                                              position,
85                                              meshData );
86 }
87
88 void AtlasGlyphManager::StitchMesh( MeshData& first,
89                                     const MeshData& second )
90 {
91   GetImplementation(*this).StitchMesh( first, second );
92 }
93
94 void AtlasGlyphManager::Cached( Text::FontId fontId,
95                                 Text::GlyphIndex index,
96                                 AtlasManager::AtlasSlot& slot )
97 {
98   GetImplementation(*this).Cached( fontId, index, slot );
99 }
100
101 void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
102 {
103   GetImplementation(*this).SetNewAtlasSize( width, height, blockWidth, blockHeight );
104 }
105
106 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
107 {
108   return GetImplementation(*this).GetAtlasSize( atlasId );
109 }
110
111 void AtlasGlyphManager::Remove( uint32_t imageId )
112 {
113   GetImplementation(*this).Remove( imageId );
114 }
115
116 Pixel::Format AtlasGlyphManager::GetPixelFormat( uint32_t atlasId )
117 {
118   return GetImplementation(*this).GetPixelFormat( atlasId );
119 }
120
121 const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
122 {
123   return GetImplementation(*this).GetMetrics();
124 }
125
126 } // namespace Toolkit
127
128 } // namespace Dali