// EXTERNAL INCLUDES
#include <sstream>
#include <iomanip>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/devel-api/object/type-registry-helper.h>
#include <dali/public-api/render-tasks/render-task-list.h>
#include <dali/integration-api/debug.h>
" gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
"}\n";
-// TODO: Add this to dali-core constraints.h
-/**
- * EqualToConstraintMatrix
- *
- * f(current, property) = property
- */
-struct EqualToConstraintMatrix
-{
- EqualToConstraintMatrix(){}
-
- Dali::Matrix operator()(const Dali::Matrix& current, const PropertyInput& property) {return property.GetMatrix();}
-};
-
} // namespace
ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale )
-: Control( CONTROL_BEHAVIOUR_NONE ),
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mChildrenRoot(Actor::New()),
mCachedShadowColor(DEFAULT_SHADOW_COLOR),
mCachedBackgroundColor(DEFAULT_SHADOW_COLOR.r, DEFAULT_SHADOW_COLOR.g, DEFAULT_SHADOW_COLOR.b, 0.0f),
mShadowPlaneBg = shadowPlane;
mShadowPlane = ImageActor::New();
+ mShadowPlane.SetName( "SHADOW_PLANE" );
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
ConstrainCamera();
- mShadowPlane.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ mShadowPlane.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- mBlurRootActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ mBlurRootActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
}
void ShadowView::SetPointLight(Actor pointLight)
{
// root actor to parent all user added actors. Used as source actor for shadow render task.
mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
- mChildrenRoot.SetRelayoutEnabled( true );
- mChildrenRoot.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ mChildrenRoot.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
Vector2 stageSize = Stage::GetCurrent().GetSize();
mCameraActor = CameraActor::New(stageSize);
mBlurFilter.SetPixelFormat(Pixel::RGBA8888);
mBlurRootActor = Actor::New();
+ mBlurRootActor.SetName( "BLUR_ROOT_ACTOR" );
- mBlurRootActor.SetRelayoutEnabled( true );
// Turn off inheritance to ensure filter renders properly
mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
mBlurRootActor.SetInheritOrientation(false);
{
}
-void ShadowView::OnStageConnection()
-{
- // TODO: can't call this here, since SetImage() calls fail to connect images to stage, since parent chain not fully on stage yet
- // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
- //Activate();
-}
-
-void ShadowView::OnStageDisconnection()
-{
- // TODO: can't call this here, since SetImage() calls fails similarly to above
- // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
- //Deactivate();
-}
-
void ShadowView::ConstrainCamera()
{
if( mPointLight && mShadowPlane )
// Constrain camera to look directly at center of shadow plane. (mPointLight position
// is under control of application, can't use transform inheritance)
- Constraint cameraOrientationConstraint =
- Constraint::New<Quaternion> ( Actor::Property::ORIENTATION,
- Source( mShadowPlane, Actor::Property::WORLD_POSITION ),
- Source( mPointLight, Actor::Property::WORLD_POSITION ),
- Source( mShadowPlane, Actor::Property::WORLD_ORIENTATION ),
- &LookAt );
-
- mCameraActor.ApplyConstraint( cameraOrientationConstraint );
+ Constraint cameraOrientationConstraint = Constraint::New<Quaternion> ( mCameraActor, Actor::Property::ORIENTATION, &LookAt );
+ cameraOrientationConstraint.AddSource( Source( mShadowPlane, Actor::Property::WORLD_POSITION ) );
+ cameraOrientationConstraint.AddSource( Source( mPointLight, Actor::Property::WORLD_POSITION ) );
+ cameraOrientationConstraint.AddSource( Source( mShadowPlane, Actor::Property::WORLD_ORIENTATION ) );
+ cameraOrientationConstraint.Apply();
- Constraint pointLightPositionConstraint = Constraint::New<Vector3>( Actor::Property::POSITION, Source( mPointLight, Actor::Property::WORLD_POSITION ), EqualToConstraint() );
-
- mCameraActor.ApplyConstraint( pointLightPositionConstraint );
+ Constraint pointLightPositionConstraint = Constraint::New<Vector3>( mCameraActor, Actor::Property::POSITION, EqualToConstraint() );
+ pointLightPositionConstraint.AddSource( Source( mPointLight, Actor::Property::WORLD_POSITION ) );
+ pointLightPositionConstraint.Apply();
}
}
Property::Index lightCameraProjectionMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME);
Property::Index lightCameraViewMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME);
- Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( lightCameraProjectionMatrixPropertyIndex, Source( mCameraActor, CameraActor::Property::PROJECTION_MATRIX ), EqualToConstraintMatrix());
- Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( lightCameraViewMatrixPropertyIndex, Source( mCameraActor, CameraActor::Property::VIEW_MATRIX ), EqualToConstraintMatrix());
+ Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowRenderShader, lightCameraProjectionMatrixPropertyIndex, EqualToConstraint() );
+ projectionMatrixConstraint.AddSource( Source( mCameraActor, CameraActor::Property::PROJECTION_MATRIX ) );
+
+ Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowRenderShader, lightCameraViewMatrixPropertyIndex, EqualToConstraint() );
+ viewMatrixConstraint.AddSource( Source( mCameraActor, CameraActor::Property::VIEW_MATRIX ) );
- mShadowRenderShader.ApplyConstraint(projectionMatrixConstraint);
- mShadowRenderShader.ApplyConstraint(viewMatrixConstraint);
+ projectionMatrixConstraint.Apply();
+ viewMatrixConstraint.Apply();
// Register a property that the user can use to control the blur in the internal object
mBlurStrengthPropertyIndex = self.RegisterProperty(BLUR_STRENGTH_PROPERTY_NAME, BLUR_STRENGTH_DEFAULT);
- mBlurFilter.GetHandleForAnimateBlurStrength().ApplyConstraint( Constraint::New<float>( mBlurFilter.GetBlurStrengthPropertyIndex() ,
- Source( self, mBlurStrengthPropertyIndex),
- EqualToConstraint()) );
+
+ Constraint blurStrengthConstraint = Constraint::New<float>( mBlurFilter.GetHandleForAnimateBlurStrength(), mBlurFilter.GetBlurStrengthPropertyIndex(), EqualToConstraint() );
+ blurStrengthConstraint.AddSource( Source( self, mBlurStrengthPropertyIndex) );
+ blurStrengthConstraint.Apply();
// Register a property that the user can use to control the color of the shadow.
Property::Index index = mShadowRenderShader.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
mShadowColorPropertyIndex = self.RegisterProperty(SHADOW_COLOR_PROPERTY_NAME, mCachedShadowColor);
- mShadowRenderShader.ApplyConstraint(Constraint::New<Dali::Vector4>( index, Source( self, mShadowColorPropertyIndex ), EqualToConstraint()) );
+ Constraint shadowRenderShaderConstraint = Constraint::New<Dali::Vector4>( mShadowRenderShader, index, EqualToConstraint() );
+ shadowRenderShaderConstraint.AddSource( Source( self, mShadowColorPropertyIndex ) );
+ shadowRenderShaderConstraint.Apply();
}
} // namespace Internal