1 #ifndef DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/weak-handle.h>
26 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
27 #include <dali-toolkit/internal/visuals/visual-url.h>
41 typedef IntrusivePtr< SvgVisual > SvgVisualPtr;
44 * The visual which renders a svg image
46 * The following property is essential
48 * | %Property Name | Type |
49 * |--------------------------|------------------|
53 class SvgVisual: public Visual::Base
58 * @brief Create the SVG Visual using the image URL.
60 * The visual will parse the SVG image once it is set.
61 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
63 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
64 * @param[in] imageUrl The URL to svg resource to use
65 * @param[in] properties A Property::Map containing settings for this visual
66 * @return A smart-pointer to the newly allocated visual.
68 static SvgVisualPtr New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl, const Property::Map& properties );
71 * @brief Create the SVG Visual using the image URL.
73 * The visual will parse the SVG image once it is set.
74 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
76 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
77 * @param[in] imageUrl The URL to svg resource to use
78 * @return A smart-pointer to the newly allocated visual.
80 static SvgVisualPtr New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl );
82 public: // from Visual
85 * @copydoc Visual::Base::GetNaturalSize
87 virtual void GetNaturalSize( Vector2& naturalSize );
90 * @copydoc Visual::Base::CreatePropertyMap
92 virtual void DoCreatePropertyMap( Property::Map& map ) const;
95 * @copydoc Visual::Base::CreateInstancePropertyMap
97 virtual void DoCreateInstancePropertyMap( Property::Map& map ) const;
102 * @brief Constructor.
104 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
106 SvgVisual( VisualFactoryCache& factoryCache );
109 * @brief A reference counted object may only be deleted by calling Unreference().
111 virtual ~SvgVisual();
114 * @copydoc Visual::Base::DoSetProperties
116 virtual void DoSetProperties( const Property::Map& propertyMap );
119 * @copydoc Visual::Base::DoSetOnStage
121 virtual void DoSetOnStage( Actor& actor );
124 * @copydoc Visual::Base::DoSetOffStage
126 virtual void DoSetOffStage( Actor& actor );
129 * @copydoc Visual::Base::OnSetTransform
131 virtual void OnSetTransform();
136 * @bried Apply the rasterized image to the visual.
138 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
140 void ApplyRasterizedImage( PixelData rasterizedPixelData );
145 * @brief Parses the SVG Image from the set URL.
147 * @param[in] imageUrl The URL of the image to parse the SVG from.
149 void ParseFromUrl( const VisualUrl& imageUrl );
152 * @bried Rasterize the svg with the given size, and add it to the visual.
154 * @param[in] size The target size of the SVG rasterization.
156 void AddRasterizationTask( const Vector2& size );
160 SvgVisual( const SvgVisual& svgRenderer );
163 SvgVisual& operator=( const SvgVisual& svgRenderer );
168 NSVGimage* mParsedImage;
169 WeakHandle<Actor> mPlacementActor;
173 } // namespace Internal
175 } // namespace Toolkit
179 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */