Merge "Stop using string comparison against exported constant to check if string...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / filters / emboss-filter.cpp
index 4993cdf..8f444ac 100644 (file)
@@ -1,24 +1,29 @@
-//
-// 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) 2014 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 "emboss-filter.h"
 
 // EXTERNAL INCLUDES
 #include <sstream>
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
 
 // INTERNAL INCLUDES
 
@@ -38,6 +43,7 @@ const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
 
 const char* EMBOSS_FRAGMENT_SOURCE1 =
 {
+ "precision highp float;\n"
  "uniform vec2 uTexScale;\n"
  "\n"
  "void main()\n"
@@ -67,6 +73,7 @@ const char* EMBOSS_FRAGMENT_SOURCE1 =
 
 const char* EMBOSS_FRAGMENT_SOURCE2 =
 {
+ "precision highp float;\n"
  "uniform vec2 uTexScale;\n"
  "\n"
  "void main()\n"
@@ -118,37 +125,37 @@ void EmbossFilter::Enable()
   mCameraActor = CameraActor::New();
   mCameraActor.SetParentOrigin(ParentOrigin::CENTER);
 
-  mImageForEmboss1 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::Unused );
-  mImageForEmboss2 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::Unused );
+  mImageForEmboss1 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::UNUSED );
+  mImageForEmboss2 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::UNUSED );
 
   // create actor to render input with applied emboss effect
   mActorForInput1 = ImageActor::New( mInputImage );
   mActorForInput1.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForInput1.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForInput1.SetSize(mTargetSize);
   mActorForInput1.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
   mActorForInput1.SetColor( Color::WHITE );
 
   mActorForInput2 = ImageActor::New( mInputImage );
   mActorForInput2.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForInput2.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForInput2.SetSize(mTargetSize);
   mActorForInput2.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
   mActorForInput2.SetColor( Color::WHITE );
 
   mActorForEmboss1 = ImageActor::New( mImageForEmboss1 );
   mActorForEmboss1.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForEmboss1.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForEmboss1.SetSize(mTargetSize);
   mActorForEmboss1.SetColor( Color::BLACK );
   mActorForEmboss1.SetShaderEffect( ShaderEffect::New( "", COMPOSITE_FRAGMENT_SOURCE ) );
 
   mActorForEmboss2 = ImageActor::New( mImageForEmboss2 );
   mActorForEmboss2.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForEmboss2.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForEmboss2.SetSize(mTargetSize);
   mActorForEmboss2.SetColor( Color::WHITE );
   mActorForEmboss2.SetShaderEffect( ShaderEffect::New( "", COMPOSITE_FRAGMENT_SOURCE ) );
 
   mActorForComposite = Actor::New();
   mActorForComposite.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForComposite.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForComposite.SetSize(mTargetSize);
   mActorForComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   // create custom shader effect
@@ -240,6 +247,31 @@ void EmbossFilter::Refresh()
   }
 }
 
+void EmbossFilter::SetSize( const Vector2& size )
+{
+  mTargetSize = size;
+  if( mActorForInput1 )
+  {
+    mActorForInput1.SetSize(mTargetSize);
+  }
+  if( mActorForInput2 )
+  {
+    mActorForInput2.SetSize(mTargetSize);
+  }
+  if( mActorForEmboss1 )
+  {
+    mActorForEmboss1.SetSize(mTargetSize);
+  }
+  if( mActorForEmboss2 )
+  {
+    mActorForEmboss2.SetSize(mTargetSize);
+  }
+  if( mActorForComposite )
+  {
+    mActorForComposite.SetSize(mTargetSize);
+  }
+}
+
 void EmbossFilter::SetupCamera()
 {
   // Create and place a camera for the embossing render, corresponding to its render target size