From ba9a398d17c7e40417e650d72ff41bba35b0de47 Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Wed, 20 Apr 2016 16:09:55 +0100 Subject: [PATCH] Changes following "Remove Geometry scene object" Change-Id: I8332f8a52b33dbd7d852d2f87d4d9d6686edcf17 --- .../ecore/common/ecore-indicator-impl.cpp | 19 ++----- adaptors/emscripten/wrappers/dali-wrapper.cpp | 3 +- .../emscripten/wrappers/geometry-wrapper.cpp | 34 +++++++++++++ .../emscripten/wrappers/geometry-wrapper.h | 50 +++++++++++++++++++ .../dali-test-suite-utils/mesh-builder.cpp | 8 +-- 5 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 adaptors/emscripten/wrappers/geometry-wrapper.cpp create mode 100644 adaptors/emscripten/wrappers/geometry-wrapper.h diff --git a/adaptors/ecore/common/ecore-indicator-impl.cpp b/adaptors/ecore/common/ecore-indicator-impl.cpp index 90ed05add..0e5d769db 100644 --- a/adaptors/ecore/common/ecore-indicator-impl.cpp +++ b/adaptors/ecore/common/ecore-indicator-impl.cpp @@ -1025,9 +1025,9 @@ Dali::Geometry Indicator::CreateBackgroundGeometry() // Create indices unsigned int numIndices = 2 * 3 * NUM_GRADIENT_INTERVALS; - unsigned int indices[ numIndices ]; + unsigned short indices[ numIndices ]; - unsigned int* currentIndex = indices; + unsigned short* currentIndex = indices; for( int y = 0; y < NUM_GRADIENT_INTERVALS; ++y ) { *currentIndex++ = (2 * y); @@ -1045,15 +1045,10 @@ Dali::Geometry Indicator::CreateBackgroundGeometry() Dali::PropertyBuffer vertexPropertyBuffer = Dali::PropertyBuffer::New( vertexFormat ); vertexPropertyBuffer.SetData( vertices, numVertices ); - Dali::Property::Map indexFormat; - indexFormat[ "indices" ] = Dali::Property::INTEGER; - Dali::PropertyBuffer indexPropertyBuffer = Dali::PropertyBuffer::New( indexFormat ); - indexPropertyBuffer.SetData( indices, numIndices ); - // Create the geometry object mTranslucentGeometry = Dali::Geometry::New(); mTranslucentGeometry.AddVertexBuffer( vertexPropertyBuffer ); - mTranslucentGeometry.SetIndexBuffer( indexPropertyBuffer ); + mTranslucentGeometry.SetIndexBuffer( &indices[0], numIndices ); } return mTranslucentGeometry; @@ -1072,7 +1067,7 @@ Dali::Geometry Indicator::CreateBackgroundGeometry() { Vector2( -0.5f, 0.5f ), 1.0f }, { Vector2( 0.5f, 0.5f ), 1.0f } }; // Create indices - unsigned int indices[ 6 ] = { 0, 3, 1, 0, 2, 3 }; + unsigned short indices[ 6 ] = { 0, 3, 1, 0, 2, 3 }; Dali::Property::Map vertexFormat; vertexFormat[ "aPosition" ] = Dali::Property::VECTOR2; @@ -1080,15 +1075,11 @@ Dali::Geometry Indicator::CreateBackgroundGeometry() Dali::PropertyBuffer vertexPropertyBuffer = Dali::PropertyBuffer::New( vertexFormat ); vertexPropertyBuffer.SetData( vertices, 4 ); - Dali::Property::Map indexFormat; - indexFormat[ "indices" ] = Dali::Property::INTEGER; - Dali::PropertyBuffer indexPropertyBuffer = Dali::PropertyBuffer::New( indexFormat ); - indexPropertyBuffer.SetData( indices, 6 ); // Create the geometry object mSolidGeometry = Dali::Geometry::New(); mSolidGeometry.AddVertexBuffer( vertexPropertyBuffer ); - mSolidGeometry.SetIndexBuffer( indexPropertyBuffer ); + mSolidGeometry.SetIndexBuffer( &indices[0], 6 ); } return mSolidGeometry; diff --git a/adaptors/emscripten/wrappers/dali-wrapper.cpp b/adaptors/emscripten/wrappers/dali-wrapper.cpp index 8de62ac56..ae55aec7c 100644 --- a/adaptors/emscripten/wrappers/dali-wrapper.cpp +++ b/adaptors/emscripten/wrappers/dali-wrapper.cpp @@ -37,6 +37,7 @@ #include "actor-wrapper.h" #include "animation-wrapper.h" #include "emscripten-utils.h" +#include "geometry-wrapper.h" #include "handle-wrapper.h" #include "image-wrapper.h" #include "property-buffer-wrapper.h" @@ -1043,7 +1044,7 @@ EMSCRIPTEN_BINDINGS(dali_wrapper) .constructor<>(&Dali::Geometry::New) .function("addVertexBuffer", &Dali::Geometry::AddVertexBuffer) .function("getNumberOfVertexBuffers", &Dali::Geometry::GetNumberOfVertexBuffers) - .function("setIndexBuffer", &Dali::Geometry::SetIndexBuffer) + .function("setIndexBuffer", &SetIndexBufferDataRaw) .function("setGeometryType", &Dali::Geometry::SetGeometryType) .function("getGeometryType", &Dali::Geometry::GetGeometryType) .function("setRequiresDepthTesting", &Dali::Geometry::SetRequiresDepthTesting) diff --git a/adaptors/emscripten/wrappers/geometry-wrapper.cpp b/adaptors/emscripten/wrappers/geometry-wrapper.cpp new file mode 100644 index 000000000..c75768af3 --- /dev/null +++ b/adaptors/emscripten/wrappers/geometry-wrapper.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "geometry-wrapper.h" + +namespace Dali +{ +namespace Internal +{ +namespace Emscripten +{ + +void SetIndexBufferDataRaw(Dali::Geometry& self, const std::string& data, std::size_t size ) +{ + self.SetIndexBuffer( reinterpret_cast( const_cast(data.c_str()) ), size ); +} + +}; // namespace Emscripten +}; // namespace Internal +}; // namespace Dali diff --git a/adaptors/emscripten/wrappers/geometry-wrapper.h b/adaptors/emscripten/wrappers/geometry-wrapper.h new file mode 100644 index 000000000..12b532425 --- /dev/null +++ b/adaptors/emscripten/wrappers/geometry-wrapper.h @@ -0,0 +1,50 @@ +#ifndef __DALI_GEOMETRY_WRAPPER_H__ +#define __DALI_GEOMETRY_WRAPPER_H__ + +/* + * Copyright (c) 2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include "emscripten/emscripten.h" +#include "emscripten/val.h" +#include "emscripten/bind.h" + +// INTERNAL INCLUDES + +namespace Dali +{ +namespace Internal +{ +namespace Emscripten +{ + +/** + * Sets the index buffer + * + * @param[in] self The Geometry + * @param[in] data The raw byte data + * + */ +void SetIndexBufferDataRaw(Dali::Geometry& self, const std::string& data, std::size_t size ); + +}; // namespace Emscripten +}; // namespace Internal +}; // namespace Dali + +#endif // header diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/mesh-builder.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/mesh-builder.cpp index 304e5679e..5b127c7de 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/mesh-builder.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/mesh-builder.cpp @@ -62,15 +62,11 @@ Geometry CreateQuadGeometryFromBuffer( PropertyBuffer vertexData ) { Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } }; vertexData.SetData(texturedQuadVertexData, 4); - unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 }; - Property::Map indexFormat; - indexFormat["indices"] = Property::INTEGER; - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); - indices.SetData( indexData, sizeof(indexData)/sizeof(indexData[0]) ); + unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 }; Geometry geometry = Geometry::New(); geometry.AddVertexBuffer( vertexData ); - geometry.SetIndexBuffer( indices ); + geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); return geometry; } -- 2.34.1