Consider loading to be complete when no resource ID is set 18/40418/5
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 3 Jun 2015 12:05:27 +0000 (13:05 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 3 Jun 2015 13:32:01 +0000 (14:32 +0100)
Change-Id: I4d68cde636b6dae4460dd537c3989f428587b87e

automated-tests/src/dali/utc-Dali-RenderTask.cpp
dali/internal/update/node-attachments/scene-graph-image-attachment.cpp
dali/internal/update/resources/complete-status-manager.cpp

index 0e86033..792ade5 100644 (file)
@@ -3122,3 +3122,44 @@ int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
 
   END_TEST;
 }
+
+int UtcDaliRenderTaskFinishMissingImage(void)
+{
+  TestApplication application;
+
+  // Previously we had bugs where not having a resource ID would cause render-tasks to wait forever
+  tet_infoline("Testing RenderTask::SignalFinished() when an ImageActor has no Image set");
+
+  Stage stage = Stage::GetCurrent();
+
+  BufferImage image = BufferImage::New( 10, 10 );
+  ImageActor rootActor = ImageActor::New( image );
+  rootActor.SetSize( 10, 10 );
+  stage.Add( rootActor );
+
+  ImageActor actorWithMissingImage = ImageActor::New( Image() );
+  actorWithMissingImage.SetSize( 10, 10 );
+  stage.Add( actorWithMissingImage );
+
+  RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+  RenderTask newTask = taskList.CreateTask();
+  newTask.SetInputEnabled( false );
+  newTask.SetClearColor( Vector4( 0.f, 0.f, 0.f, 0.f ) );
+  newTask.SetClearEnabled( true );
+  newTask.SetExclusive( true );
+  newTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
+
+  bool finished = false;
+  RenderTaskFinished renderTaskFinished( finished );
+  newTask.FinishedSignal().Connect( &application, renderTaskFinished );
+
+  // 1 render to process render task, then 1 before finished msg is sent from update to the event thread.
+  application.SendNotification();
+  application.Render();
+  application.Render();
+
+  application.SendNotification();
+  DALI_TEST_CHECK( finished );
+
+  END_TEST;
+}
index 803b557..6301b6b 100644 (file)
@@ -120,7 +120,9 @@ void ImageAttachment::SetTextureId( BufferIndex updateBufferIndex, unsigned int
   ATTACHMENT_LOG_FMT(Debug::General, " textureid: %d)\n", textureId);
 
   mTextureId = textureId;
-  mFinishedResourceAcquisition = false;
+
+  // Loading is essentially finished if we don't have a resource ID
+  mFinishedResourceAcquisition = ( 0 == mTextureId );
 
   if( mImageRenderer )
   {
@@ -219,40 +221,48 @@ bool ImageAttachment::DoPrepareResources( BufferIndex updateBufferIndex, Resourc
   DALI_LOG_TRACE_METHOD_FMT(gImageAttachmentLogFilter, "this:%p", this);
   bool ready = false;
 
-  // The metadata is used by IsFullyOpaque(), below.
-  mBitmapMetadata = resourceManager.GetBitmapMetadata( mTextureId );
+  if( 0 != mTextureId )
+  {
+    // The metadata is used by IsFullyOpaque(), below.
+    mBitmapMetadata = resourceManager.GetBitmapMetadata( mTextureId );
 
-  CompleteStatusManager& completeStatusManager = mSceneController->GetCompleteStatusManager();
-  CompleteStatusManager::CompleteState status = completeStatusManager.GetStatus( mTextureId );
+    CompleteStatusManager& completeStatusManager = mSceneController->GetCompleteStatusManager();
+    CompleteStatusManager::CompleteState status = completeStatusManager.GetStatus( mTextureId );
 
-  switch( status )
-  {
-    case CompleteStatusManager::NOT_READY:
+    switch( status )
     {
-      ready = false;
+      case CompleteStatusManager::NOT_READY:
+      {
+        ready = false;
+
+        if( mBitmapMetadata.GetIsFramebuffer() )
+        {
+          ready = true;
+        }
+        mFinishedResourceAcquisition = false;
+        FollowTracker( mTextureId );
+      }
+      break;
 
-      if( mBitmapMetadata.GetIsFramebuffer() )
+      case CompleteStatusManager::COMPLETE:
       {
         ready = true;
+        mFinishedResourceAcquisition = true;
       }
-      mFinishedResourceAcquisition = false;
-      FollowTracker( mTextureId );
-    }
-    break;
-
-    case CompleteStatusManager::COMPLETE:
-    {
-      ready = true;
-      mFinishedResourceAcquisition = true;
-    }
-    break;
+      break;
 
-    case CompleteStatusManager::NEVER:
-    {
-      ready = false;
-      mFinishedResourceAcquisition = true;
+      case CompleteStatusManager::NEVER:
+      {
+        ready = false;
+        mFinishedResourceAcquisition = true;
+      }
+      break;
     }
-    break;
+  }
+  else
+  {
+    // Loading is essentially finished if we don't have a resource ID
+    mFinishedResourceAcquisition = true;
   }
 
   ATTACHMENT_LOG_FMT(Debug::General, " ObjName:%s finished:%s ready:%s \n",
index faa2712..2a4079a 100644 (file)
@@ -107,22 +107,30 @@ CompleteStatusManager::CompleteState CompleteStatusManager::GetStatus( Integrati
 {
   CompleteState readiness = CompleteStatusManager::NOT_READY;
 
-  TrackedResourcesIter iter = mTrackedResources.find(id);
-  if( iter != mTrackedResources.end() )
+  if( 0 != id )
   {
-    if( iter->second->IsComplete() )
+    TrackedResourcesIter iter = mTrackedResources.find(id);
+    if( iter != mTrackedResources.end() )
+    {
+      if( iter->second->IsComplete() )
+      {
+        readiness = CompleteStatusManager::COMPLETE;
+      }
+    }
+    else if( mResourceManager.IsResourceLoaded(id) )
     {
       readiness = CompleteStatusManager::COMPLETE;
     }
+    else if( mResourceManager.IsResourceLoadFailed(id) )
+    {
+      readiness = CompleteStatusManager::NEVER;
+    }
   }
-  else if( mResourceManager.IsResourceLoaded(id) )
+  else
   {
+    // Loading is essentially finished if we don't have a resource ID
     readiness = CompleteStatusManager::COMPLETE;
   }
-  else if( mResourceManager.IsResourceLoadFailed(id) )
-  {
-    readiness = CompleteStatusManager::NEVER;
-  }
 
   TRACKER_LOG_FMT(Debug::General, "id:%d = %s\n", id, (readiness==CompleteStatusManager::COMPLETE)?"COMPLETE":((readiness==CompleteStatusManager::NEVER)?"NEVER":"NOT_READY"));