From 5fab3d3bc329a7a19ec9cf1cac82031ca97af72d Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Wed, 11 Jan 2017 11:10:33 +0000 Subject: [PATCH] Changed ResourceImage to use Dali::Texture internally Change-Id: Ie8e740f8549bb23e4e2caf91a837d844bc6eb89c --- .../utc-Dali-Internal-ImageFactory.cpp | 12 +- .../dali-test-suite-utils.cpp | 15 + .../dali-test-suite-utils/dali-test-suite-utils.h | 3 + automated-tests/src/dali/utc-Dali-Atlas.cpp | 15 - automated-tests/src/dali/utc-Dali-Image.cpp | 285 +----- automated-tests/src/dali/utc-Dali-RenderTask.cpp | 989 +++------------------ .../src/dali/utc-Dali-ResourceImage.cpp | 30 +- automated-tests/src/dali/utc-Dali-Scripting.cpp | 5 + dali/devel-api/images/texture-set-image.cpp | 17 +- dali/integration-api/bitmap.h | 12 + dali/internal/event/images/bitmap-compressed.h | 5 + dali/internal/event/images/bitmap-packed-pixel.h | 5 + dali/internal/event/images/image-impl.cpp | 3 +- dali/internal/event/images/image-impl.h | 14 +- .../event/images/nine-patch-image-impl.cpp | 32 +- dali/internal/event/images/nine-patch-image-impl.h | 12 - dali/internal/event/images/resource-image-impl.cpp | 189 ++-- dali/internal/event/images/resource-image-impl.h | 39 +- 18 files changed, 300 insertions(+), 1382 deletions(-) diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp index 4a70737..65833e8 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp @@ -72,7 +72,7 @@ int UtcDaliImageFactoryUseCachedRequest01(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceSynchronouslyFunc ) ); application.GetPlatform().ResetTrace(); Image image2 = ResourceImage::New( gTestImageFilename ); @@ -80,15 +80,15 @@ int UtcDaliImageFactoryUseCachedRequest01(void) application.SendNotification(); application.Render(); - // check resource is not loaded twice - DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + // Resource is loaded twice + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceSynchronouslyFunc ) ); application.GetPlatform().ResetTrace(); Image image3 = ResourceImage::New( gTestImageFilename ); application.SendNotification(); application.Render(); - DALI_TEST_CHECK( !application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceSynchronouslyFunc ) ); END_TEST; } @@ -106,7 +106,7 @@ int UtcDaliImageFactoryUseCachedRequest02(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceSynchronouslyFunc ) ); application.GetPlatform().ResetTrace(); // Add actor to stage @@ -130,7 +130,7 @@ int UtcDaliImageFactoryUseCachedRequest02(void) application.SendNotification(); application.Render(); - DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceFunc ) ); + DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::LoadResourceSynchronouslyFunc ) ); application.GetPlatform().ResetTrace(); // Resource is reloaded diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp index b50f506..61562bf 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp @@ -338,6 +338,21 @@ BufferImage CreateBufferImage() return CreateBufferImage(4, 4, Color::WHITE); } +void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat ) +{ + TestPlatformAbstraction& platform = application.GetPlatform(); + platform.SetClosestImageSize(Vector2( imageWidth, imageHeight)); + + Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN ); + Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight ); + unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat ); + unsigned int initialColor = 0xFF; + memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel); + + Integration::ResourcePointer resourcePtr(bitmap); + platform.SetSynchronouslyLoadedResource( resourcePtr ); +} + namespace Test { diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h index 261d239..72e663b 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h @@ -514,6 +514,9 @@ struct DefaultFunctionCoverage BufferImage CreateBufferImage(); BufferImage CreateBufferImage(int width, int height, const Vector4& color); +// Prepare a resource image to be loaded. Should be called before creating the ResourceImage +void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat ); + // Test namespace to prevent pollution of Dali namespace, add Test helper functions here namespace Test { diff --git a/automated-tests/src/dali/utc-Dali-Atlas.cpp b/automated-tests/src/dali/utc-Dali-Atlas.cpp index b6de2db..d7c2ae3 100644 --- a/automated-tests/src/dali/utc-Dali-Atlas.cpp +++ b/automated-tests/src/dali/utc-Dali-Atlas.cpp @@ -30,21 +30,6 @@ namespace { static const char* gTestImageFilename = "icon_wrt.png"; -void PrepareResourceImage( TestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat ) -{ - TestPlatformAbstraction& platform = application.GetPlatform(); - platform.SetClosestImageSize(Vector2( imageWidth, imageHeight)); - - Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN ); - Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight ); - unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat ); - unsigned int initialColor = 0xFF; - memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel); - - Integration::ResourcePointer resourcePtr(bitmap); - platform.SetSynchronouslyLoadedResource( resourcePtr ); -} - PixelData CreatePixelData(unsigned int width, unsigned int height, Pixel::Format pixelFormat) { unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( pixelFormat ); diff --git a/automated-tests/src/dali/utc-Dali-Image.cpp b/automated-tests/src/dali/utc-Dali-Image.cpp index a686651..aca4563 100644 --- a/automated-tests/src/dali/utc-Dali-Image.cpp +++ b/automated-tests/src/dali/utc-Dali-Image.cpp @@ -86,110 +86,32 @@ int UtcDaliImageGetWidthHeight(void) Vector2 testSize(8.0f, 16.0f); application.GetPlatform().SetClosestImageSize(testSize); + PrepareResourceImage( application, testSize.x, testSize.y, Pixel::RGBA8888 ); Image image1 = ResourceImage::New(gTestImageFilename); - DALI_TEST_EQUALS( image1.GetWidth(), testSize.width, TEST_LOCATION ); - DALI_TEST_EQUALS( image1.GetHeight(), testSize.height, TEST_LOCATION ); - - Image image2 = ResourceImage::New( gTestImageFilename, ImageDimensions(128, 256), FittingMode::SCALE_TO_FILL, SamplingMode::DEFAULT ); - DALI_TEST_EQUALS( image2.GetWidth(), 128u, TEST_LOCATION ); - DALI_TEST_EQUALS( image2.GetHeight(), 256u, TEST_LOCATION ); - - Image image3 = FrameBufferImage::New(16, 32); - DALI_TEST_EQUALS(image3.GetWidth(), 16u, TEST_LOCATION); - DALI_TEST_EQUALS(image3.GetHeight(), 32u, TEST_LOCATION); - - TestNativeImagePointer nativeImage = TestNativeImage::New(32, 64); + DALI_TEST_EQUALS( image1.GetWidth(), testSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( image1.GetHeight(), testSize.y, TEST_LOCATION ); + + testSize = Vector2(128.0f, 256.0f); + PrepareResourceImage( application, testSize.x, testSize.y, Pixel::RGBA8888 ); + Image image2 = ResourceImage::New( gTestImageFilename, ImageDimensions(testSize.x, testSize.y), FittingMode::SCALE_TO_FILL, SamplingMode::DEFAULT ); + DALI_TEST_EQUALS( image2.GetWidth(), testSize.x, TEST_LOCATION ); + DALI_TEST_EQUALS( image2.GetHeight(), testSize.y, TEST_LOCATION ); + + testSize = Vector2(16.0f, 32.0f); + Image image3 = FrameBufferImage::New(testSize.x, testSize.y); + DALI_TEST_EQUALS(image3.GetWidth(), testSize.x, TEST_LOCATION); + DALI_TEST_EQUALS(image3.GetHeight(), testSize.y, TEST_LOCATION); + + testSize = Vector2(32.0f, 64.0f); + PrepareResourceImage( application, testSize.x, testSize.y, Pixel::RGBA8888 ); + TestNativeImagePointer nativeImage = TestNativeImage::New(testSize.x, testSize.y); Image image4 = NativeImage::New(*(nativeImage.Get())); - DALI_TEST_EQUALS(image4.GetWidth(), 32u, TEST_LOCATION); - DALI_TEST_EQUALS(image4.GetHeight(), 64u, TEST_LOCATION); + DALI_TEST_EQUALS(image4.GetWidth(), testSize.x, TEST_LOCATION); + DALI_TEST_EQUALS(image4.GetHeight(), testSize.y, TEST_LOCATION); END_TEST; } -static bool SignalUploadedFlag = false; - -static void SignalUploadedHandler(Image image) -{ - tet_infoline("Received image uploaded signal"); - - SignalUploadedFlag = true; -} - -int UtcDaliImageSignalUploaded(void) -{ - TestApplication application; - TestPlatformAbstraction& platform = application.GetPlatform(); - tet_infoline("UtcDaliImageSignalUploaded - Image::SignalUploaded()"); - - // set up image in fake platform abstraction - Vector2 testSize(80.0f, 80.0f); - platform.SetClosestImageSize(testSize); - - ResourceImage image = ResourceImage::New(gTestImageFilename); - - // Load image - application.SendNotification(); - application.Render(16); - std::vector ids; - ids.push_back( 23 ); - application.GetGlAbstraction().SetNextTextureIds( ids ); - Integration::ResourceRequest* request = platform.GetRequest(); - Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD ); - Integration::ResourcePointer resource(bitmap); - bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); - - if(request) - { - platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource); - } - application.Render(16); - application.SendNotification(); - - image.UploadedSignal().Connect( SignalUploadedHandler ); - - Dali::Actor actor = CreateRenderableActor( image ); - Stage::GetCurrent().Add( actor ); - actor.SetSize(80, 80); - actor.SetVisible(true); - - application.SendNotification(); - application.Render(0); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( SignalUploadedFlag == true ); - SignalUploadedFlag = false; - - image.Reload(); - bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 160, 160, 160, 160); - - // image loading - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - request = platform.GetRequest(); - if(request) - { - platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource); - } - - //upload - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - DALI_TEST_CHECK( SignalUploadedFlag == true ); - END_TEST; -} - int UtcDaliImageDiscard01(void) { TestApplication application; @@ -221,170 +143,3 @@ int UtcDaliImageDiscard01(void) DALI_TEST_CHECK( texIds[0] == 23 ); END_TEST; } - -int UtcDaliImageDiscard02(void) -{ - TestApplication application; - application.GetGlAbstraction().EnableTextureCallTrace( true ); - tet_infoline("UtcDaliImageDiscard02 - one actor, tests TextureCache::DiscardTexture"); - - { - { - Actor actor; - { - Image image = ResourceImage::New(gTestImageFilename, ImageDimensions( 40, 30 ) ); - actor = CreateRenderableActor(image); - Stage::GetCurrent().Add(actor); - - application.SendNotification(); - application.Render(16); - - std::vector ids; - ids.push_back( 23 ); - application.GetGlAbstraction().SetNextTextureIds( ids ); - - TestPlatformAbstraction& platform = application.GetPlatform(); - LoadBitmapResource( platform ); - application.Render(16); - application.SendNotification(); - DALI_TEST_CHECK( application.GetGlAbstraction().GetTextureTrace().FindMethod("BindTexture") ); - } // lose image handle, actor should still keep one - application.SendNotification(); - application.Render(16); - - Stage::GetCurrent().Remove(actor); - application.SendNotification(); - application.Render(16); - } // lose actor - application.SendNotification(); - application.Render(16); - } - - // Cleanup - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); - - // texture should have been removed: - DALI_TEST_CHECK( application.GetGlAbstraction().CheckTextureDeleted( 23 )); - END_TEST; -} - -int UtcDaliImageDiscard03(void) -{ - TestApplication application; - tet_infoline("UtcDaliImageDiscard03 - one actor, tests TextureCache::RemoveObserver"); - - const Vector2 closestImageSize( 1, 1); - application.GetPlatform().SetClosestImageSize(closestImageSize); - - Image image = ResourceImage::New(gTestImageFilename); - Actor actor = CreateRenderableActor(image); - Stage::GetCurrent().Add(actor); - - application.SendNotification(); - application.Render(16); - - std::vector ids; - ids.push_back( 23 ); - application.GetGlAbstraction().SetNextTextureIds( ids ); - - TestPlatformAbstraction& platform = application.GetPlatform(); - LoadBitmapResource( platform ); - application.Render(16); - application.SendNotification(); - application.SendNotification(); - application.Render(16); - - const std::vector& texIds = application.GetGlAbstraction().GetNextTextureIds(); - DALI_TEST_CHECK( texIds.size() == 0 ); - const std::vector& boundTexIds = application.GetGlAbstraction().GetBoundTextures(); - DALI_TEST_CHECK( boundTexIds[0] == 23 ); - - Stage::GetCurrent().Remove(actor); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - application.Render(16); - application.SendNotification(); - application.Render(16); // Should remove image renderer - - END_TEST; -} - -int UtcDaliImageContextLoss(void) -{ - TestApplication application; // Default config: DALI_DISCARDS_ALL_DATA - - const Vector2 closestImageSize( 80, 80 ); - TestPlatformAbstraction& platform = application.GetPlatform(); - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - - platform.SetClosestImageSize(closestImageSize); - - tet_infoline("UtcDaliImageContextLoss - Load image with LoadPolicy::Immediate, bitmap discard. Check that the image is re-requested on context regain\n"); - - Image image = ResourceImage::New("image.png"); - - DALI_TEST_CHECK( image ); - - application.SendNotification(); - application.Render(16); - - // request file loading immediately - - DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); - Actor actor = CreateRenderableActor(image); - Stage::GetCurrent().Add(actor); - - application.SendNotification(); - application.Render(16); - - TraceCallStack& textureTrace = glAbstraction.GetTextureTrace(); - textureTrace.Enable(true); - - std::vector ids; - ids.push_back( 23 ); - glAbstraction.SetNextTextureIds( ids ); - - LoadBitmapResource(platform); - - application.Render(16); - application.SendNotification(); - - DALI_TEST_CHECK( textureTrace.FindMethod("GenTextures") ); - - textureTrace.Reset(); - textureTrace.Enable(true); - platform.ResetTrace(); - platform.EnableTrace(true); - - // Lose & regain context (in render 'thread') - application.ResetContext(); - - application.GetCore().RecoverFromContextLoss(); // start the recovery process - application.SendNotification(); - - // Run update/render loop - application.Render(16); - application.SendNotification(); - - // Expect new load request - DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); - - // Finish loading image - LoadBitmapResource(platform); - ids.clear(); - ids.push_back( 57 ); - glAbstraction.SetNextTextureIds(ids); - - // Run update/render loop - application.Render(16); - application.SendNotification(); - - // Expect new GenTextures - DALI_TEST_CHECK( textureTrace.FindMethod("GenTextures") ); - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index 69eb4e4..e25bf6a 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -169,47 +169,30 @@ bool TestScreenToFrameBufferFunction( Vector2& coordinates ) return true; } -Actor CreateLoadingActor(TestApplication& application, std::string filename) +Actor CreateRenderableActorSuccess(TestApplication& application, std::string filename) { + PrepareResourceImage( application, 80u, 80u, Pixel::RGBA8888 ); Image image = ResourceImage::New(filename); - DALI_TEST_CHECK( image ); - application.SendNotification(); - application.Render(16); - DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); Actor actor = CreateRenderableActor(image); actor.SetSize( 80, 80 ); - application.SendNotification(); - application.Render(16); return actor; } -Image CreateLoadingImage(TestApplication& application, std::string filename) +Actor CreateRenderableActorFailed(TestApplication& application, std::string filename) { Image image = ResourceImage::New(filename); DALI_TEST_CHECK( image ); - application.SendNotification(); - application.Render(16); - DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); - - return image; -} - -void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType) -{ - std::vector ids; - ids.push_back( 23 ); - application.GetGlAbstraction().SetNextTextureIds( ids ); - - Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD ); - Integration::ResourcePointer resource(bitmap); - bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80); - - application.GetPlatform().SetResourceLoaded(resourceId, requestType, resource); + Actor actor = CreateRenderableActor(image); + actor.SetSize( 80, 80 ); + return actor; } -void FailImageLoad(TestApplication& application, Integration::ResourceId resourceId ) +Image CreateResourceImage(TestApplication& application, std::string filename) { - application.GetPlatform().SetResourceLoadFailed(resourceId, Integration::FailureUnknown); + PrepareResourceImage( application, 80u, 80u, Pixel::RGBA8888 ); + Image image = ResourceImage::New(filename); + DALI_TEST_CHECK( image ); + return image; } RenderTask CreateRenderTask(TestApplication& application, @@ -1876,16 +1859,11 @@ int UtcDaliRenderTaskContinuous01(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); bool finished = false; RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete application.SendNotification(); // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating @@ -1919,10 +1897,7 @@ int UtcDaliRenderTaskContinuous02(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); secondRootActor.SetVisible(false); @@ -1930,7 +1905,6 @@ int UtcDaliRenderTaskContinuous02(void) bool finished = false; RenderTaskFinished renderTaskFinished( finished ); newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete application.SendNotification(); // START PROCESS/RENDER Input, Expected Input, Expected, KeepUpdating @@ -1961,17 +1935,13 @@ int UtcDaliRenderTaskContinuous03(void) Stage::GetCurrent().Add( rootActor ); CameraActor offscreenCameraActor = CameraActor::New(); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); bool finished = false; RenderTaskFinished renderTaskFinished( finished ); newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete application.SendNotification(); // START PROCESS/RENDER Input, Expected Input, Expected @@ -1992,46 +1962,7 @@ int UtcDaliRenderTaskContinuous04(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Continuous using loading image\nPRE: Resource not ready\nPOST:continuous renders, no Finished signal"); - - // SETUP AN OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - END_TEST; -} - -int UtcDaliRenderTaskContinous05(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Continuous using Mesh which accesses texture through sampler with loading image\n" - "PRE: Resource not ready\nPOST:continuous renders, no Finished signal"); + tet_infoline("Testing RenderTask Render Continuous using loaded image"); // SETUP AN OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2043,22 +1974,7 @@ int UtcDaliRenderTaskContinous05(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - - Shader shader = CreateShader(); - - - Image image = CreateLoadingImage(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - TextureSet textureSet = CreateTextureSet( image ); - - Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New(geometry, shader); - renderer.SetTextures( textureSet ); - Actor secondRootActor = Actor::New(); - secondRootActor.AddRenderer(renderer); - secondRootActor.SetSize(100, 100); + Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); @@ -2068,22 +1984,15 @@ int UtcDaliRenderTaskContinous05(void) application.SendNotification(); // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - expect 'continuous' renders to start, no finished signal - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); END_TEST; } - int UtcDaliRenderTaskOnce01(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only"); + tet_infoline("Testing RenderTask Render Once GlSync, using loaded image"); // SETUP AN OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2096,10 +2005,7 @@ int UtcDaliRenderTaskOnce01(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); @@ -2109,26 +2015,13 @@ int UtcDaliRenderTaskOnce01(void) newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // MAKE SOURCE VISIBLE - secondRootActor.SetVisible(true); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - // FINISH RESOURCE LOADING - expect no 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, __LINE__ ) ); Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); DALI_TEST_CHECK( lastSyncObj != NULL ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); END_TEST; } @@ -2137,8 +2030,7 @@ int UtcDaliRenderTaskOnce02(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n" - "PRE: Resources not ready\nPOST: Finished signal sent once only"); + tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n"); // SETUP AN OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2153,10 +2045,7 @@ int UtcDaliRenderTaskOnce02(void) Stage::GetCurrent().Add( offscreenCameraActor ); Shader shader = CreateShader(); - Image image = CreateLoadingImage(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Image image = CreateResourceImage(application, "aFile.jpg"); TextureSet textureSet = CreateTextureSet( image ); Geometry geometry = CreateQuadGeometry(); @@ -2173,21 +2062,14 @@ int UtcDaliRenderTaskOnce02(void) newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - // FINISH RESOURCE LOADING - expect no 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, __LINE__ ) ); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj != NULL ); + sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); - sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); END_TEST; } @@ -2196,9 +2078,7 @@ int UtcDaliRenderTaskOnce03(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync, using loading image. Switch from render always after ready to render once\n" - "PRE: Render task ready, Image not loaded\n" - "POST: Finished signal sent only once"); + tet_infoline("Testing RenderTask Render Once GlSync, using loaded image. Switch from render always after ready to render once\n"); // SETUP A CONTINUOUS OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2211,10 +2091,7 @@ int UtcDaliRenderTaskOnce03(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); @@ -2223,26 +2100,17 @@ int UtcDaliRenderTaskOnce03(void) newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); // Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); + application.SendNotification(); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); DALI_TEST_CHECK( lastSyncObj != NULL ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); @@ -2253,10 +2121,9 @@ int UtcDaliRenderTaskOnce03(void) int UtcDaliRenderTaskOnce04(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loading image.\n" + tet_infoline("Testing RenderTask Render Once GlSync, using Mesh which accesses texture through sampler with loaded image.\n" "Switch from render always after ready to render once\n" - "PRE: Render task ready, Image not loaded\n" - "POST: Finished signal sent only once"); + ); // SETUP AN OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2271,10 +2138,7 @@ int UtcDaliRenderTaskOnce04(void) Stage::GetCurrent().Add( offscreenCameraActor ); Shader shader = CreateShader(); - Image image = CreateLoadingImage(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Image image = CreateResourceImage(application, "aFile.jpg"); TextureSet textureSet = CreateTextureSet( image ); Geometry geometry = CreateQuadGeometry(); @@ -2291,44 +2155,31 @@ int UtcDaliRenderTaskOnce04(void) newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); // Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); + application.SendNotification(); + + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); DALI_TEST_CHECK( lastSyncObj != NULL ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); sync.SetObjectSynced( lastSyncObj, true ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); END_TEST; } -int UtcDaliRenderTaskOnce05(void) +int UtcDaliRenderTaskOnceNoSync01(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync\n" - "Switch from Render always after ready to render once with resources unready\n" - "PRE: Everything ready to render\n" - "POST: Finished signal sent once"); + tet_infoline("Testing RenderTask Render Once, \nPRE: Resources ready\nPOST: Finished signal sent once only"); - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + // SETUP AN OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); drawTrace.Enable(true); @@ -2337,63 +2188,28 @@ int UtcDaliRenderTaskOnce05(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false); bool finished = false; RenderTaskFinished renderTaskFinished( finished ); newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // CHANGE TO RENDER ONCE - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); // Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); - application.GetPlatform().ClearReadyResources(); - - sync.SetObjectSynced( lastSyncObj, true ); - - // Expect: No draw - we've just drawn our render task once, above. No finished signal - - // we won't read the gl sync until the next frame. Continue rendering - we're waiting for - // the sync - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // Expect: 1 final draw - this Update doesn't update the scene, hence render instructions - // from last frame but 1 are still present. - // Finished signal should be true - we've just done the sync. - // Should now stop rendering and updating - nothing left to do. - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, true, false, __LINE__ ) ); - + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); END_TEST; } -int UtcDaliRenderTaskOnce07(void) +int UtcDaliRenderTaskOnceNoSync02(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GLSync\n" - "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n" - "PRE: Everything ready\n" - "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK + tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loaded image.\n" + "PRE: Resources ready\nPOST: Finished signal sent once only"); + // SETUP AN OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); drawTrace.Enable(true); @@ -2402,67 +2218,43 @@ int UtcDaliRenderTaskOnce07(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - application.Render(); - application.GetPlatform().ClearReadyResources(); + Shader shader = CreateShader(); + Image image = CreateResourceImage(application, "aFile.jpg"); + TextureSet textureSet = CreateTextureSet( image ); + + Geometry geometry = CreateQuadGeometry(); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures( textureSet ); + Actor secondRootActor = Actor::New(); + secondRootActor.AddRenderer(renderer); + secondRootActor.SetSize(100, 100); Stage::GetCurrent().Add(secondRootActor); - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false); bool finished = false; RenderTaskFinished renderTaskFinished( finished ); newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - - // CHANGE TO RENDER ONCE, - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); + application.GetPlatform().ClearReadyResources(); DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); + END_TEST; } -int UtcDaliRenderTaskOnce08(void) +int UtcDaliRenderTaskOnceNoSync03(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GLSync\n" - "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers " - "another render & another finished signal\n" - "PRE: Everything ready\n" - "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); - + tet_infoline("Testing RenderTask Render Once, using loaded image. Switch from render always after ready to render once\n" + "PRE: Render task ready, Image loaded\n" + "POST: Finished signal sent only once"); // SETUP A CONTINUOUS OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - sync.GetTrace().Enable(true); drawTrace.Enable(true); Actor rootActor = Actor::New(); @@ -2470,85 +2262,35 @@ int UtcDaliRenderTaskOnce08(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - application.Render(); - application.GetPlatform().ClearReadyResources(); - + Actor secondRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, /*GL-SYNC*/ true); + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); bool finished = false; - - ConnectionTracker connectionTracker; - RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished ); - newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain ); - + RenderTaskFinished renderTaskFinished( finished ); + newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj == NULL ); - DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 0, TEST_LOCATION ); - - // CHANGE TO RENDER ONCE, newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); - DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION ); - DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - - DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION ); - DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - DALI_TEST_EQUALS( sync.GetNumberOfSyncObjects(), 1, TEST_LOCATION ); - DALI_TEST_EQUALS( sync.GetTrace().CountMethod( "CreateSyncObject" ), 1, TEST_LOCATION ); - - sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - application.SendNotification(); - - // Expect SetRefreshRate to have been called again - // Prevent next finished signal calling refresh once again - RenderTaskFinished renderTaskFinished( finished ); - connectionTracker.DisconnectAll(); - newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished ); + application.SendNotification(); // Input, Expected Input, Expected DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); - - sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); END_TEST; } - -int UtcDaliRenderTaskOnce09(void) +int UtcDaliRenderTaskOnceNoSync04(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync\n" - "SetRefreshRate(ONCE) again before first finished signal has been sent.\n" - "PRE: resources ready\n" - "POST: Only 1 finished signal sent."); + tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n" + "Switch from render always after ready to render once\n" + "PRE: Render task ready, Image not loaded\n" + "POST: Finished signal sent only once"); // SETUP A CONTINUOUS OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); drawTrace.Enable(true); @@ -2557,55 +2299,50 @@ int UtcDaliRenderTaskOnce09(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - application.Render(); - application.GetPlatform().ClearReadyResources(); + Shader shader = CreateShader(); + Image image = CreateResourceImage(application, "aFile.jpg"); + TextureSet textureSet = CreateTextureSet( image ); + + Geometry geometry = CreateQuadGeometry(); + Renderer renderer = Renderer::New(geometry, shader); + renderer.SetTextures( textureSet ); + Actor secondRootActor = Actor::New(); + secondRootActor.AddRenderer(renderer); + secondRootActor.SetSize(100, 100); Stage::GetCurrent().Add(secondRootActor); - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, true); + + RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); bool finished = false; RenderTaskFinished renderTaskFinished( finished ); newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - - // CHANGE TO RENDER ONCE, - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); + TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); + Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj == NULL ); newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); + application.SendNotification(); // Input, Expected Input, Expected DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj != NULL ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - sync.SetObjectSynced( lastSyncObj, true ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); + lastSyncObj = sync.GetLastSyncObject(); + DALI_TEST_CHECK( lastSyncObj == NULL ); END_TEST; } -int UtcDaliRenderTaskOnce10(void) +int UtcDaliRenderTaskOnceNoSync05(void) { TestApplication application; - tet_infoline("Testing RenderTask Render Once GlSync\n" - "SetRefreshRate(ONCE), resource load failed completes render task.\n" - "PRE: resources not ready\n" - "POST: Only 1 finished signal sent."); + tet_infoline("Testing RenderTask Render Once\n" + "SetRefreshRate(ONCE), resource load failed, completes render task.\n" + "PRE: resources failed to load\n" + "POST: No finished signal sent."); // SETUP A CONTINUOUS OFFSCREEN RENDER TASK application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -2617,9 +2354,7 @@ int UtcDaliRenderTaskOnce10(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); + Actor secondRootActor = CreateRenderableActorFailed(application, "aFile.jpg"); Stage::GetCurrent().Add(secondRootActor); RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); @@ -2628,498 +2363,12 @@ int UtcDaliRenderTaskOnce10(void) newTask.FinishedSignal().Connect( &application, renderTaskFinished ); application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); + // START PROCESS/RENDER Input, Expected Input, Expected + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); // CHANGE TO RENDER ONCE, newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - tet_printf(" FailImageLoad\n"); - - FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw - application.SendNotification(); - - // load is now failed so there's nothing more to render in the render task - // Expect finished signal, as all resources are complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync01(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once, using loading image\nPRE: Resources not ready, Source not visible\nPOST: Finished signal sent once only"); - - // SETUP AN OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // 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, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync02(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n" - "PRE: Resources not ready\nPOST: Finished signal sent once only"); - // SETUP AN OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - - Shader shader = CreateShader(); - Image image = CreateLoadingImage(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - TextureSet textureSet = CreateTextureSet( image ); - - Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New(geometry, shader); - renderer.SetTextures( textureSet ); - Actor secondRootActor = Actor::New(); - secondRootActor.AddRenderer(renderer); - secondRootActor.SetSize(100, 100); - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ONCE, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // 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, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync03(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once, using loading image. Switch from render always after ready to render once\n" - "PRE: Render task ready, Image not loaded\n" - "POST: Finished signal sent only once"); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); - - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); // Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync04(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once, using Mesh which accesses texture through sampler with loading image.\n" - "Switch from render always after ready to render once\n" - "PRE: Render task ready, Image not loaded\n" - "POST: Finished signal sent only once"); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - - Shader shader = CreateShader(); - Image image = CreateLoadingImage(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - TextureSet textureSet = CreateTextureSet( image ); - - Geometry geometry = CreateQuadGeometry(); - Renderer renderer = Renderer::New(geometry, shader); - renderer.SetTextures( textureSet ); - Actor secondRootActor = Actor::New(); - secondRootActor.AddRenderer(renderer); - secondRootActor.SetSize(100, 100); - Stage::GetCurrent().Add(secondRootActor); - - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj == NULL ); - - // FINISH RESOURCE LOADING - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); - - lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj == NULL ); - - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); // Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj == NULL ); - - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync05(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once\n" - "Switch from Render always after ready to render once with resources unready\n" - "PRE: Everything ready to render\n" - "POST: Finished signal sent once"); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - TestGlSyncAbstraction& sync = application.GetGlSyncAbstraction(); - Integration::GlSyncAbstraction::SyncObject* lastSyncObj = sync.GetLastSyncObject(); - DALI_TEST_CHECK( lastSyncObj == NULL ); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // CHANGE TO RENDER ONCE - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); // Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // FINISH RESOURCE LOADING - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - application.GetPlatform().ClearReadyResources(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync07(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once\n" - "Render once, Second call to SetRefreshRate(ONCE) triggers only one more finished signal\n" - "PRE: Everything ready\n" - "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - application.Render(); - application.GetPlatform().ClearReadyResources(); - - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - - // CHANGE TO RENDER ONCE, - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync08(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once\n" - "Render once, Call to SetRefreshRate(ONCE) in Finished signal callback triggers\n" - "another render & another finished signal\n" - "PRE: Everything ready\n" - "POST: exactly 1 finished signal per call to SetRefreshRate(ONCE)"); - - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - application.Render(); - application.GetPlatform().ClearReadyResources(); - - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - - ConnectionTracker connectionTracker; - RenderTaskFinishedRenderAgain renderTaskFinishedRenderAgain( finished ); - newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinishedRenderAgain ); - - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - - // CHANGE TO RENDER ONCE, - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - // Expect SetRefreshRate to have been called again - // Prevent next finished signal calling refresh once again - RenderTaskFinished renderTaskFinished( finished ); - connectionTracker.DisconnectAll(); - newTask.FinishedSignal().Connect( &connectionTracker, renderTaskFinished ); - - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - END_TEST; -} - - -int UtcDaliRenderTaskOnceNoSync09(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once\n" - "SetRefreshRate(ONCE) again before first finished signal has been sent.\n" - "PRE: resources ready\n" - "POST: Only 1 finished signal sent."); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; - CompleteImageLoad(application, imageRequestId, imageType); // Need to run update again for this to complete - application.Render(); - application.GetPlatform().ClearReadyResources(); - - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); - - // CHANGE TO RENDER ONCE, - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); - END_TEST; -} - -int UtcDaliRenderTaskOnceNoSync10(void) -{ - TestApplication application; - - tet_infoline("Testing RenderTask Render Once\n" - "SetRefreshRate(ONCE), resource load failed, completes render task.\n" - "PRE: resources not ready\n" - "POST: Only 1 finished signal sent."); - - // SETUP A CONTINUOUS OFFSCREEN RENDER TASK - application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - drawTrace.Enable(true); - - Actor rootActor = Actor::New(); - Stage::GetCurrent().Add( rootActor ); - - CameraActor offscreenCameraActor = CameraActor::New(); - Stage::GetCurrent().Add( offscreenCameraActor ); - Actor secondRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Stage::GetCurrent().Add(secondRootActor); - - RenderTask newTask = CreateRenderTask(application, offscreenCameraActor, rootActor, secondRootActor, RenderTask::REFRESH_ALWAYS, false); - bool finished = false; - RenderTaskFinished renderTaskFinished( finished ); - newTask.FinishedSignal().Connect( &application, renderTaskFinished ); - application.SendNotification(); - - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - // CHANGE TO RENDER ONCE, - newTask.SetRefreshRate(RenderTask::REFRESH_ONCE); - application.SendNotification(); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); - - FailImageLoad(application, imageRequestId); // Need to run Update again for this to complete - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, false, true, __LINE__ ) ); // nothing to draw - DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, finished, true, false, __LINE__ ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, finished, false, false, __LINE__ ) ); END_TEST; } @@ -3132,7 +2381,7 @@ int UtcDaliRenderTaskOnceChain01(void) tet_infoline("Testing RenderTask Render Once Chained render tasks\n" "SetRefreshRate(ONCE), resource load completes, both render tasks render.\n" - "PRE: resources not ready\n" + "PRE: resources ready\n" "POST: 2 finished signals sent."); // SETUP A CONTINUOUS OFFSCREEN RENDER TASK @@ -3145,10 +2394,7 @@ int UtcDaliRenderTaskOnceChain01(void) CameraActor offscreenCameraActor = CameraActor::New(); Stage::GetCurrent().Add( offscreenCameraActor ); - Actor firstRootActor = CreateLoadingActor(application, "aFile.jpg"); - Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest(); - Integration::ResourceId imageRequestId = imageRequest->GetId(); - Integration::ResourceTypeId imageType = imageRequest->GetType()->id; + Actor firstRootActor = CreateRenderableActorSuccess(application, "aFile.jpg"); Stage::GetCurrent().Add(firstRootActor); // first render task @@ -3168,15 +2414,6 @@ int UtcDaliRenderTaskOnceChain01(void) application.SendNotification(); - // START PROCESS/RENDER Input, Expected Input, Expected - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( firstFinished == false ); - DALI_TEST_CHECK( secondFinished == false ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) ); - DALI_TEST_CHECK( firstFinished == false ); - DALI_TEST_CHECK( secondFinished == false ); - - CompleteImageLoad(application, imageRequestId, imageType); DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) ); DALI_TEST_CHECK( firstFinished == false ); DALI_TEST_CHECK( secondFinished == false ); @@ -3185,7 +2422,7 @@ int UtcDaliRenderTaskOnceChain01(void) DALI_TEST_CHECK( firstFinished == true ); DALI_TEST_CHECK( secondFinished == false ); - DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, secondFinished, true, false, __LINE__ ) ); + DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, secondFinished, true, false, __LINE__ ) ); DALI_TEST_CHECK( secondFinished == true ); END_TEST; diff --git a/automated-tests/src/dali/utc-Dali-ResourceImage.cpp b/automated-tests/src/dali/utc-Dali-ResourceImage.cpp index 8fa32d4..ea95e6f 100644 --- a/automated-tests/src/dali/utc-Dali-ResourceImage.cpp +++ b/automated-tests/src/dali/utc-Dali-ResourceImage.cpp @@ -165,15 +165,11 @@ int UtcDaliResourceImageGetLoadingState01(void) tet_infoline("UtcDaliResourceImageGetLoadingState01"); ResourceImage image = ResourceImage::New(gTestImageFilename); - DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading); - application.SendNotification(); - application.Render(16); + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed); // simulate load success - TestPlatformAbstraction& platform = application.GetPlatform(); - LoadBitmapResource( platform ); - application.Render(16); - application.SendNotification(); + PrepareResourceImage( application, 100u, 100u, Pixel::RGBA8888 ); + image.Reload(); // Test state == ResourceLoadingSucceeded DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded); @@ -195,22 +191,14 @@ int UtcDaliResourceImageGetLoadingState02(void) // initialise handle image = ResourceImage::New(gTestImageFilename); - // Test state == ResourceLoading - DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading); - application.SendNotification(); - application.Render(16); + // Test state == ResourceLoadingFailed + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed); - // simulate load failure - Integration::ResourceRequest* request = application.GetPlatform().GetRequest(); - if(request) - { - application.GetPlatform().SetResourceLoadFailed(request->GetId(), Integration::FailureUnknown); - } - application.Render(16); - application.SendNotification(); + PrepareResourceImage( application, 100u, 100u, Pixel::RGBA8888 ); + image.Reload(); // Test state == ResourceLoadingFailed - DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed); + DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded); END_TEST; } @@ -232,9 +220,11 @@ int UtcDaliResourceImageSignalLoadingFinished(void) SignalLoadFlag = false; + PrepareResourceImage( application, 100u, 100u, Pixel::RGBA8888 ); ResourceImage image = ResourceImage::New(gTestImageFilename); image.LoadingFinishedSignal().Connect( SignalLoadHandler ); + image.Reload(); application.SendNotification(); application.Render(16); diff --git a/automated-tests/src/dali/utc-Dali-Scripting.cpp b/automated-tests/src/dali/utc-Dali-Scripting.cpp index 2bdfdbc..336de3d 100644 --- a/automated-tests/src/dali/utc-Dali-Scripting.cpp +++ b/automated-tests/src/dali/utc-Dali-Scripting.cpp @@ -152,6 +152,7 @@ int UtcDaliScriptingNewImageNegative06(void) map[ "width" ] = "Invalid"; map[ "height" ] = 100; // will give us a valid image + PrepareResourceImage( application, 0u, 100u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_CHECK( image ); ResourceImage resImage = ResourceImage::DownCast( image ); @@ -170,6 +171,7 @@ int UtcDaliScriptingNewImageNegative07(void) map[ "width" ] = 10; map[ "height" ] = "Invalid"; // will give us a valid image + PrepareResourceImage( application, 10u, 0u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_CHECK( image ); ResourceImage resImage = ResourceImage::DownCast( image ); @@ -307,6 +309,7 @@ int UtcDaliScriptingNewImage04P(void) // float width and height map[ "width" ] = (float) 10.0f; map[ "height" ] = (float) 20.0f; + PrepareResourceImage( application, 10u, 20u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_EQUALS( image.GetWidth(), 10u, TEST_LOCATION ); DALI_TEST_EQUALS( image.GetHeight(), 20u, TEST_LOCATION ); @@ -323,6 +326,7 @@ int UtcDaliScriptingNewImage05P(void) // width and height map[ "width"] = 50; map[ "height" ] = 70; + PrepareResourceImage( application, 50u, 70u, Pixel::RGBA8888 ); Image image = NewImage( map ); DALI_TEST_EQUALS( image.GetWidth(), 50u, TEST_LOCATION ); DALI_TEST_EQUALS( image.GetHeight(), 70u, TEST_LOCATION ); @@ -774,6 +778,7 @@ int UtcDaliScriptingCreatePropertyMapImage(void) // Change values { + PrepareResourceImage( application, 300, 400, Pixel::RGBA8888 ); ResourceImage image = ResourceImage::New( "MY_PATH", ImageDimensions( 300, 400 ), FittingMode::FIT_WIDTH ); Property::Map map; diff --git a/dali/devel-api/images/texture-set-image.cpp b/dali/devel-api/images/texture-set-image.cpp index 312e98b..3233d91 100644 --- a/dali/devel-api/images/texture-set-image.cpp +++ b/dali/devel-api/images/texture-set-image.cpp @@ -28,20 +28,25 @@ namespace Dali void TextureSetImage( TextureSet textureSet, size_t index, Image image ) { - // Get implementation of the TextureSet to use. - Internal::TextureSet& internalTextureSet = GetImplementation( textureSet ); - // Check for valid image. if( image ) { - // Get image impl and set in TextureSet. Internal::ImagePtr imagePointer( &GetImplementation( image ) ); - internalTextureSet.SetImage( index, imagePointer ); + Internal::NewTexture* texture = imagePointer->GetTexture(); + if( texture ) + { + GetImplementation( textureSet ).SetTexture( index, texture ); + } + else + { + // Get image impl and set in TextureSet. + GetImplementation( textureSet ).SetImage( index, imagePointer ); + } } else { // No valid image, Remove texture at this index. - internalTextureSet.SetImage( index, NULL ); + GetImplementation( textureSet ).SetImage( index, NULL ); } } diff --git a/dali/integration-api/bitmap.h b/dali/integration-api/bitmap.h index 7518fe9..01b3b4c 100644 --- a/dali/integration-api/bitmap.h +++ b/dali/integration-api/bitmap.h @@ -86,6 +86,12 @@ public: BITMAP_COMPRESSED }; + enum ReleaseFunction + { + FREE, ///< Use free function to release the buffer + DELETE_ARRAY, ///< Use delete[] operator to release the buffer + }; + /** * Create a new instance of a Bitmap with the required profile. * @return Pointer to created Bitmap subclass. Clients should immediately @@ -174,6 +180,12 @@ public: return !(HasAlphaChannel() && mAlphaChannelUsed); } + /** + * Returns which release function has to be called to release the data in the bitmap + * @return FREE if memory has been allocated with malloc DELETE_ARRAY if memory has been allocated with new + */ + virtual ReleaseFunction GetReleaseFunction() = 0; + /**@}*/ ///< End of generic features diff --git a/dali/internal/event/images/bitmap-compressed.h b/dali/internal/event/images/bitmap-compressed.h index 4f8e20c..874e976 100644 --- a/dali/internal/event/images/bitmap-compressed.h +++ b/dali/internal/event/images/bitmap-compressed.h @@ -88,6 +88,11 @@ public: return mBufferSize; } + /** + * See Dali::Integration::Bitmap::GetReleaseFunction() + */ + ReleaseFunction GetReleaseFunction(){ return FREE; } + protected: /** diff --git a/dali/internal/event/images/bitmap-packed-pixel.h b/dali/internal/event/images/bitmap-packed-pixel.h index c6ca538..9a72759 100644 --- a/dali/internal/event/images/bitmap-packed-pixel.h +++ b/dali/internal/event/images/bitmap-packed-pixel.h @@ -120,6 +120,11 @@ public: } /** + * See Dali::Integration::Bitmap::GetReleaseFunction() + */ + ReleaseFunction GetReleaseFunction(){ return FREE; } + + /** * Get the pixel buffer stride. * @return The buffer stride (in bytes). */ diff --git a/dali/internal/event/images/image-impl.cpp b/dali/internal/event/images/image-impl.cpp index e90ffeb..3c41b7f 100644 --- a/dali/internal/event/images/image-impl.cpp +++ b/dali/internal/event/images/image-impl.cpp @@ -109,7 +109,8 @@ Vector2 Image::GetNaturalSize() const } Image::Image() -: mWidth( 0 ), +: mTexture(), + mWidth( 0 ), mHeight( 0 ), mConnectionCount( 0 ) { diff --git a/dali/internal/event/images/image-impl.h b/dali/internal/event/images/image-impl.h index 15eeff2..e6b3af1 100644 --- a/dali/internal/event/images/image-impl.h +++ b/dali/internal/event/images/image-impl.h @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include @@ -93,6 +94,14 @@ public: */ virtual Vector2 GetNaturalSize() const; + /** + * Returns a pointer to the internal texture used by the image + */ + NewTexture* GetTexture() const + { + return mTexture.Get(); + } + public: // From ResourceTicketObserver /** @@ -142,9 +151,10 @@ protected: protected: ResourceTicketPtr mTicket; ///< smart pointer to the ticket object that gets completed when load finishes + NewTexturePtr mTexture; ///< smart pointer to the texture used by the image - mutable unsigned int mWidth; ///< natural width of the image, needs to be mutable for lazy resolving and as the API for GetWidth is const - mutable unsigned int mHeight; ///< natural height of the image, needs to be mutable for lazy resolving and as the API for GetHeight is const + unsigned int mWidth; ///< natural width of the image + unsigned int mHeight; ///< natural height of the image unsigned int mConnectionCount; ///< number of on-stage objects using this image diff --git a/dali/internal/event/images/nine-patch-image-impl.cpp b/dali/internal/event/images/nine-patch-image-impl.cpp index e165330..14c33f4 100644 --- a/dali/internal/event/images/nine-patch-image-impl.cpp +++ b/dali/internal/event/images/nine-patch-image-impl.cpp @@ -189,8 +189,16 @@ NinePatchImage::NinePatchImage( const std::string& filename ) if( resource ) { mBitmap = static_cast( resource.Get()); + mWidth = mBitmap->GetImageWidth(); mHeight = mBitmap->GetImageHeight(); + mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, mBitmap->GetPixelFormat(), mWidth, mHeight ); + + size_t bufferSize = mBitmap->GetBufferSize(); + unsigned char* buffer = new unsigned char[bufferSize]; + memcpy( buffer, mBitmap->GetBuffer(), bufferSize ); + PixelDataPtr pixelData = PixelData::New( buffer, bufferSize, mWidth, mHeight, mBitmap->GetPixelFormat(), Dali::PixelData::DELETE_ARRAY ); + mTexture->Upload( pixelData ); } else { @@ -281,30 +289,6 @@ const std::string& NinePatchImage::GetUrl() const return mUrl; } -void NinePatchImage::Connect() -{ - if( !mTicket ) - { - if( mBitmap ) - { - const ImageTicketPtr& t = mResourceClient->AddBitmapImage(mBitmap.Get()); - mTicket = t.Get(); - mTicket->AddObserver(*this); - } - } - - ++mConnectionCount; -} - -void NinePatchImage::Disconnect() -{ - if( mConnectionCount > 0 ) - { - --mConnectionCount; - } -} - - void NinePatchImage::ParseBorders() { if( !mBitmap ) diff --git a/dali/internal/event/images/nine-patch-image-impl.h b/dali/internal/event/images/nine-patch-image-impl.h index 1d14916..cdcea86 100644 --- a/dali/internal/event/images/nine-patch-image-impl.h +++ b/dali/internal/event/images/nine-patch-image-impl.h @@ -121,18 +121,6 @@ private: // from ResourceImage */ virtual const std::string& GetUrl() const; -protected: // From Resource - /** - * @copydoc Dali::Internal::Image::Connect - */ - virtual void Connect(); - - /** - * @copydoc Dali::Internal::Image::Disconnect - */ - virtual void Disconnect(); - -private: /** * Read the borders of the bitmap and determine the child area * and stretch borders diff --git a/dali/internal/event/images/resource-image-impl.cpp b/dali/internal/event/images/resource-image-impl.cpp index 141a12e..6c9ad3d 100644 --- a/dali/internal/event/images/resource-image-impl.cpp +++ b/dali/internal/event/images/resource-image-impl.cpp @@ -25,10 +25,11 @@ #include #include #include +#include #include -#include #include #include +#include using namespace Dali::Integration; @@ -45,6 +46,7 @@ namespace const char* const SIGNAL_IMAGE_LOADING_FINISHED = "imageLoadingFinished"; + BaseHandle CreateImage() { ImagePtr image = ResourceImage::New(); @@ -59,7 +61,19 @@ Dali::SignalConnectorType signalConnector1( mType, SIGNAL_IMAGE_LOADING_FINISHED ResourceImage::ResourceImage() : Image(), - mImageFactory( ThreadLocalStorage::Get().GetImageFactory() ) + mLoadingFinished(), + mAttributes(), + mUrl(), + mLoadingState( Dali::ResourceLoading ) +{ +} + +ResourceImage::ResourceImage( const std::string& url, const ImageAttributes& attributes) +: Image(), + mLoadingFinished(), + mAttributes(attributes), + mUrl(url), + mLoadingState( Dali::ResourceLoading ) { } @@ -73,22 +87,18 @@ ResourceImagePtr ResourceImage::New() ResourceImagePtr ResourceImage::New( const std::string& url, const ImageAttributes& attributes ) { ResourceImagePtr image; + if( NinePatchImage::IsNinePatchUrl( url ) ) { image = NinePatchImage::New( url ); } else { - image = new ResourceImage(); + image = new ResourceImage(url, attributes); image->Initialize(); - - // consider the requested size as natural size, 0 means we don't (yet) know it - image->mWidth = attributes.GetWidth(); - image->mHeight = attributes.GetHeight(); - image->mRequest = image->mImageFactory.RegisterRequest( url, &attributes ); - image->mTicket = image->mImageFactory.Load( *image->mRequest.Get() ); - image->mTicket->AddObserver( *image ); + image->Reload(); } + DALI_LOG_SET_OBJECT_STRING( image, url ); return image; @@ -96,15 +106,6 @@ ResourceImagePtr ResourceImage::New( const std::string& url, const ImageAttribut ResourceImage::~ResourceImage() { - if( mTicket ) - { - mTicket->RemoveObserver( *this ); - if( Stage::IsInstalled() ) - { - mImageFactory.ReleaseTicket( mTicket.Get() ); - } - mTicket.Reset(); - } } bool ResourceImage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) @@ -126,140 +127,84 @@ bool ResourceImage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterf return connected; } + const ImageAttributes& ResourceImage::GetAttributes() const { - if( mTicket ) - { - return mImageFactory.GetActualAttributes( mTicket ); - } - else - { - return mImageFactory.GetRequestAttributes( mRequest ); - } + return mAttributes; } const std::string& ResourceImage::GetUrl() const { - return mImageFactory.GetRequestPath( mRequest ); + return mUrl; } void ResourceImage::Reload() { - if ( mRequest ) - { - ResourceTicketPtr ticket = mImageFactory.Reload( *mRequest.Get() ); - SetTicket( ticket.Get() ); - } -} - -unsigned int ResourceImage::GetWidth() const -{ - // if width is 0, it means we've not yet loaded the image - if( 0u == mWidth ) - { - Size size; - mImageFactory.GetImageSize( mRequest, mTicket, size ); - mWidth = size.width; - if( 0 == mHeight ) + ThreadLocalStorage& tls = ThreadLocalStorage::Get(); + Integration::PlatformAbstraction& platformAbstraction = tls.GetPlatformAbstraction(); + Integration::BitmapResourceType resourceType( ImageDimensions(mAttributes.GetWidth(), mAttributes.GetHeight()), + mAttributes.GetScalingMode(), + mAttributes.GetFilterMode(), + mAttributes.GetOrientationCorrection() ); + + // Note, bitmap is only destroyed when the image is destroyed. + Integration::ResourcePointer resource = platformAbstraction.LoadResourceSynchronously( resourceType, mUrl ); + if( resource ) + { + Integration::Bitmap* bitmap = static_cast( resource.Get() ); + unsigned width = bitmap->GetImageWidth(); + unsigned height = bitmap->GetImageHeight(); + + //Create texture + Pixel::Format format = bitmap->GetPixelFormat(); + mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, format, width, height ); + + //Upload data to the texture + size_t bufferSize = bitmap->GetBufferSize(); + PixelDataPtr pixelData = PixelData::New( bitmap->GetBufferOwnership(), bufferSize, width, height, format, + static_cast< Dali::PixelData::ReleaseFunction >( bitmap->GetReleaseFunction() ) ); + mTexture->Upload( pixelData ); + + mWidth = mAttributes.GetWidth(); + if( mWidth == 0 ) { - mHeight = size.height; + mWidth = width; } - } - return mWidth; -} -unsigned int ResourceImage::GetHeight() const -{ - if( 0u == mHeight ) - { - Size size; - mImageFactory.GetImageSize( mRequest, mTicket, size ); - mHeight = size.height; - if( 0 == mWidth ) + mHeight = mAttributes.GetHeight(); + if( mHeight == 0 ) { - mWidth = size.width; + mHeight = height; } - } - return mHeight; -} -Vector2 ResourceImage::GetNaturalSize() const -{ - Vector2 naturalSize(mWidth, mHeight); - if( 0u == mWidth || 0u == mHeight ) + mLoadingState = Dali::ResourceLoadingSucceeded; + + } + else { - mImageFactory.GetImageSize( mRequest, mTicket, naturalSize ); - mWidth = naturalSize.width; - mHeight = naturalSize.height; + mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u ); + mWidth = mHeight = 0u; + mLoadingState = Dali::ResourceLoadingFailed; } - return naturalSize; -} -void ResourceImage::ResourceLoadingFailed(const ResourceTicket& ticket) -{ mLoadingFinished.Emit( Dali::ResourceImage( this ) ); } -void ResourceImage::ResourceLoadingSucceeded(const ResourceTicket& ticket) +unsigned int ResourceImage::GetWidth() const { - mLoadingFinished.Emit( Dali::ResourceImage( this ) ); + return mWidth; } -void ResourceImage::Connect() +unsigned int ResourceImage::GetHeight() const { - ++mConnectionCount; - - if( mConnectionCount == 1 ) - { - // ticket was thrown away when related actors went offstage or image loading on demand - if( !mTicket ) - { - DALI_ASSERT_DEBUG( mRequest.Get() ); - ResourceTicketPtr newTicket = mImageFactory.Load( *mRequest.Get() ); - SetTicket( newTicket.Get() ); - } - } + return mHeight; } -void ResourceImage::Disconnect() +Vector2 ResourceImage::GetNaturalSize() const { - if( !mTicket ) - { - return; - } - - DALI_ASSERT_DEBUG( mConnectionCount > 0 ); - --mConnectionCount; - if( mConnectionCount == 0 ) - { - // release image memory when it's not visible anymore (decrease ref. count of texture) - SetTicket( NULL ); - } + return Vector2(mWidth, mHeight); } -void ResourceImage::SetTicket( ResourceTicket* ticket ) -{ - if( ticket == mTicket.Get() ) - { - return; - } - - if( mTicket ) - { - mTicket->RemoveObserver( *this ); - mImageFactory.ReleaseTicket( mTicket.Get() ); - } - - if( ticket ) - { - mTicket.Reset( ticket ); - mTicket->AddObserver( *this ); - } - else - { - mTicket.Reset(); - } -} } // namespace Internal diff --git a/dali/internal/event/images/resource-image-impl.h b/dali/internal/event/images/resource-image-impl.h index aeac5b9..26eb252 100644 --- a/dali/internal/event/images/resource-image-impl.h +++ b/dali/internal/event/images/resource-image-impl.h @@ -63,7 +63,7 @@ public: /** * @copydoc Dali::ResourceImage::GetLoadingState() */ - Dali::LoadingState GetLoadingState() const { return mTicket ? mTicket->GetLoadingState() : ResourceLoading; } + Dali::LoadingState GetLoadingState() const { return mLoadingState; } /** * @copydoc Dali::ResourceImage::LoadingFinishedSignal() @@ -117,27 +117,6 @@ public: */ virtual Vector2 GetNaturalSize() const; - /** - * Indicates that the image is used. - */ - virtual void Connect(); - - /** - * Indicates that the image is not used anymore. - */ - virtual void Disconnect(); - -public: // From ResourceTicketObserver - - /** - * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingFailed() - */ - virtual void ResourceLoadingFailed(const ResourceTicket& ticket); - - /** - * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingSucceeded() - */ - virtual void ResourceLoadingSucceeded(const ResourceTicket& ticket); protected: @@ -151,22 +130,16 @@ protected: */ ResourceImage(); -private: - /** - * Helper method to set new resource ticket. Stops observing current ticket if any, and starts observing - * the new one or just resets the intrusive pointer. - * @param[in] ticket pointer to new resource Ticket or NULL. + * Constructor, with url and attributes */ - void SetTicket( ResourceTicket* ticket ); + ResourceImage( const std::string& url, const ImageAttributes& attributes); private: - - ImageFactory& mImageFactory; - - ImageFactoryCache::RequestPtr mRequest; ///< contains the initially requested attributes for image. Request is reissued when memory was released. - Dali::ResourceImage::ResourceImageSignal mLoadingFinished; + ImageAttributes mAttributes; + std::string mUrl; + Dali::LoadingState mLoadingState; // Changes scope, should be at end of class DALI_LOG_OBJECT_STRING_DECLARATION; -- 2.7.4