return Control::DownCast<BloomView, Internal::BloomView>(handle);
}
-void BloomView::Add(Actor child)
-{
- GetImpl(*this).Add(child);
-}
-
-void BloomView::Remove(Actor child)
-{
- GetImpl(*this).Remove(child);
-}
-
void BloomView::Activate()
{
GetImpl(*this).Activate();
static BloomView New(const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
const float downsampleWidthScale, const float downsampleHeightScale);
- /**
- * Adds a child Actor to this Actor.
- * NOTE! if the child already has a parent, it will be removed from old parent
- * and reparented to this actor. This may change childs position, color, shader effect,
- * scale etc as it now inherits them from this actor
- * @pre This Actor (the parent) has been initialized.
- * @pre The child actor has been initialized.
- * @pre The child actor is not the same as the parent actor.
- * @pre The actor is not the Root actor
- * @param [in] child The child.
- * @post The child will be referenced by its parent. This means that the child will be kept alive,
- * even if the handle passed into this method is reset or destroyed.
- */
- void Add(Actor child);
-
- /**
- * Removes a child Actor from this Actor.
- * If the actor was not a child of this actor, this is a no-op.
- * @pre This Actor (the parent) has been initialized.
- * @pre The child actor is not the same as the parent actor.
- * @param [in] child The child.
- */
- void Remove(Actor child);
-
/**
* Start rendering the BloomView. Must be called after you Add() it to the stage.
*/
return Control::DownCast<ShadowView, Internal::ShadowView>(handle);
}
-void ShadowView::Add(Actor child)
-{
- GetImpl(*this).Add(child);
-}
-
-void ShadowView::Remove(Actor child)
-{
- GetImpl(*this).Remove(child);
-}
-
void ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
{
GetImpl(*this).SetShadowPlaneBackground(shadowPlaneBackground);
*/
static ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
- /**
- * Adds a child Actor to this Actor.
- * NOTE! if the child already has a parent, it will be removed from old parent
- * and reparented to this actor. This may change childs position, color, shader effect,
- * scale etc as it now inherits them from this actor
- * @pre This Actor (the parent) has been initialized.
- * @pre The child actor has been initialized.
- * @pre The child actor is not the same as the parent actor.
- * @pre The actor is not the Root actor
- * @param [in] child The child.
- * @post The child will be referenced by its parent. This means that the child will be kept alive,
- * even if the handle passed into this method is reset or destroyed.
- */
- void Add(Actor child);
-
- /**
- * Removes a child Actor from this Actor.
- * If the actor was not a child of this actor, this is a no-op.
- * @pre This Actor (the parent) has been initialized.
- * @pre The child actor is not the same as the parent actor.
- * @param [in] child The child.
- */
- void Remove(Actor child);
-
/**
* Set the Shadow Plane Background for the shadow effect.
*
, mTargetSize(Vector2::ZERO)
, mLastSize(Vector2::ZERO)
, mChildrenRoot(Actor::New())
+ , mInternalRoot(Actor::New() )
, mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
, mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
, mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
, mTargetSize(Vector2::ZERO)
, mLastSize(Vector2::ZERO)
, mChildrenRoot(Actor::New())
+ , mInternalRoot(Actor::New())
, mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
, mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
, mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
return handle;
}
-/////////////////////////////////////////////////////////////
-// for creating a subtree for all user added child actors, so that we can have them exclusive to the mRenderChildrenTask and our other actors exclusive to our other tasks
-// 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 BloomView::Add(Actor child)
-{
- mChildrenRoot.Add(child);
-}
-
-void BloomView::Remove(Actor child)
-{
- mChildrenRoot.Remove(child);
-}
-
-
-
-
-
-
///////////////////////////////////////////////////////////
//
// Private methods
{
// root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
mChildrenRoot.SetParentOrigin( ParentOrigin::CENTER );
+ mInternalRoot.SetParentOrigin( ParentOrigin::CENTER );
//////////////////////////////////////////////////////
// Create actors
////////////////////////////////
// Connect to actor tree
Self().Add( mChildrenRoot );
- Self().Add( mBloomExtractImageActor );
- Self().Add( mGaussianBlurView );
- Self().Add( mCompositeImageActor );
- Self().Add( mTargetImageActor );
- Self().Add( mRenderDownsampledCamera );
- Self().Add( mRenderFullSizeCamera );
+ Self().Add( mInternalRoot );
+ mInternalRoot.Add( mBloomExtractImageActor );
+ mInternalRoot.Add( mGaussianBlurView );
+ mInternalRoot.Add( mCompositeImageActor );
+ mInternalRoot.Add( mTargetImageActor );
+ mInternalRoot.Add( mRenderDownsampledCamera );
+ mInternalRoot.Add( mRenderFullSizeCamera );
// bind properties for / set shader constants to defaults
SetupProperties();
}
}
+void BloomView::OnControlChildAdd( Actor& child )
+{
+ if( child != mChildrenRoot && child != mInternalRoot)
+ {
+ mChildrenRoot.Add( child );
+ }
+}
+
+void BloomView::OnControlChildRemove( Actor& child )
+{
+ mChildrenRoot.Remove( child );
+}
+
void BloomView::AllocateResources()
{
// size of render targets etc is based on the size of this actor, ignoring z
- if(mTargetSize != mLastSize)
+ if(mTargetSize != mLastSize || !mActivated)
{
mLastSize = mTargetSize;
// stop render tasks processing
// Note: render target resources are automatically freed since we set the Image::Unused flag
RemoveRenderTasks();
+ mRenderTargetForRenderingChildren.Reset();
+ mBloomExtractTarget.Reset();
+ mOutputRenderTarget.Reset();
mActivated = false;
}
static Dali::Toolkit::BloomView New();
static Dali::Toolkit::BloomView New( const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
const float downsampleWidthScale, const float downsampleHeightScale);
-
- void Add(Actor child);
- void Remove(Actor child);
-
void Activate();
void Deactivate();
virtual void OnInitialize();
virtual void OnSizeSet(const Vector3& targetSize);
+ /**
+ * @copydoc Control::OnControlChildAdd()
+ */
+ virtual void OnControlChildAdd( Actor& child );
+
+ /**
+ * @copydoc Control::OnControlChildRemove()
+ */
+ virtual void OnControlChildRemove( Actor& child );
+
void AllocateResources();
void CreateRenderTasks();
void RemoveRenderTasks();
/////////////////////////////////////////////////////////////
// for creating a subtree for all user added child actors, so that we can have them exclusive to the mRenderChildrenTask and our other actors exclusive to our other tasks
Actor mChildrenRoot;
+ // for creating a subtree for the internal actors
+ Actor mInternalRoot;
/////////////////////////////////////////////////////////////
// for mapping offscreen renders to render target sizes
// pixel format / size - set from JSON
// aspect ratio property needs to be able to be constrained also for cameras, not possible currently. Therefore changing aspect ratio of GaussianBlurView won't currently work
// default near clip value
-// mChildrenRoot Add()/Remove() overloads - better solution
// Manager object - re-use render targets if there are multiple GaussianBlurViews created
, mTargetSize(Vector2::ZERO)
, mLastSize(Vector2::ZERO)
, mChildrenRoot(Actor::New())
+ , mInternalRoot(Actor::New())
, mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
, mActivated( false )
{
, mTargetSize(Vector2::ZERO)
, mLastSize(Vector2::ZERO)
, mChildrenRoot(Actor::New())
+ , mInternalRoot(Actor::New())
, mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
, mActivated( false )
{
/////////////////////////////////////////////////////////////
// for creating a subtree for all user added child actors, so that we can have them exclusive to the mRenderChildrenTask and our other actors exclusive to our other tasks
-// 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.
+// DEPRECATED: 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 GaussianBlurView::Add(Actor child)
{
mChildrenRoot.Add(child);
{
// root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
mChildrenRoot.SetParentOrigin(ParentOrigin::CENTER);
+ mInternalRoot.SetParentOrigin(ParentOrigin::CENTER);
//////////////////////////////////////////////////////
// Create shaders
mImageActorVertBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
// Register a property that the user can control to fade the blur in / out via the GaussianBlurView object
- mBlurStrengthPropertyIndex = Self().RegisterProperty(GAUSSIAN_BLUR_VIEW_STRENGTH_PROPERTY_NAME, GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH);
+ Actor self = Self();
+ mBlurStrengthPropertyIndex = self.RegisterProperty(GAUSSIAN_BLUR_VIEW_STRENGTH_PROPERTY_NAME, GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH);
// Create an ImageActor for compositing the blur and the original child actors render
if(!mBlurUserImage)
mImageActorComposite.SetOpacity(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH); // ensure alpha is enabled for this object and set default value
Constraint blurStrengthConstraint = Constraint::New<float>( mImageActorComposite, Actor::Property::COLOR_ALPHA, EqualToConstraint());
- blurStrengthConstraint.AddSource( ParentSource(mBlurStrengthPropertyIndex) );
+ blurStrengthConstraint.AddSource( Source( self, mBlurStrengthPropertyIndex) );
blurStrengthConstraint.Apply();
// Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
//////////////////////////////////////////////////////
// Connect to actor tree
- Self().Add( mImageActorComposite );
- Self().Add( mTargetActor );
- Self().Add( mRenderFullSizeCamera );
+ mInternalRoot.Add( mImageActorComposite );
+ mInternalRoot.Add( mTargetActor );
+ mInternalRoot.Add( mRenderFullSizeCamera );
}
//////////////////////////////////////////////////////
// Connect to actor tree
Self().Add( mChildrenRoot );
- Self().Add( mImageActorHorizBlur );
- Self().Add( mImageActorVertBlur );
- Self().Add( mRenderDownsampledCamera );
+ Self().Add( mInternalRoot );
+ mInternalRoot.Add( mImageActorHorizBlur );
+ mInternalRoot.Add( mImageActorVertBlur );
+ mInternalRoot.Add( mRenderDownsampledCamera );
}
}
}
+void GaussianBlurView::OnControlChildAdd( Actor& child )
+{
+ if( child != mChildrenRoot && child != mInternalRoot)
+ {
+ mChildrenRoot.Add( child );
+ }
+}
+
+void GaussianBlurView::OnControlChildRemove( Actor& child )
+{
+ mChildrenRoot.Remove( child );
+}
+
void GaussianBlurView::AllocateResources()
{
// size of render targets etc is based on the size of this actor, ignoring z
virtual void OnInitialize();
virtual void OnSizeSet(const Vector3& targetSize);
+ /**
+ * @copydoc Control::OnControlChildAdd()
+ */
+ virtual void OnControlChildAdd( Actor& child );
+
+ /**
+ * @copydoc Control::OnControlChildRemove()
+ */
+ virtual void OnControlChildRemove( Actor& child );
+
void SetBlurBellCurveWidth(float blurBellCurveWidth);
float CalcGaussianWeight(float x);
void SetShaderConstants();
/////////////////////////////////////////////////////////////
// for creating a subtree for all user added child actors, so that we can have them exclusive to the mRenderChildrenTask and our other actors exclusive to our other tasks
Actor mChildrenRoot;
+ // for creating a subtree for the internal actors
+ Actor mInternalRoot;
/////////////////////////////////////////////////////////////
// for mapping offscreen renders to render target sizes
// 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
/////////////////////////////////////////////////////////
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;
blurStrengthConstraint.Apply();
}
-void ShadowView::OnSizeSet(const Vector3& targetSize)
+void ShadowView::OnControlChildAdd( Actor& child )
+{
+ if( child != mChildrenRoot && child != mBlurRootActor)
+ {
+ mChildrenRoot.Add( child );
+ }
+}
+
+void ShadowView::OnControlChildRemove( Actor& child )
{
+ mChildrenRoot.Remove( child );
}
void ShadowView::ConstrainCamera()
*/
static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
- /**
- * @copydoc Dali::Toolkit::ShadowView::Add(Actor child)
- */
- void Add(Actor child);
-
- /**
- * @copydoc Dali::Toolkit::ShadowView::Remove(Actor child)
- */
- void Remove(Actor child);
-
/**
* @copydoc Dali::Toolkit::ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
*/
private:
virtual void OnInitialize();
- virtual void OnSizeSet(const Vector3& targetSize);
+
+ /**
+ * @copydoc Control::OnControlChildAdd()
+ */
+ virtual void OnControlChildAdd( Actor& child );
+
+ /**
+ * @copydoc Control::OnControlChildRemove()
+ */
+ virtual void OnControlChildRemove( Actor& child );
/**
* Constrain the camera actor to the position of the point light, pointing
bool blurUserImage = false);
/**
+ * @DEPRECATED_1_1.28 Use Actor::Add(Actor) instead
* @brief Adds a child Actor to this Actor.
* @SINCE_1_0.0
* @param [in] child The child.
void Add(Actor child);
/**
+ * @DEPRECATED_1_1.28 Use Actor::Remove(Actor) instead
* @brief Removes a child Actor from this Actor.
*
* If the actor was not a child of this actor, this is a no-op.