1 #ifndef DALI_TOOLKIT_INTERNAL_ANIMATED_VECTOR_IMAGE_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_ANIMATED_VECTOR_IMAGE_VISUAL_H
5 * Copyright (c) 2018 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/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/weak-handle.h>
27 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
28 #include <dali-toolkit/internal/visuals/visual-url.h>
29 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
40 class ImageVisualShaderFactory;
41 class VectorRasterizeThread;
42 class AnimatedVectorImageVisual;
43 using AnimatedVectorImageVisualPtr = IntrusivePtr< AnimatedVectorImageVisual >;
46 * The visual which renders an animated vector image using VectorAnimationRenderer.
47 * VectorAnimationRenderer renders the animation image and this visuall controls the images.
49 * The following property is essential
51 * | %Property Name | Type |
52 * |--------------------------|------------------|
56 class AnimatedVectorImageVisual: public Visual::Base
61 * @brief Create the AnimatedVectorImageVisual using the image URL.
63 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
64 * @param[in] shaderFactory The ImageVisualShaderFactory object
65 * @param[in] imageUrl The URL to an animated vector image to use
66 * @param[in] properties A Property::Map containing settings for this visual
67 * @return A smart-pointer to the newly allocated visual.
69 static AnimatedVectorImageVisualPtr New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties );
72 * @brief Create the AnimatedVectorImageVisual using the image URL.
74 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
75 * @param[in] shaderFactory The ImageVisualShaderFactory object
76 * @param[in] imageUrl The URL to an animated vector image to use
77 * @return A smart-pointer to the newly allocated visual.
79 static AnimatedVectorImageVisualPtr New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl );
81 public: // from Visual
84 * @copydoc Visual::Base::GetNaturalSize
86 virtual void GetNaturalSize( Vector2& naturalSize ) override;
89 * @copydoc Visual::Base::CreatePropertyMap
91 virtual void DoCreatePropertyMap( Property::Map& map ) const override;
94 * @copydoc Visual::Base::CreateInstancePropertyMap
96 virtual void DoCreateInstancePropertyMap( Property::Map& map ) const override;
101 * @brief Constructor.
103 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
104 * @param[in] shaderFactory The ImageVisualShaderFactory object
105 * @param[in] imageUrl The URL to an animated vector image to use
107 AnimatedVectorImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl );
110 * @brief A reference counted object may only be deleted by calling Unreference().
112 virtual ~AnimatedVectorImageVisual();
115 * @copydoc Visual::Base::DoSetProperties
117 virtual void DoSetProperties( const Property::Map& propertyMap ) override;
120 * @copydoc Visual::Base::DoSetOnStage
122 virtual void DoSetOnStage( Actor& actor ) override;
125 * @copydoc Visual::Base::DoSetOffStage
127 virtual void DoSetOffStage( Actor& actor ) override;
130 * @copydoc Visual::Base::OnSetTransform
132 virtual void OnSetTransform() override;
135 * @copydoc Visual::Base::OnDoAction
137 virtual void OnDoAction( const Property::Index actionId, const Property::Value& attributes ) override;
142 * Helper method to set individual values by index key.
143 * @param[in] index The index key of the value
144 * @param[in] value The value
146 void DoSetProperty( Property::Index index, const Property::Value& value );
149 * @brief Event callback from rasterize thread. This is called after the first frame is ready.
151 void OnResourceReady();
154 AnimatedVectorImageVisual( const AnimatedVectorImageVisual& visual ) = delete;
157 AnimatedVectorImageVisual& operator=( const AnimatedVectorImageVisual& visual ) = delete;
160 ImageVisualShaderFactory& mImageVisualShaderFactory;
164 WeakHandle< Actor > mPlacementActor;
165 std::unique_ptr< VectorRasterizeThread > mVectorRasterizeThread;
168 DevelAnimatedVectorImageVisual::Action::Type mActionStatus;
171 } // namespace Internal
173 } // namespace Toolkit
177 #endif // DALI_TOOLKIT_INTERNAL_ANIMATED_VECTOR_IMAGE_VISUAL_H