+ DALI_TEST_CHECK( indices.Size() );
+ DALI_TEST_EQUALS( indices.Size(), task.GetPropertyCount(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliRenderTaskSetScreenToFrameBufferMappingActor(void)
+{
+ TestApplication application;
+ tet_infoline("Testing RenderTask::SetScreenToFrameBufferMappingActor ");
+
+ Stage stage = Stage::GetCurrent();
+ Size stageSize = stage.GetSize();
+ Actor mappingActor = Actor::New();
+ Vector2 scale( 0.6f, 0.75f);
+ Vector2 offset( stageSize.x*0.1f, stageSize.y*0.15f);
+ mappingActor.SetSize( stageSize * scale );
+ mappingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mappingActor.SetPosition( offset.x, offset.y );
+ stage.Add( mappingActor );
+
+ Actor offscreenActor = Actor::New();
+ offscreenActor.SetSize( stageSize );
+ offscreenActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ stage.Add( offscreenActor );
+
+ RenderTaskList taskList = stage.GetRenderTaskList();
+ RenderTask renderTask = taskList.CreateTask();
+ FrameBufferImage frameBufferImage = FrameBufferImage::New(stageSize.width*scale.x, stageSize.height*scale.y, Pixel::A8, Image::NEVER);
+ renderTask.SetSourceActor( offscreenActor );
+ renderTask.SetExclusive( true );
+ renderTask.SetInputEnabled( true );
+ renderTask.SetTargetFrameBuffer( frameBufferImage );
+ renderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
+ renderTask.SetScreenToFrameBufferMappingActor( mappingActor );
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ Vector2 screenCoordinates( stageSize.x * 0.05f, stageSize.y * 0.05f );
+ Dali::HitTestAlgorithm::Results results;
+ DALI_TEST_CHECK( !results.actor );
+ DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
+ // miss expected, results not changed
+ DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
+ DALI_TEST_CHECK( !results.actor );
+ DALI_TEST_EQUALS( Vector2::ZERO, results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ screenCoordinates.x = stageSize.x * 0.265f;
+ screenCoordinates.y = stageSize.y * 0.33f;
+ results.actor = Actor();
+ results.actorCoordinates = Vector2::ZERO;
+ // hit expected, results changed
+ DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
+ DALI_TEST_CHECK( results.actor == offscreenActor );
+ DALI_TEST_EQUALS( (screenCoordinates-offset)/scale , results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ screenCoordinates.x = stageSize.x * 0.435f;
+ screenCoordinates.y = stageSize.y * 0.52f;
+ // hit expected, results changed
+ DALI_TEST_CHECK( true == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
+ DALI_TEST_CHECK( results.actor == offscreenActor );
+ const Vector2 expectedCoordinates = (screenCoordinates-offset)/scale;
+ DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
+
+ screenCoordinates.x = stageSize.x * 0.65f;
+ screenCoordinates.y = stageSize.y * 0.95f;
+ // miss expected, results not changed
+ DALI_TEST_CHECK( false == Dali::HitTestAlgorithm::HitTest( renderTask, screenCoordinates, results, IsActorHittableFunction ) );
+ DALI_TEST_CHECK( results.actor == offscreenActor );
+ DALI_TEST_EQUALS( expectedCoordinates , results.actorCoordinates, 0.1f, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliRenderTaskFinishInvisibleSourceActor(void)
+{
+ TestApplication application;
+
+ tet_infoline("Testing RenderTask::SignalFinished()");
+
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
+
+ CameraActor offscreenCameraActor = CameraActor::New();
+
+ Stage::GetCurrent().Add( offscreenCameraActor );
+
+ BufferImage image = BufferImage::New( 10, 10 );
+ ImageActor rootActor = ImageActor::New( image );
+ rootActor.SetSize( 10, 10 );
+ rootActor.SetVisible(false);
+ Stage::GetCurrent().Add( rootActor );
+
+ RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+ NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
+ FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
+
+ // Flush all outstanding messages
+ application.SendNotification();
+ application.Render();
+
+ RenderTask newTask = taskList.CreateTask();
+ newTask.SetCameraActor( offscreenCameraActor );
+ newTask.SetSourceActor( rootActor );
+ 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 );
+ newTask.SetTargetFrameBuffer( frameBufferImage );
+
+ // Framebuffer doesn't actually get created until Connected, i.e. by previous line
+
+ bool finished = false;
+ RenderTaskFinished renderTaskFinished( finished );
+ newTask.FinishedSignal().Connect( &application, renderTaskFinished );
+
+ // Flush the queue and render.
+ application.SendNotification();
+
+ // 1 render to process render task, then wait for sync before finished msg is sent
+ // from update to the event thread.
+
+ application.Render();
+ application.SendNotification();
+ DALI_TEST_CHECK( !finished );
+
+ Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject();
+ DALI_TEST_CHECK( lastSyncObj != NULL );
+
+ application.Render();
+ DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
+ application.SendNotification();
+ DALI_TEST_CHECK( !finished );
+
+ application.Render();
+ DALI_TEST_EQUALS( (application.GetUpdateStatus() & Integration::KeepUpdating::RENDER_TASK_SYNC), Integration::KeepUpdating::RENDER_TASK_SYNC, TEST_LOCATION );
+ application.SendNotification();
+ DALI_TEST_CHECK( ! finished );
+
+ sync.SetObjectSynced( lastSyncObj, true );
+
+ application.Render();
+ application.SendNotification();
+ DALI_TEST_CHECK( !finished );
+
+ application.Render();
+ application.SendNotification();
+ DALI_TEST_CHECK( finished );
+ finished = false;
+
+ application.Render(); // Double check no more finished signal
+ application.SendNotification();
+ DALI_TEST_CHECK( ! finished );
+
+ 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 );
+