X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Fshader-effects%2Fshader-effect-api.cpp;h=4d65e64241676dd900fc063740d08bf40aaa0902;hp=74762f24786a1e2d1f9193b37108a3321e3c5ee5;hb=d04c5bdbb95cc98f90848c7a98b0b2804df6e5b8;hpb=4c85a797e24c20bfb1670c079e5f66a9a5d6fa0e diff --git a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp b/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp index 74762f2..4d65e64 100644 --- a/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp +++ b/plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp @@ -19,6 +19,9 @@ // CLASS HEADER #include "shader-effect-api.h" +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include @@ -44,7 +47,6 @@ struct GeometryTypePair const GeometryTypePair GeometryTypeTable[]= { {"image", GEOMETRY_TYPE_IMAGE }, - {"text", GEOMETRY_TYPE_TEXT }, {"mesh", GEOMETRY_TYPE_UNTEXTURED_MESH }, {"textured-mesh", GEOMETRY_TYPE_TEXTURED_MESH }, }; @@ -187,14 +189,12 @@ ShaderEffect GetShaderEffect( v8::Isolate* isolate, const v8::FunctionCallbackIn */ ShaderEffect ShaderEffectApi::New( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) { - - v8::HandleScope handleScope( isolate ); - ShaderParameters shaderParams; - if( args[0]->IsObject() ) { + ShaderParameters shaderParams; + v8::Local obj = args[0]->ToObject(); v8::Local geometryTypeValue = obj->Get(v8::String::NewFromUtf8( isolate, "geometryType")); @@ -245,9 +245,39 @@ ShaderEffect ShaderEffectApi::New( v8::Isolate* isolate, const v8::FunctionCall } shaderParams.ProcessHintsArray( hintsArray ); } + + return shaderParams.NewShader(); } - return shaderParams.NewShader(); + else + { + ShaderEffect effect; + + bool found( false ); + std::string typeName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args ); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "string parameter missing" ); + } + else + { + // create a new shader effect based on type, using the type registry. + Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( typeName ); + if( typeInfo ) // handle, check if it has a value + { + Dali::BaseHandle handle = typeInfo.CreateInstance(); + if( handle ) + { + effect = ShaderEffect::DownCast( handle ); + } + } + else + { + DALI_SCRIPT_EXCEPTION(isolate,"Unknown shader effect type"); + } + } + return effect; + } } ShaderEffect ShaderEffectApi::GetShaderEffectFromParams( int paramIndex,