Remove incorrect empty Actor handle parameter from Visuals DoInitialize
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / svg / svg-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_SVG_VISUAL_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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/devel-api/object/weak-handle.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
27
28 struct NSVGimage;
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 class SvgVisual;
40 typedef IntrusivePtr< SvgVisual > SvgVisualPtr;
41
42 /**
43  * The visual which renders a svg image
44  *
45  * The following property is essential
46  *
47  * | %Property Name           | Type             |
48  * |--------------------------|------------------|
49  * | url                      | STRING           |
50  *
51  */
52 class SvgVisual: public Visual::Base
53 {
54 public:
55
56   /**
57    * @brief Create a new SVG visual.
58    *
59    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
60    * @return A smart-pointer to the newly allocated visual.
61    */
62   static SvgVisualPtr New( VisualFactoryCache& factoryCache );
63
64   /**
65    * @brief Create the SVG Visual using the image URL.
66    *
67    * The visual will parse the SVG image once it is set.
68    * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
69    *
70    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
71    * @param[in] imageUrl The URL to svg resource to use
72    * @param[in] size The required size for the SVG
73    */
74   static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
75
76 public:  // from Visual
77
78   /**
79    * @copydoc Visual::Base::GetNaturalSize
80    */
81   virtual void GetNaturalSize( Vector2& naturalSize ) const;
82
83   /**
84    * @copydoc Visual::Base::SetSize
85    */
86   virtual void SetSize( const Vector2& size );
87
88   /**
89    * @copydoc Visual::Base::CreatePropertyMap
90    */
91   virtual void DoCreatePropertyMap( Property::Map& map ) const;
92
93   /**
94    * @copydoc Visual::Base::DoSetProperty
95    */
96   virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
97
98   /**
99    * @copydoc Visual::Base::DoGetProperty
100    */
101   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
102
103 protected:
104
105   /**
106    * @brief Constructor.
107    *
108    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
109    */
110   SvgVisual( VisualFactoryCache& factoryCache );
111
112   /**
113    * @brief A reference counted object may only be deleted by calling Unreference().
114    */
115   virtual ~SvgVisual();
116
117   /**
118    * @copydoc Visual::Base::DoSetProperties
119    */
120   virtual void DoSetProperties( const Property::Map& propertyMap );
121
122   /**
123    * @copydoc Visual::Base::DoSetOnStage
124    */
125   virtual void DoSetOnStage( Actor& actor );
126
127   /**
128    * @copydoc Visual::Base::DoSetOffStage
129    */
130   virtual void DoSetOffStage( Actor& actor );
131
132 public:
133
134   /**
135    * @bried Apply the rasterized image to the visual.
136    *
137    * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
138    */
139   void ApplyRasterizedImage( PixelData rasterizedPixelData );
140
141 private:
142
143   /**
144    * @brief Parses the SVG Image from the set URL.
145    *
146    * @param[in] imageUrl The URL of the image to parse the SVG from.
147    * @param[in] size The required size of the SVG
148    */
149   void ParseFromUrl( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
150
151   /**
152    * @bried Rasterize the svg with the given size, and add it to the visual.
153    *
154    * @param[in] size The target size of the SVG rasterization.
155    */
156   void AddRasterizationTask( const Vector2& size );
157
158
159   // Undefined
160   SvgVisual( const SvgVisual& svgRenderer );
161
162   // Undefined
163   SvgVisual& operator=( const SvgVisual& svgRenderer );
164
165 private:
166   Vector4              mAtlasRect;
167   std::string          mImageUrl;
168   NSVGimage*           mParsedImage;
169   WeakHandle<Actor>    mPlacementActor;
170
171 };
172
173 } // namespace Internal
174
175 } // namespace Toolkit
176
177 } // namespace Dali
178
179 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */