Removing rendering backend
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / scene-graph-geometry.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 // CLASS HEADER
18 #include <dali/internal/update/rendering/scene-graph-geometry.h>
19
20 // INTERNAL HEADERS
21 #include <dali/integration-api/debug.h>
22 #include <dali/internal/common/buffer-index.h>
23 #include <dali/internal/update/rendering/scene-graph-property-buffer.h>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace SceneGraph
30 {
31
32 Geometry::Geometry()
33 : mIndices(),
34   mGeometryType( Dali::Geometry::TRIANGLES ),
35   mIndicesChanged(false),
36   mHasBeenUpdated(false),
37   mAttributesChanged(true)
38 {
39 }
40
41 Geometry::~Geometry()
42 {
43 }
44
45 void Geometry::Initialize( Integration::Graphics::Graphics& graphics )
46 {
47   mGraphics = &graphics;
48 }
49
50 void Geometry::AddPropertyBuffer( SceneGraph::PropertyBuffer* propertyBuffer )
51 {
52   mVertexBuffers.PushBack( propertyBuffer );
53   mAttributesChanged = true;
54 }
55
56 void Geometry::SetIndexBuffer( Dali::Vector<unsigned short>& indices )
57 {
58   mIndices.Swap( indices );
59   mIndicesChanged = true;
60 }
61
62 void Geometry::RemovePropertyBuffer( const SceneGraph::PropertyBuffer* propertyBuffer )
63 {
64   size_t bufferCount = mVertexBuffers.Size();
65   for( size_t i(0); i<bufferCount; ++i )
66   {
67     if( propertyBuffer == mVertexBuffers[i] )
68     {
69       //This will delete the gpu buffer associated to the RenderPropertyBuffer if there is one
70       mVertexBuffers.Remove( mVertexBuffers.Begin()+i );
71       mAttributesChanged = true;
72       break;
73     }
74   }
75 }
76
77 } // namespace SceneGraph
78 } // namespace Internal
79 } // namespace Dali