Fixed issues with resolving URL type
[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 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
23
24 struct NSVGimage;
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal
33 {
34
35 /**
36  * The visual which renders a svg image
37  *
38  * The following property is essential
39  *
40  * | %Property Name           | Type             |
41  * |--------------------------|------------------|
42  * | url                      | STRING           |
43  *
44  */
45 class SvgVisual: public Visual::Base
46 {
47 public:
48
49   /**
50    * @brief Constructor.
51    *
52    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
53    */
54   SvgVisual( VisualFactoryCache& factoryCache );
55
56   /**
57    * @brief A reference counted object may only be deleted by calling Unreference().
58    */
59   ~SvgVisual();
60
61 public:  // from Visual
62
63   /**
64    * @copydoc Visual::GetNaturalSize
65    */
66   virtual void GetNaturalSize( Vector2& naturalSize ) const;
67
68   /**
69    * @copydoc Visual::SetSize
70    */
71   virtual void SetSize( const Vector2& size );
72
73   /**
74    * @copydoc Visual::CreatePropertyMap
75    */
76   virtual void DoCreatePropertyMap( Property::Map& map ) const;
77
78 protected:
79
80   /**
81    * @copydoc Visual::DoInitialize
82    */
83   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
84
85   /**
86    * @copydoc Visual::DoSetOnStage
87    */
88   virtual void DoSetOnStage( Actor& actor );
89
90   /**
91    * @copydoc Visual::DoSetOffStage
92    */
93   virtual void DoSetOffStage( Actor& actor );
94
95 public:
96
97   /**
98    * @brief Sets the svg image of this visual to the resource at imageUrl
99    * The visual will parse the svg image once it is set.
100    * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
101    *
102    * @param[in] imageUrl The URL to svg resource to use
103    */
104   void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
105
106   /**
107    * @bried Apply the rasterized image to the visual.
108    *
109    * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
110    */
111   void ApplyRasterizedImage( PixelData rasterizedPixelData );
112
113 private:
114   /**
115    * @bried Rasterize the svg with the given size, and add it to the visual.
116    *
117    * @param[in] size The target size of the SVG rasterization.
118    */
119   void AddRasterizationTask( const Vector2& size );
120
121
122   // Undefined
123   SvgVisual( const SvgVisual& svgRenderer );
124
125   // Undefined
126   SvgVisual& operator=( const SvgVisual& svgRenderer );
127
128 private:
129   Vector4              mAtlasRect;
130   std::string          mImageUrl;
131   NSVGimage*           mParsedImage;
132
133 };
134
135 } // namespace Internal
136
137 } // namespace Toolkit
138
139 } // namespace Dali
140
141 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */