projects
/
platform
/
core
/
uifw
/
dali-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-core.git]
/
dali
/
internal
/
render
/
renderers
/
render-geometry.cpp
diff --git
a/dali/internal/render/renderers/render-geometry.cpp
b/dali/internal/render/renderers/render-geometry.cpp
index
803b6eb
..
17ba522
100644
(file)
--- a/
dali/internal/render/renderers/render-geometry.cpp
+++ b/
dali/internal/render/renderers/render-geometry.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 201
5
Samsung Electronics Co., Ltd.
+ * Copyright (c) 201
8
Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-14,7
+14,10
@@
* limitations under the License.
*/
* limitations under the License.
*/
+// CLASS HEADER
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/render/renderers/render-geometry.h>
+
+// INTERNAL INCLUDES
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
@@
-56,7
+59,7
@@
void Geometry::AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer )
mAttributesChanged = true;
}
mAttributesChanged = true;
}
-void Geometry::SetIndexBuffer( Dali::Vector<u
nsigned shor
t>& indices )
+void Geometry::SetIndexBuffer( Dali::Vector<u
int16_
t>& indices )
{
mIndices.Swap( indices );
mIndicesChanged = true;
{
mIndices.Swap( indices );
mIndicesChanged = true;
@@
-64,13
+67,13
@@
void Geometry::SetIndexBuffer( Dali::Vector<unsigned short>& indices )
void Geometry::RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer )
{
void Geometry::RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer )
{
-
size_t bufferCount = mVertexBuffers.Size
();
- for(
size_t i(0); i<bufferCount; ++i
)
+
const auto&& end = mVertexBuffers.End
();
+ for(
auto&& iter = mVertexBuffers.Begin(); iter != end; ++iter
)
{
{
- if(
propertyBuffer == mVertexBuffers[i]
)
+ if(
*iter == propertyBuffer
)
{
//This will delete the gpu buffer associated to the RenderPropertyBuffer if there is one
{
//This will delete the gpu buffer associated to the RenderPropertyBuffer if there is one
- mVertexBuffers.Remove(
mVertexBuffers.Begin()+i
);
+ mVertexBuffers.Remove(
iter
);
mAttributesChanged = true;
break;
}
mAttributesChanged = true;
break;
}
@@
-81,13
+84,13
@@
void Geometry::GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation
{
attributeLocation.Clear();
{
attributeLocation.Clear();
- for(
size_t i(0); i< mVertexBuffers.Size(); ++i
)
+ for(
auto&& vertexBuffer : mVertexBuffers
)
{
{
-
unsigned int attributeCount = mVertexBuffers[i]
->GetAttributeCount();
- for( u
nsigned in
t j = 0; j < attributeCount; ++j )
+
const uint32_t attributeCount = vertexBuffer
->GetAttributeCount();
+ for( u
int32_
t j = 0; j < attributeCount; ++j )
{
{
- const std::string& attributeName =
mVertexBuffers[i]
->GetAttributeName( j );
- u
nsigned in
t index = program.RegisterCustomAttribute( attributeName );
+ const std::string& attributeName =
vertexBuffer
->GetAttributeName( j );
+ u
int32_
t index = program.RegisterCustomAttribute( attributeName );
GLint location = program.GetCustomAttributeLocation( index );
if( -1 == location )
GLint location = program.GetCustomAttributeLocation( index );
if( -1 == location )
@@
-106,12
+109,7
@@
void Geometry::OnRenderFinished()
mAttributesChanged = false;
}
mAttributesChanged = false;
}
-void Geometry::UploadAndDraw(
- Context& context,
- BufferIndex bufferIndex,
- Vector<GLint>& attributeLocation,
- size_t elementBufferOffset,
- size_t elementBufferCount )
+void Geometry::Upload( Context& context )
{
if( !mHasBeenUpdated )
{
{
if( !mHasBeenUpdated )
{
@@
-129,16
+127,16
@@
void Geometry::UploadAndDraw(
mIndexBuffer = new GpuBuffer( context );
}
mIndexBuffer = new GpuBuffer( context );
}
-
std::size_t bufferSize = sizeof( unsigned short ) * mIndices.Size(
);
- mIndexBuffer->UpdateDataBuffer( bufferSize, &mIndices[0], GpuBuffer::STATIC_DRAW, GpuBuffer::ELEMENT_ARRAY_BUFFER );
+
uint32_t bufferSize = static_cast<uint32_t>( sizeof( uint16_t ) * mIndices.Size()
);
+ mIndexBuffer->UpdateDataBuffer(
context,
bufferSize, &mIndices[0], GpuBuffer::STATIC_DRAW, GpuBuffer::ELEMENT_ARRAY_BUFFER );
}
mIndicesChanged = false;
}
}
mIndicesChanged = false;
}
- for(
unsigned int i = 0; i < mVertexBuffers.Count(); ++i
)
+ for(
auto&& buffer : mVertexBuffers
)
{
{
- if( !
mVertexBuffers[i]
->Update( context ) )
+ if( !
buffer
->Update( context ) )
{
//Vertex buffer is not ready ( Size, data or format has not been specified yet )
return;
{
//Vertex buffer is not ready ( Size, data or format has not been specified yet )
return;
@@
-147,25
+145,33
@@
void Geometry::UploadAndDraw(
mHasBeenUpdated = true;
}
mHasBeenUpdated = true;
}
+}
+void Geometry::Draw(
+ Context& context,
+ BufferIndex bufferIndex,
+ Vector<GLint>& attributeLocation,
+ uint32_t elementBufferOffset,
+ uint32_t elementBufferCount )
+{
//Bind buffers to attribute locations
//Bind buffers to attribute locations
- u
nsigned in
t base = 0u;
-
size_t vertexBufferCount(mVertexBuffers.Count()
);
- for( u
nsigned in
t i = 0; i < vertexBufferCount; ++i )
+ u
int32_
t base = 0u;
+
const uint32_t vertexBufferCount = static_cast<uint32_t>( mVertexBuffers.Count()
);
+ for( u
int32_
t i = 0; i < vertexBufferCount; ++i )
{
{
- mVertexBuffers[i]->BindBuffer( GpuBuffer::ARRAY_BUFFER );
+ mVertexBuffers[i]->BindBuffer(
context,
GpuBuffer::ARRAY_BUFFER );
base += mVertexBuffers[i]->EnableVertexAttributes( context, attributeLocation, base );
}
base += mVertexBuffers[i]->EnableVertexAttributes( context, attributeLocation, base );
}
-
size
_t numIndices(0u);
+
uint32
_t numIndices(0u);
intptr_t firstIndexOffset(0u);
if( mIndexBuffer )
{
intptr_t firstIndexOffset(0u);
if( mIndexBuffer )
{
- numIndices =
mIndices.Size(
);
+ numIndices =
static_cast<uint32_t>( mIndices.Size()
);
if( elementBufferOffset != 0u )
{
if( elementBufferOffset != 0u )
{
- elementBufferOffset =
elementBufferOffset >= numIndices
? numIndices - 1 : elementBufferOffset;
+ elementBufferOffset =
(elementBufferOffset >= numIndices )
? numIndices - 1 : elementBufferOffset;
firstIndexOffset = elementBufferOffset * sizeof(GLushort);
numIndices -= elementBufferOffset;
}
firstIndexOffset = elementBufferOffset * sizeof(GLushort);
numIndices -= elementBufferOffset;
}
@@
-220,27
+226,29
@@
void Geometry::UploadAndDraw(
if( mIndexBuffer && geometryGLType != GL_POINTS )
{
//Indexed draw call
if( mIndexBuffer && geometryGLType != GL_POINTS )
{
//Indexed draw call
- mIndexBuffer->Bind( GpuBuffer::ELEMENT_ARRAY_BUFFER );
- context.DrawElements(geometryGLType, numIndices, GL_UNSIGNED_SHORT, reinterpret_cast<void*>(firstIndexOffset));
+ mIndexBuffer->Bind( context, GpuBuffer::ELEMENT_ARRAY_BUFFER );
+ // numIndices truncated, no value loss happening in practice
+ context.DrawElements( geometryGLType, static_cast<GLsizei>( numIndices ), GL_UNSIGNED_SHORT, reinterpret_cast<void*>( firstIndexOffset ) );
}
else
{
//Unindex draw call
}
else
{
//Unindex draw call
-
unsigned int
numVertices(0u);
+
GLsizei
numVertices(0u);
if( vertexBufferCount > 0 )
{
if( vertexBufferCount > 0 )
{
- numVertices = mVertexBuffers[0]->GetElementCount();
+ // truncated, no value loss happening in practice
+ numVertices = static_cast<GLsizei>( mVertexBuffers[0]->GetElementCount() );
}
context.DrawArrays( geometryGLType, 0, numVertices );
}
//Disable attributes
}
context.DrawArrays( geometryGLType, 0, numVertices );
}
//Disable attributes
- for(
unsigned int i = 0; i < attributeLocation.Count(); ++i
)
+ for(
auto&& attribute : attributeLocation
)
{
{
- if( attribute
Location[i]
!= -1 )
+ if( attribute != -1 )
{
{
- context.DisableVertexAttributeArray(
attributeLocation[i]
);
+ context.DisableVertexAttributeArray(
static_cast<GLuint>( attribute )
);
}
}
}
}
}
}