2 * Copyright (c) 2020 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/environment-variable.h>
23 #include <dali/devel-api/common/singleton-service.h>
26 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
34 const char* const DALI_DEBUG_RENDERING("DALI_DEBUG_RENDERING");
37 VisualFactory VisualFactory::Get()
39 VisualFactory factory;
41 // Check whether the VisualFactory is already created
42 SingletonService singletonService(SingletonService::Get());
45 BaseHandle handle = singletonService.GetSingleton(typeid(VisualFactory));
48 //If so, downcast the handle of singleton to VisualFactory
49 factory = VisualFactory(dynamic_cast<Internal::VisualFactory*>(handle.GetObjectPtr()));
52 if(!factory) // If not, create the VisualFactory and register it as a singleton
54 // Check whether debug rendering is required
55 if(EnvironmentVariable::GetEnvironmentVariable(DALI_DEBUG_RENDERING))
57 factory = VisualFactory(new Internal::VisualFactory(true));
61 factory = VisualFactory(new Internal::VisualFactory(false));
63 singletonService.Register(typeid(VisualFactory), factory);
70 VisualFactory::VisualFactory()
74 VisualFactory::~VisualFactory()
78 VisualFactory::VisualFactory(const VisualFactory& handle)
83 VisualFactory& VisualFactory::operator=(const VisualFactory& handle)
85 BaseHandle::operator=(handle);
89 VisualFactory::VisualFactory(Internal::VisualFactory* impl)
94 Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyMap)
96 return GetImplementation(*this).CreateVisual(propertyMap);
99 Visual::Base VisualFactory::CreateVisual(const std::string& url, ImageDimensions size)
101 return GetImplementation(*this).CreateVisual(url, size);
104 void VisualFactory::SetPreMultiplyOnLoad(bool preMultiply)
106 GetImplementation(*this).SetPreMultiplyOnLoad(preMultiply);
109 bool VisualFactory::GetPreMultiplyOnLoad() const
111 return GetImplementation(*this).GetPreMultiplyOnLoad();
114 } // namespace Toolkit