1 #ifndef DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
5 * Copyright (c) 2016 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/devel-api/object/weak-handle.h>
26 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
40 typedef IntrusivePtr< SvgVisual > SvgVisualPtr;
43 * The visual which renders a svg image
45 * The following property is essential
47 * | %Property Name | Type |
48 * |--------------------------|------------------|
52 class SvgVisual: public Visual::Base
57 * @brief Create the SVG Visual using the image URL.
59 * The visual will parse the SVG image once it is set.
60 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
62 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
63 * @param[in] imageUrl The URL to svg resource to use
64 * @param[in] properties A Property::Map containing settings for this visual
65 * @return A smart-pointer to the newly allocated visual.
67 static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties );
70 * @brief Create the SVG Visual using the image URL.
72 * The visual will parse the SVG image once it is set.
73 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
75 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
76 * @param[in] imageUrl The URL to svg resource to use
77 * @return A smart-pointer to the newly allocated visual.
79 static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl );
81 public: // from Visual
84 * @copydoc Visual::Base::GetNaturalSize
86 virtual void GetNaturalSize( Vector2& naturalSize );
89 * @copydoc Visual::Base::CreatePropertyMap
91 virtual void DoCreatePropertyMap( Property::Map& map ) const;
98 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
100 SvgVisual( VisualFactoryCache& factoryCache );
103 * @brief A reference counted object may only be deleted by calling Unreference().
105 virtual ~SvgVisual();
108 * @copydoc Visual::Base::DoSetProperties
110 virtual void DoSetProperties( const Property::Map& propertyMap );
113 * @copydoc Visual::Base::DoSetOnStage
115 virtual void DoSetOnStage( Actor& actor );
118 * @copydoc Visual::Base::DoSetOffStage
120 virtual void DoSetOffStage( Actor& actor );
123 * @copydoc Visual::Base::OnSetTransform
125 virtual void OnSetTransform();
130 * @bried Apply the rasterized image to the visual.
132 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
134 void ApplyRasterizedImage( PixelData rasterizedPixelData );
139 * @brief Parses the SVG Image from the set URL.
141 * @param[in] imageUrl The URL of the image to parse the SVG from.
143 void ParseFromUrl( const std::string& imageUrl );
146 * @bried Rasterize the svg with the given size, and add it to the visual.
148 * @param[in] size The target size of the SVG rasterization.
150 void AddRasterizationTask( const Vector2& size );
154 SvgVisual( const SvgVisual& svgRenderer );
157 SvgVisual& operator=( const SvgVisual& svgRenderer );
161 std::string mImageUrl;
162 NSVGimage* mParsedImage;
163 WeakHandle<Actor> mPlacementActor;
167 } // namespace Internal
169 } // namespace Toolkit
173 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */