Merge "update bouncing-effect-actor to use new mesh" into devel/new_mesh
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / shader-effects / motion-stretch-effect.cpp
index cc2a9ca..9cde815 100644 (file)
@@ -1,20 +1,27 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
 #include <dali-toolkit/public-api/shader-effects/motion-stretch-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/animation/constraints.h>
+
 namespace Dali
 {
 
@@ -87,19 +94,18 @@ MotionStretchEffect::~MotionStretchEffect()
 {
 }
 
-MotionStretchEffect MotionStretchEffect::Apply( Actor handle )
+MotionStretchEffect MotionStretchEffect::Apply( ImageActor renderable )
 {
   MotionStretchEffect newEffect = New();
-  handle.SetShaderEffect( newEffect );
+  renderable.SetShaderEffect( newEffect );
 
-  Property::Index uModelProperty = newEffect.GetPropertyIndex( MOTION_STRETCH_MODELVIEW_LASTFRAME );
+  Dali::Property::Index uModelProperty = newEffect.GetPropertyIndex( MOTION_STRETCH_MODELVIEW_LASTFRAME );
 
-  Constraint constraint = Constraint::New<Matrix>( uModelProperty,
-                                                   Source( handle, Actor::WORLD_MATRIX ),
-                                                   EqualToConstraint() );
+  Constraint constraint = Constraint::New<Matrix>( newEffect, uModelProperty, EqualToConstraint() );
+  constraint.AddSource( Source( renderable, Actor::Property::WORLD_MATRIX ) );
 
   // and set up constraint.
-  newEffect.ApplyConstraint(constraint);
+  constraint.Apply();
   return newEffect;
 }
 
@@ -117,6 +123,7 @@ MotionStretchEffect MotionStretchEffect::New()
   // varying   vec2  vTexCoord;
   std::string vertexSource;
   vertexSource =
+    "precision mediump float;\n"
     "uniform mat4  uModelLastFrame;\n"
     "uniform float uTimeDelta;\n"
 
@@ -217,10 +224,9 @@ MotionStretchEffect MotionStretchEffect::New()
     "}";
 
   // NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
-  ShaderEffect shader = ShaderEffect::New( vertexSource,
-                                           fragmentSource,
-                                           GeometryType( GEOMETRY_TYPE_IMAGE ),
-                                           ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ) );
+  ShaderEffect shader = ShaderEffect::New(
+    vertexSource, fragmentSource, GeometryType( GEOMETRY_TYPE_IMAGE ),
+    ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ) );
 
 
 
@@ -296,4 +302,3 @@ const std::string& MotionStretchEffect::GetAlphaScalePropertyName() const
 }
 
 }
-