Merge "Added PathConstraint support to Javascript API" into tizen
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 25 Mar 2015 09:18:04 +0000 (02:18 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 25 Mar 2015 09:18:04 +0000 (02:18 -0700)
automated-tests/README.md
plugins/dali-script-v8/docs/content/shader-effect.js
plugins/dali-script-v8/src/actors/actor-wrapper.h
plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp
plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.cpp

index 8db6f2c..db21746 100644 (file)
@@ -62,19 +62,19 @@ Run the following commands:
     cd automated-tests
     ./build.sh
 
-This will build dali and dali-internal test sets.
+This will build dali-toolkit and dali-toolkit-internal test sets.
 
 Test sets can be built individually:
 
-    ./build.sh dali
+    ./build.sh dali-toolkit
 
 They can also be built without regenerating test case scripts (Useful for quicker rebuilds)
 
-    ./build.sh -n dali-internal
+    ./build.sh -n dali-toolkit-internal
 
 Or without cleaning down the build area (Useful for fast build/run/debug cycles)
 
-    ./build.sh -n -r dali-internal
+    ./build.sh -n -r dali-toolkit-internal
 
 
 Executing the tests
index a83df51..98e9c17 100644 (file)
@@ -5,7 +5,13 @@
 
 Shader effects provide a visual effect for actors.
 
-For a Custom shader you can provide the vertex and fragment shader code as strings.
+You can create a type-registered shader effect by its type name.
+```
+// create a new shader effect
+var shader = new dali.ShaderEffect("BlindEffect");
+```
+
+Alternatively you can create a Custom shader by providing the vertex and fragment shader code as strings.
 Each shader is provided with default uniforms and attributes.
 For a vertex shader this part contains the following code:
 ```
index 79381ba..76eee47 100644 (file)
@@ -52,8 +52,7 @@ public:
     MESH_ACTOR   =3,
     LAYER_ACTOR  =4,
     CAMERA_ACTOR =5,
-    LIGHT_ACTOR  =6,
-    TEXT_VIEW    =7
+    TEXT_VIEW    =6
   };
 
   /**
index 74762f2..d7bd2a5 100644 (file)
@@ -19,6 +19,9 @@
 // CLASS HEADER
 #include "shader-effect-api.h"
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
 // INTERNAL INCLUDES
 #include <v8-utils.h>
 #include <shader-effects/shader-effect-wrapper.h>
@@ -187,14 +190,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<v8::Object > obj = args[0]->ToObject();
 
     v8::Local<v8::Value> geometryTypeValue = obj->Get(v8::String::NewFromUtf8( isolate, "geometryType"));
@@ -245,9 +246,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,
index 04ae5fa..89f4ebe 100644 (file)
@@ -126,8 +126,11 @@ void ShaderEffectWrapper::NewShaderEffect( const v8::FunctionCallbackInfo< v8::V
   }
   Dali::ShaderEffect shaderEffect = ShaderEffectApi::New( isolate, args );
 
-  v8::Local<v8::Object> localObject = WrapShaderEffect( isolate, shaderEffect );
-  args.GetReturnValue().Set( localObject );
+  if(shaderEffect)
+  {
+    v8::Local<v8::Object> localObject = WrapShaderEffect( isolate, shaderEffect );
+    args.GetReturnValue().Set( localObject );
+  }
 }