Disabling EmbossFilter now removes all render tasks. 55/96355/2
authorDavid Steele <david.steele@partner.samsung.com>
Tue, 8 Nov 2016 17:16:27 +0000 (17:16 +0000)
committerDavid Steele <david.steele@partner.samsung.com>
Wed, 9 Nov 2016 10:40:42 +0000 (10:40 +0000)
Ensured all render tasks of EmbossFilter are removed when disabling the filter.
There should be no render tasks lying around, and they all get re-created if the
filter is re-enabled.

Fixed effects-view to ensure that AllocateResources actually allocates following a Disable, Enable pair.

Change-Id: I2172530b451ed86ce43cf944a90efd27f8f631fc
Signed-off-by: David Steele <david.steele@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-EffectsView.cpp
dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp
dali-toolkit/internal/filters/emboss-filter.cpp

index 09b51f2..c80e25a 100644 (file)
@@ -124,6 +124,69 @@ int UtcDaliEffectsViewAddRemove(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
+
+int UtcDaliEffectsViewAddRemoveEmboss(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliEffectsViewAddRemoveEmboss");
+
+  tet_infoline("Checking number of render tasks = 1");
+  application.SendNotification();
+  application.Render();
+  Stage stage = Stage::GetCurrent();
+  DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTaskCount(), 1, TEST_LOCATION );
+
+  tet_infoline("Create effects view");
+
+  EffectsView view = EffectsView::New( EffectsView::EMBOSS );
+  Vector3 offsetSet( 2.f, 3.f, 4.f );
+  Vector4 colorSet( 0.2f, 0.3f, 0.4f, 0.5f );
+  view.SetProperty( EffectsView::Property::EFFECT_OFFSET, offsetSet);
+  view.SetProperty( EffectsView::Property::EFFECT_COLOR, colorSet);
+  Vector3 offsetAnimate( 4.f, 6.f, 8.f );
+  float durationSeconds(0.05f);
+  Animation animation = Animation::New( durationSeconds );
+  animation.AnimateTo( Property(view,EffectsView::Property::EFFECT_OFFSET ), offsetAnimate );
+  animation.Play();
+
+  DALI_TEST_CHECK( view );
+
+  Actor actor = Actor::New();
+  actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+  DALI_TEST_CHECK( !actor.OnStage() );
+
+  view.SetParentOrigin(ParentOrigin::CENTER);
+
+  view.Add(actor);
+  view.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+  stage.Add(view);
+
+  DALI_TEST_CHECK( actor.OnStage() );
+
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("Removing view from stage disables view");
+  stage.Remove(view);
+
+  tet_infoline("Checking number of render tasks = 1");
+  DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTaskCount(), 1, TEST_LOCATION );
+
+  tet_infoline("Adding view to stage again re-enables view");
+  stage.Add(view);
+
+  tet_infoline("Removing view from stage disables view");
+  DALI_TEST_GREATER( stage.GetRenderTaskList().GetTaskCount(), 1u, TEST_LOCATION );
+  stage.Remove(view);
+  view.Reset();
+
+  tet_infoline("Checking number of render tasks = 1");
+  DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTaskCount(), 1, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliEffectsViewGetTypeP(void)
 {
   ToolkitTestApplication application;
 int UtcDaliEffectsViewGetTypeP(void)
 {
   ToolkitTestApplication application;
index 24f82bc..0b207e4 100644 (file)
@@ -214,6 +214,7 @@ void EffectsView::Disable()
   // stop render tasks processing
   // Note: render target resources are automatically freed since we set the Image::Unused flag
   RemoveRenderTasks();
   // stop render tasks processing
   // Note: render target resources are automatically freed since we set the Image::Unused flag
   RemoveRenderTasks();
+  mLastSize = Vector2::ZERO; // Ensure resources are reallocated on subsequent enable
   mEnabled = false;
 }
 
   mEnabled = false;
 }
 
index 849e81b..6fe082d 100644 (file)
@@ -181,6 +181,11 @@ void EmbossFilter::Disable()
       taskList.RemoveTask(mRenderTaskForEmboss2);
     }
 
       taskList.RemoveTask(mRenderTaskForEmboss2);
     }
 
+    if( mRenderTaskForOutput )
+    {
+      taskList.RemoveTask( mRenderTaskForOutput );
+    }
+
     mRootActor.Reset();
   }
 }
     mRootActor.Reset();
   }
 }