#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
#include <dali/integration-api/debug.h>
+#include <test-native-image.h>
#define BOOLSTR(x) ((x)?"T":"F")
namespace // unnamed namespace
{
-class TestNativeImage : public NativeImage
-{
-public:
- int mWidth;
- int mHeight;
- TestNativeImage(int width, int height)
- : mWidth(width),
- mHeight(height)
- {}
-
- virtual bool GlExtensionCreate() {return true;};
-
- /**
- * Destroy the GL resource for the NativeImage.
- * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
- * @pre There is a GL context for the current thread.
- */
- virtual void GlExtensionDestroy() {};
-
- /**
- * Use the NativeImage as a texture for rendering
- * @pre There is a GL context for the current thread.
- * @return A GL error code
- */
- virtual unsigned int TargetTexture() {return 0;};
-
- /**
- * Called in each NativeTexture::Bind() call to allow implementation specific operations.
- * The correct texture sampler has already been bound before the function gets called.
- * @pre glAbstraction is being used by context in current thread
- */
- virtual void PrepareTexture() {}
-
- /**
- * Returns the width of the NativeImage
- * @return width
- */
- virtual unsigned int GetWidth() const {return mWidth;}
-
- /**
- * Returns the height of the NativeImage
- * @return height
- */
- virtual unsigned int GetHeight() const {return mHeight;}
-
- /**
- * Returns the internal pixel NativeImage::PixelFormat of the NativeImage
- * @return pixel format
- */
- virtual Pixel::Format GetPixelFormat() const { return Pixel::RGBA8888; }
-protected:
- ~TestNativeImage(){}
-};
-
-
const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
/*
FrameBufferImage frameBufferImage;
if( glSync )
{
- NativeImagePtr testNativeImagePtr = new TestNativeImage(10, 10);
- frameBufferImage= FrameBufferImage::New( *testNativeImagePtr.Get() );
+ NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
+ frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
}
else
{
ids.push_back( 7 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor newActor = ImageActor::New( img );
newActor.SetSize(1,1);
stage.Add( newActor );
ids.push_back( expectedTextureId );
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor newActor = ImageActor::New( img );
newActor.SetSize(1,1);
task.SetSourceActor( newActor );
ids.push_back( expectedTextureId );
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor newActor = ImageActor::New( img );
newActor.SetSize(1,1);
stage.Add( newActor );
ids.push_back( 10 ); // 10 = actor3
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img1 = BitmapImage::New( 1,1 );
+ BufferImage img1 = BufferImage::New( 1,1 );
ImageActor actor1 = ImageActor::New( img1 );
actor1.SetSize(1,1);
Stage::GetCurrent().Add( actor1 );
DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
}
- BitmapImage img2 = BitmapImage::New( 1,1 );
+ BufferImage img2 = BufferImage::New( 1,1 );
ImageActor actor2 = ImageActor::New( img2 );
actor2.SetSize(1,1);
DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
}
- BitmapImage img3 = BitmapImage::New( 1,1 );
+ BufferImage img3 = BufferImage::New( 1,1 );
ImageActor actor3 = ImageActor::New( img3 );
actor3.SetSize(1,1);
// Set by Property test
Vector2 newPosition2(32.0f, 32.0f);
- task.SetProperty( RenderTask::VIEWPORT_POSITION, newPosition2 );
+ task.SetProperty( RenderTask::Property::VIEWPORT_POSITION, newPosition2 );
// Update
application.SendNotification();
Vector2 newPosition3(64.0f, 0.0f);
Animation animation = Animation::New(1.0f);
- animation.AnimateTo( Property( task, RenderTask::VIEWPORT_POSITION ), newPosition3, AlphaFunctions::Linear );
+ animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunctions::Linear );
animation.Play();
// Perform 1000ms worth of updates at which point animation should have completed.
// Set by Property test
Vector2 newSize2(50.0f, 50.0f);
- task.SetProperty( RenderTask::VIEWPORT_SIZE, newSize2 );
+ task.SetProperty( RenderTask::Property::VIEWPORT_SIZE, newSize2 );
// Update
application.SendNotification();
Vector2 newSize3(10.0f, 10.0f);
Animation animation = Animation::New(1.0f);
- animation.AnimateTo( Property( task, RenderTask::VIEWPORT_SIZE ), newSize3, AlphaFunctions::Linear );
+ animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunctions::Linear );
animation.Play();
// Perform 1000ms worth of updates at which point animation should have completed.
DALI_TEST_EQUALS( task.GetClearColor(), testColor, TEST_LOCATION );
- task.SetProperty( RenderTask::CLEAR_COLOR, testColor2 );
+ task.SetProperty( RenderTask::Property::CLEAR_COLOR, testColor2 );
// Wait a frame.
Wait(application);
Stage::GetCurrent().Add( offscreenCameraActor );
- BitmapImage image = BitmapImage::New( 10, 10 );
+ BufferImage image = BufferImage::New( 10, 10 );
ImageActor rootActor = ImageActor::New( image );
rootActor.SetSize( 10, 10 );
Stage::GetCurrent().Add( rootActor );
RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- NativeImagePtr testNativeImagePtr = new TestNativeImage(10, 10);
+ NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
// Flush all outstanding messages
Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
Stage::GetCurrent().Add(secondRootActor);
- secondRootActor.SetVisible(false);
RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, true);
bool finished = false;
Integration::ResourceTypeId imageType = imageRequest->GetType()->id;
Stage::GetCurrent().Add(secondRootActor);
- secondRootActor.SetVisible(false);
RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false);
bool finished = false;
DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
- // MAKE SOURCE VISIBLE
- secondRootActor.SetVisible(true);
- application.SendNotification();
- DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
- DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true ) );
-
// FINISH RESOURCE LOADING - expect immediate rendering yet
CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete
DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true ) );
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;
+}