Merge "DALi Version 1.0.27" into tizen
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 29 Jan 2015 11:18:40 +0000 (03:18 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 29 Jan 2015 11:18:40 +0000 (03:18 -0800)
optional/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp
optional/dali-toolkit/internal/filters/blur-two-pass-filter.cpp
optional/dali-toolkit/internal/filters/blur-two-pass-filter.h
optional/dali-toolkit/internal/filters/emboss-filter.cpp
optional/dali-toolkit/internal/filters/emboss-filter.h
optional/dali-toolkit/internal/filters/image-filter.h
optional/dali-toolkit/internal/filters/spread-filter.cpp
optional/dali-toolkit/internal/filters/spread-filter.h

index 82c6ffe..f928e1c 100644 (file)
@@ -220,7 +220,7 @@ void EffectsView::SetOutputImage( FrameBufferImage image )
       }
       mActorForResult = Actor::New();
       mActorForResult.SetParentOrigin( ParentOrigin::CENTER );
-      mActorForResult.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+      mActorForResult.SetSize( mTargetSize );
       mActorForResult.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
       Self().Add( mActorForResult );
@@ -266,7 +266,6 @@ void EffectsView::SetupProperties()
   mEffectOffsetPropertyIndex   = self.RegisterProperty(EFFECT_OFFSET_PROPERTY_NAME, EFFECT_OFFSET_DEFAULT);
   mEffectColorPropertyIndex    = self.RegisterProperty(EFFECT_COLOR_PROPERTY_NAME, EFFECT_COLOR_DEFAULT);
   mActorPostFilter.ApplyConstraint( Constraint::New<Vector3>( Actor::POSITION, Source( self, mEffectOffsetPropertyIndex ), EqualToConstraint() ) );
-  mActorPostFilter.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
   mActorPostFilter.ApplyConstraint( Constraint::New<Vector4>( Actor::COLOR, Source( self, mEffectColorPropertyIndex ), EqualToConstraint() ) );
 }
 
@@ -290,12 +289,10 @@ void EffectsView::OnInitialize()
 
   mActorForChildren = ImageActor::New();
   mActorForChildren.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  mActorForChildren.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); // same size as EffectsView object
   mActorForChildren.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   mActorPostFilter = ImageActor::New();
   mActorPostFilter.SetParentOrigin( ParentOrigin::CENTER );
-  mActorPostFilter.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); // same size as EffectsView object
   mActorPostFilter.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
   mActorPostFilter.SetShaderEffect( ShaderEffect::New( "", EFFECTS_VIEW_FRAGMENT_SOURCE ) );
 
@@ -316,6 +313,38 @@ void EffectsView::OnControlSizeSet(const Vector3& targetSize)
   {
     AllocateResources();
   }
+
+  if( mActorForResult )
+  {
+    mActorForResult.SetSize( targetSize );
+  }
+  if( mActorForChildren )
+  {
+    mActorForChildren.SetSize( targetSize );
+  }
+  if( mActorPostFilter )
+  {
+    mActorPostFilter.SetSize( targetSize );
+  }
+
+  // Children render camera must move when EffectsView object is resized.
+  // This is since we cannot change render target size - so we need to remap the child actors' rendering
+  // accordingly so they still exactly fill the render target.
+  // Note that this means the effective resolution of the child render changes as the EffectsView object
+  // changes size, this is the trade off for not being able to modify render target size
+  // Change camera z position based on EffectsView actor height
+  if( mCameraForChildren )
+  {
+    const float cameraPosScale( 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f) );
+    mCameraForChildren.SetZ( targetSize.height * cameraPosScale );
+  }
+
+  const size_t numFilters( mFilters.size() );
+  for( size_t i = 0; i < numFilters; ++i )
+  {
+    mFilters[i]->SetSize( mTargetSize );
+  }
+
 }
 
 void EffectsView::OnStageDisconnection()
@@ -421,7 +450,7 @@ void EffectsView::AllocateResources()
 
 void EffectsView::SetupCameras()
 {
-  const float cameraPosConstraintScale( 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f) );
+  const float cameraPosScale( 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f) );
 
   // Create and place a camera for the children render, corresponding to its render target size
   mCameraForChildren.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
@@ -429,17 +458,9 @@ void EffectsView::SetupCameras()
   mCameraForChildren.SetNearClippingPlane(1.0f);
   mCameraForChildren.SetAspectRatio(mTargetSize.width / mTargetSize.height);
   mCameraForChildren.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
-  mCameraForChildren.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale);
+  mCameraForChildren.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosScale);
   mCameraForChildren.SetRotation(Quaternion(M_PI, Vector3::YAXIS));
-
-  // Children render camera must move when EffectsView object is resized.
-  // This is since we cannot change render target size - so we need to remap the child actors' rendering
-  // accordingly so they still exactly fill the render target.
-  // Note that this means the effective resolution of the child render changes as the EffectsView object
-  // changes size, this is the trade off for not being able to modify render target size
-  // Change camera z position based on EffectsView actor height
-  mCameraForChildren.RemoveConstraints();
-  mCameraForChildren.ApplyConstraint( Constraint::New<float>( Actor::POSITION_Z, ParentSource( Actor::SIZE_HEIGHT ), RelativeToConstraintFloat(cameraPosConstraintScale) ) );
+  mCameraForChildren.SetZ( mTargetSize.height * cameraPosScale );
 }
 
 void EffectsView::CreateRenderTasks()
