X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Frendering%2Fgeometry-api.cpp;h=7011c206b2c5516df96f2bc266c434fe9068bc77;hb=f558388c388bcdf4939ca7af098cbcfc1631ad89;hp=01aec00bde427b11db5b0f4b10f5bf9fca781121;hpb=8c31a5ca493d17693e53f9909a4453b1fa058ab3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/plugins/dali-script-v8/src/rendering/geometry-api.cpp b/plugins/dali-script-v8/src/rendering/geometry-api.cpp index 01aec00..7011c20 100644 --- a/plugins/dali-script-v8/src/rendering/geometry-api.cpp +++ b/plugins/dali-script-v8/src/rendering/geometry-api.cpp @@ -188,8 +188,15 @@ void GeometryApi::RemoveVertexBuffer( const v8::FunctionCallbackInfo< v8::Value * * @method setIndexBuffer * @for Geometry - * @param {Object} indexBuffer PropertyBuffer to be used as a source of indices - * for the geometry + * @param {Uint32Array} data The data that will be copied to the buffer + * + * @example + * var indexData = [0, 1, 1, 2, 2, 3, 3, 4, 4, 0]; + * var indexDataArray = new Uint32Array(indexData.length); + * indexDataArray.set(indexData, 0); + * + * geometry.SetIndexBuffer( indexDataArray, indexDataArray.length ); + *``` */ void GeometryApi::SetIndexBuffer( const v8::FunctionCallbackInfo& args ) { @@ -199,21 +206,37 @@ void GeometryApi::SetIndexBuffer( const v8::FunctionCallbackInfo& arg Geometry geometry = GetGeometry( isolate, args ); bool found( false ); - PropertyBuffer indexBuffer = PropertyBufferApi::GetPropertyBufferFromParams( 0, found, isolate, args ); - if( !found ) + void* data = V8Utils::GetArrayBufferViewParameter( PARAMETER_0, found, isolate, args); + + if( ! found ) { - DALI_SCRIPT_EXCEPTION( isolate, "invalid property buffer parameter" ); + DALI_SCRIPT_EXCEPTION( isolate, "invalid data parameter" ); } else { - geometry.SetIndexBuffer(indexBuffer); + unsigned int size = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "missing buffer size from param 1" ); + } + else + { + Dali::Vector indices; + indices.Resize( size ); + unsigned int* indexData = static_cast(data); + for( size_t i(0); i& arg * dali.GEOMETRY_TRIANGLE_FAN * dali.GEOMETRY_TRIANGLE_STRIP * - * geometry.SetGeometryType( dali.GEOMETRY_LINES ); + * geometry.SetType( dali.GEOMETRY_LINES ); */ -void GeometryApi::SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args ) +void GeometryApi::SetType( const v8::FunctionCallbackInfo< v8::Value >& args ) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope handleScope( isolate ); @@ -243,14 +266,14 @@ void GeometryApi::SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& } else { - geometry.SetGeometryType(static_cast(geometryType)); + geometry.SetType(static_cast(geometryType)); } } /** * Get the type of primitives this geometry contains * - * @method getGeometryType + * @method getType * @for Geometry * @return {integer} Type of primitives this geometry contains * @example @@ -263,14 +286,14 @@ void GeometryApi::SetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& * dali.GEOMETRY_TRIANGLE_FAN * dali.GEOMETRY_TRIANGLE_STRIP */ -void GeometryApi::GetGeometryType( const v8::FunctionCallbackInfo< v8::Value >& args ) +void GeometryApi::GetType( const v8::FunctionCallbackInfo< v8::Value >& args ) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope handleScope( isolate ); Geometry geometry = GetGeometry( isolate, args ); - args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetGeometryType() ) ); + args.GetReturnValue().Set( v8::Integer::New( isolate, geometry.GetType() ) ); } } // namespace V8Plugin