/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/rendering/shader.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/controls/shadow-view/shadow-view-impl.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
// pixel format / size - set from JSON
// aspect ratio property needs to be able to be constrained also for cameras. (now do-able)
// default near clip value
-// mChildrenRoot Add()/Remove() overloads - better solution
/////////////////////////////////////////////////////////
} // namespace
ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale )
-: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mChildrenRoot(Actor::New()),
mCachedShadowColor(DEFAULT_SHADOW_COLOR),
mCachedBackgroundColor(DEFAULT_SHADOW_COLOR.r, DEFAULT_SHADOW_COLOR.g, DEFAULT_SHADOW_COLOR.b, 0.0f),
return handle;
}
-/////////////////////////////////////////////////////////////
-// for creating a subtree for all user added child actors.
-// TODO: overloading Actor::Add()/Remove() not nice since breaks polymorphism. Need another method to pass ownership of added child actors to our internal actor root.
-void ShadowView::Add(Actor child)
-{
- mChildrenRoot.Add(child);
-}
-
-void ShadowView::Remove(Actor child)
-{
- mChildrenRoot.Remove(child);
-}
-
void ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
{
mShadowPlaneBg = shadowPlaneBackground;
- mShadowPlane = Toolkit::ImageView::New();
+ mShadowPlane = Toolkit::ImageView::New( mOutputImage );
mShadowPlane.SetName( "SHADOW_PLANE" );
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
- mShadowPlane.SetImage(mOutputImage);
- mShadowPlane.SetProperty( Toolkit::ImageView::Property::IMAGE, mShadowRenderShader );
+ mShadowPlane.SetProperty( Toolkit::ImageView::Property::IMAGE, mShadowVisualMap );
SetShaderConstants();
// Rather than parent the shadow plane drawable and have constraints to move it to the same
void ShadowView::OnInitialize()
{
// root actor to parent all user added actors. Used as source actor for shadow render task.
- mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
+ mChildrenRoot.SetParentOrigin( ParentOrigin::CENTER );
mChildrenRoot.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
Vector2 stageSize = Stage::GetCurrent().GetSize();
Property::Map customShader;
- customShader[ "vertex-shader" ] = RENDER_SHADOW_VERTEX_SOURCE;
- customShader[ "fragment-shader" ] = RENDER_SHADOW_FRAGMENT_SOURCE;
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = RENDER_SHADOW_VERTEX_SOURCE;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = RENDER_SHADOW_FRAGMENT_SOURCE;
- customShader[ "subdivide-grid-x" ] = 20;
- customShader[ "subdivide-grid-y" ] = 20;
+ customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
+ customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
- customShader[ "hints" ] = "output-is-transparent";
+ customShader[ Toolkit::Visual::Shader::Property::HINTS ] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
- mShadowRenderShader[ "shader" ] = customShader;
+ mShadowVisualMap[ Toolkit::DevelVisual::Property::SHADER ] = customShader;
// Create render targets needed for rendering from light's point of view
mSceneFromLightRenderTarget = FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 );
mBlurRootActor.SetName( "BLUR_ROOT_ACTOR" );
// Turn off inheritance to ensure filter renders properly
- mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
+ mBlurRootActor.SetParentOrigin( ParentOrigin::CENTER );
+ mBlurRootActor.SetInheritPosition(false);
mBlurRootActor.SetInheritOrientation(false);
mBlurRootActor.SetInheritScale(false);
mBlurRootActor.SetColorMode(USE_OWN_COLOR);
blurStrengthConstraint.Apply();
}
-void ShadowView::OnSizeSet(const Vector3& targetSize)
+void ShadowView::OnChildAdd( Actor& child )
{
+ if( child != mChildrenRoot && child != mBlurRootActor)
+ {
+ mChildrenRoot.Add( child );
+ }
+
+ Control::OnChildAdd( child );
+}
+
+void ShadowView::OnChildRemove( Actor& child )
+{
+ mChildrenRoot.Remove( child );
+
+ Control::OnChildRemove( child );
}
void ShadowView::ConstrainCamera()