X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch-data.h;h=99c4d08147312f8f5c6c8a4cdb785263e272151b;hb=407f50841927305f1598dd028003637465d5b229;hp=f67e5998c9b3b62bf03613e966cc66aab074e4a6;hpb=7946b5a1a7188e31803ac8de5c4a8ea3cbc560cc;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/npatch-data.h b/dali-toolkit/internal/visuals/npatch-data.h index f67e599..99c4d08 100644 --- a/dali-toolkit/internal/visuals/npatch-data.h +++ b/dali-toolkit/internal/visuals/npatch-data.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_NPATCH_DATA_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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,6 +19,7 @@ // EXTERNAL INCLUDES #include +#include #include #include @@ -33,20 +34,24 @@ namespace Toolkit { namespace Internal { -class NPatchData : public Dali::Toolkit::TextureUploadObserver +class NPatchData; +typedef IntrusivePtr NPatchDataPtr; + +class NPatchData : public ConnectionTracker, public Dali::Toolkit::TextureUploadObserver, public Dali::RefObject { public: - typedef int32_t NPatchDataId; ///< The NPatchDataId type. This is used as a handle to refer to a particular Npatch Data. - static const int INVALID_NPATCH_DATA_ID = -1; ///< Used to represent a null TextureId or error + typedef int32_t NPatchDataId; ///< The NPatchDataId type. This is used as a handle to refer to a particular Npatch Data. + static const NPatchDataId INVALID_NPATCH_DATA_ID = -1; ///< Used to represent a null TextureId or error /** * @brief Loading State of the NPatch image. */ enum class LoadingState { - LOADING = 0, ///< NPatch is on loading. - LOAD_COMPLETE, ///< NPatch loading is completed successfully. - LOAD_FAILED ///< NPatch loading is failed. + NOT_STARTED = 0, ///< NPatch loading is not started yet. + LOADING, ///< NPatch is on loading. + LOAD_COMPLETE, ///< NPatch loading is completed successfully. + LOAD_FAILED ///< NPatch loading is failed. }; public: @@ -251,6 +256,14 @@ public: */ void SetLoadedNPatchData(Devel::PixelBuffer& pixelBuffer, bool preMultiplied); + /** + * @brief Send LoadComplete notify with current setuped NPatchData + * + * @param [in] observer observer who will be got LoadComplete notify + * @param [in] loadSuccess whether the image load success or not. + */ + void NotifyObserver(TextureUploadObserver* observer, const bool& loadSuccess); + private: /** * @copydoc TextureUploadObserver::LoadComplete @@ -260,22 +273,33 @@ private: */ void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override; + /** + * This is called by the TextureUploadObserver when an observer is destroyed. + * We use the callback to know when to remove an observer from our notify list. + * @param[in] observer The observer that generated the callback + */ + void ObserverDestroyed(TextureUploadObserver* observer); + private: using ObserverListType = Dali::Vector; - NPatchDataId mId; - ObserverListType mObserverList; ///< Container used to store all observer clients of this Texture - VisualUrl mUrl; ///< Url of the N-Patch - TextureSet mTextureSet; ///< Texture containing the cropped image - NPatchUtility::StretchRanges mStretchPixelsX; ///< X stretch pixels - NPatchUtility::StretchRanges mStretchPixelsY; ///< Y stretch pixels - std::size_t mHash; ///< Hash code for the Url - uint32_t mCroppedWidth; ///< Width of the cropped middle part of N-patch - uint32_t mCroppedHeight; ///< Height of the cropped middle part of N-patch - Rect mBorder; ///< The size of the border - LoadingState mLoadingState; ///< True if the data loading is completed - bool mPreMultiplyOnLoad; ///< Whether to multiply alpha into color channels on load - void* mRenderingMap; ///< NPatch rendering data + NPatchDataId mId; + ObserverListType mObserverList; ///< Container used to store all observer clients of this Texture + ObserverListType mQueuedObservers; ///< Container observers when user try to add during notify observers + + VisualUrl mUrl; ///< Url of the N-Patch + TextureSet mTextureSet; ///< Texture containing the cropped image + NPatchUtility::StretchRanges mStretchPixelsX; ///< X stretch pixels + NPatchUtility::StretchRanges mStretchPixelsY; ///< Y stretch pixels + std::size_t mHash; ///< Hash code for the Url + uint32_t mCroppedWidth; ///< Width of the cropped middle part of N-patch + uint32_t mCroppedHeight; ///< Height of the cropped middle part of N-patch + Rect mBorder; ///< The size of the border + LoadingState mLoadingState; ///< True if the data loading is completed + void* mRenderingMap; ///< NPatch rendering data + + bool mPreMultiplyOnLoad : 1; ///< Whether to multiply alpha into color channels on load + bool mObserverNotifying : 1; ///< Whether this NPatchData notifying observers or not. }; } // namespace Internal