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-toolkit/internal/visuals/visual-base-impl.h>
36 * The visual which renders a svg image
38 * The following property is essential
40 * | %Property Name | Type |
41 * |--------------------------|------------------|
45 class SvgVisual: public Visual::Base
52 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
54 SvgVisual( VisualFactoryCache& factoryCache );
57 * @brief A reference counted object may only be deleted by calling Unreference().
61 public: // from Visual
64 * @copydoc Visual::GetNaturalSize
66 virtual void GetNaturalSize( Vector2& naturalSize ) const;
69 * @copydoc Visual::SetSize
71 virtual void SetSize( const Vector2& size );
74 * @copydoc Visual::CreatePropertyMap
76 virtual void DoCreatePropertyMap( Property::Map& map ) const;
81 * @copydoc Visual::DoInitialize
83 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
86 * @copydoc Visual::DoSetOnStage
88 virtual void DoSetOnStage( Actor& actor );
91 * @copydoc Visual::DoSetOffStage
93 virtual void DoSetOffStage( Actor& actor );
98 * @brief Helper method to determine whether the url indicate that it is a svg image.
100 * @param [in] url The URL of the image file.
101 * @return true if it is a svg image
103 static bool IsSvgUrl( const std::string& url );
106 * @brief Sets the svg image of this visual to the resource at imageUrl
107 * The visual will parse the svg image once it is set.
108 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
110 * @param[in] imageUrl The URL to svg resource to use
112 void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
115 * @bried Apply the rasterized image to the visual.
117 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
119 void ApplyRasterizedImage( PixelData rasterizedPixelData );
123 * @bried Rasterize the svg with the given size, and add it to the visual.
125 * @param[in] size The target size of the SVG rasterization.
127 void AddRasterizationTask( const Vector2& size );
131 SvgVisual( const SvgVisual& svgRenderer );
134 SvgVisual& operator=( const SvgVisual& svgRenderer );
138 std::string mImageUrl;
139 NSVGimage* mParsedImage;
143 } // namespace Internal
145 } // namespace Toolkit
149 #endif /* DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H */