Changes following "Remove Geometry scene object" 45/66745/7
authorFerran Sole <ferran.sole@samsung.com>
Wed, 20 Apr 2016 15:09:55 +0000 (16:09 +0100)
committerFerran Sole <ferran.sole@samsung.com>
Mon, 25 Apr 2016 15:32:39 +0000 (16:32 +0100)
Change-Id: I8332f8a52b33dbd7d852d2f87d4d9d6686edcf17

adaptors/ecore/common/ecore-indicator-impl.cpp
adaptors/emscripten/wrappers/dali-wrapper.cpp
adaptors/emscripten/wrappers/geometry-wrapper.cpp [new file with mode: 0644]
adaptors/emscripten/wrappers/geometry-wrapper.h [new file with mode: 0644]
automated-tests/src/dali-adaptor/dali-test-suite-utils/mesh-builder.cpp

index 90ed05a..0e5d769 100644 (file)
@@ -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;
index 8de62ac..ae55aec 100644 (file)
@@ -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 (file)
index 0000000..c75768a
--- /dev/null
@@ -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<unsigned short*>( const_cast<char*>(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 (file)
index 0000000..12b5324
--- /dev/null
@@ -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 <dali/public-api/dali-core.h>
+#include <dali/devel-api/rendering/geometry.h>
+#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
index 304e567..5b127c7 100644 (file)
@@ -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;
 }