X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch%2Fnpatch-visual.h;h=19bdaff8493643d690a3b7fd8b15bf40a4019886;hp=a76162808e4b2885139895c682ee7e3b5a2fe992;hb=e9ce8b35ce64531e5c6c6214527a5bf9b9747a36;hpb=fedd5ae8da46cd798f730fd07c942df853e055dd diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.h b/dali-toolkit/internal/visuals/npatch/npatch-visual.h index a761628..19bdaff 100644 --- a/dali-toolkit/internal/visuals/npatch/npatch-visual.h +++ b/dali-toolkit/internal/visuals/npatch/npatch-visual.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_N_PATCH_VISUAL_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,14 +20,15 @@ // EXTERNAL INCLUDES #include -#include #include -#include #include #include #include +#include // INTERNAL INCLUDES +#include +#include #include #include @@ -56,7 +57,7 @@ typedef IntrusivePtr< NPatchVisual > NPatchVisualPtr; * | auxiliaryImage | STRING | * | auxiliaryImageAlpha | FLOAT | */ -class NPatchVisual: public Visual::Base +class NPatchVisual: public Visual::Base, public TextureUploadObserver { public: @@ -83,14 +84,6 @@ public: */ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl ); - /** - * @brief Create an N-patch visual with a NinePatchImage resource. - * - * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object - * @param[in] image The NinePatchImage to use - */ - static NPatchVisualPtr New( VisualFactoryCache& factoryCache, NinePatchImage image ); - public: // from Visual /** @@ -128,14 +121,14 @@ protected: void DoSetProperties( const Property::Map& propertyMap ) override; /** - * @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 @@ -206,16 +199,40 @@ private: */ Geometry CreateBorderGeometry( Uint16Pair gridSize ); + /** + * @brief Creates a renderer by using loaded resource. + */ + void SetResource(); + private: - NPatchLoader& mLoader; ///< reference to N patch loader for fast access - VisualUrl mImageUrl; ///< The url to the N patch to load - VisualUrl mAuxiliaryUrl; ///< An auxiliary image that can be displayed on top of the N-Patch - std::size_t mId; ///< id of the N patch (from loader/cache) - Devel::PixelBuffer mAuxiliaryPixelBuffer; ///< pixel buffer of the auxiliary mask image - bool mBorderOnly; ///< if only border is desired - Rect mBorder; ///< The size of the border - float mAuxiliaryImageAlpha; ///< The alpha value for the auxiliary image only + /** + * @copydoc TextureUploadObserver::UploadCompleted + * + * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready. + * This callback is the place to add the renderer as it would be called once the loading is finished. + */ + void UploadComplete( bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied ) override; + + /** + * @copydoc TextureUploadObserver::LoadComplete + * + * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready. + * This callback is the place to add the renderer as it would be called once the loading is finished. + */ + void LoadComplete( bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied ) override; + +private: + WeakHandle mPlacementActor; ///< Weakhandle to contain Actor during texture loading + NPatchLoader& mLoader; ///< reference to N patch loader for fast access + VisualUrl mImageUrl; ///< The url to the N patch to load + VisualUrl mAuxiliaryUrl; ///< An auxiliary image that can be displayed on top of the N-Patch + NPatchData::NPatchDataId mId; ///< id of the N patch (from loader/cache) + Devel::PixelBuffer mAuxiliaryPixelBuffer; ///< pixel buffer of the auxiliary mask image + bool mBorderOnly; ///< if only border is desired + Rect mBorder; ///< The size of the border + float mAuxiliaryImageAlpha; ///< The alpha value for the auxiliary image only + Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy; ///< The release policy to determine when an image should no longer be cached. }; } // namespace Internal