5a54a68d3c071782b92a23ac40f7710da6f5e276
[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) 2015 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.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   enum RendererType
50   {
51     COLOR,
52     BORDER,
53     GRADIENT,
54     IMAGE,
55     N_PATCH,
56     SVG,
57     MESH,
58     PRIMITIVE,
59     UNDEFINED
60   };
61
62   /**
63    * @brief Constructor
64    *
65    * @param[in] debugEnabled If true, use debug renderer to replace all the concrete renderer.
66    */
67   VisualFactory( bool debugEnabled );
68
69   /**
70    * @copydoc Toolkit::RenderFactory::CreateVisual( const Property::Map& )
71    */
72   Toolkit::Visual CreateVisual( const Property::Map& propertyMap );
73
74   /**
75    * @copydoc Toolkit::RenderFactory::CreateVisual( const Image& )
76    */
77   Toolkit::Visual CreateVisual( const Image& image );
78
79   /**
80    * @copydoc Toolkit::RenderFactory::CreateVisual( const std::string&, ImageDimensions )
81    */
82   Toolkit::Visual CreateVisual( const std::string& image, ImageDimensions size );
83
84 public:
85   /**
86    * @brief Returns an image to be used when a renderer has failed to correctly render
87    */
88   static Image GetBrokenRendererImage();
89
90 protected:
91
92   /**
93    * A reference counted object may only be deleted by calling Unreference()
94    */
95   virtual ~VisualFactory();
96
97 private:
98
99   /**
100    * Get the visual type from the property map.
101    *
102    * @param[in] propertyMap The map contains the properties of the visual
103    * @return The rendererType
104    */
105   RendererType GetRendererType( const Property::Map& propertyMap );
106
107   /**
108    * Prepare the atlas manager
109    */
110   void CreateAtlasManager();
111
112   /**
113    * Undefined copy constructor.
114    */
115   VisualFactory(const VisualFactory&);
116
117   /**
118    * Undefined assignment operator.
119    */
120   VisualFactory& operator=(const VisualFactory& rhs);
121
122 private:
123
124   VisualFactoryCachePtr   mFactoryCache;
125   ImageAtlasManagerPtr    mAtlasManager;
126   bool                    mDebugEnabled;
127 };
128
129 } // namespace Internal
130
131 inline const Internal::VisualFactory& GetImplementation(const Toolkit::VisualFactory& factory)
132 {
133   DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" );
134
135   const BaseObject& handle = factory.GetBaseObject();
136
137   return static_cast<const Internal::VisualFactory&>(handle);
138 }
139
140 inline Internal::VisualFactory& GetImplementation(Toolkit::VisualFactory& factory)
141 {
142   DALI_ASSERT_ALWAYS( factory && "VisualFactory handle is empty" );
143
144   BaseObject& handle = factory.GetBaseObject();
145
146   return static_cast<Internal::VisualFactory&>(handle);
147 }
148
149 } // namespace Toolkit
150
151 } // namespace Dali
152
153 #endif /* DALI_TOOLKIT_VISUAL_FACTORY_IMPL_H */