2 * Copyright (c) 2018 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.
19 #include <dali/internal/update/rendering/scene-graph-property-buffer.h>
22 #include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
23 #include <dali/graphics-api/graphics-api-controller.h>
24 #include <dali/graphics-api/graphics-api-buffer.h>
34 PropertyBuffer::PropertyBuffer()
35 : mGraphics( nullptr ),
40 mGraphicsBuffer{ nullptr },
41 mGraphicsBufferUsage{ Graphics::API::Buffer::UsageHint::ATTRIBUTES }
45 PropertyBuffer::~PropertyBuffer()
49 void PropertyBuffer::Initialize( Integration::Graphics::Graphics& graphics )
51 mGraphics = &graphics;
54 void PropertyBuffer::SetUsage( Graphics::API::Buffer::UsageHint usage )
56 mGraphicsBufferUsage = usage;
59 void PropertyBuffer::SetFormat( OwnerPointer< PropertyBuffer::Format >& format )
61 mFormat.Swap( format );
65 void PropertyBuffer::SetData( OwnerPointer< Dali::Vector<char> >& data, size_t size )
73 auto& controller = mGraphics->GetController();
74 mGraphicsBuffer = controller.CreateBuffer( controller.GetBufferFactory()
75 .SetSize( uint32_t( mFormat->size * size) )
76 .SetUsage(Graphics::API::Buffer::UsageHint::ATTRIBUTES ));
81 bool PropertyBuffer::Update( Dali::Graphics::API::Controller& controller )
83 if( !mData || !mFormat || !mSize )
88 if( mDataChanged || !mGraphicsBuffer )
90 if( !mGraphicsBuffer )
92 mGraphicsBuffer = controller.CreateBuffer( controller.GetBufferFactory()
93 .SetUsage( mGraphicsBufferUsage )
97 // schedule deferred write
98 mGraphicsBuffer.Get().Write( mData.Get()->begin(), GetDataSize(), 0u );
100 mDataChanged = false;