1 #ifndef DALI_TOOLKIT_INTERNAL_ANIMATED_IMAGE_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_ANIMATED_IMAGE_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/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/math/vector4.h>
25 #include <dali/public-api/adaptor-framework/timer.h>
28 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
39 class AnimatedImageVisual;
40 typedef IntrusivePtr< AnimatedImageVisual > AnimatedImageVisualPtr;
43 * The visual which renders an animated image
45 * The following property is essential
47 * | %Property Name | Type |
48 * |--------------------------|------------------|
53 class AnimatedImageVisual : public Visual::Base, public ConnectionTracker
59 * @brief Create the animated image Visual using the image URL.
61 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
62 * @param[in] imageUrl The URL to svg resource to use
63 * @param[in] properties A Property::Map containing settings for this visual
64 * @return A smart-pointer to the newly allocated visual.
66 static AnimatedImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties );
69 * @brief Create the animated image visual using the image URL.
71 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
72 * @param[in] imageUrl The URL to animated image resource to use
74 static AnimatedImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl );
76 public: // from Visual
79 * @copydoc Visual::Base::GetNaturalSize
81 virtual void GetNaturalSize( Vector2& naturalSize );
84 * @copydoc Visual::Base::CreatePropertyMap
86 virtual void DoCreatePropertyMap( Property::Map& map ) const;
93 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
95 AnimatedImageVisual( VisualFactoryCache& factoryCache );
98 * @brief A reference counted object may only be deleted by calling Unreference().
100 virtual ~AnimatedImageVisual();
103 * @copydoc Visual::Base::DoSetProperties
105 virtual void DoSetProperties( const Property::Map& propertyMap );
108 * @copydoc Visual::Base::DoSetOnStage
110 virtual void DoSetOnStage( Actor& actor );
113 * @copydoc Visual::Base::DoSetOffStage
115 virtual void DoSetOffStage( Actor& actor );
118 * @copydoc Visual::Base::OnSetTransform
120 virtual void OnSetTransform();
125 * Load the animated image and pack the frames into atlas.
126 * @return That atlas texture.
128 Texture PrepareAnimatedImage();
131 * Display the next frame. It is called when the mFrameDelayTimes ticks.
133 bool DisplayNextFrame();
136 AnimatedImageVisual( const AnimatedImageVisual& animatedImageVisual );
139 AnimatedImageVisual& operator=( const AnimatedImageVisual& animatedImageVisual );
143 Timer mFrameDelayTimer;
144 Dali::Vector<Vector4> mTextureRectContainer;
145 Dali::Vector<uint32_t> mFrameDelayContainer;
146 std::string mImageUrl;
147 ImageDimensions mImageSize;
148 uint32_t mCurrentFrameIndex;
151 } // namespace Internal
153 } // namespace Toolkit
156 #endif /* DALI_TOOLKIT_INTERNAL_ANIMATED_IMAGE_VISUAL_H */