2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "renderer-factory-cache.h"
21 #include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
32 RendererFactoryCache::RendererFactoryCache()
36 RendererFactoryCache::~RendererFactoryCache()
38 for( int i=0; i<= SHADER_TYPE_MAX; i++)
46 for( int i=0; i<= GEOMETRY_TYPE_MAX; i++)
56 Geometry RendererFactoryCache::GetGeometry( GeometryType type )
58 return mGeometry[type];
61 void RendererFactoryCache::SaveGeometry( GeometryType type, Geometry geometry )
63 mGeometry[type] = geometry;
66 Shader RendererFactoryCache::GetShader( ShaderType type )
71 void RendererFactoryCache::SaveShader( ShaderType type, Shader shader )
73 mShader[type] = shader;
76 Geometry RendererFactoryCache::CreateQuadGeometry()
78 const float halfWidth = 0.5f;
79 const float halfHeight = 0.5f;
80 struct QuadVertex { Vector2 position;};
81 QuadVertex quadVertexData[4] =
83 { Vector2(-halfWidth, -halfHeight) },
84 { Vector2( halfWidth, -halfHeight) },
85 { Vector2(-halfWidth, halfHeight) },
86 { Vector2( halfWidth, halfHeight) }
89 Property::Map quadVertexFormat;
90 quadVertexFormat["aPosition"] = Property::VECTOR2;
91 PropertyBuffer quadVertices = PropertyBuffer::New( quadVertexFormat, 4 );
92 quadVertices.SetData(quadVertexData);
95 //TODO: replace with triangle strip when Geometry supports it
96 unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
97 Property::Map indexFormat;
98 indexFormat["indices"] = Property::INTEGER;
99 PropertyBuffer indices = PropertyBuffer::New( indexFormat, 6 );
100 indices.SetData(indexData);
102 // Create the geometry object
103 Geometry geometry = Geometry::New();
104 geometry.AddVertexBuffer( quadVertices );
105 geometry.SetIndexBuffer( indices );
110 } // namespace Internal
112 } // namespace Toolkit