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 "renderer-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/controls/renderers/renderer-factory-impl.h>
36 const char * const DALI_DEBUG_RENDERING("DALI_DEBUG_RENDERING");
39 RendererFactory RendererFactory::Get()
41 RendererFactory factory;
43 // Check whether the RendererFactory is already created
44 SingletonService singletonService( SingletonService::Get() );
45 if( singletonService )
47 BaseHandle handle = singletonService.GetSingleton( typeid(RendererFactory) );
50 //If so, downcast the handle of singleton to RendererFactory
51 factory = RendererFactory( dynamic_cast<Internal::RendererFactory*>(handle.GetObjectPtr()) );
54 if( !factory )// If not, create the RendererFactory and register it as a singleton
56 // Check whether debug rendering is required
57 if( EnvironmentVariable::GetEnvironmentVariable( DALI_DEBUG_RENDERING ) )
59 factory = RendererFactory( new Internal::RendererFactory(true) );
63 factory = RendererFactory( new Internal::RendererFactory(false) );
65 singletonService.Register( typeid(RendererFactory), factory );
73 RendererFactory::RendererFactory()
77 RendererFactory::~RendererFactory()
81 RendererFactory::RendererFactory( const RendererFactory& handle )
82 : BaseHandle( handle )
86 RendererFactory& RendererFactory::operator=( const RendererFactory& handle )
88 BaseHandle::operator=( handle );
92 RendererFactory::RendererFactory(Internal::RendererFactory *impl)
97 ControlRenderer RendererFactory::GetControlRenderer( const Property::Map& propertyMap )
99 return GetImplementation( *this ).GetControlRenderer( propertyMap );
102 ControlRenderer RendererFactory::GetControlRenderer( const Vector4& color )
104 return GetImplementation( *this ).GetControlRenderer( color );
107 void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Vector4& color )
109 GetImplementation( *this ).ResetRenderer( renderer, actor, color );
112 ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor )
114 return GetImplementation( *this ).GetControlRenderer( borderSize, borderColor, false );
118 ControlRenderer RendererFactory::GetControlRenderer( float borderSize, const Vector4& borderColor, bool antiAliasing )
120 return GetImplementation( *this ).GetControlRenderer( borderSize, borderColor, antiAliasing );
123 ControlRenderer RendererFactory::GetControlRenderer( const Image& image )
125 return GetImplementation( *this ).GetControlRenderer( image );
128 void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Image& image )
130 GetImplementation( *this ).ResetRenderer( renderer, actor, image );
133 ControlRenderer RendererFactory::GetControlRenderer( const std::string& url, ImageDimensions size )
135 return GetImplementation( *this ).GetControlRenderer( url, size );
138 void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const std::string& url, ImageDimensions size )
140 GetImplementation( *this ).ResetRenderer( renderer, actor, url, size );
143 void RendererFactory::ResetRenderer( ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
145 GetImplementation( *this ).ResetRenderer( renderer, actor, propertyMap );
148 } // namespace Toolkit