+ TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction();
+
+ CameraActor offscreenCameraActor = CameraActor::New();
+
+ Stage::GetCurrent().Add( offscreenCameraActor );
+
+ BufferImage image = BufferImage::New( 10, 10 );
+ Actor rootActor = CreateRenderableActor( 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 );
+ newTask.SetProperty( RenderTask::Property::REQUIRES_SYNC, true );
+
+ // 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( (Integration::KeepUpdating::Reasons)(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( (Integration::KeepUpdating::Reasons)(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 Actor has no Image set");
+
+ Stage stage = Stage::GetCurrent();
+
+ BufferImage image = BufferImage::New( 10, 10 );
+ Actor rootActor = CreateRenderableActor( image );
+ rootActor.SetSize( 10, 10 );
+ stage.Add( rootActor );
+
+ Actor actorWithMissingImage = CreateRenderableActor( 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;
+}
+
+int UtcDaliRenderTaskWorldToViewport(void)
+{
+ TestApplication application( 400u, 400u ); // square surface
+
+ RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+
+ Actor actor = Actor::New();
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetPosition( Vector3(0.0, 0.0, 0.0) );
+
+ actor.SetParentOrigin( Vector3(0.5, 0.5, 0.5) );
+ actor.SetAnchorPoint( Vector3(0.5, 0.5, 0.5) );
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ RenderTask task = taskList.GetTask( 0u );
+
+ CameraActor camera = task.GetCameraActor();
+
+ Vector2 screenSize = task.GetCurrentViewportSize();
+
+ float screenX = 0.0;
+ float screenY = 0.0;
+
+ bool ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
+ DALI_TEST_CHECK(ok == true);
+
+ DALI_TEST_EQUALS(screenX, screenSize.x/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenY, screenSize.y/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ Actor actor2 = Actor::New();
+ float actor2Size = 100.f;
+ actor2.SetSize( actor2Size, actor2Size );
+ actor2.SetPosition( Vector3(0.0, 0.0, 0.0) );
+ actor2.SetParentOrigin( Vector3(0.5, 0.5, 0.0) );
+ actor2.SetAnchorPoint( Vector3(0.5, 0.5, 0.0) );
+ Stage::GetCurrent().Add( actor2 );
+ actor2.Add(actor);
+ actor.SetParentOrigin( Vector3(0,0,0) );
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ ok = task.WorldToViewport(actor.GetCurrentWorldPosition(), screenX, screenY);
+ DALI_TEST_CHECK(ok == true);
+
+ DALI_TEST_EQUALS(screenX, screenSize.x/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenY, screenSize.y/2 - actor2Size/2, Math::MACHINE_EPSILON_10000, TEST_LOCATION);
+
+ END_TEST;
+}
+
+
+int UtcDaliRenderTaskViewportToLocal(void)
+{
+ TestApplication application;
+ Actor actor = Actor::New();
+ actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetPosition(10.0f, 10.0f);
+ Stage::GetCurrent().Add(actor);
+
+ RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+ RenderTask task = taskList.GetTask( 0u );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();