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.
17 #include <dali/internal/update/common/scene-graph-property-buffer.h>
26 PropertyBuffer::PropertyBuffer()
33 PropertyBuffer::~PropertyBuffer()
37 void PropertyBuffer::SetFormat( PropertyBufferMetadata::Format* format )
42 void PropertyBuffer::SetSize( BufferIndex bufferIndex, unsigned int size )
44 mSize.Set(bufferIndex, size);
47 void PropertyBuffer::SetData( BufferIndex bufferIndex, PropertyBufferDataProvider::BufferType* data )
49 mBufferData[bufferIndex] = data;
50 mDataChanged[bufferIndex] = true;
53 void PropertyBuffer::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
57 void PropertyBuffer::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
61 bool PropertyBuffer::HasDataChanged( BufferIndex bufferIndex ) const
63 return mDataChanged[ bufferIndex ];
66 unsigned int PropertyBuffer::GetAttributeCount( BufferIndex bufferIndex ) const
68 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
69 return mFormat->components.size();
72 const std::string& PropertyBuffer::GetAttributeName( BufferIndex bufferIndex, unsigned int index ) const
74 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
75 return mFormat->components[index].name;
78 size_t PropertyBuffer::GetAttributeSize( BufferIndex bufferIndex, unsigned int index ) const
80 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
82 return mFormat->components[index].size;
85 Property::Type PropertyBuffer::GetAttributeType( BufferIndex bufferIndex, unsigned int index ) const
87 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
89 return mFormat->components[index].type;
92 size_t PropertyBuffer::GetAttributeOffset( BufferIndex bufferIndex, unsigned int index ) const
94 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
96 return mFormat->components[index].offset;
99 const PropertyBufferDataProvider::BufferType& PropertyBuffer::GetData( BufferIndex bufferIndex ) const
101 DALI_ASSERT_DEBUG( mBufferData[bufferIndex] && "Should have some data.");
103 return *mBufferData[bufferIndex];
106 std::size_t PropertyBuffer::GetDataSize( BufferIndex bufferIndex ) const
108 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
110 return mFormat->size * mSize[ bufferIndex ];
114 std::size_t PropertyBuffer::GetElementSize( BufferIndex bufferIndex ) const
116 return mFormat->size;
119 unsigned int PropertyBuffer::GetElementCount( BufferIndex bufferIndex ) const
121 return mSize[bufferIndex];
124 unsigned int PropertyBuffer::GetGpuBufferId( BufferIndex bufferIndex ) const
126 //TODO: MESH_REWORK fix this
127 DALI_ASSERT_DEBUG(false && "FIX THIS");
132 void PropertyBuffer::ResetDefaultProperties( BufferIndex updateBufferIndex )
134 // Age the double buffered properties
135 mSize.CopyPrevious(updateBufferIndex);
137 // Update double buffered value
138 mBufferData.CopyPrevious(updateBufferIndex);
140 // The flag should be reset each frame
141 mDataChanged[updateBufferIndex] = false;
144 } // namespace SceneGraph
145 } // namespace Internal