X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Frendering%2Frenderer-api.cpp;h=8834c354ed435553917ae65ec1d1f466d15cf6ad;hp=2ec736d6eccb0a26d0b28e614c8399dfed18af64;hb=22fac05feb6021eba8ab72268225a00293119089;hpb=2a8f032f9d3e1a78a31986a95ea72964a5b515b0 diff --git a/plugins/dali-script-v8/src/rendering/renderer-api.cpp b/plugins/dali-script-v8/src/rendering/renderer-api.cpp index 2ec736d..8834c35 100644 --- a/plugins/dali-script-v8/src/rendering/renderer-api.cpp +++ b/plugins/dali-script-v8/src/rendering/renderer-api.cpp @@ -27,8 +27,9 @@ #include #include #include -#include -#include +#include +#include +#include namespace Dali { @@ -85,7 +86,7 @@ Renderer RendererApi::GetRendererFromParams( int paramIndex, * @method Renderer * @for Renderer * @param {Object} geometry The geometry to be used by this renderer - * @param {Object} material The material to be used by this renderer + * @param {Object} shader The shader to be used by this renderer * @return {Object} Renderer */ Renderer RendererApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) @@ -102,14 +103,14 @@ Renderer RendererApi::New( const v8::FunctionCallbackInfo< v8::Value >& args ) } found = false; - Material material = MaterialApi::GetMaterialFromParams( 1, found, isolate, args ); + Shader shader = ShaderApi::GetShaderFromParams( 1, found, isolate, args ); if( !found ) { - DALI_SCRIPT_EXCEPTION( isolate, "missing material from param 0" ); + DALI_SCRIPT_EXCEPTION( isolate, "missing shader from param 0" ); return Renderer(); } - return Renderer::New(geometry, material); + return Renderer::New(geometry, shader); } /** @@ -159,13 +160,13 @@ void RendererApi::GetGeometry( const v8::FunctionCallbackInfo& args ) } /** - * Sets the material to be used by this renderer + * Sets the texture set to be used by this renderer * - * @method setMaterial + * @method setTextures * @for Renderer - * @param {Object} material The material to be used by this renderer + * @param {Object} textureSet The TextureSet to be used by this renderer */ -void RendererApi::SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args ) +void RendererApi::SetTextures( const v8::FunctionCallbackInfo< v8::Value >& args ) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope handleScope( isolate ); @@ -173,193 +174,37 @@ void RendererApi::SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args Renderer renderer = GetRenderer( isolate, args ); bool found( false ); - Material material = MaterialApi::GetMaterialFromParams( 0, found, isolate, args ); + TextureSet textureSet = TextureSetApi::GetTextureSetFromParams( 0, found, isolate, args ); if( !found ) { - DALI_SCRIPT_EXCEPTION( isolate, "missing material from param 0" ); + DALI_SCRIPT_EXCEPTION( isolate, "missing texture set from param 0" ); } else { - renderer.SetMaterial(material); + renderer.SetTextures(textureSet); } } /** - * Gets the material used by this renderer + * Gets the texture set used by this renderer * - * @method getMaterial + * @method getTextures * @for Renderer - * @return {Object} The material used by this renderer + * @return {Object} The texture set used by this renderer */ -void RendererApi::GetMaterial( const v8::FunctionCallbackInfo& args ) +void RendererApi::GetTextures( const v8::FunctionCallbackInfo& args ) { v8::Isolate* isolate = args.GetIsolate(); v8::HandleScope handleScope( isolate ); Renderer renderer = GetRenderer( isolate, args ); - Material material = renderer.GetMaterial(); + TextureSet textureSet = renderer.GetTextures(); - // Wrap the material - v8::Local localObject = MaterialWrapper::WrapMaterial( isolate, material ); + // Wrap the textureset + v8::Local localObject = TextureSetWrapper::WrapTextureSet( isolate, textureSet ); args.GetReturnValue().Set( localObject ); } -/** - * Specify the pixel arithmetic used when the actor is blended. - * - * @for Renderer - * @method setBlendFunc - * @param {integer} srcFactorRgb Source Blending RGB - * @param {integer} destFactorRgb Destination Blending RGB - * @param {integer} srcFactorAlpha Source Blending Alpha - * @param {integer} destFactorAlpha Destination Blending Alpha - * @example - * //blending constants - * dali.BLEND_FACTOR_ZERO - * dali.BLEND_FACTOR_ONE - * dali.BLEND_FACTOR_SRC_COLOR - * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR - * dali.BLEND_FACTOR_SRC_ALPHA - * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA - * dali.BLEND_FACTOR_DST_ALPHA - * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA - * dali.BLEND_FACTOR_DST_COLOR - * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR - * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE - * dali.BLEND_FACTOR_CONSTANT_COLOR - * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR - * dali.BLEND_FACTOR_CONSTANT_ALPHA - * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA - * - * renderer.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR, - * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA ); - */ -void RendererApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - Renderer renderer = GetRenderer( isolate, args ); - - int params[4]; - bool foundAllParams(false); - V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 ); - if( foundAllParams ) - { - renderer.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]), - static_cast< Dali::BlendingFactor::Type>(params[1]), - static_cast< Dali::BlendingFactor::Type>(params[2]), - static_cast< Dali::BlendingFactor::Type>(params[3]) ); - } - else - { - DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter"); - } -} - -/** - * Query the pixel arithmetic used when the actor is blended. - * - * @for Renderer - * @method getBlendFunc - * @return {Object} Blend properties - * @example Blend properties object has 4 fields - * - * blendProperties.sourceRgb // source rgb enum - * blendProperties.destinationRgb // destination rgb enum - * blendProperties.sourceAlpha source // alpha enum - * blendProperties.destinationAlpha // destination alpha enum - */ -void RendererApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - // Pass by reference doesn't work in Javascript - // For now just return a vector 4... - - BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha; - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - Renderer renderer = GetRenderer( isolate, args ); - - renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - - v8::Local blendProperties = v8::Object::New( isolate ); - - blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) ); - blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) ); - blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) ); - blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) ); - - args.GetReturnValue().Set( blendProperties ); -} - -/** - * Specify the equation used when the actor is blended. - * - * @for Renderer - * @method setBlendEquation - * @param { integer } equationRgb The equation used for combining red, green, and blue components. - * @param { integer } equationAlpha The equation used for combining the alpha component. - * @example - * // blend equation is one of the following - * dali.BLEND_EQUATION_ADD - * dali.BLEND_EQUATION_SUBTRACT - * dali.BLEND_EQUATION_REVERSE_SUBTRACT - * - * renderer.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT ); - */ -void RendererApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - Renderer renderer = GetRenderer( isolate, args ); - - int params[2]; - bool foundAllParams(false); - V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 ); - if( foundAllParams ) - { - renderer.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) ); - } - else - { - DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter"); - } -} - -/** - * Query the equation used when the actor is blended. - * - * @for Renderer - * @method getBlendEquation - * @return {Object} Blend equations - * @example Blend equations object has 2 fields - * - * blendEquations.equationRgb // equation used for combining rgb components - * blendEquations.equationAlpha // equation used for combining alpha components - */ -void RendererApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args ) -{ - // Pass by reference doesn't work in Javascript - // For now just return a vector 2... - - BlendingEquation::Type equationRgb, equationAlpha; - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope handleScope( isolate ); - - Renderer renderer = GetRenderer( isolate, args ); - - renderer.GetBlendEquation( equationRgb, equationAlpha ); - - v8::Local blendEquations = v8::Object::New( isolate ); - - blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) ); - blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) ); - - args.GetReturnValue().Set( blendEquations ); -} - } // namespace V8Plugin } // namespace Dali