DALI_TEST_EQUALS( ticket, ticket3, TEST_LOCATION );
// request differs in scaled size - not default size
- ImageAttributes attr = ImageAttributes::New( 80, 160, Pixel::BGR8888 );
+ ImageAttributes attr = ImageAttributes::New( 80, 160);
req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr );
ResourceTicketPtr ticket4 = imageFactory.Load( *req2.Get() );
DALI_TEST_CHECK( req != req2 );
ImageFactory& imageFactory = Internal::ThreadLocalStorage::Get().GetImageFactory();
- ImageAttributes attr = ImageAttributes::New( 80, 160, Pixel::BGR8888 );
+ ImageAttributes attr = ImageAttributes::New( 80, 160 );
RequestPtr req = imageFactory.RegisterRequest( gTestImageFilename, &attr );
- ImageAttributes attr2 = ImageAttributes::New( 80, 160, Pixel::BGR8888 );
+ ImageAttributes attr2 = ImageAttributes::New( 80, 160 );
RequestPtr req2 = imageFactory.RegisterRequest( gTestImageFilename, &attr2 );
DALI_TEST_EQUALS( req, req2, TEST_LOCATION );
END_TEST;
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION );
application.SendNotification(); // Flush update queue
application.Render(0); // Process message
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION );
Integration::Bitmap* bitmap = resourceClient.GetBitmap(imageTicket);
DALI_TEST_CHECK ( bitmap != NULL );
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION );
application.SendNotification(); // Flush update queue
application.Render(0); // Process message
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGB565, TEST_LOCATION );
Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket);
DALI_TEST_CHECK ( theBitmap != NULL );
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 0, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 0, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
application.SendNotification(); // Flush update queue
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 0, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 0, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION );
DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
Integration::Bitmap* theBitmap = resourceClient.GetBitmap(imageTicket);
DALI_TEST_EQUALS ( imageTicket->GetWidth(), 80, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetHeight(), 80, TEST_LOCATION );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::A8, TEST_LOCATION );
DALI_TEST_EQUALS ( imageTicket->GetLoadingState(), ResourceLoadingSucceeded, TEST_LOCATION );
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 );
- DALI_TEST_EQUALS ( imageTicket->GetAttributes().GetPixelFormat(), Pixel::A8, TEST_LOCATION );
DALI_TEST_CHECK ( 0 == testTicketObserver.LoadSucceededCalled() ); // Check no message was sent
Integration::Bitmap* theBitmap = NULL;
utc-Dali-Model.cpp
utc-Dali-MouseWheelEvent.cpp
utc-Dali-Mutex.cpp
+ utc-Dali-NativeImage.cpp
utc-Dali-NinePatchImages.cpp
utc-Dali-ObjectRegistry.cpp
utc-Dali-PanGesture.cpp
utc-Dali-RenderTask.cpp
utc-Dali-RenderTaskList.cpp
utc-Dali-RenderableActor.cpp
+ utc-Dali-ResourceImage.cpp
utc-Dali-ShaderEffect.cpp
utc-Dali-Scripting.cpp
utc-Dali-SignalTemplatesFunctors.cpp
*/
// INTERNAL INCLUDES
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
namespace Dali
{
class TestNativeImage;
typedef IntrusivePtr<TestNativeImage> TestNativeImagePointer;
-class DALI_IMPORT_API TestNativeImage : public Dali::NativeImage
+class DALI_IMPORT_API TestNativeImage : public Dali::NativeImageInterface
{
public:
static TestNativeImagePointer New(int width, int height);
inline virtual void PrepareTexture() {};
inline virtual unsigned int GetWidth() const {return mWidth;};
inline virtual unsigned int GetHeight() const {return mHeight;};
- inline virtual Pixel::Format GetPixelFormat() const {return Pixel::RGBA8888;};
+ inline virtual bool RequiresBlending() const {return true;};
private:
TestNativeImage(int width, int height);
#include <stdlib.h>
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
+#include <test-native-image.h>
using std::max;
using namespace Dali;
END_TEST;
}
+int UtcDaliFrameBufferImageNew02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliFrameBufferImageNew02 - FrameBufferImage::New(NativeImageInterface&)");
+
+ // invoke default handle constructor
+ FrameBufferImage image;
+ TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
+
+ DALI_TEST_CHECK( !image );
+
+ // initialise handle
+ image = FrameBufferImage::New(*(nativeImage.Get()));
+
+ DALI_TEST_CHECK( image );
+ END_TEST;
+}
+
int UtcDaliFrameBufferImageDownCast(void)
{
TestApplication application;
static const char* gTestImageFilename = "icon_wrt.png";
-
-// 1.1
-int UtcDaliImageNew01(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageNew01 - Image::New(const std::string&)");
-
- // invoke default handle constructor
- Image image;
-
- DALI_TEST_CHECK( !image );
-
- // initialise handle
- image = ResourceImage::New(gTestImageFilename);
-
- DALI_TEST_CHECK( image );
- END_TEST;
-}
-
-// 1.2
-int UtcDaliImageNew02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageNew02 - Image::New(const std::string&, const ImageAttributes&)");
-
- // invoke default handle constructor
- Image image;
-
- DALI_TEST_CHECK( !image );
-
- // initialise handle
- Dali::ImageAttributes imageAttributes;
- imageAttributes.SetSize(128, 256);
- imageAttributes.SetScalingMode(Dali::ImageAttributes::FitHeight);
- image = ResourceImage::New(gTestImageFilename, imageAttributes);
-
- DALI_TEST_CHECK( image );
- END_TEST;
-}
-
-// 1.3
-int UtcDaliImageNew03(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageNew03 - Image::New(NativeImage&)");
-
- // invoke default handle constructor
- Image image;
- TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
-
- DALI_TEST_CHECK( !image );
-
- // initialise handle
- image = Image::New(*(nativeImage.Get()));
-
- DALI_TEST_CHECK( image );
- END_TEST;
-}
-
-// 1.4
-int UtcDaliImageNewWithPolicies01(void)
+namespace
{
- TestApplication application;
-
- // testing delayed loading
- tet_infoline("UtcDaliImageNewWithPolicies01 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Never");
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- Image image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
-
- DALI_TEST_CHECK( image );
-
- application.SendNotification();
- application.Render(16);
-
- // request file loading only when actor added to stage
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- ImageActor actor = ImageActor::New(image);
-
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- // testing ReleasePolicy::Never
- // fake loading image
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // never discard texture
- Stage::GetCurrent().Remove(actor);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
- END_TEST;
-}
-
-// 1.5
-int UtcDaliImageNewWithPolicies02(void)
+void LoadBitmapResource(TestPlatformAbstraction& platform)
{
- TestApplication application;
- const Vector2 closestImageSize( 80, 45);
- application.GetPlatform().SetClosestImageSize(closestImageSize);
-
- // testing resource deletion when taken off stage
- tet_infoline("UtcDaliImageNewWithPolicies02 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Unused");
-
- Image image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::UNUSED);
-
- DALI_TEST_CHECK( image );
-
- application.SendNotification();
- application.Render(16);
-
- // request file loading only when actor added to stage
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- ImageActor actor = ImageActor::New(image);
-
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- // testing ReleasePolicy::Unused
- // fake loading image
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ Integration::ResourceRequest* request = platform.GetRequest();
Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
if(request)
{
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
+ platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
}
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // discard texture when actor comes off stage
- Stage::GetCurrent().Remove(actor);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
- END_TEST;
}
-// 1.6
-int UtcDaliImageNewWithPolicies03(void)
-{
- TestApplication application;
- const Vector2 closestImageSize( 80, 45);
- application.GetPlatform().SetClosestImageSize(closestImageSize);
-
- // load immediately -> resource deletion when taken off stage -> put actor back on stage -> load resource again
- tet_infoline("UtcDaliImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Unused");
-
- Image image = ResourceImage::New(gTestImageFilename, ResourceImage::IMMEDIATE, Image::UNUSED);
-
- DALI_TEST_CHECK( image );
-
- application.SendNotification();
- application.Render(16);
-
- // request file loading immediately
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- ImageActor actor = ImageActor::New(image);
-
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- // testing ReleasePolicy::Unused
- // fake loading image
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // discard texture when actor comes off stage
- Stage::GetCurrent().Remove(actor);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // check load request when actor added back to stage
- application.GetPlatform().ResetTrace();
-
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- END_TEST;
}
-// 1.7
-int UtcDaliImageNewWithPolicies04(void)
-{
- TestApplication application;
-
- // load immediately, don't release texture when off stage
- tet_infoline("UtcDaliImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Never");
-
- Image image = ResourceImage::New(gTestImageFilename, ResourceImage::IMMEDIATE, Image::NEVER);
-
- DALI_TEST_CHECK( image );
-
- application.SendNotification();
- application.Render(16);
-
- // request file loading immediately
- DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- ImageActor actor = ImageActor::New(image);
-
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- // testing ReleasePolicy::Never
- // fake loading image
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // texture is not discarded
- Stage::GetCurrent().Remove(actor);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // no load request when actor added back to stage
- application.GetPlatform().ResetTrace();
-
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_CHECK( !application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- END_TEST;
-}
-
-// 1.8
int UtcDaliImageDownCast(void)
{
TestApplication application;
END_TEST;
}
-// 1.9
-int UtcDaliImageGetImageSize(void)
-{
- TestApplication application;
- TestPlatformAbstraction& platform = application.GetPlatform();
-
- tet_infoline("UtcDaliImageGetImageSize - Image::GetImageSize()");
-
- Vector2 testSize(8.0f, 16.0f);
- platform.SetClosestImageSize(testSize);
-
- Vector2 size = ResourceImage::GetImageSize(gTestImageFilename);
-
- DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethod("GetClosestImageSize"));
- DALI_TEST_EQUALS( size, testSize, TEST_LOCATION);
- END_TEST;
-}
-
-// 1.10
-int UtcDaliImageGetUrl(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageGetFilename");
-
- // invoke default handle constructor
- ResourceImage image;
-
- DALI_TEST_CHECK( !image );
-
- // initialise handle
- image = ResourceImage::New(gTestImageFilename);
-
- DALI_TEST_EQUALS( image.GetUrl(), gTestImageFilename, TEST_LOCATION);
- END_TEST;
-}
-
-// 1.11
-int UtcDaliImageGetLoadingState01(void)
-{
- TestApplication application;
- tet_infoline("UtcDaliImageGetLoadingState01");
-
- ResourceImage image = ResourceImage::New(gTestImageFilename);
- DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading);
- application.SendNotification();
- application.Render(16);
-
- // simulate load success
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
- application.Render(16);
- application.SendNotification();
-
- // Test state == ResourceLoadingSucceeded
- DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded);
- END_TEST;
-}
-
-// 1.12
-int UtcDaliImageGetLoadingState02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageGetLoadingState02");
-
- // invoke default handle constructor
- ResourceImage image;
-
- DALI_TEST_CHECK( !image );
-
- // initialise handle
- image = ResourceImage::New(gTestImageFilename);
-
- // Test state == ResourceLoading
- DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading);
- application.SendNotification();
- application.Render(16);
-
- // simulate load failure
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- if(request)
- {
- application.GetPlatform().SetResourceLoadFailed(request->GetId(), Integration::FailureUnknown);
- }
- application.Render(16);
- application.SendNotification();
-
- // Test state == ResourceLoadingFailed
- DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed);
- END_TEST;
-}
-
-// 1.13
int UtcDaliImageGetReleasePolicy(void)
{
TestApplication application;
END_TEST;
}
-// 1.14
-int UtcDaliImageGetLoadPolicy(void)
+int UtcDaliImageGetWidthHeight(void)
{
TestApplication application;
- tet_infoline("UtcDaliImageGetLoadPolicy");
-
- ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
+ tet_infoline("UtcDaliImageGetWidthHeight - Image::GetWidth() & Image::GetHeight");
- DALI_TEST_CHECK( image );
+ Vector2 testSize(8.0f, 16.0f);
+ application.GetPlatform().SetClosestImageSize(testSize);
+ Image image1 = ResourceImage::New(gTestImageFilename);
+ DALI_TEST_EQUALS( image1.GetWidth(), testSize.width, TEST_LOCATION );
+ DALI_TEST_EQUALS( image1.GetHeight(), testSize.height, TEST_LOCATION );
- DALI_TEST_CHECK( ResourceImage::ON_DEMAND == image.GetLoadPolicy());
- END_TEST;
-}
+ Dali::ImageAttributes imageAttributes;
+ imageAttributes.SetSize(128, 256);
+ imageAttributes.SetScalingMode(Dali::ImageAttributes::FitHeight);
+ Image image2 = ResourceImage::New(gTestImageFilename, imageAttributes);
+ DALI_TEST_EQUALS( image2.GetWidth(), 128u, TEST_LOCATION );
+ DALI_TEST_EQUALS( image2.GetHeight(), 256u, TEST_LOCATION );
-static bool SignalLoadFlag = false;
+ Image image3 = FrameBufferImage::New(16, 32);
+ DALI_TEST_EQUALS(image3.GetWidth(), 16u, TEST_LOCATION);
+ DALI_TEST_EQUALS(image3.GetHeight(), 32u, TEST_LOCATION);
-static void SignalLoadHandler(ResourceImage image)
-{
- tet_infoline("Received image load finished signal");
+ TestNativeImagePointer nativeImage = TestNativeImage::New(32, 64);
+ Image image4 = NativeImage::New(*(nativeImage.Get()));
+ DALI_TEST_EQUALS(image4.GetWidth(), 32u, TEST_LOCATION);
+ DALI_TEST_EQUALS(image4.GetHeight(), 64u, TEST_LOCATION);
- SignalLoadFlag = true;
+ END_TEST;
}
static bool SignalUploadedFlag = false;
SignalUploadedFlag = true;
}
-// 1.15
-int UtcDaliImageSignalLoadingFinished(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageSignalLoadingFinished");
-
- SignalLoadFlag = false;
-
- ResourceImage image = ResourceImage::New(gTestImageFilename);
-
- image.LoadingFinishedSignal().Connect( SignalLoadHandler );
- application.SendNotification();
- application.Render(16);
-
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD)));
- }
-
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( SignalLoadFlag == true );
- END_TEST;
-}
-
-// 1.16
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);
- application.GetPlatform().SetClosestImageSize(testSize);
+ platform.SetClosestImageSize(testSize);
ResourceImage image = ResourceImage::New(gTestImageFilename);
- image.LoadingFinishedSignal().Connect( SignalLoadHandler );
// Load image
application.SendNotification();
std::vector<GLuint> ids;
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ Integration::ResourceRequest* request = platform.GetRequest();
Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
Integration::ResourcePointer resource(bitmap);
bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
+
if(request)
{
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
+ platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
}
application.Render(16);
application.SendNotification();
application.Render(16);
application.SendNotification();
- DALI_TEST_CHECK( SignalLoadFlag == true );
DALI_TEST_CHECK( SignalUploadedFlag == true );
- SignalLoadFlag = false;
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();
- DALI_TEST_CHECK( SignalLoadFlag == true );
+ //upload
application.Render(16);
application.SendNotification();
application.Render(16);
END_TEST;
}
-// 1.17
int UtcDaliImageDiscard01(void)
{
TestApplication application;
std::vector<GLuint> ids;
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ LoadBitmapResource( platform );
application.Render(16);
application.SendNotification();
} // Drop image handle
END_TEST;
}
-// 1.18
int UtcDaliImageDiscard02(void)
{
TestApplication application;
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ LoadBitmapResource( platform );
application.Render(16);
application.SendNotification();
DALI_TEST_CHECK( application.GetGlAbstraction().GetTextureTrace().FindMethod("BindTexture") );
END_TEST;
}
-// 1.19
int UtcDaliImageDiscard03(void)
{
TestApplication application;
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
-
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ LoadBitmapResource( platform );
application.Render(16);
application.SendNotification();
application.SendNotification();
END_TEST;
}
-
-namespace
-{
-void LoadBitmapResource(TestPlatformAbstraction& platform)
-{
- Integration::ResourceRequest* request = platform.GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
- if(request)
- {
- platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
-}
-
-}
-
int UtcDaliImageContextLoss(void)
{
TestApplication application; // Default config: DALI_DISCARDS_ALL_DATA
imageAttributesHeight.SetSize(Size(1,2));
DALI_TEST_CHECK(imageAttributes < imageAttributesHeight);
- ImageAttributes imageAttributesFormat;
- imageAttributesFormat.SetPixelFormat(Pixel::BGRA8888);
- DALI_TEST_CHECK(imageAttributes < imageAttributesFormat);
ImageAttributes imageAttributesScaling;
imageAttributesScaling.SetScalingMode(ImageAttributes::FitHeight);
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <algorithm>
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <test-native-image.h>
+
+using namespace Dali;
+
+void utc_dali_native_image_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_native_image_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliNativeImageNew(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliNativeImageNew - NativeImage::New(NativeImageInterface&)");
+
+ // invoke default handle constructor
+ NativeImage image;
+ TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
+
+ DALI_TEST_CHECK( !image );
+
+ // initialise handle
+ image = NativeImage::New(*(nativeImage.Get()));
+
+ DALI_TEST_CHECK( image );
+ END_TEST;
+}
+
+int UtcDaliNativeImageDownCast(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::Image::DownCast()");
+
+ TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
+ NativeImage image = NativeImage::New(*(nativeImage.Get()));
+
+ BaseHandle object(image);
+
+ NativeImage image2 = NativeImage::DownCast(object);
+ DALI_TEST_CHECK(image2);
+
+ NativeImage image3 = DownCast< NativeImage >(object);
+ DALI_TEST_CHECK(image3);
+
+ BaseHandle unInitializedObject;
+ NativeImage image4 = NativeImage::DownCast(unInitializedObject);
+ DALI_TEST_CHECK(!image4);
+
+ NativeImage image5 = DownCast< NativeImage >(unInitializedObject);
+ DALI_TEST_CHECK(!image5);
+
+ Image image6 = NativeImage::New(*(nativeImage.Get()));
+ NativeImage image7 = NativeImage::DownCast(image6);
+ DALI_TEST_CHECK(image7);
+ END_TEST;
+}
#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
#include <dali/integration-api/debug.h>
+#include <test-native-image.h>
#define BOOLSTR(x) ((x)?"T":"F")
namespace // unnamed namespace
{
-class TestNativeImage : public NativeImage
-{
-public:
- int mWidth;
- int mHeight;
- TestNativeImage(int width, int height)
- : mWidth(width),
- mHeight(height)
- {}
-
- virtual bool GlExtensionCreate() {return true;};
-
- /**
- * Destroy the GL resource for the NativeImage.
- * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
- * @pre There is a GL context for the current thread.
- */
- virtual void GlExtensionDestroy() {};
-
- /**
- * Use the NativeImage as a texture for rendering
- * @pre There is a GL context for the current thread.
- * @return A GL error code
- */
- virtual unsigned int TargetTexture() {return 0;};
-
- /**
- * Called in each NativeTexture::Bind() call to allow implementation specific operations.
- * The correct texture sampler has already been bound before the function gets called.
- * @pre glAbstraction is being used by context in current thread
- */
- virtual void PrepareTexture() {}
-
- /**
- * Returns the width of the NativeImage
- * @return width
- */
- virtual unsigned int GetWidth() const {return mWidth;}
-
- /**
- * Returns the height of the NativeImage
- * @return height
- */
- virtual unsigned int GetHeight() const {return mHeight;}
-
- /**
- * Returns the internal pixel NativeImage::PixelFormat of the NativeImage
- * @return pixel format
- */
- virtual Pixel::Format GetPixelFormat() const { return Pixel::RGBA8888; }
-protected:
- ~TestNativeImage(){}
-};
-
-
const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
/*
FrameBufferImage frameBufferImage;
if( glSync )
{
- NativeImagePtr testNativeImagePtr = new TestNativeImage(10, 10);
- frameBufferImage= FrameBufferImage::New( *testNativeImagePtr.Get() );
+ NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
+ frameBufferImage= FrameBufferImage::New( *(testNativeImagePtr.Get()) );
}
else
{
Stage::GetCurrent().Add( rootActor );
RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- NativeImagePtr testNativeImagePtr = new TestNativeImage(10, 10);
+ NativeImageInterfacePtr testNativeImagePtr = TestNativeImage::New(10, 10);
FrameBufferImage frameBufferImage = FrameBufferImage::New( *testNativeImagePtr.Get() );
// Flush all outstanding messages
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <algorithm>
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+void utc_dali_resource_image_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_resource_image_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+static const char* gTestImageFilename = "icon_wrt.png";
+
+namespace
+{
+
+void LoadBitmapResource(TestPlatformAbstraction& platform)
+{
+ Integration::ResourceRequest* request = platform.GetRequest();
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
+ Integration::ResourcePointer resource(bitmap);
+ bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
+
+ if(request)
+ {
+ platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
+ }
+}
+
+} // namespace
+
+
+// 1.1
+int UtcDaliResourceImageNew01(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliResourceImageNew01 - ResourceImage::New(const std::string&)");
+
+ // invoke default handle constructor
+ ResourceImage image;
+
+ DALI_TEST_CHECK( !image );
+
+ // initialise handle
+ image = ResourceImage::New(gTestImageFilename);
+
+ DALI_TEST_CHECK( image );
+ END_TEST;
+}
+
+// 1.2
+int UtcDaliResourceImageNew02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliREsourceImageNew02 - ResourceImage::New(const std::string&, const ImageAttributes&)");
+
+ // invoke default handle constructor
+ ResourceImage image;
+
+ DALI_TEST_CHECK( !image );
+
+ // initialise handle
+ Dali::ImageAttributes imageAttributes;
+ imageAttributes.SetSize(128, 256);
+ imageAttributes.SetScalingMode(Dali::ImageAttributes::FitHeight);
+ image = ResourceImage::New(gTestImageFilename, imageAttributes);
+
+ DALI_TEST_CHECK( image );
+ END_TEST;
+}
+
+// 1.3
+int UtcDaliResourceImageNewWithPolicies01(void)
+{
+ TestApplication application;
+ TestPlatformAbstraction& platform = application.GetPlatform();
+
+ // testing delayed loading
+ tet_infoline("UtcDaliResourceImageNewWithPolicies01 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Never");
+ DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
+
+ DALI_TEST_CHECK( image );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // request file loading only when actor added to stage
+ DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+
+ ImageActor actor = ImageActor::New(image);
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+
+ // testing ReleasePolicy::Never
+ // fake loading image
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+ LoadBitmapResource( platform );
+
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // never discard texture
+ Stage::GetCurrent().Remove(actor);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+ END_TEST;
+}
+
+// 1.4
+int UtcDaliResourceImageNewWithPolicies02(void)
+{
+ TestApplication application;
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ const Vector2 closestImageSize( 80, 45);
+ platform.SetClosestImageSize(closestImageSize);
+
+ // testing resource deletion when taken off stage
+ tet_infoline("UtcDaliResourceImageNewWithPolicies02 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Unused");
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::UNUSED);
+
+ DALI_TEST_CHECK( image );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // request file loading only when actor added to stage
+ DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+
+ ImageActor actor = ImageActor::New(image);
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+
+ // testing ReleasePolicy::Unused
+ // fake loading image
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+ LoadBitmapResource( platform );
+
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // discard texture when actor comes off stage
+ Stage::GetCurrent().Remove(actor);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
+ END_TEST;
+}
+
+// 1.5
+int UtcDaliResourceImageNewWithPolicies03(void)
+{
+ TestApplication application;
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ const Vector2 closestImageSize( 80, 45);
+ platform.SetClosestImageSize(closestImageSize);
+
+ // load immediately -> resource deletion when taken off stage -> put actor back on stage -> load resource again
+ tet_infoline("UtcDaliResourceImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Unused");
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::IMMEDIATE, Image::UNUSED);
+
+ DALI_TEST_CHECK( image );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // request file loading immediately
+ DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+
+ ImageActor actor = ImageActor::New(image);
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+
+ // testing ReleasePolicy::Unused
+ // fake loading image
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+ LoadBitmapResource( platform );
+
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // discard texture when actor comes off stage
+ Stage::GetCurrent().Remove(actor);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // check load request when actor added back to stage
+ application.GetPlatform().ResetTrace();
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ END_TEST;
+}
+
+// 1.6
+int UtcDaliResourceImageNewWithPolicies04(void)
+{
+ TestApplication application;
+ TestPlatformAbstraction& platform = application.GetPlatform();
+
+ // load immediately, don't release texture when off stage
+ tet_infoline("UtcDaliResourceImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Never");
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::IMMEDIATE, Image::NEVER);
+
+ DALI_TEST_CHECK( image );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // request file loading immediately
+ DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+
+ ImageActor actor = ImageActor::New(image);
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+
+ // testing ReleasePolicy::Never
+ // fake loading image
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+ LoadBitmapResource(platform);
+
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // texture is not discarded
+ Stage::GetCurrent().Remove(actor);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // no load request when actor added back to stage
+ application.GetPlatform().ResetTrace();
+
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
+ END_TEST;
+}
+
+// 1.7
+int UtcDaliResourceImageDownCast(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::ResourceImage::DownCast()");
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename);
+
+ BaseHandle object(image);
+
+ ResourceImage image2 = ResourceImage::DownCast(object);
+ DALI_TEST_CHECK(image2);
+
+ ResourceImage image3 = DownCast< ResourceImage >(object);
+ DALI_TEST_CHECK(image3);
+
+ BaseHandle unInitializedObject;
+ ResourceImage image4 = ResourceImage::DownCast(unInitializedObject);
+ DALI_TEST_CHECK(!image4);
+
+ ResourceImage image5 = DownCast< ResourceImage >(unInitializedObject);
+ DALI_TEST_CHECK(!image5);
+
+ Image image6 = ResourceImage::New(gTestImageFilename);
+ ResourceImage image7 = ResourceImage::DownCast(image6);
+ DALI_TEST_CHECK(image7);
+ END_TEST;
+}
+
+// 1.8
+int UtcDaliResourceImageGetImageSize(void)
+{
+ TestApplication application;
+ TestPlatformAbstraction& platform = application.GetPlatform();
+
+ tet_infoline("UtcDaliResourceImageGetImageSize - ResourceImage::GetImageSize()");
+
+ Vector2 testSize(8.0f, 16.0f);
+ platform.SetClosestImageSize(testSize);
+
+ Vector2 size = ResourceImage::GetImageSize(gTestImageFilename);
+
+ DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethod("GetClosestImageSize"));
+ DALI_TEST_EQUALS( size, testSize, TEST_LOCATION);
+ END_TEST;
+}
+
+// 1.9
+int UtcDaliResourceImageGetUrl(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliResourceImageGetFilename - ResourceImage::GetUrl()");
+
+ // invoke default handle constructor
+ ResourceImage image;
+
+ DALI_TEST_CHECK( !image );
+
+ // initialise handle
+ image = ResourceImage::New(gTestImageFilename);
+
+ DALI_TEST_EQUALS( image.GetUrl(), gTestImageFilename, TEST_LOCATION);
+ END_TEST;
+}
+
+// 1.10
+int UtcDaliResourceImageGetLoadingState01(void)
+{
+ TestApplication application;
+ tet_infoline("UtcDaliResourceImageGetLoadingState01");
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename);
+ DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading);
+ application.SendNotification();
+ application.Render(16);
+
+ // simulate load success
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ LoadBitmapResource( platform );
+ application.Render(16);
+ application.SendNotification();
+
+ // Test state == ResourceLoadingSucceeded
+ DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded);
+ END_TEST;
+}
+
+// 1.11
+int UtcDaliResourceImageGetLoadingState02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliResourceImageGetLoadingState02");
+
+ // invoke default handle constructor
+ ResourceImage image;
+
+ DALI_TEST_CHECK( !image );
+
+ // initialise handle
+ image = ResourceImage::New(gTestImageFilename);
+
+ // Test state == ResourceLoading
+ DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading);
+ application.SendNotification();
+ application.Render(16);
+
+ // simulate load failure
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoadFailed(request->GetId(), Integration::FailureUnknown);
+ }
+ application.Render(16);
+ application.SendNotification();
+
+ // Test state == ResourceLoadingFailed
+ DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed);
+ END_TEST;
+}
+
+// 1.12
+int UtcDaliResourceImageGetLoadPolicy(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliImageGetLoadPolicy");
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
+
+ DALI_TEST_CHECK( image );
+
+ DALI_TEST_CHECK( ResourceImage::ON_DEMAND == image.GetLoadPolicy());
+ END_TEST;
+}
+
+static bool SignalLoadFlag = false;
+
+static void SignalLoadHandler(ResourceImage image)
+{
+ tet_infoline("Received image load finished signal");
+
+ SignalLoadFlag = true;
+}
+
+// 1.13
+int UtcDaliResourceImageSignalLoadingFinished(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliResourceImageSignalLoadingFinished");
+
+ SignalLoadFlag = false;
+
+ ResourceImage image = ResourceImage::New(gTestImageFilename);
+
+ image.LoadingFinishedSignal().Connect( SignalLoadHandler );
+ application.SendNotification();
+ application.Render(16);
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD)));
+ }
+
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( SignalLoadFlag == true );
+ END_TEST;
+}
return image;
}
+/// Helper method to create ResourceImage using property
+BitmapImage NewBitmapImage( const Property::Value& map )
+{
+ BitmapImage image = BitmapImage::DownCast( NewImage( map ) );
+ return image;
+}
+
/// Helper method to create ImageAttributes using an Image
ImageAttributes NewImageAttributes( const Property::Value& map )
{
//map.erase( map.end() - 2, map.end() );
- // pixel-format
- map[ "pixel-format" ] = "";
- {
- const StringEnum< int > values[] =
- {
- { "A8", Pixel::A8 },
- { "L8", Pixel::L8 },
- { "LA88", Pixel::LA88 },
- { "RGB565", Pixel::RGB565 },
- { "BGR565", Pixel::BGR565 },
- { "RGBA4444", Pixel::RGBA4444 },
- { "BGRA4444", Pixel::BGRA4444 },
- { "RGBA5551", Pixel::RGBA5551 },
- { "BGRA5551", Pixel::BGRA5551 },
- { "RGB888", Pixel::RGB888 },
- { "RGB8888", Pixel::RGB8888 },
- { "BGR8888", Pixel::BGR8888 },
- { "RGBA8888", Pixel::RGBA8888 },
- { "BGRA8888", Pixel::BGRA8888 },
- { "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
- { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
- { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
- { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
- { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
- { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
- { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
- { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
- { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
- { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
- { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },
- { "A8", Pixel::A8 }, // Checked already but reset so that BitmapImage works
- };
- TestEnumStrings< Pixel::Format, ImageAttributes >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &ImageAttributes::GetPixelFormat, &NewImageAttributes );
- }
-
// scaling-mode
map[ "scaling-mode" ] = "";
{
DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
}
// type BitMapImage
- map[ "type" ] = "BitmapImage";
- {
- Image image = NewImage( map );
- DALI_TEST_CHECK( BitmapImage::DownCast( image ) );
- }
+ map[ "type" ] = "BitmapImage";
+ {
+ Image image = NewImage( map );
+ DALI_TEST_CHECK( BitmapImage::DownCast( image ) );
+ DALI_TEST_CHECK((BitmapImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
+ }
+
+ // pixel-format
+ map[ "pixel-format" ] = "";
+ {
+ const StringEnum< int > values[] =
+ {
+ { "A8", Pixel::A8 },
+ { "L8", Pixel::L8 },
+ { "LA88", Pixel::LA88 },
+ { "RGB565", Pixel::RGB565 },
+ { "BGR565", Pixel::BGR565 },
+ { "RGBA4444", Pixel::RGBA4444 },
+ { "BGRA4444", Pixel::BGRA4444 },
+ { "RGBA5551", Pixel::RGBA5551 },
+ { "BGRA5551", Pixel::BGRA5551 },
+ { "RGB888", Pixel::RGB888 },
+ { "RGB8888", Pixel::RGB8888 },
+ { "BGR8888", Pixel::BGR8888 },
+ { "RGBA8888", Pixel::RGBA8888 },
+ { "BGRA8888", Pixel::BGRA8888 },
+ /*{ "COMPRESSED_R11_EAC", Pixel::COMPRESSED_R11_EAC },
+ { "COMPRESSED_SIGNED_R11_EAC", Pixel::COMPRESSED_SIGNED_R11_EAC },
+ { "COMPRESSED_RG11_EAC", Pixel::COMPRESSED_RG11_EAC },
+ { "COMPRESSED_SIGNED_RG11_EAC", Pixel::COMPRESSED_SIGNED_RG11_EAC },
+ { "COMPRESSED_RGB8_ETC2", Pixel::COMPRESSED_RGB8_ETC2 },
+ { "COMPRESSED_SRGB8_ETC2", Pixel::COMPRESSED_SRGB8_ETC2 },
+ { "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 },
+ { "COMPRESSED_RGBA8_ETC2_EAC", Pixel::COMPRESSED_RGBA8_ETC2_EAC },
+ { "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
+ { "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
+ { "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },*/
+ // BitmapImage doesnot support compressed format
+ };
+
+ TestEnumStrings< Pixel::Format, BitmapImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BitmapImage::GetPixelFormat, &NewBitmapImage );
+ }
+
// type Image
map[ "type" ] = "Image";
{
DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION );
DALI_TEST_CHECK( value.HasKey( "release-policy") );
DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "pixel-format") );
- DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "RGBA8888", TEST_LOCATION );
DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "SHRINK_TO_FIT", TEST_LOCATION );
DALI_TEST_CHECK( !value.HasKey( "width" ) );
// Change values
{
ImageAttributes attributes;
- attributes.SetPixelFormat( Pixel::A8 );
attributes.SetScalingMode( ImageAttributes::FitWidth );
attributes.SetSize( 300, 400 );
Image image = ResourceImage::New( "MY_PATH", attributes, ResourceImage::ON_DEMAND, Image::UNUSED );
DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION );
DALI_TEST_CHECK( value.HasKey( "release-policy") );
DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION );
- DALI_TEST_CHECK( value.HasKey( "pixel-format") );
- DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
DALI_TEST_CHECK( value.HasKey( "scaling-mode") );
DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "FIT_WIDTH", TEST_LOCATION );
DALI_TEST_CHECK( value.HasKey( "width" ) );
// BitmapImage
{
- Image image = BitmapImage::New( 200, 300, Pixel::RGBA8888 );
+ Image image = BitmapImage::New( 200, 300, Pixel::A8 );
Property::Map map;
CreatePropertyMap( image, map );
Property::Value value( map );
DALI_TEST_CHECK( value.HasKey( "type" ) );
DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BitmapImage", TEST_LOCATION );
+ DALI_TEST_CHECK( value.HasKey( "pixel-format") );
+ DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
}
// FrameBufferImage
return image;
}
-FrameBufferImagePtr FrameBufferImage::New( NativeImage& nativeImage )
+FrameBufferImagePtr FrameBufferImage::New( NativeImageInterface& nativeImage )
{
FrameBufferImagePtr image = new FrameBufferImage(nativeImage);
image->Initialize();
return image;
}
-FrameBufferImagePtr FrameBufferImage::New( NativeImage& nativeImage, ReleasePolicy releasePolicy )
+FrameBufferImagePtr FrameBufferImage::New( NativeImageInterface& nativeImage, ReleasePolicy releasePolicy )
{
FrameBufferImagePtr image = new FrameBufferImage(nativeImage, releasePolicy);
image->Initialize();
mHeight = height;
}
-FrameBufferImage::FrameBufferImage( NativeImage& nativeImage )
+FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage )
: Image(),
- mNativeImage(&nativeImage),
- mPixelFormat(nativeImage.GetPixelFormat())
+ mNativeImage(&nativeImage)
{
mWidth = nativeImage.GetWidth();
mHeight = nativeImage.GetHeight();
}
-FrameBufferImage::FrameBufferImage( NativeImage& nativeImage, ReleasePolicy releasePolicy )
+FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage, ReleasePolicy releasePolicy )
: Image(releasePolicy),
- mNativeImage(&nativeImage),
- mPixelFormat(nativeImage.GetPixelFormat())
+ mNativeImage(&nativeImage)
{
mWidth = nativeImage.GetWidth();
mHeight = nativeImage.GetHeight();
static FrameBufferImagePtr New(unsigned int width, unsigned int height, Pixel::Format pixelFormat, ReleasePolicy releasePolicy);
/**
- * @copydoc Dali::FrameBufferImage::New(NativeImage&)
+ * @copydoc Dali::FrameBufferImage::New(NativeImageInterface&)
*/
- static FrameBufferImagePtr New( NativeImage& nativeImage );
+ static FrameBufferImagePtr New( NativeImageInterface& nativeImage );
/**
- * @copydoc Dali::FrameBufferImage::New(NativeImage&, ReleasePolicy)
+ * @copydoc Dali::FrameBufferImage::New(NativeImageInterface&, ReleasePolicy)
*/
- static FrameBufferImagePtr New( NativeImage& nativeImage, ReleasePolicy releasePolicy );
+ static FrameBufferImagePtr New( NativeImageInterface& nativeImage, ReleasePolicy releasePolicy );
/**
* @copydoc Dali::FrameBufferImage::FrameBufferImage
/**
* @copydoc Dali::FrameBufferImage::FrameBufferImage
*/
- FrameBufferImage(NativeImage& image);
+ FrameBufferImage(NativeImageInterface& image);
/**
* @copydoc Dali::FrameBufferImage::FrameBufferImage
*/
- FrameBufferImage(NativeImage& image, ReleasePolicy releasePolicy);
+ FrameBufferImage(NativeImageInterface& image, ReleasePolicy releasePolicy);
public: // From Image
/**
private:
// cached values for the size / pixel format we were created with. Needed to recreate us when we Connect() to stage and mTicket was reset from a previous call to Disconnect().
- NativeImagePtr mNativeImage;
+ NativeImageInterfacePtr mNativeImage;
Pixel::Format mPixelFormat;
}; // class FrameBufferImage
(requested.GetFilterMode() == actual.GetFilterMode()) ||
(requested.GetFilterMode() == ImageAttributes::DontCare)
) &&
- (requested.GetPixelFormat() == actual.GetPixelFormat()) &&
- (requested.GetFieldBorder() == actual.GetFieldBorder()) &&
- (fabs(actual.GetFieldRadius() - requested.GetFieldRadius()) <= FLT_EPSILON) &&
- (requested.IsDistanceField() == actual.IsDistanceField()) &&
(fabsf(requested.GetWidth() - actual.GetWidth()) <= actual.GetWidth() * mMaxScale) &&
(fabsf(requested.GetHeight() - actual.GetHeight()) <= actual.GetHeight() * mMaxScale);
}
}
-ImagePtr Image::New( NativeImage& nativeImg )
-{
- ImagePtr image = new Image;
- image->Initialize();
-
- ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
-
- image->mWidth = nativeImg.GetWidth();
- image->mHeight = nativeImg.GetHeight();
-
- const ResourceTicketPtr& ticket = resourceClient.AddNativeImage( nativeImg );
- DALI_ASSERT_DEBUG( dynamic_cast<ImageTicket*>( ticket.Get() ) && "Resource ticket not ImageTicket subclass for image resource.\n" );
- image->mTicket = static_cast<ImageTicket*>(ticket.Get());
- image->mTicket->AddObserver( *image );
-
- return image;
-}
-
bool Image::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
bool connected( true );
// INTERNAL INCLUDES
#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/native-image.h>
#include <dali/public-api/object/base-object.h>
#include <dali/internal/event/resources/resource-client.h>
#include <dali/internal/event/resources/resource-ticket-observer.h>
public:
/**
- * Creates object with already loaded NativeImage
- * the maximum size of the image is limited by GL_MAX_TEXTURE_SIZE
- * @pre nativeImg should be initialised
- * @param [in] nativeImg already initialised NativeImage
- * @return a pointer to a newly created object.
- */
- static ImagePtr New( NativeImage& nativeImg );
-
- /**
* @copydoc Dali::Image::GetReleasePolicy()
*/
ReleasePolicy GetReleasePolicy () const { return mReleasePolicy; }
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/event/images/native-image-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/integration-api/debug.h>
+#include <dali/internal/event/resources/resource-ticket.h>
+#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/event/resources/resource-client.h>
+#include <dali/internal/event/common/stage-impl.h>
+
+using namespace Dali::Integration;
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace
+{
+TypeRegistration mType( typeid(Dali::NativeImage), typeid(Dali::Image), NULL );
+}
+
+NativeImage::NativeImage()
+: Image()
+{
+}
+
+NativeImagePtr NativeImage::New( NativeImageInterface& resourceData )
+{
+ NativeImagePtr image = new NativeImage;
+ image->Initialize();
+
+ ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
+
+ image->mWidth = resourceData.GetWidth();
+ image->mHeight = resourceData.GetHeight();
+
+ const ResourceTicketPtr& ticket = resourceClient.AddNativeImage( resourceData );
+ DALI_ASSERT_DEBUG( dynamic_cast<ImageTicket*>( ticket.Get() ) && "Resource ticket not ImageTicket subclass for image resource.\n" );
+ image->mTicket = static_cast<ImageTicket*>(ticket.Get());
+ image->mTicket->AddObserver( *image );
+
+ return image;
+}
+
+NativeImage::~NativeImage()
+{
+}
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_NATIVE_IMAGE_H__
+#define __DALI_INTERNAL_NATIVE_IMAGE_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/images/native-image.h>
+#include <dali/internal/event/images/image-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+class NativeImage;
+typedef IntrusivePtr<NativeImage> NativeImagePtr;
+
+/**
+ * @copydoc Dali::NativeImage
+ */
+class NativeImage : public Image
+{
+public:
+
+ /**
+ * Creates object by using native resources
+ * the maximum size of the image is limited by GL_MAX_TEXTURE_SIZE
+ * @param [in] nativeImageInterface An reference to the object of the interface implementation.
+ * @return a pointer to a newly created object.
+ */
+ static NativeImagePtr New( NativeImageInterface& nativeImageInterface );
+
+protected:
+
+ /**
+ * Constructor
+ */
+ NativeImage();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~NativeImage();
+};
+
+} // namespace Internal
+
+/**
+ * Helper methods for public API.
+ */
+inline Internal::NativeImage& GetImplementation(Dali::NativeImage& image)
+{
+ DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
+
+ BaseObject& handle = image.GetBaseObject();
+
+ return static_cast<Internal::NativeImage&>(handle);
+}
+
+inline const Internal::NativeImage& GetImplementation(const Dali::NativeImage& image)
+{
+ DALI_ASSERT_ALWAYS( image && "Image handle is empty" );
+
+ const BaseObject& handle = image.GetBaseObject();
+
+ return static_cast<const Internal::NativeImage&>(handle);
+}
+
+} // namespace Dali
+#endif // __DALI_INTERNAL_NATIVE_IMAGE_H__
const ResourceId newId = ++(mImpl->mNextId);
- Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New(bitmap->GetImageWidth(), bitmap->GetImageHeight(), bitmap->GetPixelFormat());
+ Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New(bitmap->GetImageWidth(), bitmap->GetImageHeight());
BitmapResourceType bitmapResourceType(imageAttributes); // construct first as no copy ctor (needed to bind ref to object)
ResourceTypePath typePath(bitmapResourceType, "");
newTicket = new ImageTicket(*this, newId, typePath);
return newTicket;
}
-ResourceTicketPtr ResourceClient::AddNativeImage ( NativeImage& resourceData )
+ResourceTicketPtr ResourceClient::AddNativeImage ( NativeImageInterface& resourceData )
{
ImageTicketPtr newTicket;
ResourceTypePath typePath(nativeImageResourceType, "");
newTicket = new ImageTicket(*this, newId, typePath);
newTicket->mAttributes = ImageAttributes::New(resourceData.GetWidth(),
- resourceData.GetHeight(),
- resourceData.GetPixelFormat());
+ resourceData.GetHeight());
newTicket->LoadingSucceeded();
mImpl->mTickets.insert(TicketPair(newId, newTicket.Get()));
const ResourceId newId = ++(mImpl->mNextId);
- Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New(width, height, pixelFormat );
+ Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New(width, height);
RenderTargetResourceType renderTargetResourceType(imageAttributes) ; // construct first as no copy ctor (needed to bind ref to object)
ResourceTypePath typePath(renderTargetResourceType, "");
newTicket = new ImageTicket(*this, newId, typePath);
return newTicket;
}
-ImageTicketPtr ResourceClient::AddFrameBufferImage ( NativeImage& nativeImage )
+ImageTicketPtr ResourceClient::AddFrameBufferImage ( NativeImageInterface& nativeImage )
{
ImageTicketPtr newTicket;
const ResourceId newId = ++(mImpl->mNextId);
- Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New(nativeImage.GetWidth(), nativeImage.GetHeight(), nativeImage.GetPixelFormat() );
+ Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New(nativeImage.GetWidth(), nativeImage.GetHeight() );
RenderTargetResourceType renderTargetResourceType(imageAttributes); // construct first as no copy ctor (needed to bind ref to object)
ResourceTypePath typePath(renderTargetResourceType, "");
newTicket = new ImageTicket(*this, newId, typePath);
ImageTicketPtr newTicket;
const ResourceId newId = ++(mImpl->mNextId);
- Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New( width, height, pixelformat);
+ Dali::ImageAttributes imageAttributes = Dali::ImageAttributes::New( width, height);
BitmapResourceType bitmapResourceType(imageAttributes); // construct first as no copy ctor (needed to bind ref to object)
ResourceTypePath typePath(bitmapResourceType, "");
newTicket = new ImageTicket(*this, newId, typePath);
// INTERNAL INCLUDES
#include <dali/public-api/common/ref-counted-dali-vector.h>
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/integration-api/glyph-set.h>
#include <dali/internal/event/resources/resource-client-declarations.h>
#include <dali/internal/event/resources/image-ticket.h>
* @param [in] resourceData the NativeImage object
* @return A ref-counted request object. Keep a copy until the resource is no longer required.
*/
- ResourceTicketPtr AddNativeImage ( NativeImage& resourceData );
+ ResourceTicketPtr AddNativeImage ( NativeImageInterface& resourceData );
/**
* Add a framebuffer resource to the resource manager.
* @param[in] nativeImage the NativeImage object
* @return A ref-counted request object. Keep a copy until the resource is no longer required.
*/
- ImageTicketPtr AddFrameBufferImage ( NativeImage& nativeImage );
+ ImageTicketPtr AddFrameBufferImage ( NativeImageInterface& nativeImage );
/**
* Request allocation of a texture.
$(internal_src_dir)/event/images/nine-patch-image-impl.cpp \
$(internal_src_dir)/event/images/emoji-factory.cpp \
$(internal_src_dir)/event/images/resource-image-impl.cpp \
+ $(internal_src_dir)/event/images/native-image-impl.cpp \
$(internal_src_dir)/event/modeling/animatable-mesh-impl.cpp \
$(internal_src_dir)/event/modeling/cloth-impl.cpp \
$(internal_src_dir)/event/modeling/entity-impl.cpp \
#include <stdint.h>
// INTERNAL INCLUDES
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/public-api/images/bitmap-image.h>
#include <dali/public-api/images/pixel.h>
#include <dali/internal/common/message.h>
* @param[in] id Resource Id of the native image
* @param[in] nativeImage The native image
*/
- virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImagePtr nativeImage ) = 0;
+ virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
/**
* Dispatch a message to create a framebuffer texture and add it to the texture cache
* @param[in] id Resource Id of the framebuffer
* @param[in] nativeImage The NativeImage
*/
- virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImagePtr nativeImage ) = 0;
+ virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage ) = 0;
/**
* Dispatch a message to update the texture.
bitmapPackedPixelsProfile->GetBufferWidth(),
bitmapPackedPixelsProfile->GetBufferHeight(),
bitmap->GetImageWidth(),
- bitmap->GetImageHeight(),
- bitmap->GetPixelFormat()),
+ bitmap->GetImageHeight()),
mBitmap(bitmap),
mClearPixels(false),
- mDiscardPolicy(policy)
+ mDiscardPolicy(policy),
+ mPixelFormat(bitmap->GetPixelFormat())
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
DALI_LOG_SET_OBJECT_STRING(this, DALI_LOG_GET_OBJECT_STRING(bitmap));
ResourcePolicy::Discardable policy)
: Texture( context,
width, height,
- width, height,
- pixelFormat),
+ width, height),
mBitmap(NULL),
mClearPixels(clearPixels),
- mDiscardPolicy(policy)
+ mDiscardPolicy(policy),
+ mPixelFormat( pixelFormat )
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
}
Integration::BitmapPtr mBitmap; ///< The Bitmap the Texture was created from (may be NULL)
bool mClearPixels; ///< true if initial texture should be cleared on creation
ResourcePolicy::Discardable mDiscardPolicy; ///< The bitmap discard policy
+ Pixel::Format mPixelFormat;
// Changes scope, should be at end of class
DALI_LOG_OBJECT_STRING_DECLARATION;
bitmap->GetImageWidth(),
bitmap->GetImageHeight(),
bitmap->GetImageWidth(),
- bitmap->GetImageHeight(),
- bitmap->GetPixelFormat()),
+ bitmap->GetImageHeight()),
mBitmap(bitmap),
- mDiscardPolicy(discardPolicy)
+ mDiscardPolicy(discardPolicy),
+ mPixelFormat( bitmap->GetPixelFormat() )
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
DALI_LOG_SET_OBJECT_STRING(this, DALI_LOG_GET_OBJECT_STRING(bitmap));
private:
Internal::BitmapCompressedPtr mBitmap; ///< The Bitmap the Texture was created from (may be NULL)
ResourcePolicy::Discardable mDiscardPolicy;
+ Pixel::Format mPixelFormat;
// Changes scope, should be at end of class
DALI_LOG_OBJECT_STRING_DECLARATION;
namespace Internal
{
-FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, Context& context)
+FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Context& context)
: Texture( context,
width, height,
+ width, height )
+{
+ DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
+
+ mFrameBufferName = 0;
+ mRenderBufferName = 0;
+}
+
+FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, Context& context)
+: Texture( context,
width, height,
- pixelFormat )
+ width, height ),
+ mPixelFormat( pixelFormat )
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
class FrameBufferTexture : public Texture
{
public:
+
+ /**
+ * Creates a new texture object
+ * @param[in] width The width (pixels)
+ * @param[in] height The height (pixels)
+ * @param context The GL context
+ */
+ FrameBufferTexture(unsigned int width, unsigned int height, Context& context);
+
/**
* Creates a new texture object
* @param[in] width The width (pixels)
protected:
unsigned int mFrameBufferName;
unsigned int mRenderBufferName;
+ Pixel::Format mPixelFormat;
/**
* @copydoc Texture::CreateGlTexture
namespace Internal
{
-NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImagePtr nativeImage, Context& context)
+NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context)
: FrameBufferTexture(nativeImage->GetWidth(),
nativeImage->GetHeight(),
- nativeImage->GetPixelFormat(),
context),
mNativeImage(nativeImage)
{
bool NativeFrameBufferTexture::IsFullyOpaque() const
{
- // TODO - Should test actual texture...
return !HasAlphaChannel();
}
bool NativeFrameBufferTexture::HasAlphaChannel() const
{
- return Pixel::HasAlpha(mNativeImage->GetPixelFormat());
+ return mNativeImage->RequiresBlending();
}
bool NativeFrameBufferTexture::Init()
mNativeImage.Reset();
}
-
} //namespace Internal
} //namespace Dali
* @param[in] nativeImage The NativeImage
* @param context The GL context
*/
- NativeFrameBufferTexture( NativeImagePtr nativeImage, Context& context);
+ NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context);
/**
* Destructor.
virtual void GlCleanup();
private:
- NativeImagePtr mNativeImage; ///< reference to NativeImage the Texture was created from
+ NativeImageInterfacePtr mNativeImage; ///< reference to NativeImage the Texture was created from
}; // class NativeFrameBufferTexture
namespace Internal
{
-NativeTexture::NativeTexture(NativeImage* nativeImg, Context& context)
+NativeTexture::NativeTexture(NativeImageInterface* nativeImg, Context& context)
: Texture(context,
nativeImg->GetWidth(),
nativeImg->GetHeight(),
nativeImg->GetWidth(),
- nativeImg->GetHeight(),
- nativeImg->GetPixelFormat()),
+ nativeImg->GetHeight()),
mNativeImage(nativeImg)
{
DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "NativeTexture created 0x%x\n", &nativeImg );
bool NativeTexture::IsFullyOpaque() const
{
- // TODO - Should test actual texture...
return !HasAlphaChannel();
}
bool NativeTexture::HasAlphaChannel() const
{
- return Pixel::HasAlpha( mNativeImage->GetPixelFormat() );
-}
-
-Pixel::Format NativeTexture::GetPixelFormat() const
-{
- return mNativeImage->GetPixelFormat();
+ return mNativeImage->RequiresBlending();
}
bool NativeTexture::CreateGlTexture()
// INTERNAL INCLUDES
#include <dali/integration-api/gl-defines.h>
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/internal/render/gl-resources/texture.h>
namespace Dali
* @param nativeImg the NativeImage to be used
* @param context the GL context
*/
- NativeTexture(NativeImage* nativeImg, Context& context);
+ NativeTexture(NativeImageInterface* nativeImg, Context& context);
/**
* Destructor.
*/
virtual bool HasAlphaChannel() const;
-
- /**
- * @copydoc Texture::GetPixelFormat
- */
- virtual Pixel::Format GetPixelFormat() const;
-
/**
* @copydoc Texture::Init
*/
private:
- NativeImagePtr mNativeImage; ///< reference to NativeImage the Texture was created from
+ NativeImageInterfacePtr mNativeImage; ///< reference to NativeImage the Texture was created from
};
} //namespace Internal
mTextures.insert(TexturePair(id, texture));
}
-void TextureCache::AddNativeImage(ResourceId id, NativeImagePtr nativeImage)
+void TextureCache::AddNativeImage(ResourceId id, NativeImageInterfacePtr nativeImage)
{
DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddNativeImage(id=%i NativeImg:%p)\n", id, nativeImage.Get());
mFramebufferTextures.insert(TexturePair(id, texture));
}
-void TextureCache::AddFrameBuffer( ResourceId id, NativeImagePtr nativeImage )
+void TextureCache::AddFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage )
{
DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddFrameBuffer(id=%i width:%u height:%u)\n", id, nativeImage->GetWidth(), nativeImage->GetHeight());
}
}
-void TextureCache::DispatchCreateTextureForNativeImage( ResourceId id, NativeImagePtr nativeImage )
+void TextureCache::DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage )
{
// NULL, means being shutdown, so ignore msgs
if( mSceneGraphBuffers != NULL )
{
- typedef MessageValue2< TextureCache, ResourceId, NativeImagePtr > DerivedType;
+ typedef MessageValue2< TextureCache, ResourceId, NativeImageInterfacePtr > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mRenderQueue.ReserveMessageSlot( mSceneGraphBuffers->GetUpdateBufferIndex(), sizeof( DerivedType ) );
}
}
-void TextureCache::DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImagePtr nativeImage )
+void TextureCache::DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage )
{
// NULL, means being shutdown, so ignore msgs
if( mSceneGraphBuffers != NULL )
{
- typedef MessageValue2< TextureCache, ResourceId, NativeImagePtr > DerivedType;
+ typedef MessageValue2< TextureCache, ResourceId, NativeImageInterfacePtr > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mRenderQueue.ReserveMessageSlot( mSceneGraphBuffers->GetUpdateBufferIndex(), sizeof( DerivedType ) );
namespace Dali
{
-class NativeImage;
+class NativeImageInterface;
namespace Integration
* @param[in] id Resource Id of the native image
* @param[in] nativeImage The native image
*/
- void AddNativeImage( ResourceId id, NativeImagePtr nativeImage );
+ void AddNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage );
/**
* Create a framebuffer texture and add it to the texture cache
* @param[in] id Resource Id of the native image
* @param[in] nativeImage The NativeImage
*/
- void AddFrameBuffer( ResourceId id, NativeImagePtr nativeImage );
+ void AddFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage );
/**
* Update the texture with a newly loaded bitmap
/**
* @copydoc TextureCacheDispatcher::DispatchCreateTextureForNativeImage()
*/
- virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImagePtr nativeImage );
+ virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage );
/**
* @copydoc TextureCacheDispatcher::DispatchCreateTextureForFramebuffer()
/**
* @copydoc TextureCacheDispatcher::DispatchCreateTextureForFramebuffer()
*/
- virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImagePtr nativeImage );
+ virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage );
/**
* @copydoc TextureCacheDispatcher::DispatchUpdateTexture()
#include <dali/internal/render/gl-resources/native-texture.h>
#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
#include <dali/internal/render/gl-resources/native-frame-buffer-texture.h>
-#include <dali/public-api/images/native-image.h>
namespace Dali
{
-class NativeImage;
+class NativeImageInterface;
namespace Internal
{
}
-Internal::Texture* NewNativeImageTexture( NativeImage& nativeImg, Context& context )
+Internal::Texture* NewNativeImageTexture( NativeImageInterface& nativeImg, Context& context )
{
NativeTexture* texture = new NativeTexture(&nativeImg, context);
if (!texture->Init())
return texture;
}
-Internal::Texture* NewFrameBufferTexture( NativeImagePtr nativeImage,
+Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage,
Context& context )
{
NativeFrameBufferTexture* texture = new NativeFrameBufferTexture(nativeImage, context);
// INTERNAL INCLUDES
#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
namespace Dali
{
-class NativeImage;
+class NativeImageInterface;
namespace Integration
{
* @param[in] context The GL context
* @return A newly allocated texture
*/
-Internal::Texture* NewNativeImageTexture( NativeImage& nativeImage, Context& context );
+Internal::Texture* NewNativeImageTexture( NativeImageInterface& nativeImage, Context& context );
/**
* @copydoc FrameBufferTexture::FrameBufferTexture
* @copydoc FrameBufferTexture::FrameBufferTexture
* @return A newly allocated texture
*/
-Internal::Texture* NewFrameBufferTexture( NativeImagePtr nativeImage, Context& context );
+Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context );
};
unsigned int width,
unsigned int height,
unsigned int imageWidth,
- unsigned int imageHeight,
- Pixel::Format pixelFormat)
+ unsigned int imageHeight)
: mContext(context),
mId(0),
mSamplerBitfield( 0 ),
mWidth(width),
mHeight(height),
mImageWidth(imageWidth),
- mImageHeight(imageHeight),
- mPixelFormat(pixelFormat)
+ mImageHeight(imageHeight)
{
}
return mHeight;
}
-Pixel::Format Texture::GetPixelFormat() const
-{
- return mPixelFormat;
-}
-
void Texture::GetTextureCoordinates(UvRect& uv, const PixelArea* pixelArea)
{
if( pixelArea == NULL )
virtual bool IsFullyOpaque() const = 0;
/**
- * Get the pixel format of the image data.
- * @return the pixel format of the image.
- */
- virtual Pixel::Format GetPixelFormat() const;
-
- /**
* Sets the texture id.
* @param id OpenGL texture id
*/
* @param[in] height The buffer height
* @param[in] imageWidth The image width
* @param[in] imageHeight The image height
- * @param[in] pixelFormat The pixel format
*/
Texture( Context& context,
unsigned int width,
unsigned int height,
unsigned int imageWidth,
- unsigned int imageHeight,
- Pixel::Format pixelFormat );
+ unsigned int imageHeight );
/**
* Constructor.
* @param[in] context The GL context
* @param[in] width Both the buffer width and the image width (they are equal)
* @param[in] height Both the buffer height and the image height.
- * @param[in] pixelFormat The pixel format
*/
Texture( Context& context,
unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat );
+ unsigned int height );
/**
* Initialize texture for rendering.
unsigned int mImageWidth; ///< width of the original image (may be smaller than texture width)
unsigned int mImageHeight; ///< height of the original image (may be smaller than texture height)
-
- Pixel::Format mPixelFormat; ///< Pixel format of the contained image data.
-
};
} // namespace Internal
namespace Internal
{
-BitmapMetadata BitmapMetadata::New(NativeImagePtr nativeImage)
+BitmapMetadata BitmapMetadata::New(NativeImageInterfacePtr nativeImage)
{
- return BitmapMetadata(nativeImage->GetWidth(), nativeImage->GetHeight(), nativeImage->GetPixelFormat(), ! Pixel::HasAlpha(nativeImage->GetPixelFormat()));
+ return BitmapMetadata(nativeImage->GetWidth(), nativeImage->GetHeight(), nativeImage->RequiresBlending(), ! nativeImage->RequiresBlending());
}
BitmapMetadata BitmapMetadata::New(Integration::Bitmap* const bitmap)
{
- return BitmapMetadata(bitmap->GetImageWidth(), bitmap->GetImageHeight(), bitmap->GetPixelFormat(), bitmap->IsFullyOpaque());
+ return BitmapMetadata(bitmap->GetImageWidth(), bitmap->GetImageHeight(), Pixel::HasAlpha(bitmap->GetPixelFormat()), bitmap->IsFullyOpaque());
}
BitmapMetadata BitmapMetadata::New(unsigned int width,
unsigned int height,
- Pixel::Format pixelFormat)
+ bool hasAlphaChannel)
{
- return BitmapMetadata(width, height, pixelFormat, ! Pixel::HasAlpha(pixelFormat) );
+ return BitmapMetadata(width, height, hasAlphaChannel, !hasAlphaChannel );
}
BitmapMetadata::BitmapMetadata( unsigned int width,
unsigned int height,
- Pixel::Format pixelFormat,
+ bool hasAlphaChanne,
bool opaqueness )
: mImageWidth(width),
mImageHeight(height),
- mPixelFormat(pixelFormat),
+ mHasAlphaChannel(hasAlphaChanne),
mOpaqueness(opaqueness),
mIsNativeImage(false),
mIsFramebuffer(false)
BitmapMetadata::BitmapMetadata( )
: mImageWidth(0),
mImageHeight(0),
- mPixelFormat(Pixel::RGBA8888),
+ mHasAlphaChannel(true),
mOpaqueness(false),
mIsNativeImage(false),
mIsFramebuffer(false)
BitmapMetadata::BitmapMetadata( const BitmapMetadata& rhs )
: mImageWidth(rhs.mImageWidth),
mImageHeight(rhs.mImageHeight),
- mPixelFormat(rhs.mPixelFormat),
+ mHasAlphaChannel(rhs.mHasAlphaChannel),
mOpaqueness(rhs.mOpaqueness),
mIsNativeImage(rhs.mIsNativeImage),
mIsFramebuffer(rhs.mIsFramebuffer)
{
mImageWidth = rhs.mImageWidth;
mImageHeight =rhs.mImageHeight;
- mPixelFormat = rhs.mPixelFormat;
+ mHasAlphaChannel = rhs.mHasAlphaChannel;
mOpaqueness = rhs.mOpaqueness;
mIsNativeImage = rhs.mIsNativeImage;
mIsFramebuffer = rhs.mIsFramebuffer;
return *this;
}
-void BitmapMetadata::Update(NativeImagePtr nativeImage)
+void BitmapMetadata::Update(NativeImageInterfacePtr nativeImage)
{
mImageWidth = nativeImage->GetWidth();
mImageHeight = nativeImage->GetHeight();
- mPixelFormat = nativeImage->GetPixelFormat();
- mOpaqueness = ! Pixel::HasAlpha( mPixelFormat );
+ mHasAlphaChannel = nativeImage->RequiresBlending();
+ mOpaqueness = ! mHasAlphaChannel;
mIsNativeImage = true;
}
{
mImageWidth = bitmap->GetImageWidth();
mImageHeight = bitmap->GetImageHeight();
- mPixelFormat = bitmap->GetPixelFormat();
+ mHasAlphaChannel = Pixel::HasAlpha(bitmap->GetPixelFormat());
mOpaqueness = bitmap->IsFullyOpaque();
mIsNativeImage = false;
}
return mImageHeight;
}
-Pixel::Format BitmapMetadata::GetPixelFormat() const
-{
- return mPixelFormat;
-}
-
bool BitmapMetadata::HasAlphaChannel() const
{
- return HasAlpha(mPixelFormat);
+ return mHasAlphaChannel;
}
bool BitmapMetadata::IsFullyOpaque() const
mImageHeight = height;
}
-void BitmapMetadata::SetPixelFormat(Pixel::Format pixelFormat)
+void BitmapMetadata::SetHasAlphaChannel( bool hasAlphaChannel )
{
- mPixelFormat = pixelFormat;
+ mHasAlphaChannel = hasAlphaChannel;
}
void BitmapMetadata::SetOpaqueness(bool opaqueness)
// INTERNAL INCLUDES
#include <dali/integration-api/bitmap.h>
#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
namespace Dali
{
* @param[in] nativeImage The native image to load
* @return A newly allocated BitmapMetadata
*/
- static BitmapMetadata New(NativeImagePtr nativeImage);
+ static BitmapMetadata New(NativeImageInterfacePtr nativeImage);
/**
* Creates a new BitmapMetadata object from a Bitmap
* Creates a new BitmapMetadata object from framebuffer metadata
* @return A newly allocated BitmapMetadata
*/
- static BitmapMetadata New(unsigned int width, unsigned int height, Pixel::Format pixelFormat);
+ static BitmapMetadata New(unsigned int width, unsigned int height, bool hasAlphaChannel);
/**
* Constructor
*/
- BitmapMetadata( unsigned int width, unsigned int height, Pixel::Format pixelFormat, bool opaqueness );
+ BitmapMetadata( unsigned int width, unsigned int height, bool hasAlphaChanne, bool opaqueness );
/**
* Copy constructor
* Updates the metadata with information from the native image
* @param[in] nativeImage The native image that was updated
*/
- void Update(NativeImagePtr nativeImage);
+ void Update(NativeImageInterfacePtr nativeImage);
/**
* Updates the metadata with information from the bitmap
unsigned int GetHeight() const;
/**
- * Get the pixel format of the image data.
- * @return the pixel format of the image.
- */
- Pixel::Format GetPixelFormat() const;
-
- /**
* Query whether the texture data has an alpha channel.
* @return True if the texture data has an alpha channel.
*/
void SetHeight(unsigned int height);
/**
- * Set the pixel format of the image data.
- * @param[in] pixelFormat The pixel format of the image.
+ * Set whether the texture has alpha channel
+ * @param[in] hasAlphaChannel whether the texture has alpha channel
*/
- void SetPixelFormat(Pixel::Format pixelFormat);
-
+ void SetHasAlphaChannel( bool hasAlphaChannel );
/**
* Set whether the texture is completely opaque, i.e.
private:
unsigned int mImageWidth; ///< width of the original image
unsigned int mImageHeight; ///< height of the original image
- Pixel::Format mPixelFormat; ///< Pixel format of the contained image data.
+ bool mHasAlphaChannel:1; ///< Pixel format of the contained image data.
bool mOpaqueness:1; ///< Whether the bitmap was fully opaque when loaded / updated
bool mIsNativeImage:1; ///< Whether the image is native or not
bool mIsFramebuffer:1; ///< Whether the image is an FBO
mImpl->mTextureCacheDispatcher.DispatchCreateTextureForBitmap( id, bitmap.Get() );
}
-void ResourceManager::HandleAddNativeImageRequest(ResourceId id, NativeImagePtr nativeImage)
+void ResourceManager::HandleAddNativeImageRequest(ResourceId id, NativeImageInterfacePtr nativeImage)
{
DALI_ASSERT_DEBUG( mImpl->mResourceClient != NULL );
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAddNativeImageRequest(id:%u)\n", id);
mImpl->oldCompleteRequests.insert(id);
- BitmapMetadata bitmapMetadata = BitmapMetadata::New(width, height, pixelFormat);
+ BitmapMetadata bitmapMetadata = BitmapMetadata::New(width, height, Pixel::HasAlpha(pixelFormat));
bitmapMetadata.SetIsFramebuffer(true);
mImpl->mBitmapMetadata.insert(BitmapMetadataPair(id, bitmapMetadata));
mImpl->mTextureCacheDispatcher.DispatchCreateTextureForFrameBuffer( id, width, height, pixelFormat );
}
-void ResourceManager::HandleAddFrameBufferImageRequest( ResourceId id, NativeImagePtr nativeImage )
+void ResourceManager::HandleAddFrameBufferImageRequest( ResourceId id, NativeImageInterfacePtr nativeImage )
{
DALI_ASSERT_DEBUG( mImpl->mResourceClient != NULL );
DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAddFrameBufferImageRequest(id:%u)\n", id);
mImpl->oldCompleteRequests.insert(id);
- BitmapMetadata bitmapMetadata = BitmapMetadata::New(nativeImage->GetWidth(), nativeImage->GetHeight(), nativeImage->GetPixelFormat());
+ BitmapMetadata bitmapMetadata = BitmapMetadata::New(nativeImage);
bitmapMetadata.SetIsNativeImage(true);
bitmapMetadata.SetIsFramebuffer(true);
mImpl->mBitmapMetadata.insert(BitmapMetadataPair(id, bitmapMetadata));
bitmapWidth = packedBitmap->GetBufferWidth();
bitmapHeight = packedBitmap->GetBufferHeight();
}
- Pixel::Format pixelFormat = bitmap->GetPixelFormat();
-
- ImageAttributes attrs = ImageAttributes::New( bitmapWidth, bitmapHeight, pixelFormat ); ///!< Issue #AHC01
+ ImageAttributes attrs = ImageAttributes::New( bitmapWidth, bitmapHeight ); ///!< Issue #AHC01
UpdateImageTicket (id, attrs);
// Check for reloaded bitmap
case ResourceNativeImage:
{
- NativeImagePtr nativeImg( static_cast<NativeImage*>(resource.Get()) );
+ NativeImageInterfacePtr nativeImg( static_cast<NativeImageInterface*>(resource.Get()) );
- ImageAttributes attrs = ImageAttributes::New(nativeImg->GetWidth(), nativeImg->GetHeight(), nativeImg->GetPixelFormat());
+ ImageAttributes attrs = ImageAttributes::New(nativeImg->GetWidth(), nativeImg->GetHeight());
mImpl->mBitmapMetadata.insert(BitmapMetadataPair(id, BitmapMetadata::New(nativeImg)));
mImpl->mTextureCacheDispatcher.DispatchCreateTextureForNativeImage( id, nativeImg );
// INTERNAL INCLUDES
#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/public-api/images/bitmap-image.h>
#include <dali/public-api/common/ref-counted-dali-vector.h>
namespace Dali
{
-class NativeImage;
+class NativeImageInterface;
namespace Integration
{
/**
* Add an existing resource to the resource manager.
* @param[in] id The resource id
- * @param [in] resourceData the NativeImage object
+ * @param [in] resourceData the NativeImageInterface object
* @return A ref-counted request object. Keep a copy until the resource is no longer required.
*/
- void HandleAddNativeImageRequest( ResourceId id, NativeImagePtr resourceData );
+ void HandleAddNativeImageRequest( ResourceId id, NativeImageInterfacePtr resourceData );
/**
* Add an existing resource to the resource manager.
* @param[in] id The resource id
* @param[in] nativeImage The NativeImage
*/
- void HandleAddFrameBufferImageRequest( ResourceId id, NativeImagePtr nativeImage );
+ void HandleAddFrameBufferImageRequest( ResourceId id, NativeImageInterfacePtr nativeImage );
/**
* Allocate a new empty texture.
inline void RequestAddNativeImageMessage( EventToUpdate& eventToUpdate,
ResourceManager& manager,
ResourceId id,
- NativeImagePtr resourceData )
+ NativeImageInterfacePtr resourceData )
{
- typedef MessageValue2< ResourceManager, ResourceId, NativeImagePtr > LocalType;
+ typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
ResourceManager& manager,
ResourceId id,
- NativeImagePtr resourceData )
+ NativeImageInterfacePtr resourceData )
{
- typedef MessageValue2< ResourceManager, ResourceId, NativeImagePtr > LocalType;
+ typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
#include <dali/public-api/images/glyph-image.h>
#include <dali/public-api/images/image-attributes.h>
#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/images/nine-patch-image.h>
#include <dali/public-api/images/pixel.h>
$(public_api_src_dir)/images/nine-patch-image.cpp \
$(public_api_src_dir)/images/glyph-image.cpp \
$(public_api_src_dir)/images/resource-image.cpp \
+ $(public_api_src_dir)/images/native-image.cpp \
$(public_api_src_dir)/math/angle-axis.cpp \
$(public_api_src_dir)/math/compile-time-math.cpp \
$(public_api_src_dir)/math/degree.cpp \
$(public_api_src_dir)/images/glyph-image.h \
$(public_api_src_dir)/images/image.h \
$(public_api_src_dir)/images/image-attributes.h \
- $(public_api_src_dir)/images/native-image.h \
+ $(public_api_src_dir)/images/native-image-interface.h \
$(public_api_src_dir)/images/nine-patch-image.h \
$(public_api_src_dir)/images/pixel.h \
- $(public_api_src_dir)/images/resource-image.h
+ $(public_api_src_dir)/images/resource-image.h \
+ $(public_api_src_dir)/images/native-image.h
public_api_core_math_header_files = \
$(public_api_src_dir)/math/angle-axis.h \
return FrameBufferImage(internal.Get());
}
-FrameBufferImage FrameBufferImage::New( NativeImage& image, ReleasePolicy releasePolicy )
+FrameBufferImage FrameBufferImage::New( NativeImageInterface& image, ReleasePolicy releasePolicy )
{
Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New( image, releasePolicy );
return FrameBufferImage(internal.Get());
}
-FrameBufferImage FrameBufferImage::New( NativeImage& image )
+FrameBufferImage FrameBufferImage::New( NativeImageInterface& image )
{
Internal::FrameBufferImagePtr internal = Internal::FrameBufferImage::New( image );
return FrameBufferImage(internal.Get());
// INTERNAL INCLUDES
#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/native-image-interface.h>
#include <dali/public-api/images/pixel.h>
namespace Dali
* @post When the FrameBufferImage is first used as a render target, an exception may be thrown if the NativeImage cannot be mapped to a texture.
* @return A handle to a new instance of a FrameBufferImage.
*/
- static FrameBufferImage New(NativeImage& image);
+ static FrameBufferImage New(NativeImageInterface& image);
/**
* @brief Create a new FrameBufferImage.
* @post When the FrameBufferImage is first used as a render target, an exception may be thrown if the NativeImage cannot be mapped to a texture.
* @return A handle to a new instance of a FrameBufferImage.
*/
- static FrameBufferImage New(NativeImage& image, ReleasePolicy releasePolicy);
+ static FrameBufferImage New(NativeImageInterface& image, ReleasePolicy releasePolicy);
/**
* @brief Downcast an Object handle to FrameBufferImage handle.
struct ImageAttributes::ImageAttributesImpl
{
ImageAttributesImpl()
- : fieldRadius(4.0f),
- fieldBorder(4),
- width(0),
+ : width(0),
height(0),
scaling(ShrinkToFit),
filtering(Box),
- pixelformat(Pixel::RGBA8888),
- mOrientationCorrection(false),
- isDistanceField(false)
+ mOrientationCorrection(false)
{
}
}
ImageAttributesImpl(const ImageAttributesImpl& rhs)
- : fieldRadius( rhs.fieldRadius ),
- fieldBorder( rhs.fieldBorder ),
- width( rhs.width ),
+ : width( rhs.width ),
height( rhs.height ),
scaling( rhs.scaling ),
filtering( rhs.filtering ),
- pixelformat( rhs.pixelformat ),
- mOrientationCorrection( rhs.mOrientationCorrection ),
- isDistanceField( rhs.isDistanceField )
+ mOrientationCorrection( rhs.mOrientationCorrection )
{
}
scaling = rhs.scaling;
filtering = rhs.filtering;
- pixelformat = rhs.pixelformat;
mOrientationCorrection = rhs.mOrientationCorrection;
- isDistanceField = rhs.isDistanceField;
- fieldRadius = rhs.fieldRadius;
- fieldBorder = rhs.fieldBorder;
}
return *this;
}
- float fieldRadius; ///< The minimum search radius to check for differing pixels
- int fieldBorder : 16; ///< The amount of distancefield cells to add around the data (for glow/shadow effects)
unsigned int width : 16; ///< image width in pixels
unsigned int height : 16; ///< image height in pixels
ScalingMode scaling : 3; ///< scaling option, ShrinkToFit is default
FilterMode filtering : 3; ///< filtering option. Box is the default
- Pixel::Format pixelformat : 5; ///< pixel format, default is RGBA8888
bool mOrientationCorrection : 1; ///< If true, image pixels are reordered according to orientation metadata on load.
bool isDistanceField : 1; ///< true, if the image is a distancefield. Default is false.
};
impl->height = size.height;
}
-void ImageAttributes::SetPixelFormat(Pixel::Format format)
-{
- impl->pixelformat = format;
-}
-
void ImageAttributes::SetScalingMode(ScalingMode scale)
{
impl->scaling = scale;
return Size(impl->width, impl->height);
}
-Pixel::Format ImageAttributes::GetPixelFormat() const
-{
- return impl->pixelformat;
-}
-
ImageAttributes::ScalingMode ImageAttributes::GetScalingMode() const
{
return impl->scaling;
return impl->filtering;
}
-bool ImageAttributes::IsDistanceField() const
-{
- return impl->isDistanceField;
-}
-
-int ImageAttributes::GetFieldBorder() const
-{
- return impl->fieldBorder;
-}
-
-float ImageAttributes::GetFieldRadius() const
-{
- return impl->fieldRadius;
-}
-
bool ImageAttributes::GetOrientationCorrection() const
{
return impl->mOrientationCorrection;
return ImageAttributes();
}
-ImageAttributes ImageAttributes::New(unsigned int imageWidth, unsigned int imageHeight, Pixel::Format format)
+ImageAttributes ImageAttributes::New(unsigned int imageWidth, unsigned int imageHeight)
{
ImageAttributes attributes;
attributes.impl->width = imageWidth;
attributes.impl->height = imageHeight;
- attributes.impl->pixelformat = format;
- return attributes;
-}
-
-ImageAttributes ImageAttributes::NewDistanceField()
-{
- ImageAttributes attributes;
- attributes.impl->isDistanceField = true;
- attributes.impl->fieldRadius = 4.0f;
- attributes.impl->fieldBorder = 4;
- return attributes;
-}
-
-ImageAttributes ImageAttributes::NewDistanceField(float fieldRadius, int fieldBorder)
-{
- ImageAttributes attributes;
- attributes.impl->isDistanceField = true;
- attributes.impl->fieldRadius = fieldRadius;
- attributes.impl->fieldBorder = fieldBorder;
return attributes;
}
return a.impl->mOrientationCorrection < b.impl->mOrientationCorrection;
}
- if (a.impl->pixelformat != b.impl->pixelformat)
- {
- return a.impl->pixelformat < b.impl->pixelformat;
- }
-
if (a.impl->scaling != b.impl->scaling)
{
return a.impl->scaling < b.impl->scaling;
return a.impl->filtering < b.impl->filtering;
}
- if (a.impl->isDistanceField && b.impl->isDistanceField)
- {
- if (fabs(a.impl->fieldRadius - b.impl->fieldRadius) > Math::MACHINE_EPSILON_0)
- {
- return a.impl->fieldRadius < b.impl->fieldRadius;
- }
-
- if (a.impl->fieldBorder != b.impl->fieldBorder)
- {
- return a.impl->fieldBorder < b.impl->fieldBorder;
- }
- }
-
// they are equal
return false;
}
return a.impl->width == b.impl->width &&
a.impl->height == b.impl->height &&
a.impl->mOrientationCorrection == b.impl->mOrientationCorrection &&
- a.impl->pixelformat == b.impl->pixelformat &&
a.impl->scaling == b.impl->scaling &&
- a.impl->filtering == b.impl->filtering &&
- a.impl->isDistanceField == b.impl->isDistanceField &&
- fabs(a.impl->fieldRadius - b.impl->fieldRadius) < Math::MACHINE_EPSILON_0 &&
- a.impl->fieldBorder == b.impl->fieldBorder;
+ a.impl->filtering == b.impl->filtering;
}
/**
*
* @param [in] width desired width.
* @param [in] height desired height
- * @param [in] format desired pixelformat
* @return A handle to a newly allocated object
*/
- static ImageAttributes New(unsigned int width, unsigned int height, Pixel::Format format);
-
- /**
- * @brief Create an initialised image attributes object for distance field generation
- * using default parameters.
- *
- * @return A handle to a newly allocated object
- */
- static ImageAttributes NewDistanceField();
-
- /**
- * @brief Create an initialised image attributes object for distance field generation.
- *
- * @param [in] fieldRadius The minimum search radius to check for differing pixels
- * @param [in] fieldBorder The amount of distancefield cells to add around the data (for glow/shadow effects)
- * @return A handle to a newly allocated object
- */
- static ImageAttributes NewDistanceField(float fieldRadius, int fieldBorder);
+ static ImageAttributes New(unsigned int width, unsigned int height);
/**
* @brief Set the size properties.
void SetSize( const Size& size );
/**
- * @brief Set the pixelformat field of the image attributes.
- *
- * By default is set to Pixel::RGBA8888.
- * @param [in] format desired pixelformat
- */
- void SetPixelFormat(Pixel::Format format);
-
- /**
* @brief Set the scale field of the image attributes.
*
* By default, ShrinkToFit is set.
Size GetSize() const;
/**
- * @brief Return the pixel format currently represented by the attribute.
- *
- * @return pixel format
- */
- Pixel::Format GetPixelFormat() const;
-
- /**
* @brief Return the scale currently represented by the attribute.
*
* @return scale
FilterMode GetFilterMode() const;
/**
- * @brief Return if the attribute set up as a distance field.
- *
- * @return true, if the attribute is a distance field.
- */
- bool IsDistanceField() const;
-
- /**
- * @brief Return the field border currently represented by the attribute.
- *
- * @return field border
- */
- int GetFieldBorder() const;
-
- /**
- * @brief Return the field search radius currently represented by the attribute.
- *
- * @return field radius
- */
- float GetFieldRadius() const;
-
- /**
* @brief Whether to correct for physical orientation of an image.
*
* @return Whether image pixels should be transformed according to the
return *this;
}
-Image Image::New(NativeImage& nativeImg)
-{
- Internal::ImagePtr internal = Internal::Image::New(nativeImg);
- return Image(internal.Get());
-}
-
Image Image::DownCast( BaseHandle handle )
{
return Image( dynamic_cast<Dali::Internal::Image*>(handle.GetObjectPtr()) );
class Image;
}
-class NativeImage;
-
/**
* @brief An Image object represents an image resource that can be added to ImageActors.
*
Image& operator=(const Image& rhs);
/**
- * @brief Creates object with already loaded NativeImage.
- *
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE
- * @pre nativeImg should be initialised
- * @param [in] nativeImg already initialised NativeImage
- * @return A handle to a newly allocated object
- */
- static Image New(NativeImage& nativeImg);
-
- /**
* @brief Downcast an Object handle to Image handle.
*
* If handle points to a Image object the
--- /dev/null
+#ifndef __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
+#define __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+
+namespace Dali
+{
+
+/**
+ * @brief Abstract interface to provide platform-specific support for handling image data.
+ *
+ * For example, an implementation could use EGL extensions, etc.
+ */
+class NativeImageInterface : public Dali::RefObject
+{
+public:
+
+ /**
+ * @brief Create the GL resource for the NativeImage.
+ *
+ * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR()
+ * @pre There is a GL context for the current thread.
+ * @return false If the initialization fails.
+ */
+ virtual bool GlExtensionCreate() = 0;
+
+ /**
+ * @brief Destroy the GL resource for the NativeImage.
+ *
+ * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
+ * @pre There is a GL context for the current thread.
+ */
+ virtual void GlExtensionDestroy() = 0;
+
+ /**
+ * @brief Use the NativeImage as a texture for rendering.
+ *
+ * @pre There is a GL context for the current thread.
+ * @return A GL error code
+ */
+ virtual unsigned int TargetTexture() = 0;
+
+ /**
+ * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
+ *
+ * The correct texture sampler has already been bound before the function gets called.
+ * @pre glAbstraction is being used by context in current thread
+ */
+ virtual void PrepareTexture() = 0;
+
+ /**
+ * @brief Returns the width of the NativeImage.
+ *
+ * @return width
+ */
+ virtual unsigned int GetWidth() const = 0;
+
+ /**
+ * @brief Returns the height of the NativeImage.
+ *
+ * @return height
+ */
+ virtual unsigned int GetHeight() const = 0;
+
+ /**
+ * Query whether blending is required
+ */
+ virtual bool RequiresBlending() const = 0;
+
+protected:
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ *
+ * The implementation should destroy the NativeImage resources.
+ */
+ virtual ~NativeImageInterface()
+ {
+ }
+
+};
+
+/**
+ * @brief Pointer to Dali::NativeImageInterface
+ */
+typedef IntrusivePtr<NativeImageInterface> NativeImageInterfacePtr;
+
+} // namespace Dali
+
+#endif // __DALI_INTEGRATION_NATIVE_IMAGE_INTERFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/images/native-image.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/images/native-image-impl.h>
+
+namespace Dali
+{
+
+NativeImage::NativeImage()
+{
+}
+
+NativeImage::NativeImage(Internal::NativeImage* internal)
+: Image(internal)
+{
+}
+
+NativeImage::~NativeImage()
+{
+}
+
+NativeImage::NativeImage( const NativeImage& handle )
+: Image(handle)
+{
+}
+
+NativeImage& NativeImage::operator=( const NativeImage& rhs )
+{
+ BaseHandle::operator=(rhs);
+ return *this;
+}
+
+NativeImage NativeImage::New( NativeImageInterface& resourceData )
+{
+ Internal::NativeImagePtr internal = Internal::NativeImage::New( resourceData );
+ return NativeImage(internal.Get());
+}
+
+NativeImage NativeImage::DownCast( BaseHandle handle )
+{
+ return NativeImage( dynamic_cast<Internal::NativeImage*>( handle.GetObjectPtr()) );
+}
+
+} // namespace Dali
-#ifndef __DALI_INTEGRATION_NATIVE_IMAGE_H__
-#define __DALI_INTEGRATION_NATIVE_IMAGE_H__
+#ifndef __DALI_NATIVE_IMAGE_H__
+#define __DALI_NATIVE_IMAGE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/native-image-interface.h>
namespace Dali
{
+namespace Internal DALI_INTERNAL
+{
+class NativeImage;
+}
+
/**
- * @brief Abstract interface to provide platform-specific support for handling image data.
- *
- * For example, an implementation could use EGL extensions, etc.
+ * @brief NativeImage represents an image resource that can be added to ImageActors.
+ * Its data is provided by native resources, such as shared bitmap memory or pixmap from X11 or ECORE-X11, etc.
*/
-class NativeImage : public Dali::RefObject
+class DALI_IMPORT_API NativeImage : public Image
{
public:
/**
- * @brief Create the GL resource for the NativeImage.
- *
- * e.g. For the EglImageKHR extension, this corresponds to calling eglCreateImageKHR()
- * @pre There is a GL context for the current thread.
- * @return false If the initialization fails.
- */
- virtual bool GlExtensionCreate() = 0;
-
- /**
- * @brief Destroy the GL resource for the NativeImage.
+ * @brief Constructor with creates an uninitialized NativeImage object.
*
- * e.g. For the EglImageKHR extension, this corresponds to calling eglDestroyImageKHR()
- * @pre There is a GL context for the current thread.
+ * Use NativeImage::New(...) to create an initialised object.
*/
- virtual void GlExtensionDestroy() = 0;
+ NativeImage();
/**
- * @brief Use the NativeImage as a texture for rendering.
+ * @brief Destructor.
*
- * @pre There is a GL context for the current thread.
- * @return A GL error code
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
*/
- virtual unsigned int TargetTexture() = 0;
+ ~NativeImage();
- /**
- * @brief Called in each NativeTexture::Bind() call to allow implementation specific operations.
- *
- * The correct texture sampler has already been bound before the function gets called.
- * @pre glAbstraction is being used by context in current thread
- */
- virtual void PrepareTexture() = 0;
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle
+ */
+ NativeImage( const NativeImage& handle );
/**
- * @brief Returns the width of the NativeImage.
+ * @brief This assignment operator is required for (smart) pointer semantics.
*
- * @return width
+ * @param[in] rhs A reference to the copied handle.
+ * @return A reference to this.
*/
- virtual unsigned int GetWidth() const = 0;
+ NativeImage& operator=( const NativeImage& rhs );
/**
- * @brief Returns the height of the NativeImage.
+ * @brief Create a new NativeImage, which used native resources.
*
- * @return height
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE
+ * @param [in] nativeImageInterface An reference to the object of the interface implementation.
+ * @return A handle to a newly allocated object.
*/
- virtual unsigned int GetHeight() const = 0;
+ static NativeImage New( NativeImageInterface& nativeImageInterface );
/**
- * @brief Returns the internal pixel NativeImage::PixelFormat of the NativeImage.
+ * @brief Downcast an Object handle to NativeImage handle.
*
- * @return pixel format
+ * If handle points to a NativeImage object, the downcast produces valid handle.
+ * If not, the returned handle is left unintialized.
+ * @param[in] handle Handle to an object.
+ * @return handle to a NativeImage or an uninitialized handle.
*/
- virtual Pixel::Format GetPixelFormat() const = 0;
+ static NativeImage DownCast( BaseHandle handle );
-protected:
+public: // Not intended for application developers
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- *
- * The implementation should destroy the NativeImage resources.
- */
- virtual ~NativeImage()
- {
- }
+ explicit DALI_INTERNAL NativeImage( Internal::NativeImage* );
};
-/**
- * @brief Pointer to Dali::NativeImage
- */
-typedef IntrusivePtr<NativeImage> NativeImagePtr;
-
} // namespace Dali
-#endif // __DALI_INTEGRATION_NATIVE_IMAGE_H__
+#endif // __DALI_NATIVE_IMAGE_H__
}
field = "pixel-format";
+ Pixel::Format pixelFormat = Pixel::RGBA8888;
if( map.HasKey(field) )
{
DALI_ASSERT_ALWAYS(map.GetValue(field).GetType() == Property::STRING && "Image release-policy property is not a string" );
std::string s(map.GetValue(field).Get<std::string>());
- attributes.SetPixelFormat( GetEnumeration< Pixel::Format >( s.c_str(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT ));
+ pixelFormat = GetEnumeration< Pixel::Format >( s.c_str(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
}
field = "scaling-mode";
std::string s(map.GetValue("type").Get<std::string>());
if("FrameBufferImage" == s)
{
- ret = Image( new Internal::FrameBufferImage(attributes.GetWidth(),
- attributes.GetHeight(),
- attributes.GetPixelFormat(),
- releasePolicy) );
+ ret = FrameBufferImage::New(attributes.GetWidth(),
+ attributes.GetHeight(),
+ pixelFormat,
+ releasePolicy);
}
else if("BitmapImage" == s)
{
- ret = Image( new Internal::BitmapImage(attributes.GetWidth(),
- attributes.GetHeight(),
- attributes.GetPixelFormat(),
- releasePolicy) );
+ ret = BitmapImage::New(attributes.GetWidth(),
+ attributes.GetHeight(),
+ pixelFormat,
+ releasePolicy);
}
- else if("Image" == s)
+ else if("Image" == s || "ResourceImage" == s)
{
ret = ResourceImage::New(filename, attributes, loadPolicy, releasePolicy);
}
std::string imageType( "ResourceImage" );
// Get Type - cannot use TypeRegistry as Image is not an Object and thus, not registered
- if ( BitmapImage::DownCast( image ) )
+ BitmapImage bitmapImage = BitmapImage::DownCast( image );
+ if ( bitmapImage )
{
imageType = "BitmapImage";
+ map[ "pixel-format" ] = GetEnumerationName< Pixel::Format >( bitmapImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
}
else if ( FrameBufferImage::DownCast( image ) )
{
map[ "load-policy" ] = GetEnumerationName< ResourceImage::LoadPolicy >( resourceImage.GetLoadPolicy(), IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT );
ImageAttributes attributes( resourceImage.GetAttributes() );
- map[ "pixel-format" ] = GetEnumerationName< Pixel::Format >( attributes.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
map[ "scaling-mode" ] = GetEnumerationName< ImageAttributes::ScalingMode >( attributes.GetScalingMode(), IMAGE_SCALING_MODE_TABLE, IMAGE_SCALING_MODE_TABLE_COUNT );
}