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;
84 * @copydoc Visual::Base::DoInitialize
86 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
89 * @copydoc Visual::Base::DoSetOnStage
91 virtual void DoSetOnStage( Actor& actor );
94 * @copydoc Visual::Base::DoSetOffStage
96 virtual void DoSetOffStage( Actor& actor );
101 * @brief Sets the svg image of this visual to the resource at imageUrl
102 * The visual will parse the svg image once it is set.
103 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
105 * @param[in] imageUrl The URL to svg resource to use
107 void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
110 * @bried Apply the rasterized image to the visual.
112 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
114 void ApplyRasterizedImage( PixelData rasterizedPixelData );
118 * @bried Rasterize the svg with the given size, and add it to the visual.
120 * @param[in] size The target size of the SVG rasterization.
122 void AddRasterizationTask( const Vector2& size );
126 SvgVisual( const SvgVisual& svgRenderer );
129 SvgVisual& operator=( const SvgVisual& svgRenderer );
133 std::string mImageUrl;
134 NSVGimage* mParsedImage;
135 WeakHandle<Actor> mPlacementActor;
139 } // namespace Internal
141 } // namespace Toolkit
145 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */