Moved framebuffer messages from UpdateManager to FrameBuffer
[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 : mGraphics( nullptr ),
34   mIndices(),
35   mGeometryType( Dali::Geometry::TRIANGLES ),
36   mIndicesChanged(false),
37   mHasBeenUpdated(false),
38   mAttributesChanged(true)
39 {
40 }
41
42 Geometry::~Geometry()
43 {
44 }
45
46 void Geometry::Initialize( Integration::Graphics::Graphics& graphics )
47 {
48   mGraphics = &graphics;
49 }
50
51 void Geometry::AddPropertyBuffer( SceneGraph::PropertyBuffer* propertyBuffer )
52 {
53   mVertexBuffers.PushBack( propertyBuffer );
54   mAttributesChanged = true;
55 }
56
57 void Geometry::SetIndexBuffer( Dali::Vector<unsigned short>& indices )
58 {
59   mIndices.Swap( indices );
60   mIndicesChanged = true;
61 }
62
63 void Geometry::RemovePropertyBuffer( const SceneGraph::PropertyBuffer* propertyBuffer )
64 {
65   size_t bufferCount = mVertexBuffers.Size();
66   for( size_t i(0); i<bufferCount; ++i )
67   {
68     if( propertyBuffer == mVertexBuffers[i] )
69     {
70       //This will delete the gpu buffer associated to the RenderPropertyBuffer if there is one
71       mVertexBuffers.Remove( mVertexBuffers.Begin()+i );
72       mAttributesChanged = true;
73       break;
74     }
75   }
76 }
77
78 } // namespace SceneGraph
79 } // namespace Internal
80 } // namespace Dali