Create Renderer when the Visual is created
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / wireframe / wireframe-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H
3
4 /*
5  * Copyright (c) 2021 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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 class WireframeVisual;
37 typedef IntrusivePtr< WireframeVisual > WireframeVisualPtr;
38
39 /**
40  * @brief Renders a wireframe outline to the control's quad.
41  */
42 class WireframeVisual: public Visual::Base
43 {
44 public:
45
46   /**
47    * @brief Create a new wireframe visual.
48    *
49    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
50    * @param[in] properties A Property::Map containing settings for this visual
51    * @return A smart-pointer to the newly allocated visual.
52    */
53   static WireframeVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
54
55   /**
56    * @brief Create a new wireframe visual with an encapsulated actual visual.
57    *
58    * For debugging purpose, the rendering of the encapsulated visual is replaced with wireframe
59    *
60    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
61    * @param[in] actualVisual The encapsulated actual visual.
62    * @return A smart-pointer to the newly allocated visual.
63    */
64   static WireframeVisualPtr New( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual );
65
66   /**
67    * @brief Create a new wireframe visual with an encapsulated actual visual.
68    *
69    * For debugging purpose, the rendering of the encapsulated visual is replaced with wireframe
70    *
71    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
72    * @param[in] actualVisual The encapsulated actual visual.
73    * @param[in] properties A Property::Map containing settings for this visual
74    * @return A smart-pointer to the newly allocated visual.
75    */
76   static WireframeVisualPtr New( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual, const Property::Map& properties );
77
78
79 protected:
80
81   /**
82    * @brief Constructor.
83    *
84    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
85    * @param[in] actualVisual The encapsulated actual visual.
86    */
87   WireframeVisual( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual );
88
89   /**
90    * @brief A reference counted object may only be deleted by calling Unreference().
91    */
92   virtual ~WireframeVisual();
93
94 protected: // from Visual::Base
95   /**
96    * @copydoc Visual::Base::OnInitialize
97    */
98   void OnInitialize() override;
99
100   /**
101    * @copydoc Visual::Base::GetHeightForWidth()
102    */
103   float GetHeightForWidth( float width ) override;
104
105   /**
106    * @copydoc Visual::Base::GetNaturalSize()
107    */
108   void GetNaturalSize( Vector2& naturalSize ) override;
109
110   /**
111    * @copydoc Visual::Base::CreatePropertyMap()
112    */
113   void DoCreatePropertyMap( Property::Map& map ) const override;
114
115   /**
116    * @copydoc Visual::Base::CreateInstancePropertyMap
117    */
118   void DoCreateInstancePropertyMap( Property::Map& map ) const override;
119
120   /**
121    * @copydoc Visual::Base::DoSetProperties()
122    */
123   void DoSetProperties( const Property::Map& propertyMap ) override;
124
125   /**
126    * @copydoc Visual::Base::DoSetOnScene
127    */
128   void DoSetOnScene( Actor& actor ) override;
129
130   /**
131    * @copydoc Visual::Base::OnSetTransform
132    */
133   void OnSetTransform() override;
134
135   /**
136    * @copydoc Visual::Base::GetVisualObject
137    *
138    * Overriding as this visual can sometimes act as a proxy to the actual visual, i.e. when using debug rendering.
139    */
140   Base& GetVisualObject() override;
141
142 private:
143   /**
144    * Create the geometry which presents the quad wireframe.
145    * @return The border geometry
146    */
147   Geometry CreateQuadWireframeGeometry();
148
149   // Undefined
150   WireframeVisual( const WireframeVisual& visual);
151
152   // Undefined
153   WireframeVisual& operator=( const WireframeVisual& visual );
154
155 private:
156
157   Visual::BasePtr mActualVisual;
158
159 };
160
161 } // namespace Internal
162
163 } // namespace Toolkit
164
165 } // namespace Dali
166
167 #endif // DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H