X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Frenderers%2Frenderer-factory-cache.h;h=947fd47506ac1601ac9ca513852d1f321a6bef0c;hp=4797c5427a0b9d00cd0a6bca09395e829a8c75f4;hb=f3da11c2818c6d17706fbb2417f21b602b3190f5;hpb=c560f95435d40fd3980cd5f92da65c9f28f440e7 diff --git a/dali-toolkit/internal/controls/renderers/renderer-factory-cache.h b/dali-toolkit/internal/controls/renderers/renderer-factory-cache.h index 4797c54..947fd47 100644 --- a/dali-toolkit/internal/controls/renderers/renderer-factory-cache.h +++ b/dali-toolkit/internal/controls/renderers/renderer-factory-cache.h @@ -17,10 +17,16 @@ * limitations under the License. */ +#include + // EXTERNAL INCLUDES #include #include #include +#include +#include +#include + namespace Dali { @@ -45,10 +51,12 @@ public: { COLOR_SHADER, BORDER_SHADER, - GRADIENT_SHADER_LINEAR, - GRADIENT_SHADER_RADIAL, + GRADIENT_SHADER_LINEAR_USER_SPACE, + GRADIENT_SHADER_LINEAR_BOUNDING_BOX, + GRADIENT_SHADER_RADIAL_USER_SPACE, + GRADIENT_SHADER_RADIAL_BOUNDING_BOX, IMAGE_SHADER, - N_PATCH_SHADER, + NINE_PATCH_SHADER, SVG_SHADER, SHADER_TYPE_MAX = SVG_SHADER }; @@ -59,8 +67,10 @@ public: enum GeometryType { QUAD_GEOMETRY, + BORDER_GEOMETRY, NINE_PATCH_GEOMETRY, - GEOMETRY_TYPE_MAX = NINE_PATCH_GEOMETRY + NINE_PATCH_BORDER_GEOMETRY, + GEOMETRY_TYPE_MAX = NINE_PATCH_BORDER_GEOMETRY }; public: @@ -102,6 +112,33 @@ public: */ static Geometry CreateQuadGeometry(); +public: + + /** + * @brief Request renderer from the url + * + * @return The cached renderer if exist in the cache. Otherwise an empty handle is returned. + */ + Renderer GetRenderer( const std::string& key ) const; + + /** + * @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 + */ + void SaveRenderer( const std::string& key, Renderer& renderer ); + + /** + * @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 + */ + void CleanRendererCache( const std::string& key ); + protected: /** @@ -109,13 +146,47 @@ protected: */ virtual ~RendererFactoryCache(); + /** + * Undefined copy constructor. + */ + RendererFactoryCache(const RendererFactoryCache&); + + /** + * Undefined assignment operator. + */ + RendererFactoryCache& operator=(const RendererFactoryCache& 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 renderers 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: // ToDo: test whether using the WeakHandle could improve the performance // With WeakHandle, the resource would be released automatically when no control is using it Geometry mGeometry[GEOMETRY_TYPE_MAX+1]; Shader mShader[SHADER_TYPE_MAX+1]; + + HashVector mRendererHashes; + CachedRenderers mRenderers; }; } // namespace Internal