X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-image%2Fanimated-image-visual.h;h=1d21356689019881ee854dc52be3f654e2d5cca9;hp=0d21f97f22eb42f063447dc22a8b1daee8338fef;hb=d2a6f4d721fbc03b51d4f1328a58b1fa65f90d43;hpb=a00bbe499550a054e6692eb46b32f8c1548f3647 diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h old mode 100755 new mode 100644 index 0d21f97..1d21356 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_ANIMATED_IMAGE_VISUAL_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,31 +19,29 @@ */ // EXTERNAL INCLUDES +#include +#include #include #include #include #include -#include -#include // INTERNAL INCLUDES +#include +#include +#include #include #include -#include -#include namespace Dali { - namespace Toolkit { - namespace Internal { - class ImageVisualShaderFactory; class AnimatedImageVisual; -typedef IntrusivePtr< AnimatedImageVisual > AnimatedImageVisualPtr; +typedef IntrusivePtr AnimatedImageVisualPtr; /** * The visual which renders an animated image @@ -84,19 +82,17 @@ class AnimatedImageVisual : public Visual::Base, public ConnectionTracker, public ImageCache::FrameReadyObserver { - public: - /** * @brief Create the animated image Visual using the image URL. * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object * @param[in] shaderFactory The ImageVisualShaderFactory object - * @param[in] imageUrl The URL to gif resource to use + * @param[in] imageUrl The URL to animated image 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, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties ); + static AnimatedImageVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties); /** * @brief Create the animated image Visual using image URLs. @@ -107,7 +103,7 @@ public: * @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, ImageVisualShaderFactory& shaderFactory, const Property::Array& imageUrls, const Property::Map& properties ); + static AnimatedImageVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const Property::Array& imageUrls, const Property::Map& properties); /** * @brief Create the animated image visual using the image URL. @@ -116,72 +112,85 @@ public: * @param[in] shaderFactory The ImageVisualShaderFactory object * @param[in] imageUrl The URL to animated image resource to use */ - static AnimatedImageVisualPtr New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl ); - -public: // from Visual + static AnimatedImageVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl); +public: // from Visual /** * @copydoc Visual::Base::GetNaturalSize */ - void GetNaturalSize( Vector2& naturalSize ) override; + void GetNaturalSize(Vector2& naturalSize) override; /** * @copydoc Visual::Base::CreatePropertyMap */ - void DoCreatePropertyMap( Property::Map& map ) const override; + void DoCreatePropertyMap(Property::Map& map) const override; /** * @copydoc Visual::Base::CreateInstancePropertyMap */ - void DoCreateInstancePropertyMap( Property::Map& map ) const override; + void DoCreateInstancePropertyMap(Property::Map& map) const override; /** * @copydoc Visual::Base::OnDoAction */ - void OnDoAction( const Dali::Property::Index actionName, const Dali::Property::Value& attributes ) override; + void OnDoAction(const Dali::Property::Index actionName, const Dali::Property::Value& attributes) override; protected: - /** * @brief Constructor. * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object * @param[in] shaderFactory The ImageVisualShaderFactory object */ - AnimatedImageVisual( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory ); + AnimatedImageVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory); /** * @brief A reference counted object may only be deleted by calling Unreference(). */ - virtual ~AnimatedImageVisual(); + ~AnimatedImageVisual() override; + + /** + * @copydoc Visual::Base::OnInitialize + */ + void OnInitialize() override; /** * @copydoc Visual::Base::DoSetProperties */ - void DoSetProperties( const Property::Map& propertyMap ) override; + void DoSetProperties(const Property::Map& propertyMap) override; /** * 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 ); + void DoSetProperty(Property::Index index, const Property::Value& value); /** - * @copydoc Visual::Base::DoSetOnStage + * @copydoc Visual::Base::DoSetOnScene */ - void DoSetOnStage( Actor& actor ) override; + void DoSetOnScene(Actor& actor) override; /** - * @copydoc Visual::Base::DoSetOffStage + * @copydoc Visual::Base::DoSetOffScene */ - void DoSetOffStage( Actor& actor ) override; + void DoSetOffScene(Actor& actor) override; /** * @copydoc Visual::Base::OnSetTransform */ void OnSetTransform() override; + /** + * @copydoc Visual::Base::UpdateShader + */ + void UpdateShader() override; + + /** + * @copydoc Visual::Base::GenerateShader + */ + Shader GenerateShader() const override; + private: /** * Creates the renderer for the animated image @@ -198,7 +207,7 @@ private: * placement actor, and starts the frame timer * @param[in] textureSet The texture set to apply */ - void StartFirstFrame( TextureSet& textureSet ); + void StartFirstFrame(TextureSet& textureSet); /** * Prepares the texture set for displaying @@ -209,13 +218,13 @@ private: * Set the image size from the texture set * @param[in] textureSet The texture set to get the size from */ - void SetImageSize( TextureSet& textureSet ); + void SetImageSize(TextureSet& textureSet); /** * Called when the next frame is ready. * @param[in] textureSet the texture set to apply */ - void FrameReady( TextureSet textureSet ); + void FrameReady(TextureSet textureSet) override; /** * Display the next frame. It is called when the mFrameDelayTimer ticks. @@ -224,50 +233,55 @@ private: bool DisplayNextFrame(); /** - * Initialize the gif variables. - * @param[in] imageUrl The url of the animated gif + * Initialize the animated image variables. + * @param[in] imageUrl The url of the animated image */ - void InitializeGif( const VisualUrl& imageUrl ); + void InitializeAnimatedImage(const VisualUrl& imageUrl); + + /** + * Set the state of loading fail of an image or a frame. + * Returns TextureSet of broken image. + */ + TextureSet SetLoadingFailed(); // Undefined - AnimatedImageVisual( const AnimatedImageVisual& animatedImageVisual ); + AnimatedImageVisual(const AnimatedImageVisual& animatedImageVisual); // Undefined - AnimatedImageVisual& operator=( const AnimatedImageVisual& animatedImageVisual ); + AnimatedImageVisual& operator=(const AnimatedImageVisual& animatedImageVisual); private: - - Timer mFrameDelayTimer; - WeakHandle mPlacementActor; + Timer mFrameDelayTimer; + WeakHandle mPlacementActor; ImageVisualShaderFactory& mImageVisualShaderFactory; - // Variables for GIF player - Dali::Vector mFrameDelayContainer; - Vector4 mPixelArea; - VisualUrl mImageUrl; - std::unique_ptr mGifLoading; // Only needed for animated gifs - uint32_t mCurrentFrameIndex; // Frame index into textureRects + // Variables for Animated Image player + Vector4 mPixelArea; + VisualUrl mImageUrl; + Dali::AnimatedImageLoading mAnimatedImageLoading; // Only needed for animated image + uint32_t mFrameIndexForJumpTo; // Frame index into textureRects // Variables for Multi-Image player ImageCache::UrlList* mImageUrls; - ImageCache* mImageCache; - uint16_t mCacheSize; - uint16_t mBatchSize; - uint16_t mFrameDelay; - int16_t mLoopCount; - int16_t mCurrentLoopIndex; - uint16_t mUrlIndex; + ImageCache* mImageCache; + uint16_t mCacheSize; + uint16_t mBatchSize; + uint16_t mFrameDelay; + int16_t mLoopCount; + int16_t mCurrentLoopIndex; + uint16_t mUrlIndex; // Shared variables - uint32_t mFrameCount; // Number of frames + uint32_t mFrameCount; // Number of frames ImageDimensions mImageSize; - Dali::WrapMode::Type mWrapModeU:3; - Dali::WrapMode::Type mWrapModeV:3; - DevelAnimatedImageVisual::Action::Type mActionStatus:3; - DevelImageVisual::StopBehavior::Type mStopBehavior:2; - bool mStartFirstFrame:1; - bool mIsJumpTo:1; + DevelAnimatedImageVisual::Action::Type mActionStatus; + + Dali::WrapMode::Type mWrapModeU : 3; + Dali::WrapMode::Type mWrapModeV : 3; + DevelImageVisual::StopBehavior::Type mStopBehavior : 2; + bool mStartFirstFrame : 1; + bool mIsJumpTo : 1; }; } // namespace Internal