/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <test-native-image.h>
// Internal headers are allowed here
-#include <dali/public-api/shader-effects/shader-effect.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/update/resources/bitmap-metadata.h>
+#include <dali/internal/update/resources/texture-metadata.h>
#include <dali/internal/update/resources/resource-manager.h>
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/event/resources/resource-client.h>
#include <dali/internal/event/images/resource-image-impl.h>
#include <dali/integration-api/resource-cache.h>
#include <dali/internal/render/gl-resources/texture-declarations.h>
-#include <dali/internal/render/shaders/shader.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/common/image-attributes.h>
public:
TestTicketObserver()
: mLoadingFailedCalled(0), mLoadingSucceededCalled(0),
- mSavingFailedCalled(0), mSavingSucceededCalled(0),
mUploadedCount(0)
{}
int LoadFailedCalled() {
- tet_printf("TicketObserver: LoadingFailed() called %d times", mLoadingFailedCalled);
+ tet_printf("TicketObserver: LoadingFailed() called %d times\n", mLoadingFailedCalled);
return mLoadingFailedCalled;
}
int LoadSucceededCalled() {
- tet_printf("TicketObserver: LoadingSucceeded() called %d times", mLoadingSucceededCalled);
+ tet_printf("TicketObserver: LoadingSucceeded() called %d times\n", mLoadingSucceededCalled);
return mLoadingSucceededCalled;
}
- int SaveFailedCalled() {
- tet_printf("TicketObserver: SavingFailed() called %d times", mSavingFailedCalled);
- return mSavingFailedCalled;
- }
- int SaveSucceededCalled() {
- tet_printf("TicketObserver: SavingSucceeded() called %d times", mSavingSucceededCalled);
- return mSavingSucceededCalled;
- }
int UploadCalled() {
- tet_printf("TicketObserver: Uploaded() called %d times", mUploadedCount);
+ tet_printf("TicketObserver: Uploaded() called %d times\n", mUploadedCount);
return mUploadedCount;
}
void Reset() {
mLoadingFailedCalled = 0;
mLoadingSucceededCalled = 0;
- mSavingFailedCalled = 0;
- mSavingSucceededCalled = 0;
mUploadedCount = 0;
}
public: // From ResourceTicketObserver
virtual void ResourceLoadingFailed(const Internal::ResourceTicket& ticket) {mLoadingFailedCalled++;}
virtual void ResourceLoadingSucceeded(const Internal::ResourceTicket& ticket) {mLoadingSucceededCalled++;}
- virtual void ResourceSavingFailed(const Internal::ResourceTicket& ticket) {mSavingFailedCalled++;}
- virtual void ResourceSavingSucceeded(const Internal::ResourceTicket& ticket) {mSavingSucceededCalled++;}
virtual void ResourceUploaded(const Internal::ResourceTicket& ticket) {mUploadedCount++;}
private:
int mLoadingFailedCalled;
int mLoadingSucceededCalled;
- int mSavingFailedCalled;
- int mSavingSucceededCalled;
int mUploadedCount;
};
application.SendNotification(); // Flush update messages
application.Render(); // Process resource request
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80,80,80,80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
application.SendNotification(); // Flush update messages
application.Render(); // Process resource request
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, w, h, w, h );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
// Create a resource
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) );
DALI_TEST_CHECK( resourceManager.IsResourceLoaded(req->GetId()) );
- Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(req->GetId());
- DALI_TEST_CHECK( bitmapData.GetWidth() == 80 );
- DALI_TEST_CHECK( bitmapData.GetHeight() == 80 );
+ Internal::TextureMetadata* bitmapData = NULL;
+ DALI_TEST_CHECK( resourceManager.GetTextureMetadata(req->GetId(), bitmapData ) );
+ DALI_TEST_CHECK( bitmapData->GetWidth() == 80 );
+ DALI_TEST_CHECK( bitmapData->GetHeight() == 80 );
DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION );
// Create a new resource - the image size could have changed in the meantime
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 120, 120, 120, 120 );
Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
DALI_TEST_CHECK( req->GetId() == ticket->GetId() );
application.GetPlatform().SetResourceLoaded(id, Integration::ResourceBitmap, resourcePtr2);
- application.Render(0); // Process update messages / UpdateCache
+ application.Render(0 , TEST_LOCATION ); // Process update messages / UpdateCache
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) );
DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id));
- Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(id);
- DALI_TEST_CHECK( bitmapData.GetWidth() == 120 );
- DALI_TEST_CHECK( bitmapData.GetHeight() == 120 );
+ Internal::TextureMetadata* bitmapData = NULL;
+ DALI_TEST_CHECK( resourceManager.GetTextureMetadata(req->GetId(), bitmapData ) );
+ DALI_TEST_CHECK( bitmapData->GetWidth() == 120 );
+ DALI_TEST_CHECK( bitmapData->GetHeight() == 120 );
// Ticket can't have been updated yet - it should still have old values
DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION );
application.SendNotification(); // Process event messages
- application.Render(0); // Process update messages / UpdateCache
+ application.Render(0, TEST_LOCATION ); // Process update messages / UpdateCache
application.SendNotification(); // Process event messages
DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 2, TEST_LOCATION );
- DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 1, TEST_LOCATION );
DALI_TEST_EQUALS( ticket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetWidth(), 120, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 120, TEST_LOCATION );
} // Discard ticket
application.SendNotification(); // Flush update queue (with ticket discarded message
- application.Render(1); // Process update messages
+ application.Render(1, TEST_LOCATION ); // Process update messages
application.SendNotification(); // Send event notifications
- application.Render(1); // Process update messages
// Resource should have been discarded.
DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::CancelLoadFunc ) );
DALI_TEST_EQUALS( testTicketObserver.LoadSucceededCalled(), 2, TEST_LOCATION );
DALI_TEST_EQUALS( testTicketObserver.LoadFailedCalled(), 0, TEST_LOCATION );
- DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 1, TEST_LOCATION );
END_TEST;
}
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) );
// Create a resource
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
application.Render(0);
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) );
DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id));
- Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(id);
- DALI_TEST_CHECK( bitmapData.GetWidth() == 80 );
- DALI_TEST_CHECK( bitmapData.GetHeight() == 80 );
+ Internal::TextureMetadata* bitmapData = NULL;
+ DALI_TEST_CHECK( resourceManager.GetTextureMetadata(req->GetId(), bitmapData ) );
+ DALI_TEST_CHECK( bitmapData->GetWidth() == 80 );
+ DALI_TEST_CHECK( bitmapData->GetHeight() == 80 );
DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION );
DALI_TEST_EQUALS( testTicketObserver.UploadCalled(), 0, TEST_LOCATION );
DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id));
- bitmapData = resourceManager.GetBitmapMetadata(id);
- DALI_TEST_CHECK( bitmapData.GetWidth() == 80 );
- DALI_TEST_CHECK( bitmapData.GetHeight() == 80 );
+ DALI_TEST_CHECK( resourceManager.GetTextureMetadata(req->GetId(), bitmapData ) );
+ DALI_TEST_CHECK( bitmapData->GetWidth() == 80 );
+ DALI_TEST_CHECK( bitmapData->GetHeight() == 80 );
DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION );
// Create a resource
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 80, 80, 80, 80 );
Integration::ResourcePointer resourcePtr(bitmap); // reference it
DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetResourcesFunc ) );
DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id));
- Internal::BitmapMetadata bitmapData = resourceManager.GetBitmapMetadata(id);
- DALI_TEST_CHECK( bitmapData.GetWidth() == 80 );
- DALI_TEST_CHECK( bitmapData.GetHeight() == 80 );
+ Internal::TextureMetadata* bitmapData = NULL;
+ DALI_TEST_CHECK( resourceManager.GetTextureMetadata(req->GetId(), bitmapData ) );
+ DALI_TEST_CHECK( bitmapData->GetWidth() == 80 );
+ DALI_TEST_CHECK( bitmapData->GetHeight() == 80 );
DALI_TEST_EQUALS( imageTicket->GetWidth(), 0, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 0, TEST_LOCATION );
// Create a new resource - the image size could have changed in the meantime
req = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 120, 120, 120, 120 );
Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
DALI_TEST_CHECK( req->GetId() == id );
application.Render(0); // Process update messages / UpdateCache
DALI_TEST_CHECK( resourceManager.IsResourceLoaded(id));
- bitmapData = resourceManager.GetBitmapMetadata(id);
- DALI_TEST_CHECK( bitmapData.GetWidth() == 120 );
- DALI_TEST_CHECK( bitmapData.GetHeight() == 120 );
+ DALI_TEST_CHECK( resourceManager.GetTextureMetadata(req->GetId(), bitmapData ) );
+ DALI_TEST_CHECK( bitmapData->GetWidth() == 120 );
+ DALI_TEST_CHECK( bitmapData->GetHeight() == 120 );
DALI_TEST_EQUALS( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS( imageTicket->GetHeight(), 80, TEST_LOCATION );
END_TEST;
}
-/**
-//int UtcDaliInternalSaveResource01(void)//
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with valid id, and valid filename");
- testTicketObserver.Reset();
-
- DALI_TEST_CHECK(0);
- END_TEST;
-}
-
-
-//int UtcDaliInternalSaveResource02(void)//
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with invalid id");
- testTicketObserver.Reset();
-
- DALI_TEST_CHECK(0);
- END_TEST;
-}
-
-//int UtcDaliInternalSaveResource03(void)//
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with invalid id");
- testTicketObserver.Reset();
-
- DALI_TEST_CHECK ( 0 );
- END_TEST;
-}
-
-
-//int UtcDaliInternalSaveResource04(void)//
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with valid id, but invalid filename");
- testTicketObserver.Reset();
- DALI_TEST_CHECK( 0 );
- END_TEST;
-}
-*/
-
-int UtcDaliInternalSaveResource05(void)
-{
- TestApplication application;
- tet_infoline("Testing SaveResource() with valid id, but invalid resource type");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- // First, load a bitmap resource
- Internal::ResourceTicketPtr ticket = CheckLoadBitmap(application, "bitmap.jpg", 80, 80);
-
- // Try saving it
- resourceClient.SaveResource( ticket, "bitmap.png" );
- application.SendNotification(); // Flush update messages
- application.Render(); // Process save resource request
-
- DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) );
- END_TEST;
-}
-
int UtcDaliInternalRequestResourceTicket01(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliInternalLoadShaderRequest01(void)
-{
- TestApplication application;
- tet_infoline("Testing LoadShader() success");
- testTicketObserver.Reset();
-
- // Clear through all of the outstanding shader load requests from the default shader effect
- std::vector< unsigned char > buffer;
- for( int i=0; i<10; i++ )
- {
- buffer.push_back((unsigned char)i);
- }
- application.GetPlatform().SetLoadFileResult( true, buffer );
- application.GetGlAbstraction().SetLinkStatus(1);
- application.SendNotification(); // Flush update messages
- application.Render(); // Process load shader request (immediately)
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
-
- Integration::ShaderResourceType shaderRequest(123, "vertex src", "frag src");
- std::string shaderBinaryFile("shader.bin");
- Internal::ResourceTicketPtr ticket = resourceClient.LoadShader(shaderRequest, shaderBinaryFile);
- DALI_TEST_CHECK( ticket );
-
- application.GetPlatform().SetLoadFileResult( true, buffer );
- application.GetGlAbstraction().EnableShaderCallTrace( true );
- application.GetGlAbstraction().SetLinkStatus(1);
-
- application.SendNotification(); // Flush update messages
- application.Render(); // Process load shader request (immediately)
-
- application.SendNotification();
- application.Render();
-
- application.SendNotification();
- application.Render();
-
- // If shader program loads OK, we shouldn't see any calls to CompileShader or SaveResource
- TraceCallStack& shaderTrace = application.GetGlAbstraction().GetShaderTrace();
- DALI_TEST_CHECK( ! shaderTrace.FindMethod("CompileShader") );
-
- // Ensure no request sent to platform abstraction
- DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::SaveResourceFunc ) );
- END_TEST;
-}
-
-int UtcDaliInternalAllocateBitmapImage01(void)
-{
- TestApplication application;
- tet_infoline("Testing AllocateBitmapImage()");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Internal::ImageTicketPtr imageTicket = resourceClient.AllocateBitmapImage(80, 80, 80, 80, Pixel::RGB565);
- imageTicket->AddObserver( testTicketObserver );
-
- DALI_TEST_CHECK( imageTicket );
- DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
-
- application.SendNotification(); // Flush update queue
- application.Render(0); // Process message
- application.SendNotification(); // Send message to tickets
-
- DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
- DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
-
- Integration::Bitmap* bitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK ( bitmap != NULL );
- DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGB565, TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliInternalAddBitmapImage01(void)
{
TestApplication application;
tet_infoline("Testing AddBitmap with reserved buffer()");
testTicketObserver.Reset();
Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGB565, 80, 80, 80, 80 );
Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap );
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
-
- Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK ( theBitmap != NULL );
- DALI_TEST_CHECK ( bitmap == theBitmap );
- DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGB565, TEST_LOCATION );
END_TEST;
}
tet_infoline("Testing AddBitmap without reserved buffer()");
testTicketObserver.Reset();
Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap );
DALI_TEST_CHECK( imageTicket );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 0, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 0, TEST_LOCATION );
DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
-
- Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK ( theBitmap != NULL );
- DALI_TEST_CHECK ( bitmap == theBitmap );
- DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
-
- // There is no way for the ticket's image attributes to be updated if the bitmap
- // reserves a buffer after ticket generation.
- // Probably not an issue - there is no public API in BufferImage to change the image size.
END_TEST;
}
END_TEST;
}
-int UtcDaliInternalGetBitmapImage01(void)
-{
- TestApplication application;
- tet_infoline("Testing GetBitmap() with valid ticket");
- testTicketObserver.Reset();
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
- bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 20, 20, 80, 80 );
- Internal::ImageTicketPtr imageTicket = resourceClient.AddBitmapImage( bitmap );
-
- Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK ( theBitmap != NULL );
- DALI_TEST_CHECK ( bitmap == theBitmap );
- DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 20u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 20u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
-
- imageTicket->AddObserver( testTicketObserver );
- application.SendNotification(); // Flush update queue
- application.Render(0); // Process message
- application.SendNotification(); // Send message to tickets
-
- theBitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK ( theBitmap != NULL );
- DALI_TEST_CHECK ( bitmap == theBitmap );
- DALI_TEST_EQUALS ( bitmap->GetImageWidth(), 20u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetImageHeight(), 20u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferWidth(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPackedPixelsProfile()->GetBufferHeight(), 80u, TEST_LOCATION );
- DALI_TEST_EQUALS ( bitmap->GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliInternalGetBitmapImage02(void)
-{
- TestApplication application;
- tet_infoline("Testing GetBitmap() with invalid ticket");
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Internal::ImageTicketPtr imageTicket;
- Integration::Bitmap* theBitmap = NULL;
- bool exceptionRaised = false;
- try
- {
- theBitmap = resourceClient.GetBitmap(imageTicket);
- } catch (DaliException& e)
- {
- exceptionRaised = true;
- }
- DALI_TEST_CHECK( exceptionRaised );
- DALI_TEST_CHECK( ! theBitmap );
- END_TEST;
-}
-
-int UtcDaliInternalGetBitmapImage03(void)
-{
- TestApplication application;
- tet_infoline("Testing GetBitmap() with valid ticket for incorrect type");
-
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient(); Internal::ResourceTicketPtr imageTicket = CheckLoadBitmap( application, "Stuff.png", 100, 100 );
-
- Integration::Bitmap* theBitmap = NULL;
- theBitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK( ! theBitmap );
-
- END_TEST;
-}
-
int UtcDaliInternalAllocateTexture01(void)
{
TestApplication application;
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
-
- Integration::Bitmap* theBitmap = NULL;
- theBitmap = resourceClient.GetBitmap(imageTicket);
-
- DALI_TEST_CHECK ( theBitmap == NULL );
END_TEST;
}
testTicketObserver.Reset();
Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Internal::ImageTicketPtr imageTicket = resourceClient.AddFrameBufferImage(80, 80, Pixel::A8 );
+ Internal::ImageTicketPtr imageTicket = resourceClient.AddFrameBufferImage(80, 80, Pixel::A8, RenderBuffer::COLOR );
DALI_TEST_CHECK( imageTicket );
imageTicket->AddObserver( testTicketObserver );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
-
- Integration::Bitmap* theBitmap = NULL;
- theBitmap = resourceClient.GetBitmap(imageTicket);
- DALI_TEST_CHECK ( theBitmap == NULL );
- END_TEST;
-}
-
-int UtcDaliInternalAllocateMesh01(void)
-{
- TestApplication application;
- tet_infoline("Testing AllocateMesh() with vald mesh data");
-
- MeshData publicMeshData;
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices faces;
- BoneContainer bones;
- ConstructVertices(vertices, 60);
- ConstructFaces(vertices, faces);
- Material customMaterial = ConstructMaterial();
- publicMeshData.SetData(vertices, faces, bones, customMaterial);
- publicMeshData.SetHasNormals(true);
- publicMeshData.SetHasTextureCoords(true);
-
- testTicketObserver.Reset();
- Internal::ResourceClient& resourceClient = Internal::ThreadLocalStorage::Get().GetResourceClient();
- Internal::OwnerPointer<Internal::MeshData> meshDataPtr( new Internal::MeshData( publicMeshData, ResourcePolicy::DISCARD, true ) );
- Internal::ResourceTicketPtr meshTicket = resourceClient.AllocateMesh(meshDataPtr);
- DALI_TEST_CHECK( meshTicket );
- meshTicket->AddObserver( testTicketObserver );
-
- DALI_TEST_EQUALS ( meshTicket->GetLoadingState(), ResourceLoading, TEST_LOCATION );
-
- application.SendNotification(); // Flush update queue
- application.Render(0); // Process message
- application.SendNotification(); // Send message to tickets
-
- DALI_TEST_EQUALS ( meshTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
END_TEST;
}