f6e8d9ca3a9826bf0ee3dbbc8f6876348a94414e
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-factory-impl.h
1 #ifndef DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H
2 #define DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/object/base-object.h>
22
23 // INTERNAL INCLUDES
24 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
25 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 class VisualFactoryCache;
37 typedef IntrusivePtr<VisualFactoryCache> VisualFactoryCachePtr;
38
39 class ImageAtlasManager;
40 typedef IntrusivePtr<ImageAtlasManager> ImageAtlasManagerPtr;
41
42 /**
43  * @copydoc Toolkit::VisualFactory
44  */
45 class VisualFactory : public BaseObject
46 {
47 public:
48
49   /**
50    * @brief Constructor
51    *
52    * @param[in] debugEnabled If true, use debug renderer to replace all the concrete renderer.
53    */
54   VisualFactory( bool debugEnabled );
55
56   /**
57    * @copydoc Toolkit::RenderFactory::CreateVisual( const Property::Map& )
58    */
59   Toolkit::Visual::Base CreateVisual( const Property::Map& propertyMap );
60
61   /**
62    * @copydoc Toolkit::RenderFactory::CreateVisual( const Image& )
63    */
64   Toolkit::Visual::Base CreateVisual( const Image& image );
65
66   /**
67    * @copydoc Toolkit::RenderFactory::CreateVisual( const std::string&, ImageDimensions )
68    */
69   Toolkit::Visual::Base CreateVisual( const std::string& image, ImageDimensions size );
70
71 public:
72   /**
73    * @brief Returns an image to be used when a visual has failed to correctly render
74    */
75   static Image GetBrokenVisualImage();
76
77 protected:
78
79   /**
80    * A reference counted object may only be deleted by calling Unreference()
81    */
82   virtual ~VisualFactory();
83
84 private:
85
86   /**
87    * Prepare the atlas manager
88    */
89   void CreateAtlasManager();
90
91   /**
92    * Undefined copy constructor.
93    */
94   VisualFactory(const VisualFactory&);
95
96   /**
97    * Undefined assignment operator.
98    */
99   VisualFactory& operator=(const VisualFactory& rhs);
100
101 private:
102
103   VisualFactoryCachePtr   mFactoryCache;
104   ImageAtlasManagerPtr    mAtlasManager;
105   bool                    mDebugEnabled;
106 };
107
108 } // namespace Internal
109
110 inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFactory& factory)
111 {
112   DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" );
113
114   const BaseObject& handle = factory.GetBaseObject();
115
116   return static_cast<const Internal::VisualFactory&>(handle);
117 }
118
119 inline Internal::VisualFactory& GetImplementation(Toolkit::VisualFactory& factory)
120 {
121   DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" );
122
123   BaseObject& handle = factory.GetBaseObject();
124
125   return static_cast<Internal::VisualFactory&>(handle);
126 }
127
128 } // namespace Toolkit
129
130 } // namespace Dali
131
132 #endif /* DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H */