X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Fshader-effects%2Fshader-effect-api.cpp;h=4d65e64241676dd900fc063740d08bf40aaa0902;hb=06990b10c42c9f1ec0ec3c44b690d83b8b14b366;hp=a793c072b70ed96cae8db96ee8ad7adbfa7d8324;hpb=3e17d9f63dedb5d669409301f8d9a3d8c393f979;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 a793c07..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 @@ -186,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")); @@ -244,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,