childControl.SetRenderEffect(BackgroundBlurEffect::New());
taskList = scene.GetRenderTaskList();
- DALI_LOG_ERROR("%d\n", taskList.GetTaskCount());
DALI_TEST_CHECK(4u == taskList.GetTaskCount());
END_TEST;
control2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
scene.Add(control2);
- control2.SetRenderEffect(blurEffect); // Ownership changed.
+ control2.SetRenderEffect(blurEffect);
taskList = scene.GetRenderTaskList();
DALI_TEST_CHECK(4u == taskList.GetTaskCount());
control.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
scene.Add(control);
- try
- {
- control.ClearRenderEffect();
- DALI_TEST_CHECK(false);
- }
- catch(Dali::DaliException& e)
- {
- DALI_TEST_PRINT_ASSERT(e);
- DALI_TEST_CHECK(true);
- }
+ RenderTaskList taskList = scene.GetRenderTaskList();
+ DALI_TEST_CHECK(1u == taskList.GetTaskCount());
+ control.ClearRenderEffect(); // Nothing happens
+ DALI_TEST_CHECK(1u == taskList.GetTaskCount());
END_TEST;
}
-int UtcDaliRenderEffectRepeatActivateDeactivate(void)
+int UtcDaliRenderEffectActivateDeactivateInplace(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliRenderEffectRepeatActivateDeactivate");
+ tet_infoline("UtcDaliRenderEffectActivateDeactivateInplace");
Integration::Scene scene = application.GetScene();
scene.Add(control);
BackgroundBlurEffect blurEffect = BackgroundBlurEffect::New();
- for(int i = 0; i < 3; i++)
- {
- control.SetRenderEffect(blurEffect); // Activate
- RenderTaskList taskList = scene.GetRenderTaskList();
- DALI_TEST_CHECK(4u == taskList.GetTaskCount());
- //control.ClearRenderEffect(); // Deactivate, Done automatically on duplicated jobs.
- }
+ control.SetRenderEffect(blurEffect);
+
+ RenderTaskList taskList = scene.GetRenderTaskList();
+ DALI_TEST_CHECK(4u == taskList.GetTaskCount());
+
+ control.ClearRenderEffect();
+ control.SetRenderEffect(blurEffect);
+ control.ClearRenderEffect();
+ control.SetRenderEffect(blurEffect);
+ DALI_TEST_CHECK(4u == taskList.GetTaskCount());
+
+ END_TEST;
+}
+
+int UtcDaliRenderEffectReassign(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliRenderEffectReassign");
+
+ Integration::Scene scene = application.GetScene();
+
+ Control control = Control::New();
+ control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ control.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
+ scene.Add(control);
+
+ BackgroundBlurEffect blurEffect = BackgroundBlurEffect::New();
+ control.SetRenderEffect(blurEffect); // Duplicate actions will be ignored
+ control.SetRenderEffect(blurEffect); // Duplicate actions will be ignored
+ control.SetRenderEffect(blurEffect); // Duplicate actions will be ignored
+ RenderTaskList taskList = scene.GetRenderTaskList();
+ DALI_TEST_CHECK(4u == taskList.GetTaskCount());
+
+ END_TEST;
+}
+
+int UtcDaliRenderEffectResize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliRenderEffectResize");
+
+ Integration::Scene scene = application.GetScene();
+ Control control = Control::New();
+ control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ scene.Add(control);
+ control.SetRenderEffect(BackgroundBlurEffect::New());
+
+ application.SendNotification();
+ application.Render();
+
+ control.SetProperty(Actor::Property::SIZE, Vector2(30.0f, 30.0f));
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(control.GetProperty<float>(Actor::Property::SIZE_WIDTH), 30.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(control.GetProperty<float>(Actor::Property::SIZE_HEIGHT), 30.0f, TEST_LOCATION);
END_TEST;
}
mInternalRoot.Add(mVerticalBlurActor);
}
-void BlurEffectImpl::Activate()
+void BlurEffectImpl::Activate(Toolkit::Control ownerControl)
{
- DALI_ASSERT_ALWAYS(!mIsActivated &&
- "This effect is already taken. Call Toolkit::Control::ClearRenderEffect(); to free the effect.");
+ DALI_ASSERT_ALWAYS(ownerControl && "Given empty owner control");
- Toolkit::Control handle = GetOwnerControl();
- DALI_ASSERT_ALWAYS(handle); // RenderEffect::SetOwnerControl(mOwnerControl); was done.
+ if(mIsActivated)
+ {
+ if(ownerControl == GetOwnerControl())
+ {
+ return;
+ }
+ else
+ {
+ Deactivate();
+ }
+ }
+ SetOwnerControl(ownerControl);
+ mIsActivated = true;
// Get input texture size
Vector2 size = GetTargetSize();
if(size == Vector2::ZERO)
{
- size = handle.GetNaturalSize();
+ size = ownerControl.GetNaturalSize();
if(size == Vector2::ZERO)
{
return;
if(mIsBackground)
{
mSourceRenderTask.SetSourceActor(Stage::GetCurrent().GetRootLayer());
- mSourceRenderTask.RenderUntil(handle);
+ mSourceRenderTask.RenderUntil(ownerControl);
}
else
{
- mSourceRenderTask.SetSourceActor(handle);
+ mSourceRenderTask.SetSourceActor(ownerControl);
}
mSourceRenderTask.SetOrderIndex(BLUR_EFFECT_ORDER_INDEX);
mSourceRenderTask.SetCameraActor(mRenderFullSizeCamera);
{
renderer.SetProperty(Dali::Renderer::Property::DEPTH_INDEX, Dali::Toolkit::DepthIndex::CONTENT);
}
- handle.AddRenderer(renderer);
+ ownerControl.AddRenderer(renderer);
SetRendererTexture(renderer, mSourceFrameBuffer);
- handle.Add(mInternalRoot);
- mIsActivated = true;
+ ownerControl.Add(mInternalRoot);
}
void BlurEffectImpl::Deactivate()
taskList.RemoveTask(mVerticalBlurTask);
taskList.RemoveTask(mSourceRenderTask);
- auto ownerControl = GetOwnerControl();
- if(ownerControl)
- {
- Renderer renderer = GetTargetRenderer();
- ownerControl.RemoveRenderer(renderer);
- }
+ ClearOwnerControl();
}
void BlurEffectImpl::SetShaderConstants(float downsampledWidth, float downsampledHeight)
/**
* @brief Activates blur effect
+ * @param[in] ownerControl The control to apply effect
*/
- void Activate() override;
+ void Activate(Toolkit::Control ownerControl) override;
/**
* @brief Dectivates blur effect
{
namespace Internal
{
-RenderEffectImpl::~RenderEffectImpl() = default;
-
-void RenderEffectImpl::SetOwnerControl(Dali::Toolkit::Control control)
+RenderEffectImpl::~RenderEffectImpl()
{
if(mOwnerControl)
{
- Deactivate();
- mOwnerControl.RemovePropertyNotification(mSizeNotification);
+ mOwnerControl.ClearRenderEffect();
}
+}
- mOwnerControl = control;
-
- if(mOwnerControl)
+void RenderEffectImpl::SetOwnerControl(Dali::Toolkit::Control control)
+{
+ if(control)
{
+ mOwnerControl = control;
+
mTargetSize = mOwnerControl.GetProperty<Vector2>(Actor::Property::SIZE);
mRenderer = CreateRenderer(SHADER_RENDER_EFFECT_VERT, SHADER_RENDER_EFFECT_FRAG);
}
}
+void RenderEffectImpl::ClearOwnerControl()
+{
+ if(mOwnerControl)
+ {
+ Renderer renderer = GetTargetRenderer();
+ mOwnerControl.RemoveRenderer(renderer);
+ mOwnerControl.RemovePropertyNotification(mSizeNotification);
+ mOwnerControl.Reset();
+ }
+}
+
Toolkit::Control RenderEffectImpl::GetOwnerControl() const
{
return mOwnerControl;
{
mTargetSize = mOwnerControl.GetProperty<Vector2>(Actor::Property::SIZE);
Deactivate();
- Activate();
+ Activate(mOwnerControl);
}
Renderer RenderEffectImpl::GetTargetRenderer() const
{
public:
/**
- * @brief Sets owner Control. Applies effect on the owner.
+ * @brief Activates effect on ownerControl
* @param[in] control The owner control to apply RenderEffect.
*/
- void SetOwnerControl(Dali::Toolkit::Control control);
-
- /**
- * @brief Get Owner control.
- * @return mOwnerControl
- */
- Toolkit::Control GetOwnerControl() const;
+ virtual void Activate(Toolkit::Control ownerControl) = 0;
/**
- * @brief Activate effect.
- */
- virtual void Activate() = 0;
-
- /**
- * @brief Deactivate effect.
+ * @brief Deactivates effect
*/
virtual void Deactivate() = 0;
*/
Vector2 GetTargetSize() const;
+ /**
+ * @brief Sets owner Control. Applies effect on the owner.
+ * @param[in] control The owner control to apply RenderEffect.
+ */
+ void SetOwnerControl(Toolkit::Control control);
+
+ /**
+ * @brief Clears owner Control.
+ */
+ void ClearOwnerControl();
+
+ /**
+ * @brief Get Owner control.
+ * @return mOwnerControl
+ */
+ Toolkit::Control GetOwnerControl() const;
+
private:
Dali::Renderer mRenderer; // An additional renderer for mOwnerControl
Dali::Toolkit::Control mOwnerControl;
- Vector2 mTargetSize; // The final size of mOwnerControl
PropertyNotification mSizeNotification; // Resize/Relayout signal
+ Vector2 mTargetSize; // The final size of mOwnerControl
};
} // namespace Internal
{
if(mImpl->mRenderEffect != effect)
{
+ ClearRenderEffect();
mImpl->mRenderEffect = effect;
BaseObject& handle = effect.GetBaseObject();
DALI_ASSERT_ALWAYS(object && "Not a valid RenderEffect set.");
Dali::Toolkit::Control ownerControl(GetOwner());
- object->SetOwnerControl(ownerControl);
- object->Activate();
+ object->Activate(ownerControl);
}
}
{
BaseObject& handle = mImpl->mRenderEffect.GetBaseObject();
Toolkit::Internal::RenderEffectImpl* object = dynamic_cast<Toolkit::Internal::RenderEffectImpl*>(&handle);
- DALI_ASSERT_ALWAYS(object && "Set any render effect before you clear.");
- object->Deactivate();
- object->SetOwnerControl(Toolkit::Control());
+ if(object)
+ {
+ object->Deactivate();
+ }
+ mImpl->mRenderEffect.Reset();
}
void Control::SetResourceReady()