Merge "Dont register accessibility and keyboard focus properties as scene graph prope...
[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( Text::FontId fontId,
73                              const Text::GlyphInfo& glyph,
74                              const BufferImage& bitmap,
75                              AtlasManager::AtlasSlot& slot )
76 {
77   GetImplementation(*this).Add( fontId, glyph, bitmap, slot );
78 }
79
80 void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
81                                           const Vector2& position,
82                                           MeshData& meshData )
83 {
84   GetImplementation(*this).GenerateMeshData( imageId,
85                                              position,
86                                              meshData );
87 }
88
89 void AtlasGlyphManager::StitchMesh( MeshData& first,
90                                     const MeshData& second )
91 {
92   GetImplementation(*this).StitchMesh( first, second );
93 }
94
95 bool AtlasGlyphManager::Cached( Text::FontId fontId,
96                                 Text::GlyphIndex index,
97                                 AtlasManager::AtlasSlot& slot )
98 {
99   return GetImplementation(*this).Cached( fontId, index, slot );
100 }
101
102 void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
103 {
104   GetImplementation(*this).SetNewAtlasSize( width, height, blockWidth, blockHeight );
105 }
106
107 Vector2 AtlasGlyphManager::GetAtlasSize( uint32_t atlasId )
108 {
109   return GetImplementation(*this).GetAtlasSize( atlasId );
110 }
111
112 Pixel::Format AtlasGlyphManager::GetPixelFormat( uint32_t atlasId )
113 {
114   return GetImplementation(*this).GetPixelFormat( atlasId );
115 }
116
117 const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
118 {
119   return GetImplementation(*this).GetMetrics();
120 }
121
122 void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, uint32_t imageId, int32_t delta )
123 {
124   GetImplementation(*this).AdjustReferenceCount( fontId, imageId, delta );
125 }
126
127 } // namespace Toolkit
128
129 } // namespace Dali