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/devel-api/object/weak-handle.h>
25 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
39 * The visual which renders a svg image
41 * The following property is essential
43 * | %Property Name | Type |
44 * |--------------------------|------------------|
48 class SvgVisual: public Visual::Base
55 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
57 SvgVisual( VisualFactoryCache& factoryCache );
60 * @brief Constructor which creates the SVG Visual using the image URL.
62 * The visual will parse the SVG image once it is set.
63 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
65 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
66 * @param[in] imageUrl The URL to svg resource to use
68 SvgVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
71 * @brief A reference counted object may only be deleted by calling Unreference().
75 public: // from Visual
78 * @copydoc Visual::Base::GetNaturalSize
80 virtual void GetNaturalSize( Vector2& naturalSize ) const;
83 * @copydoc Visual::Base::SetSize
85 virtual void SetSize( const Vector2& size );
88 * @copydoc Visual::Base::CreatePropertyMap
90 virtual void DoCreatePropertyMap( Property::Map& map ) const;
93 * @copydoc Visual::Base::DoSetProperty
95 virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
98 * @copydoc Visual::Base::DoGetProperty
100 virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
105 * @copydoc Visual::Base::DoInitialize
107 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
110 * @copydoc Visual::Base::DoSetOnStage
112 virtual void DoSetOnStage( Actor& actor );
115 * @copydoc Visual::Base::DoSetOffStage
117 virtual void DoSetOffStage( Actor& actor );
122 * @bried Apply the rasterized image to the visual.
124 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
126 void ApplyRasterizedImage( PixelData rasterizedPixelData );
131 * @brief Parses the SVG Image from the set URL.
133 * @param[in] imageUrl The URL of the image to parse the SVG from.
134 * @param[in] size The required size of the SVG
136 void ParseFromUrl( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
139 * @bried Rasterize the svg with the given size, and add it to the visual.
141 * @param[in] size The target size of the SVG rasterization.
143 void AddRasterizationTask( const Vector2& size );
147 SvgVisual( const SvgVisual& svgRenderer );
150 SvgVisual& operator=( const SvgVisual& svgRenderer );
154 std::string mImageUrl;
155 NSVGimage* mParsedImage;
156 WeakHandle<Actor> mPlacementActor;
160 } // namespace Internal
162 } // namespace Toolkit
166 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */