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 A reference counted object may only be deleted by calling Unreference().
64 public: // from Visual
67 * @copydoc Visual::Base::GetNaturalSize
69 virtual void GetNaturalSize( Vector2& naturalSize ) const;
72 * @copydoc Visual::Base::SetSize
74 virtual void SetSize( const Vector2& size );
77 * @copydoc Visual::Base::CreatePropertyMap
79 virtual void DoCreatePropertyMap( Property::Map& map ) const;
82 * @copydoc Visual::Base::DoSetProperty
84 virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
87 * @copydoc Visual::Base::DoGetProperty
89 virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
94 * @copydoc Visual::Base::DoInitialize
96 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
99 * @copydoc Visual::Base::DoSetOnStage
101 virtual void DoSetOnStage( Actor& actor );
104 * @copydoc Visual::Base::DoSetOffStage
106 virtual void DoSetOffStage( Actor& actor );
111 * @brief Sets the svg image of this visual to the resource at imageUrl
112 * The visual will parse the svg image once it is set.
113 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
115 * @param[in] imageUrl The URL to svg resource to use
117 void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
120 * @bried Apply the rasterized image to the visual.
122 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
124 void ApplyRasterizedImage( PixelData rasterizedPixelData );
128 * @bried Rasterize the svg with the given size, and add it to the visual.
130 * @param[in] size The target size of the SVG rasterization.
132 void AddRasterizationTask( const Vector2& size );
136 SvgVisual( const SvgVisual& svgRenderer );
139 SvgVisual& operator=( const SvgVisual& svgRenderer );
143 std::string mImageUrl;
144 NSVGimage* mParsedImage;
145 WeakHandle<Actor> mPlacementActor;
149 } // namespace Internal
151 } // namespace Toolkit
155 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */