X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fimage-loader%2Fimage-load-thread.h;h=520d2b2afabab2962c7b7363e64a50fe63a0cf6b;hb=11e1ee5bb1a33525dd3016a0fd145a6a3ee2c133;hp=53f6e477a1524dd8aed95e4bfd3bc2556a871f4d;hpb=81529cb3b54f998306def4db0ba3f5f5a65c0c30;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/image-loader/image-load-thread.h b/dali-toolkit/internal/image-loader/image-load-thread.h index 53f6e47..520d2b2 100644 --- a/dali-toolkit/internal/image-loader/image-load-thread.h +++ b/dali-toolkit/internal/image-loader/image-load-thread.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_IMAGE_LOAD_THREAD_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -18,27 +18,25 @@ */ // EXTERNAL INCLUDES -#include -#include -#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include namespace Dali { - namespace Toolkit { - namespace Internal { - /** * The task of loading and packing an image into the atlas. */ @@ -47,20 +45,52 @@ struct LoadingTask /** * Constructor. * @param [in] id of the task + * @param [in] animatedImageLoading The AnimatedImageLoading to load animated image + * @param [in] frameIndex The frame index of a frame to be loaded frame + * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask. + */ + LoadingTask(uint32_t id, + Dali::AnimatedImageLoading animatedImageLoading, + uint32_t frameIndex, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad); + + /** + * Constructor. + * @param [in] id of the task * @param [in] url The URL of the image file to load. * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter. * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size. * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. - * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. + * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask. + * @param [in] loadPlanes true to load image planes or false to load bitmap image. */ - LoadingTask( uint32_t id, - const VisualUrl& url, - ImageDimensions dimensions, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad); + LoadingTask(uint32_t id, + const VisualUrl& url, + ImageDimensions dimensions, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad, + bool loadPlanes); + + /** + * Constructor. + * @param [in] id of the task + * @param [in] encodedImageBuffer The encoded buffer of the image to load. + * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image + * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter. + * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size. + * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. + * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask. + */ + LoadingTask(uint32_t id, + const EncodedImageBuffer& encodedImageBuffer, + ImageDimensions dimensions, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad); /** * Constructor. @@ -69,12 +99,14 @@ struct LoadingTask * @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 + * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha. */ - LoadingTask( uint32_t id, - Devel::PixelBuffer pixelBuffer, - Devel::PixelBuffer maskPixelBuffer, - float contentScale, - bool cropToMask ); + LoadingTask(uint32_t id, + Devel::PixelBuffer pixelBuffer, + Devel::PixelBuffer maskPixelBuffer, + float contentScale, + bool cropToMask, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad); /** * Load the image @@ -86,51 +118,57 @@ struct LoadingTask */ void ApplyMask(); -private: + /** + * Multiply alpha + */ + void MultiplyAlpha(); +private: // Undefined - LoadingTask( const LoadingTask& queue ); + LoadingTask(const LoadingTask& queue); // Undefined - LoadingTask& operator=( const LoadingTask& queue ); + LoadingTask& operator=(const LoadingTask& queue); public: - - Devel::PixelBuffer pixelBuffer; ///< pixelBuffer handle after successful load - ///< or pixelBuffer to be masked image in the mask task - VisualUrl url; ///< url of the image to load - uint32_t id; ///< The unique id associated with this task. - ImageDimensions dimensions; ///< dimensions to load - FittingMode::Type fittingMode; ///< fitting options - SamplingMode::Type samplingMode; ///< sampling options - bool orientationCorrection:1; ///< if orientation correction is needed - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad; //< if the image's color should be multiplied by it's alpha - - bool isMaskTask; ///< whether this task is for mask or not - Devel::PixelBuffer maskPixelBuffer; ///< pixelBuffer of mask image - float contentScale; ///< The factor to scale the content - bool cropToMask; ///< Whether to crop the content to the mask size + std::vector pixelBuffers{}; ///< pixelBuffer handle after successful load + ///< or pixelBuffer to be masked image in the mask task + VisualUrl url; ///< url of the image to load + EncodedImageBuffer encodedImageBuffer; ///< encoded buffer of the image to load + uint32_t id; ///< The unique id associated with this task. + ImageDimensions dimensions; ///< dimensions to load + FittingMode::Type fittingMode; ///< fitting options + SamplingMode::Type samplingMode; ///< sampling options + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad; ///< if the image's color should be multiplied by it's alpha + + Devel::PixelBuffer maskPixelBuffer; ///< pixelBuffer of mask image + float contentScale; ///< The factor to scale the content + Dali::AnimatedImageLoading animatedImageLoading; + uint32_t frameIndex; + + bool orientationCorrection : 1; ///< if orientation correction is needed + bool isMaskTask : 1; ///< whether this task is for mask or not + bool cropToMask : 1; ///< Whether to crop the content to the mask size + bool loadPlanes : 1; ///< Whether to load image planes }; - /** * The worker thread for image loading. */ class ImageLoadThread : public Thread { public: - /** * Constructor. * * @param[in] mTrigger The trigger to wake up the main thread. */ - ImageLoadThread( EventThreadCallback* mTrigger ); + ImageLoadThread(EventThreadCallback* mTrigger); /** * Destructor. */ - virtual ~ImageLoadThread(); + ~ImageLoadThread() override; /** * Add a task in to the loading queue @@ -139,7 +177,7 @@ public: * * @note This class takes ownership of the task object */ - void AddTask( LoadingTask* task ); + void AddTask(LoadingTask* task); /** * Pop the next task out from the completed queue. @@ -151,7 +189,7 @@ public: /** * Remove the loading task from the waiting queue. */ - bool CancelTask( uint32_t loadingTaskId ); + bool CancelTask(uint32_t loadingTaskId); /** * Remove all the loading tasks in the waiting queue. @@ -159,7 +197,6 @@ public: void CancelAll(); private: - /** * Pop the next loading task out from the queue to process. * @@ -172,33 +209,30 @@ private: * * @param[in] task The task added to the queue. */ - void AddCompletedTask( LoadingTask* task ); + void AddCompletedTask(LoadingTask* task); protected: - /** * The entry function of the worker thread. * It fetches loading task from the loadQueue, loads the image and adds to the completeQueue. */ - virtual void Run(); + void Run() override; private: - // Undefined - ImageLoadThread( const ImageLoadThread& thread ); + ImageLoadThread(const ImageLoadThread& thread); // Undefined - ImageLoadThread& operator=( const ImageLoadThread& thread ); + ImageLoadThread& operator=(const ImageLoadThread& thread); private: - - Vector< LoadingTask* > mLoadQueue; /// mCompleteQueue; /// mLoadQueue; /// mCompleteQueue; ///