index 6544046..5ab09a1 100644 (file)
@@ -142,7 +142,7 @@ void BlurTwoPassFilter::Enable()
   // create actor to render input with applied emboss effect
   mActorForInput = ImageActor::New( mInputImage );
   mActorForInput.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForInput.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForInput.SetSize(mTargetSize);
   mActorForInput.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   // create internal offscreen for result of horizontal pass
@@ -151,7 +151,7 @@ void BlurTwoPassFilter::Enable()
   // create an actor to render mImageForHorz for vertical blur pass
   mActorForHorz = ImageActor::New( mImageForHorz );
   mActorForHorz.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForHorz.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForHorz.SetSize(mTargetSize);
   mActorForHorz.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   // create internal offscreen for result of the two pass blurred image
@@ -160,7 +160,7 @@ void BlurTwoPassFilter::Enable()
   // create an actor to blend the blurred image and the input image with the given blur strength
   mActorForBlending = ImageActor::New( mBlurredImage );
   mActorForBlending.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForBlending.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForBlending.SetSize(mTargetSize);
   mActorForBlending.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   mRootActor.Add( mActorForInput );
@@ -271,6 +271,23 @@ void BlurTwoPassFilter::Refresh()
   }
 }
 
+void BlurTwoPassFilter::SetSize( const Vector2& size )
+{
+  mTargetSize = size;
+  if( mActorForInput )
+  {
+    mActorForInput.SetSize(mTargetSize);
+  }
+  if( mActorForHorz )
+  {
+    mActorForHorz.SetSize(mTargetSize);
+  }
+  if( mActorForBlending )
+  {
+    mActorForBlending.SetSize(mTargetSize);
+  }
+}
+
 Constrainable BlurTwoPassFilter::GetHandleForAnimateBlurStrength()
 {
   return mShaderForBlending;
index 2528996..9b29dde 100644 (file)
@@ -63,6 +63,9 @@ public: // From ImageFilter
   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Refresh
   virtual void Refresh();
 
+  /// @copydoc Dali::Toolkit::Internal::ImageFilter::SetSize
+  virtual void SetSize( const Vector2& size );
+
   /**
    * Get the property index that controls the strength of the blur applied to the image. Useful for animating this property.
    * This property represents a value in the range [0.0 - 1.0] where 0.0 is no blur and 1.0 is full blur.
index b715e11..dee4a2e 100644 (file)
@@ -131,31 +131,31 @@ void EmbossFilter::Enable()
   // 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
@@ -247,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
index 1f706b2..c912428 100644 (file)
@@ -61,6 +61,9 @@ public: // From ImageFilter
   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Refresh
   virtual void Refresh();
 
+  /// @copydoc Dali::Toolkit::Internal::ImageFilter::SetSize
+  virtual void SetSize( const Vector2& size );
+
 private:
   /**
    * Setup position and parameters for camera
index 8de47b0..5a07ded 100644 (file)
@@ -90,7 +90,7 @@ public:
    * Set size of ImageFilter. Used to create internal offscreen buffers
    * @param[in] size  THe size.
    */
-  void SetSize( const Vector2& size );
+  virtual void SetSize( const Vector2& size );
 
   /**
    * Set the pixel format for internal offscreen buffers
index b04d173..3d911b9 100644 (file)
@@ -96,7 +96,7 @@ void SpreadFilter::Enable()
   // create actor to render input with applied emboss effect
   mActorForInput = ImageActor::New( mInputImage );
   mActorForInput.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForInput.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForInput.SetSize(mTargetSize);
   mActorForInput.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   // create internal offscreen for result of horizontal pass
@@ -105,7 +105,7 @@ void SpreadFilter::Enable()
   // create an actor to render mImageForHorz for vertical blur pass
   mActorForHorz = ImageActor::New( mImageForHorz );
   mActorForHorz.SetParentOrigin( ParentOrigin::CENTER );
-  mActorForHorz.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+  mActorForHorz.SetSize(mTargetSize);
   mActorForHorz.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
 
   mRootActor.Add( mActorForInput );
@@ -183,6 +183,19 @@ void SpreadFilter::Refresh()
   }
 }
 
+void SpreadFilter::SetSize( const Vector2& size )
+{
+  mTargetSize = size;
+  if( mActorForInput )
+  {
+    mActorForInput.SetSize(mTargetSize);
+  }
+  if( mActorForHorz )
+  {
+    mActorForHorz.SetSize(mTargetSize);
+  }
+}
+
 void SpreadFilter::SetupCamera()
 {
   // Create and place a camera for the embossing render, corresponding to its render target size
index e04484c..5f5d857 100644 (file)
@@ -68,6 +68,9 @@ public: // From ImageFilter
   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Refresh
   virtual void Refresh();
 
+  /// @copydoc Dali::Toolkit::Internal::ImageFilter::SetSize
+  virtual void SetSize( const Vector2& size );
+
 private:
   /**
    * Setup position and parameters for camera