X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Ftexture-manager-impl.h;h=d2c55fd768c59384317895e4e26b490b45d0b8ce;hb=bb50e557f03b618d38c095e6794a4174c58f095d;hp=6df17c6ed134d9f2ab9681b63ece2bf43c9eae07;hpb=5dd8d9b17470720a322865f56925acce5f25fee7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.h b/dali-toolkit/internal/visuals/texture-manager-impl.h index 6df17c6..d2c55fd 100755 --- a/dali-toolkit/internal/visuals/texture-manager-impl.h +++ b/dali-toolkit/internal/visuals/texture-manager-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXTURE_MANAGER_IMPL_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -99,6 +99,8 @@ public: LOADING, ///< Loading has been started, but not finished. LOAD_FINISHED, ///< Loading has finished. (for CPU storage only) WAITING_FOR_MASK,///< Loading has finished, but waiting for mask image + MASK_APPLYING, ///< Loading has finished, Mask is applying + MASK_APPLIED, ///< Loading has finished, Mask is applyied by GPU UPLOADED, ///< Uploaded and ready. (For GPU upload only) CANCELLED, ///< Removed before loading completed LOAD_FAILED ///< Async loading failed, e.g. connection problem @@ -424,6 +426,8 @@ private: typedef size_t TextureHash; ///< The type used to store the hash used for Texture caching. + // Structs: + /** * @brief This struct is used to manage the life-cycle of Texture loading and caching. */ @@ -495,7 +499,20 @@ private: bool preMultiplied:1; ///< true if the image's color was multiplied by it's alpha }; - // Structs: + /** + * Structure to hold info about a texture load queued during NotifyObservers + */ + struct LoadQueueElement + { + LoadQueueElement( TextureId textureId, TextureUploadObserver* observer ) + : mTextureId( textureId ), + mObserver( observer ) + { + } + + TextureId mTextureId; ///< The texture id of the requested load. + TextureUploadObserver* mObserver; ///< Observer of texture load. + }; /** * Struct to hold information about a requested Async load. @@ -519,16 +536,35 @@ private: typedef std::vector TextureInfoContainerType; ///< The container type used to manage the life-cycle and caching of Textures /** + * @brief Initiate a load or queue load if NotifyObservers is invoking callbacks + * @param[in] textureInfo The TextureInfo struct associated with the Texture + * @param[in] observer The observer wishing to observe the texture upload + */ + void LoadOrQueueTexture( TextureInfo& textureInfo, TextureUploadObserver* observer ); + + /** + * @brief Queue a texture load to be subsequently handled by ProcessQueuedTextures. + * @param[in] textureInfo The TextureInfo struct associated with the Texture + * @param[in] observer The observer wishing to observe the texture upload + */ + void QueueLoadTexture( TextureInfo& textureInfo, TextureUploadObserver* observer ); + + /** * @brief Used internally to initiate a load. * @param[in] textureInfo The TextureInfo struct associated with the Texture - * @return True if the load was initiated + * @param[in] observer The observer wishing to observe the texture upload + */ + void LoadTexture( TextureInfo& textureInfo, TextureUploadObserver* observer ); + + /** + * @brief Initiate load of textures queued whilst NotifyObservers invoking callbacks. */ - bool LoadTexture( TextureInfo& textureInfo ); + void ProcessQueuedTextures(); /** * Add the observer to the observer list * @param[in] textureInfo The TextureInfo struct associated with the texture - * observer The observer wishing to observe the texture upload + * @param[in] observer The observer wishing to observe the texture upload */ void ObserveTexture( TextureInfo & textureInfo, TextureUploadObserver* observer ); @@ -551,8 +587,9 @@ private: * @param[in] container The Async loading container * @param[in] id This is the async image loaders Id * @param[in] pixelBuffer The loaded image data + * @param[in] isMaskTask whether this task is for mask or not */ - void AsyncLoadComplete( AsyncLoadingInfoContainerType& container, uint32_t id, Devel::PixelBuffer pixelBuffer ); + void AsyncLoadComplete( AsyncLoadingInfoContainerType& container, uint32_t id, Devel::PixelBuffer pixelBuffer, bool isMaskTask ); /** * @brief Performs Post-Load steps including atlasing. @@ -571,13 +608,10 @@ private: /** * Apply the mask to the pixelBuffer. - * @param[in] pixelBuffer The pixelBuffer to apply the mask to + * @param[in] textureInfo The information of texture to apply the mask to * @param[in] maskTextureId The texture id of the mask. - * @param[in] contentScale The factor to scale the content - * @param[in] cropToMask Whether to crop the content to the mask size */ - void ApplyMask( Devel::PixelBuffer& pixelBuffer, TextureId maskTextureId, - float contentScale, bool cropToMask ); + void ApplyMask( TextureInfo& textureInfo, TextureId maskTextureId ); /** * Upload the texture specified in pixelBuffer to the appropriate location @@ -631,8 +665,8 @@ private: TextureHash GenerateHash( const std::string& url, const ImageDimensions size, const FittingMode::Type fittingMode, const Dali::SamplingMode::Type samplingMode, const UseAtlas useAtlas, - TextureId maskTextureId, - MultiplyOnLoad preMultiplyOnLoad); + TextureId maskTextureId ); + /** * @brief Looks up a cached texture by its hash. * If found, the given parameters are used to check there is no hash-collision. @@ -679,13 +713,29 @@ private: * @param[in] samplingMode The SamplingMode to use * @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image, * e.g., from portrait to landscape + * @param[in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. */ void Load(TextureId textureId, const VisualUrl& url, ImageDimensions desiredSize, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, - bool orientationCorrection); + bool orientationCorrection, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad); + + /** + * @brief Apply mask + * @param [in] id of the texture + * @param [in] pixelBuffer of the to be masked image + * @param [in] maskPixelBuffer of the mask image + * @param [in] contentScale The factor to scale the content + * @param [in] cropToMask Whether to crop the content to the mask size + */ + void ApplyMask( TextureId textureId, + Devel::PixelBuffer pixelBuffer, + Devel::PixelBuffer maskPixelBuffer, + float contentScale, + bool cropToMask ); public: AsyncLoadingHelper(const AsyncLoadingHelper&) = delete; @@ -706,8 +756,9 @@ private: * @brief Callback to be called when texture loading is complete, it passes the pixel buffer on to texture manager. * @param[in] id Loader id * @param[in] pixelBuffer Image data + * @param[in] isMaskTask whether this task is for mask or not */ - void AsyncLoadComplete(uint32_t id, Devel::PixelBuffer pixelBuffer); + void AsyncLoadComplete(uint32_t id, Devel::PixelBuffer pixelBuffer, bool isMaskTask); private: Toolkit::AsyncImageLoader mLoader; @@ -747,8 +798,10 @@ private: // Member Variables: RoundRobinContainerView< AsyncLoadingHelper > mAsyncRemoteLoaders; ///< The Asynchronous image loaders used to provide all remote async loads std::vector< ExternalTextureInfo > mExternalTextures; ///< Externally provided textures Dali::Vector mLifecycleObservers; ///< Lifecycle observers of texture manager + Dali::Vector mLoadQueue; ///< Queue of textures to load after NotifyObservers std::string mBrokenImageUrl; ///< Broken image url TextureId mCurrentTextureId; ///< The current value used for the unique Texture Id generation + bool mQueueLoadFlag; ///< Flag that causes Load Textures to be queued. };