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 "visual-factory.h"
22 #include <dali/devel-api/adaptor-framework/singleton-service.h>
23 #include <dali/devel-api/adaptor-framework/environment-variable.h>
26 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
36 const char * const DALI_DEBUG_RENDERING("DALI_DEBUG_RENDERING");
39 VisualFactory VisualFactory::Get()
41 VisualFactory factory;
43 // Check whether the VisualFactory is already created
44 SingletonService singletonService( SingletonService::Get() );
45 if( singletonService )
47 BaseHandle handle = singletonService.GetSingleton( typeid(VisualFactory) );
50 //If so, downcast the handle of singleton to VisualFactory
51 factory = VisualFactory( dynamic_cast<Internal::VisualFactory*>(handle.GetObjectPtr()) );
54 if( !factory )// If not, create the VisualFactory and register it as a singleton
56 // Check whether debug rendering is required
57 if( EnvironmentVariable::GetEnvironmentVariable( DALI_DEBUG_RENDERING ) )
59 factory = VisualFactory( new Internal::VisualFactory(true) );
63 factory = VisualFactory( new Internal::VisualFactory(false) );
65 singletonService.Register( typeid(VisualFactory), factory );
73 VisualFactory::VisualFactory()
77 VisualFactory::~VisualFactory()
81 VisualFactory::VisualFactory( const VisualFactory& handle )
82 : BaseHandle( handle )
86 VisualFactory& VisualFactory::operator=( const VisualFactory& handle )
88 BaseHandle::operator=( handle );
92 VisualFactory::VisualFactory(Internal::VisualFactory *impl)
97 Visual::Base VisualFactory::CreateVisual( const Property::Map& propertyMap )
99 return GetImplementation( *this ).CreateVisual( propertyMap );
102 Visual::Base VisualFactory::CreateVisual( const Image& image )
104 return GetImplementation( *this ).CreateVisual( image );
107 Visual::Base VisualFactory::CreateVisual( const std::string& url, ImageDimensions size )
109 return GetImplementation( *this ).CreateVisual( url, size );
112 void VisualFactory::SetPreMultiplyOnLoad( bool preMultiply )
114 GetImplementation( *this ).SetPreMultiplyOnLoad( preMultiply );
117 bool VisualFactory::GetPreMultiplyOnLoad() const
119 return GetImplementation( *this ).GetPreMultiplyOnLoad();
122 } // namespace Toolkit