1 #ifndef __DALI_TOOLKIT_INTERNAL_SVG_RENDERER_H__
2 #define __DALI_TOOLKIT_INTERNAL_SVG_RENDERER_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/controls/renderers/control-renderer-impl.h>
23 #include <dali-toolkit/internal/controls/renderers/image-atlas-manager.h>
37 * The renderer which renders a svg image
39 * The following property is essential
41 * | %Property Name | Type |
42 * |--------------------------|------------------|
43 * | imageUrl | STRING |
46 class SvgRenderer: public ControlRenderer
53 * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
55 SvgRenderer( RendererFactoryCache& factoryCache, ImageAtlasManager& atlasManager );
58 * @brief A reference counted object may only be deleted by calling Unreference().
62 public: // from ControlRenderer
65 * @copydoc ControlRenderer::GetNaturalSize
67 virtual void GetNaturalSize( Vector2& naturalSize ) const;
70 * @copydoc ControlRenderer::SetSize
72 virtual void SetSize( const Vector2& size );
75 * @copydoc ControlRenderer::CreatePropertyMap
77 virtual void DoCreatePropertyMap( Property::Map& map ) const;
82 * @copydoc ControlRenderer::DoInitialize
84 virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
87 * @copydoc ControlRenderer::DoSetOnStage
89 virtual void DoSetOnStage( Actor& actor );
92 * @copydoc ControlRenderer::DoSetOffStage
94 virtual void DoSetOffStage( Actor& actor );
99 * @brief Helper method to determine whether the url indicate that it is a svg image.
101 * @param [in] url The URL of the image file.
102 * @return true if it is a svg image
104 static bool IsSvgUrl( const std::string& url );
107 * @brief Sets the svg image of this renderer to the resource at imageUrl
108 * The renderer will parse the svg image once it is set.
109 * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
111 * @param[in] imageUrl The URL to svg resource to use
113 void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
116 * @bried Apply the rasterized image to the renderer.
118 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
120 void ApplyRasterizedImage( PixelDataPtr rasterizedPixelData );
124 * @bried Rasterize the svg with the given size, and add it to the renderer.
126 * @param[in] size The target size of the SVG rasterization.
128 void AddRasterizationTask( const Vector2& size );
132 SvgRenderer( const SvgRenderer& svgRenderer );
135 SvgRenderer& operator=( const SvgRenderer& svgRenderer );
139 ImageAtlasManager& mAtlasManager;
140 std::string mImageUrl;
141 NSVGimage* mParsedImage;
145 } // namespace Internal
147 } // namespace Toolkit
151 #endif /* __DALI_TOOLKIT_INTERNAL_SVG_RENDERER_H__ */