2 * Copyright (c) 2016 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/vector-based/vector-blob-atlas-share.h>
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/devel-api/adaptor-framework/singleton-service.h>
28 const int INITIAL_VECTOR_BLOB_ATLAS_WIDTH = 512;
29 const int INITIAL_VECTOR_BLOB_ATLAS_HEIGHT = 512;
31 const int NEW_VECTOR_BLOB_ATLAS_WIDTH = 1024;
32 const int NEW_VECTOR_BLOB_ATLAS_HEIGHT = 1024;
34 const int VECTOR_BLOB_ATLAS_ITEM_WIDTH = 64;
35 const int VECTOR_BLOB_ATLAS_HEIGHT_QUANTUM = 8;
37 } // unnamed namespace
48 class VectorBlobAtlasShare::Impl : public Dali::BaseObject
59 VectorBlobAtlas* GetCurrentAtlas()
63 mCurrentAtlas = new VectorBlobAtlas( INITIAL_VECTOR_BLOB_ATLAS_WIDTH, INITIAL_VECTOR_BLOB_ATLAS_HEIGHT, VECTOR_BLOB_ATLAS_ITEM_WIDTH, VECTOR_BLOB_ATLAS_HEIGHT_QUANTUM );
66 return mCurrentAtlas.Get();
69 VectorBlobAtlas* GetNewAtlas()
71 // The current atlas should have been filled, before asking for a new one
72 DALI_ASSERT_DEBUG( mCurrentAtlas->IsFull() && "Current atlas is not full yet" );
74 mCurrentAtlas = new VectorBlobAtlas( NEW_VECTOR_BLOB_ATLAS_WIDTH, NEW_VECTOR_BLOB_ATLAS_HEIGHT, VECTOR_BLOB_ATLAS_ITEM_WIDTH, VECTOR_BLOB_ATLAS_HEIGHT_QUANTUM );
76 return mCurrentAtlas.Get();
82 * A reference counted object may only be deleted by calling Unreference()
90 IntrusivePtr<VectorBlobAtlas> mCurrentAtlas;
93 VectorBlobAtlasShare::VectorBlobAtlasShare()
97 VectorBlobAtlasShare::~VectorBlobAtlasShare()
101 VectorBlobAtlasShare VectorBlobAtlasShare::Get()
103 VectorBlobAtlasShare manager;
105 // Check whether the VectorBlobAtlasShare is already created
106 SingletonService singletonService( SingletonService::Get() );
107 if ( singletonService )
109 Dali::BaseHandle handle = singletonService.GetSingleton( typeid( VectorBlobAtlasShare ) );
112 // If so, downcast the handle of singleton to VectorBlobAtlasShare
113 manager = VectorBlobAtlasShare( dynamic_cast<VectorBlobAtlasShare::Impl*>( handle.GetObjectPtr() ) );
118 // If not, create the VectorBlobAtlasShare and register it as a singleton
119 manager = VectorBlobAtlasShare( new VectorBlobAtlasShare::Impl() );
120 singletonService.Register( typeid( manager ), manager );
127 VectorBlobAtlasShare::VectorBlobAtlasShare( VectorBlobAtlasShare::Impl* impl )
132 VectorBlobAtlas* VectorBlobAtlasShare::GetCurrentAtlas()
134 VectorBlobAtlasShare::Impl& impl = static_cast<VectorBlobAtlasShare::Impl&>( GetBaseObject() );
136 return impl.GetCurrentAtlas();
139 VectorBlobAtlas* VectorBlobAtlasShare::GetNewAtlas()
141 VectorBlobAtlasShare::Impl& impl = static_cast<VectorBlobAtlasShare::Impl&>( GetBaseObject() );
143 return impl.GetNewAtlas();
148 } // namespace Toolkit