1 #ifndef __DALI_TOOLKIT_RENDERER_FACTORY_CACHE_H__
2 #define __DALI_TOOLKIT_RENDERER_FACTORY_CACHE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/object/ref-object.h>
22 #include <dali/devel-api/rendering/geometry.h>
23 #include <dali/devel-api/rendering/shader.h>
35 * Caches shaders and geometries. Owned by RenderFactory.
37 class RendererFactoryCache : public RefObject
42 * Type of shader for caching.
48 GRADIENT_SHADER_LINEAR,
49 GRADIENT_SHADER_RADIAL,
53 SHADER_TYPE_MAX = SVG_SHADER
57 * Type of geometry for caching.
64 NINE_PATCH_BORDER_GEOMETRY,
65 GEOMETRY_TYPE_MAX = NINE_PATCH_BORDER_GEOMETRY
73 RendererFactoryCache();
76 * Request geometry of the given type.
77 * @return The geometry of the required type if it exist in the cache. Otherwise, an empty handle is returned.
79 Geometry GetGeometry( GeometryType type );
82 * Cache the geometry of the give type.
83 * @param[in] type The geometry type.
84 * @param[in] geometry The geometry for caching.
86 void SaveGeometry( GeometryType type, Geometry geometry);
89 * Request shader of the given type.
90 * @return The shader of the required type if it exist in the cache. Otherwise, an empty handle is returned.
92 Shader GetShader( ShaderType type );
95 * Cache the geometry of the give type.
96 * @param[in] type The geometry type.
97 * @param[in] geometry The geometry for caching.
99 void SaveShader( ShaderType type, Shader shader );
102 * Greate the quad geometry.
103 * Quad geometry is shared by multiple kind of Renderer, so implement it in the factory-cache.
105 static Geometry CreateQuadGeometry();
110 * A reference counted object may only be deleted by calling Unreference()
112 virtual ~RendererFactoryCache();
115 * Undefined copy constructor.
117 RendererFactoryCache(const RendererFactoryCache&);
120 * Undefined assignment operator.
122 RendererFactoryCache& operator=(const RendererFactoryCache& rhs);
126 // ToDo: test whether using the WeakHandle could improve the performance
127 // With WeakHandle, the resource would be released automatically when no control is using it
129 Geometry mGeometry[GEOMETRY_TYPE_MAX+1];
130 Shader mShader[SHADER_TYPE_MAX+1];
133 } // namespace Internal
135 } // namespace Toolkit
139 #endif /*__DALI_TOOLKIT_RENDERER_FACTORY_CACHE_H__ */