X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Fanimated-image-visual.h;h=2796c20342b32a44ea3ec4aa7d1146b33ac643d8;hb=354a975a68a9989a45344f2a3d2827fcc716111f;hp=4e11ccea8abbc8535fa3256f57547fbce3d1c257;hpb=ddef399f249128bef52cbb79eb321b0bfdaa0ced;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h index 4e11cce..2796c20 100644 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h @@ -19,14 +19,15 @@ */ // EXTERNAL INCLUDES -#include #include +#include #include #include // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -43,29 +44,41 @@ typedef IntrusivePtr< AnimatedImageVisual > AnimatedImageVisualPtr; /** * The visual which renders an animated image * - * The following property is essential + * One of the following properties is mandatory * * | %Property Name | Type | * |------------------- |-------------------| * | url | STRING | + * | urls | ARRAY of STRING | + * + * The remaining properties are optional * | pixelArea | VECTOR4 | * | wrapModeU | INTEGER OR STRING | * | wrapModeV | INTEGER OR STRING | + * | cacheSize | INTEGER | + * | batchSize | INTEGER | + * | frameDelay | INTEGER | * - * where pixelArea is a rectangular area. + * pixelArea is a rectangular area. * In its Vector4 value, the first two elements indicate the top-left position of the area, * and the last two elements are the area width and height respectively. * If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image. * - * where wrapModeU and wrapModeV separately decide how the texture should be sampled when the u and v coordinate exceeds the range of 0.0 to 1.0. + * wrapModeU and wrapModeV separately decide how the texture should be sampled when the u and v coordinate exceeds the range of 0.0 to 1.0. * Its value should be one of the following wrap mode: * "DEFAULT" * "CLAMP_TO_EDGE" * "REPEAT" * "MIRRORED_REPEAT" + * + * cacheSize is used with multiple images - it determines how many images are kept pre-loaded + * batchSize is used with multiple images - it determines how many images to load on each frame + * frameDelay is used with multiple images - it is the number of milliseconds between each frame */ -class AnimatedImageVisual : public Visual::Base, public ConnectionTracker +class AnimatedImageVisual : public Visual::Base, + public ConnectionTracker, + public ImageCache::FrameReadyObserver { public: @@ -74,13 +87,23 @@ public: * @brief Create the animated image Visual using the image URL. * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object - * @param[in] imageUrl The URL to svg resource to use + * @param[in] imageUrl The URL to gif resource to use * @param[in] properties A Property::Map containing settings for this visual * @return A smart-pointer to the newly allocated visual. */ static AnimatedImageVisualPtr New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl, const Property::Map& properties ); /** + * @brief Create the animated image Visual using image URLs. + * + * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object + * @param[in] imageUrls A Property::Array containing the URLs to the image resources + * @param[in] properties A Property::Map containing settings for this visual + * @return A smart-pointer to the newly allocated visual. + */ + static AnimatedImageVisualPtr New( VisualFactoryCache& factoryCache, const Property::Array& imageUrls, const Property::Map& properties ); + + /** * @brief Create the animated image visual using the image URL. * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object @@ -125,6 +148,13 @@ protected: virtual void DoSetProperties( const Property::Map& propertyMap ); /** + * Helper method to set individual values by index key. + * @param[in] index The index key of the value + * @param[in] value The value + */ + void DoSetProperty( Property::Index index, const Property::Value& value ); + + /** * @copydoc Visual::Base::DoSetOnStage */ virtual void DoSetOnStage( Actor& actor ); @@ -140,18 +170,50 @@ protected: virtual void OnSetTransform(); private: + /** + * Creates the renderer for the animated image + */ + void CreateRenderer(); /** - * Load the animated image and pack the frames into atlas. - * @return That atlas texture. + * Starts the Load of the first batch of URLs */ - Texture PrepareAnimatedImage(); + void LoadFirstBatch(); /** - * Display the next frame. It is called when the mFrameDelayTimes ticks. + * Adds the texture set to the renderer, and the renderer to the + * placement actor, and starts the frame timer + */ + void StartFirstFrame( TextureSet& textureSet ); + + /** + * Prepares the texture set for displaying + */ + TextureSet PrepareTextureSet(); + + /** + * Load the gif image and pack the frames into atlas. + * @return The atlas texture. + */ + TextureSet PrepareAnimatedGifImage(); + + /** + * Set the image size from the texture set + */ + void SetImageSize( TextureSet& textureSet ); + + /** + * Called when the next frame is ready. + */ + void FrameReady( TextureSet textureSet ); + + /** + * Display the next frame. It is called when the mFrameDelayTimer ticks. + * Returns true to ensure the timer continues running. */ bool DisplayNextFrame(); + // Undefined AnimatedImageVisual( const AnimatedImageVisual& animatedImageVisual ); @@ -161,15 +223,29 @@ private: private: Timer mFrameDelayTimer; + WeakHandle mPlacementActor; + + // Variables for GIF player Dali::Vector mTextureRectContainer; Dali::Vector mFrameDelayContainer; Vector4 mPixelArea; VisualUrl mImageUrl; + uint32_t mCurrentFrameIndex; // Frame index into textureRects + // Variables for Multi-Image player + ImageCache::UrlList* mImageUrls; + ImageCache* mImageCache; + uint16_t mCacheSize; + uint16_t mBatchSize; + uint16_t mFrameDelay; + uint16_t mUrlIndex; + + // Shared variables ImageDimensions mImageSize; - uint32_t mCurrentFrameIndex; + Dali::WrapMode::Type mWrapModeU:3; Dali::WrapMode::Type mWrapModeV:3; + bool mStartFirstFrame:1; }; } // namespace Internal