X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-factory-cache.h;h=f22fb86fc81672eba6df996a5ab4088af7057319;hp=c674aacd577b79636472dc99efffc37660bc57e3;hb=d9a463c5e80699fb011b3425bde306803c419322;hpb=0a98cc9159a2b5868987ec7f0b31b76f3dc10259 diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.h b/dali-toolkit/internal/visuals/visual-factory-cache.h index c674aac..f22fb86 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.h +++ b/dali-toolkit/internal/visuals/visual-factory-cache.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VISUAL_FACTORY_CACHE_H /* - * Copyright (c) 2016 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. @@ -21,14 +21,14 @@ #include #include #include -#include #include #include -#include // INTERNAL INCLUDES #include #include +#include +#include namespace Dali { @@ -38,16 +38,17 @@ namespace Toolkit namespace Internal { - class ImageAtlasManager; +class NPatchLoader; +class TextureManager; + typedef IntrusivePtr ImageAtlasManagerPtr; -class NPatchLoader; /** * Caches shaders and geometries. Owned by VisualFactory. */ -class VisualFactoryCache : public RefObject +class VisualFactoryCache { public: @@ -57,20 +58,46 @@ public: enum ShaderType { COLOR_SHADER, + COLOR_SHADER_ROUNDED_CORNER, + COLOR_SHADER_BLUR_EDGE, BORDER_SHADER, BORDER_SHADER_ANTI_ALIASING, GRADIENT_SHADER_LINEAR_USER_SPACE, GRADIENT_SHADER_LINEAR_BOUNDING_BOX, GRADIENT_SHADER_RADIAL_USER_SPACE, GRADIENT_SHADER_RADIAL_BOUNDING_BOX, + GRADIENT_SHADER_LINEAR_USER_SPACE_ROUNDED_CORNER, + GRADIENT_SHADER_LINEAR_BOUNDING_BOX_ROUNDED_CORNER, + GRADIENT_SHADER_RADIAL_USER_SPACE_ROUNDED_CORNER, + GRADIENT_SHADER_RADIAL_BOUNDING_BOX_ROUNDED_CORNER, IMAGE_SHADER, IMAGE_SHADER_ATLAS_DEFAULT_WRAP, IMAGE_SHADER_ATLAS_CUSTOM_WRAP, + IMAGE_SHADER_ROUNDED_CORNER, NINE_PATCH_SHADER, - SVG_SHADER, - TEXT_SHADER, + NINE_PATCH_MASK_SHADER, + TEXT_SHADER_MULTI_COLOR_TEXT, + TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, + TEXT_SHADER_SINGLE_COLOR_TEXT, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI, + TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI, + ANIMATED_GRADIENT_SHADER_LINEAR_BOUNDING_REFLECT, + ANIMATED_GRADIENT_SHADER_LINEAR_BOUNDING_REPEAT, + ANIMATED_GRADIENT_SHADER_LINEAR_BOUNDING_CLAMP, + ANIMATED_GRADIENT_SHADER_LINEAR_USER_REFLECT, + ANIMATED_GRADIENT_SHADER_LINEAR_USER_REPEAT, + ANIMATED_GRADIENT_SHADER_LINEAR_USER_CLAMP, + ANIMATED_GRADIENT_SHADER_RADIAL_BOUNDING_REFLECT, + ANIMATED_GRADIENT_SHADER_RADIAL_BOUNDING_REPEAT, + ANIMATED_GRADIENT_SHADER_RADIAL_BOUNDING_CLAMP, + ANIMATED_GRADIENT_SHADER_RADIAL_USER_REFLECT, + ANIMATED_GRADIENT_SHADER_RADIAL_USER_REPEAT, + ANIMATED_GRADIENT_SHADER_RADIAL_USER_CLAMP, WIREFRAME_SHADER, - SHADER_TYPE_MAX = WIREFRAME_SHADER + ARC_BUTT_CAP_SHADER, + ARC_ROUND_CAP_SHADER, + SHADER_TYPE_MAX = ARC_ROUND_CAP_SHADER }; /** @@ -90,8 +117,15 @@ public: /** * @brief Constructor + * + * @param[in] preMultiplyOnLoad True if image visuals should pre-multiply alpha on image load. */ - VisualFactoryCache(); + VisualFactoryCache( bool preMultiplyOnLoad ); + + /** + * @brief Destructor + */ + ~VisualFactoryCache(); /** * Request geometry of the given type. @@ -136,37 +170,25 @@ public: * @brief Returns an image to be used when a visual has failed to correctly render * @return The broken image handle. */ - static Image GetBrokenVisualImage(); - -public: + Image GetBrokenVisualImage(); /** - * @brief Request renderer from the url - * - * @return The cached renderer if exist in the cache. Otherwise an empty handle is returned. + * @copydoc Toolkit::VisualFactory::SetPreMultiplyOnLoad() */ - Renderer GetRenderer( const std::string& key ) const; + void SetPreMultiplyOnLoad( bool preMultiply ); /** - * @brief Cache the renderer based on the given key. - * - * If the key already exists in the cache, then the cache will save an additional renderer to the cache. - * RemoveRenderer will then need to be called twice to remove both items from the cache. - * - * @param[in] key The key to use for caching - * @param[in] renderer The Renderer to be cached + * @copydoc Toolkit::VisualFactory::GetPreMultiplyOnLoad() */ - void SaveRenderer( const std::string& key, Renderer& renderer ); + bool GetPreMultiplyOnLoad(); /** - * @brief Cleans the renderer cache by removing the renderer from the cache based on the given key if there are no longer any references to it - * - * @param[in] key The key used for caching - * - * @return True if the renderer is no longer used anywhere, false otherwise + * @brief Set an image to be used when a visual has failed to correctly render + * @param[in] brokenImageUrl The broken image url. */ - bool CleanRendererCache( const std::string& key ); + void SetBrokenImageUrl(const std::string& brokenImageUrl); +public: /** * Get the image atlas manager. * @return A pointer to the atlas manager @@ -174,6 +196,12 @@ public: ImageAtlasManagerPtr GetAtlasManager(); /** + * Get the texture manager + * @return A reference to the texture manager + */ + TextureManager& GetTextureManager(); + + /** * Get the N-Patch texture cache. * @return A reference to the N patch loader */ @@ -185,6 +213,12 @@ public: */ SvgRasterizeThread* GetSVGRasterizationThread(); + /** + * Get the vector animation thread. + * @return A raw pointer pointing to the vector animation thread. + */ + VectorAnimationThread& GetVectorAnimationThread(); + private: // for svg rasterization thread /** @@ -195,11 +229,6 @@ private: // for svg rasterization thread protected: /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~VisualFactoryCache(); - - /** * Undefined copy constructor. */ VisualFactoryCache(const VisualFactoryCache&); @@ -210,40 +239,16 @@ protected: VisualFactoryCache& operator=(const VisualFactoryCache& rhs); private: - struct CachedRenderer - { - std::string mKey; - WeakHandle< Renderer > mRenderer; - - CachedRenderer( const std::string& key, Renderer& renderer ) - : mKey( key ), - mRenderer( renderer) - {} - }; - - typedef Dali::Vector< std::size_t > HashVector; - typedef Dali::OwnerContainer< const CachedRenderer* > CachedRenderers; - - /** - * @brief Finds the first index into the cached visuals from the url - * - * @return Returns the first index into the cached renderer from the url if it exists in the cache, otherwise returns -1 - */ - int FindRenderer( const std::string& key ) const; - -private: Geometry mGeometry[GEOMETRY_TYPE_MAX+1]; Shader mShader[SHADER_TYPE_MAX+1]; - HashVector mRendererHashes; - CachedRenderers mRenderers; - - Renderer mWireframeRenderer; - - ImageAtlasManagerPtr mAtlasManager; - NPatchLoader mNPatchLoader; - - SvgRasterizeThread* mSvgRasterizeThread; + ImageAtlasManagerPtr mAtlasManager; + TextureManager mTextureManager; + NPatchLoader mNPatchLoader; + SvgRasterizeThread* mSvgRasterizeThread; + std::unique_ptr< VectorAnimationThread > mVectorAnimationThread; + std::string mBrokenImageUrl; + bool mPreMultiplyOnLoad; }; } // namespace Internal