Distinguish NativeImage from Image & Clean PixelFormat from ImageAttribute and Texture 93/35593/11
authorXiangyin Ma <x1.ma@samsung.com>
Wed, 18 Feb 2015 17:11:18 +0000 (17:11 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Tue, 24 Feb 2015 16:13:14 +0000 (16:13 +0000)
Change-Id: Ia89c86829cc22497b6d709a3f84b580ef4e04397

54 files changed:
automated-tests/src/dali-internal/utc-Dali-Internal-ImageFactory.cpp
automated-tests/src/dali-internal/utc-Dali-Internal-ResourceClient.cpp
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/dali-test-suite-utils/test-native-image.h
automated-tests/src/dali/utc-Dali-FrameBufferImage.cpp
automated-tests/src/dali/utc-Dali-Image.cpp
automated-tests/src/dali/utc-Dali-ImageAttributes.cpp
automated-tests/src/dali/utc-Dali-NativeImage.cpp [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-RenderTask.cpp
automated-tests/src/dali/utc-Dali-ResourceImage.cpp [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-Scripting.cpp
dali/internal/event/images/frame-buffer-image-impl.cpp
dali/internal/event/images/frame-buffer-image-impl.h
dali/internal/event/images/image-factory.cpp
dali/internal/event/images/image-impl.cpp
dali/internal/event/images/image-impl.h
dali/internal/event/images/native-image-impl.cpp [new file with mode: 0644]
dali/internal/event/images/native-image-impl.h [new file with mode: 0644]
dali/internal/event/resources/resource-client.cpp
dali/internal/event/resources/resource-client.h
dali/internal/file.list
dali/internal/render/common/texture-cache-dispatcher.h
dali/internal/render/gl-resources/bitmap-texture.cpp
dali/internal/render/gl-resources/bitmap-texture.h
dali/internal/render/gl-resources/compressed-bitmap-texture.cpp
dali/internal/render/gl-resources/compressed-bitmap-texture.h
dali/internal/render/gl-resources/frame-buffer-texture.cpp
dali/internal/render/gl-resources/frame-buffer-texture.h
dali/internal/render/gl-resources/native-frame-buffer-texture.cpp
dali/internal/render/gl-resources/native-frame-buffer-texture.h
dali/internal/render/gl-resources/native-texture.cpp
dali/internal/render/gl-resources/native-texture.h
dali/internal/render/gl-resources/texture-cache.cpp
dali/internal/render/gl-resources/texture-cache.h
dali/internal/render/gl-resources/texture-factory.cpp
dali/internal/render/gl-resources/texture-factory.h
dali/internal/render/gl-resources/texture.cpp
dali/internal/render/gl-resources/texture.h
dali/internal/update/resources/bitmap-metadata.cpp
dali/internal/update/resources/bitmap-metadata.h
dali/internal/update/resources/resource-manager.cpp
dali/internal/update/resources/resource-manager.h
dali/public-api/dali-core.h
dali/public-api/file.list
dali/public-api/images/frame-buffer-image.cpp
dali/public-api/images/frame-buffer-image.h
dali/public-api/images/image-attributes.cpp
dali/public-api/images/image-attributes.h
dali/public-api/images/image.cpp
dali/public-api/images/image.h
dali/public-api/images/native-image-interface.h [new file with mode: 0644]
dali/public-api/images/native-image.cpp [new file with mode: 0644]
dali/public-api/images/native-image.h
dali/public-api/scripting/scripting.cpp

index 19d8428..a9aef9b 100644 (file)
@@ -166,7 +166,7 @@ int UtcDaliImageFactoryUseCachedRequest03(void)
   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 );
@@ -181,10 +181,10 @@ int UtcDaliImageFactoryUseCachedRequest04(void)
 
   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;
index 5feb844..030d4bd 100644 (file)
@@ -1024,7 +1024,6 @@ int UtcDaliInternalAllocateBitmapImage01(void)
   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
@@ -1034,7 +1033,6 @@ int UtcDaliInternalAllocateBitmapImage01(void)
   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 );
@@ -1062,7 +1060,6 @@ int UtcDaliInternalAddBitmapImage01(void)
   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
@@ -1072,7 +1069,6 @@ int UtcDaliInternalAddBitmapImage01(void)
   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 );
@@ -1100,7 +1096,6 @@ int UtcDaliInternalAddBitmapImage02(void)
   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
@@ -1110,7 +1105,6 @@ int UtcDaliInternalAddBitmapImage02(void)
   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);
@@ -1299,7 +1293,6 @@ int UtcDaliInternalAddFrameBufferImage(void)
 
   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
 
@@ -1310,7 +1303,6 @@ int UtcDaliInternalAddFrameBufferImage(void)
   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;
index 072ad59..e546654 100644 (file)
@@ -57,6 +57,7 @@ SET(TC_SOURCES
         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
@@ -74,6 +75,7 @@ SET(TC_SOURCES
         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
index b4876cc..720b429 100644 (file)
  */
 
 // 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);
@@ -37,7 +37,7 @@ public:
   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);
index f282693..7e86c5c 100644 (file)
@@ -21,6 +21,7 @@
 #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;
@@ -76,6 +77,25 @@ int UtcDaliFrameBufferImageNew01(void)
   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;
index 8170b69..4d68d73 100644 (file)
@@ -36,317 +36,23 @@ void utc_dali_image_cleanup(void)
 
 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;
@@ -371,107 +77,6 @@ int UtcDaliImageDownCast(void)
   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;
@@ -487,28 +92,35 @@ int UtcDaliImageGetReleasePolicy(void)
   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;
@@ -520,46 +132,17 @@ static void SignalUploadedHandler(Image image)
   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();
@@ -567,13 +150,14 @@ int UtcDaliImageSignalUploaded(void)
   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();
@@ -596,20 +180,19 @@ int UtcDaliImageSignalUploaded(void)
   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);
@@ -618,7 +201,6 @@ int UtcDaliImageSignalUploaded(void)
   END_TEST;
 }
 
-// 1.17
 int UtcDaliImageDiscard01(void)
 {
   TestApplication application;
@@ -633,14 +215,8 @@ int UtcDaliImageDiscard01(void)
     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
@@ -657,7 +233,6 @@ int UtcDaliImageDiscard01(void)
   END_TEST;
 }
 
-// 1.18
 int UtcDaliImageDiscard02(void)
 {
   TestApplication application;
@@ -682,14 +257,8 @@ int UtcDaliImageDiscard02(void)
         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") );
@@ -716,7 +285,6 @@ int UtcDaliImageDiscard02(void)
   END_TEST;
 }
 
-// 1.19
 int UtcDaliImageDiscard03(void)
 {
   TestApplication application;
@@ -736,15 +304,8 @@ int UtcDaliImageDiscard03(void)
   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();
@@ -766,24 +327,6 @@ int UtcDaliImageDiscard03(void)
   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
index 0874419..1b95b6d 100644 (file)
@@ -70,9 +70,6 @@ int UtcDaliImageAttributesLessThan(void)
   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);
diff --git a/automated-tests/src/dali/utc-Dali-NativeImage.cpp b/automated-tests/src/dali/utc-Dali-NativeImage.cpp
new file mode 100644 (file)
index 0000000..9a36354
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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;
+}
index dcba4c1..43f1918 100644 (file)
@@ -21,6 +21,7 @@
 #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")
 
@@ -40,61 +41,6 @@ void utc_dali_render_task_cleanup(void)
 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)
 
 /*
@@ -239,8 +185,8 @@ RenderTask CreateRenderTask(TestApplication& application,
   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
   {
@@ -1190,7 +1136,7 @@ int UtcDaliRenderTaskSignalFinished(void)
   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
diff --git a/automated-tests/src/dali/utc-Dali-ResourceImage.cpp b/automated-tests/src/dali/utc-Dali-ResourceImage.cpp
new file mode 100644 (file)
index 0000000..e702b3e
--- /dev/null
@@ -0,0 +1,494 @@
+/*
+ * 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;
+}
index fa6476b..870fc96 100644 (file)
@@ -90,6 +90,13 @@ ResourceImage NewResourceImage( const Property::Value& map )
   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 )
 {
@@ -490,42 +497,6 @@ int UtcDaliScriptingNewImage(void)
 
   //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" ] = "";
   {
@@ -546,11 +517,50 @@ int UtcDaliScriptingNewImage(void)
     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";
   {
@@ -944,8 +954,6 @@ int UtcDaliScriptingCreatePropertyMapImage(void)
     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" ) );
@@ -955,7 +963,6 @@ int UtcDaliScriptingCreatePropertyMapImage(void)
   // 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 );
@@ -973,8 +980,6 @@ int UtcDaliScriptingCreatePropertyMapImage(void)
     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" ) );
@@ -985,12 +990,14 @@ int UtcDaliScriptingCreatePropertyMapImage(void)
 
   // 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
index 2a9d279..2329e6b 100644 (file)
@@ -45,14 +45,14 @@ FrameBufferImagePtr  FrameBufferImage::New(unsigned int width, unsigned int heig
   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();
@@ -67,19 +67,17 @@ FrameBufferImage::FrameBufferImage(unsigned int width, unsigned int height, Pixe
   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();
index 04e150f..62e3c58 100644 (file)
@@ -43,14 +43,14 @@ public:
   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
@@ -65,12 +65,12 @@ public:
   /**
    * @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
   /**
@@ -91,7 +91,7 @@ protected:
 
 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
 
index 34bdbd2..2e97ffd 100644 (file)
@@ -258,10 +258,6 @@ bool ImageFactory::CompareAttributes( const Dali::ImageAttributes& requested,
             (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);
 }
index 2c7cd27..9a9ccb9 100644 (file)
@@ -49,24 +49,6 @@ Dali::SignalConnectorType signalConnector1( mType, SIGNAL_IMAGE_UPLOADED, &Image
 
 }
 
-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 );
index d517b8c..0d5a9da 100644 (file)
@@ -23,7 +23,6 @@
 
 // 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>
@@ -52,15 +51,6 @@ class Image : public BaseObject, public ResourceTicketObserver
 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; }
diff --git a/dali/internal/event/images/native-image-impl.cpp b/dali/internal/event/images/native-image-impl.cpp
new file mode 100644 (file)
index 0000000..46211cb
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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
diff --git a/dali/internal/event/images/native-image-impl.h b/dali/internal/event/images/native-image-impl.h
new file mode 100644 (file)
index 0000000..7ea947b
--- /dev/null
@@ -0,0 +1,86 @@
+#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__
index d82be43..a4a92e2 100644 (file)
@@ -303,7 +303,7 @@ ImageTicketPtr ResourceClient::AddBitmapImage(Bitmap* bitmap)
 
   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);
@@ -321,7 +321,7 @@ ImageTicketPtr ResourceClient::AddBitmapImage(Bitmap* bitmap)
   return newTicket;
 }
 
-ResourceTicketPtr ResourceClient::AddNativeImage ( NativeImage& resourceData )
+ResourceTicketPtr ResourceClient::AddNativeImage ( NativeImageInterface& resourceData )
 {
   ImageTicketPtr newTicket;
 
@@ -330,8 +330,7 @@ ResourceTicketPtr ResourceClient::AddNativeImage ( NativeImage& resourceData )
   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()));
@@ -349,7 +348,7 @@ ImageTicketPtr ResourceClient::AddFrameBufferImage ( unsigned int width, unsigne
 
   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);
@@ -364,13 +363,13 @@ ImageTicketPtr ResourceClient::AddFrameBufferImage ( unsigned int width, unsigne
   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);
@@ -393,7 +392,7 @@ ResourceTicketPtr ResourceClient::AllocateTexture( unsigned int width,
   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);
index 1b5ec87..0c88d06 100644 (file)
@@ -23,7 +23,7 @@
 
 // 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>
@@ -195,7 +195,7 @@ public:
    * @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.
@@ -211,7 +211,7 @@ public:
    * @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.
index 587de24..fee2d9e 100644 (file)
@@ -82,6 +82,7 @@ internal_src_files = \
   $(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 \
index 1ea5f80..20a1c6a 100644 (file)
@@ -22,7 +22,7 @@
 #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>
@@ -99,7 +99,7 @@ public:
    * @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
@@ -117,7 +117,7 @@ public:
    * @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.
index 39b09a7..e45e553 100644 (file)
@@ -40,11 +40,11 @@ BitmapTexture::BitmapTexture(
            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));
@@ -59,11 +59,11 @@ BitmapTexture::BitmapTexture(
   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);
 }
index 7cbdfbc..15494c6 100644 (file)
@@ -184,6 +184,7 @@ private:
   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;
index 53d270f..73e5afe 100644 (file)
@@ -36,10 +36,10 @@ CompressedBitmapTexture::CompressedBitmapTexture(Internal::BitmapCompressed* con
           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));
index 583c1ff..f06a225 100644 (file)
@@ -124,6 +124,7 @@ private:
 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;
index 542efb4..68ba684 100644 (file)
@@ -29,11 +29,22 @@ namespace Dali
 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);
 
index f44286b..92e4604 100644 (file)
@@ -39,6 +39,15 @@ namespace Internal
 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)
@@ -77,6 +86,7 @@ public:
 protected:
   unsigned int mFrameBufferName;
   unsigned int mRenderBufferName;
+  Pixel::Format mPixelFormat;
 
   /**
    * @copydoc Texture::CreateGlTexture
index 48f23e7..7899963 100644 (file)
@@ -29,10 +29,9 @@ namespace Dali
 namespace Internal
 {
 
-NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImagePtr nativeImage, Context& context)
+NativeFrameBufferTexture::NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context)
   : FrameBufferTexture(nativeImage->GetWidth(),
                        nativeImage->GetHeight(),
-                       nativeImage->GetPixelFormat(),
                        context),
     mNativeImage(nativeImage)
 {
@@ -48,13 +47,12 @@ NativeFrameBufferTexture::~NativeFrameBufferTexture()
 
 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()
@@ -125,7 +123,6 @@ void NativeFrameBufferTexture::GlCleanup()
   mNativeImage.Reset();
 }
 
-
 } //namespace Internal
 
 } //namespace Dali
index f44300f..0d7cee6 100644 (file)
@@ -45,7 +45,7 @@ public:
    * @param[in] nativeImage The NativeImage
    * @param     context The GL context
    */
-  NativeFrameBufferTexture( NativeImagePtr nativeImage, Context& context);
+  NativeFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context);
 
   /**
    * Destructor.
@@ -79,7 +79,7 @@ protected:
   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
 
index 5e227e8..8ac99c6 100644 (file)
@@ -31,13 +31,12 @@ namespace Dali
 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 );
@@ -71,18 +70,12 @@ bool NativeTexture::Bind(GLenum target, TextureUnit textureunit )
 
 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()
index b91a04e..0076934 100644 (file)
@@ -20,7 +20,7 @@
 
 // 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
@@ -46,7 +46,7 @@ public:
    * @param nativeImg         the NativeImage to be used
    * @param context           the GL context
    */
-  NativeTexture(NativeImage* nativeImg, Context& context);
+  NativeTexture(NativeImageInterface* nativeImg, Context& context);
 
   /**
    * Destructor.
@@ -68,12 +68,6 @@ public:
    */
   virtual bool HasAlphaChannel() const;
 
-
-  /**
-   * @copydoc Texture::GetPixelFormat
-   */
-  virtual Pixel::Format GetPixelFormat() const;
-
   /**
    * @copydoc Texture::Init
    */
@@ -93,7 +87,7 @@ protected:
 
 private:
 
-  NativeImagePtr mNativeImage; ///< reference to NativeImage the Texture was created from
+  NativeImageInterfacePtr mNativeImage; ///< reference to NativeImage the Texture was created from
 };
 
 }  //namespace Internal
index bfa9185..bf8e768 100644 (file)
@@ -89,7 +89,7 @@ void TextureCache::AddBitmap(ResourceId id, Integration::BitmapPtr bitmap)
   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());
 
@@ -108,7 +108,7 @@ void TextureCache::AddFrameBuffer( ResourceId id, unsigned int width, unsigned i
   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());
 
@@ -472,12 +472,12 @@ void TextureCache::DispatchCreateTextureForBitmap( ResourceId id, Bitmap* bitmap
   }
 }
 
-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 ) );
@@ -502,12 +502,12 @@ void TextureCache::DispatchCreateTextureForFrameBuffer( ResourceId id, unsigned
   }
 }
 
-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 ) );
index 1bbc7f9..f7cd399 100644 (file)
@@ -38,7 +38,7 @@
 
 namespace Dali
 {
-class NativeImage;
+class NativeImageInterface;
 
 
 namespace Integration
@@ -112,7 +112,7 @@ public:
    * @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
@@ -128,7 +128,7 @@ public:
    * @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
@@ -267,7 +267,7 @@ protected: // Implements TextureCacheDispatcher
   /**
    * @copydoc TextureCacheDispatcher::DispatchCreateTextureForNativeImage()
    */
-  virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImagePtr nativeImage );
+  virtual void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage );
 
   /**
    * @copydoc TextureCacheDispatcher::DispatchCreateTextureForFramebuffer()
@@ -277,7 +277,7 @@ protected: // Implements TextureCacheDispatcher
   /**
    * @copydoc TextureCacheDispatcher::DispatchCreateTextureForFramebuffer()
    */
-  virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImagePtr nativeImage );
+  virtual void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage );
 
   /**
    * @copydoc TextureCacheDispatcher::DispatchUpdateTexture()
index 72ac11a..8a86b35 100644 (file)
 #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
 {
@@ -79,7 +78,7 @@ Internal::Texture* NewBitmapTexture( unsigned int      width,
 }
 
 
-Internal::Texture* NewNativeImageTexture( NativeImage& nativeImg, Context& context )
+Internal::Texture* NewNativeImageTexture( NativeImageInterface& nativeImg, Context& context )
 {
   NativeTexture* texture = new NativeTexture(&nativeImg, context);
   if (!texture->Init())
@@ -104,7 +103,7 @@ Internal::Texture* NewFrameBufferTexture( unsigned int width,
   return texture;
 }
 
-Internal::Texture* NewFrameBufferTexture( NativeImagePtr nativeImage,
+Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage,
                                           Context& context )
 {
   NativeFrameBufferTexture* texture = new NativeFrameBufferTexture(nativeImage, context);
index 59131eb..d04d1ee 100644 (file)
 
 // 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
 {
@@ -70,7 +70,7 @@ Internal::Texture* NewBitmapTexture( unsigned int      width,
  * @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
@@ -85,7 +85,7 @@ Internal::Texture* NewFrameBufferTexture( unsigned int width,
  * @copydoc FrameBufferTexture::FrameBufferTexture
  * @return A newly allocated texture
  */
-Internal::Texture* NewFrameBufferTexture( NativeImagePtr nativeImage, Context& context );
+Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context );
 
 };
 
index d2c1b0d..687cbf4 100644 (file)
@@ -89,16 +89,14 @@ Texture::Texture(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)
 {
 }
 
@@ -203,11 +201,6 @@ unsigned int Texture::GetHeight() const
   return mHeight;
 }
 
-Pixel::Format Texture::GetPixelFormat() const
-{
-  return mPixelFormat;
-}
-
 void Texture::GetTextureCoordinates(UvRect& uv, const PixelArea* pixelArea)
 {
   if( pixelArea == NULL )
index 0479f01..c43ddbf 100644 (file)
@@ -137,12 +137,6 @@ public:
   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
    */
@@ -197,25 +191,21 @@ protected:
    * @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.
@@ -284,9 +274,6 @@ protected:
 
   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
index 7a1e836..3fce21d 100644 (file)
@@ -31,32 +31,32 @@ namespace Dali
 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)
@@ -66,7 +66,7 @@ BitmapMetadata::BitmapMetadata( unsigned int width,
 BitmapMetadata::BitmapMetadata( )
 : mImageWidth(0),
   mImageHeight(0),
-  mPixelFormat(Pixel::RGBA8888),
+  mHasAlphaChannel(true),
   mOpaqueness(false),
   mIsNativeImage(false),
   mIsFramebuffer(false)
@@ -76,7 +76,7 @@ BitmapMetadata::BitmapMetadata( )
 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)
@@ -87,19 +87,19 @@ BitmapMetadata& BitmapMetadata::operator=( const BitmapMetadata& rhs )
 {
   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;
 }
 
@@ -107,7 +107,7 @@ void BitmapMetadata::Update(Integration::Bitmap* const bitmap)
 {
   mImageWidth  = bitmap->GetImageWidth();
   mImageHeight = bitmap->GetImageHeight();
-  mPixelFormat = bitmap->GetPixelFormat();
+  mHasAlphaChannel = Pixel::HasAlpha(bitmap->GetPixelFormat());
   mOpaqueness  = bitmap->IsFullyOpaque();
   mIsNativeImage = false;
 }
@@ -122,14 +122,9 @@ unsigned int BitmapMetadata::GetHeight() const
   return mImageHeight;
 }
 
-Pixel::Format BitmapMetadata::GetPixelFormat() const
-{
-  return mPixelFormat;
-}
-
 bool BitmapMetadata::HasAlphaChannel() const
 {
-  return HasAlpha(mPixelFormat);
+  return mHasAlphaChannel;
 }
 
 bool BitmapMetadata::IsFullyOpaque() const
@@ -147,9 +142,9 @@ void BitmapMetadata::SetHeight(unsigned int height)
   mImageHeight = height;
 }
 
-void BitmapMetadata::SetPixelFormat(Pixel::Format pixelFormat)
+void BitmapMetadata::SetHasAlphaChannel( bool hasAlphaChannel )
 {
-  mPixelFormat = pixelFormat;
+  mHasAlphaChannel = hasAlphaChannel;
 }
 
 void BitmapMetadata::SetOpaqueness(bool opaqueness)
index 82ef62e..13bd699 100644 (file)
@@ -21,7 +21,7 @@
 // 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
 {
@@ -39,7 +39,7 @@ public:
    * @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
@@ -52,12 +52,12 @@ public:
    * 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
@@ -78,7 +78,7 @@ public:
    * 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
@@ -99,12 +99,6 @@ public:
   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.
    */
@@ -129,11 +123,10 @@ public:
   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.
@@ -150,7 +143,7 @@ public:
 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
index 82b7e53..9650df8 100644 (file)
@@ -327,7 +327,7 @@ void ResourceManager::HandleAddBitmapImageRequest( ResourceId id, BitmapPtr bitm
   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);
@@ -345,21 +345,21 @@ void ResourceManager::HandleAddFrameBufferImageRequest( ResourceId id, unsigned
 
   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));
@@ -792,9 +792,7 @@ void ResourceManager::LoadResponse( ResourceId id, ResourceTypeId type, Resource
           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
@@ -815,9 +813,9 @@ void ResourceManager::LoadResponse( ResourceId id, ResourceTypeId type, Resource
 
       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 );
index 43bab93..103a690 100644 (file)
@@ -23,7 +23,7 @@
 
 // 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>
 
@@ -48,7 +48,7 @@
 namespace Dali
 {
 
-class NativeImage;
+class NativeImageInterface;
 
 namespace Integration
 {
@@ -209,10 +209,10 @@ public: // Used by ResourceClient
   /**
    * 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.
@@ -228,7 +228,7 @@ public: // Used by ResourceClient
    * @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.
@@ -512,9 +512,9 @@ inline void RequestAddBitmapImageMessage( EventToUpdate& eventToUpdate,
 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 ) );
@@ -542,9 +542,9 @@ inline void RequestAddFrameBufferImageMessage( EventToUpdate& eventToUpdate,
 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 ) );
index 35aa175..5268997 100644 (file)
@@ -99,7 +99,9 @@
 #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>
 
index 83d25a3..2cfb825 100644 (file)
@@ -69,6 +69,7 @@ public_api_src_files = \
   $(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 \
@@ -220,10 +221,11 @@ public_api_core_images_header_files = \
   $(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 \
index 32f3507..37d557f 100644 (file)
@@ -75,13 +75,13 @@ FrameBufferImage FrameBufferImage::New(unsigned int width, unsigned int height,
   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());
index b5fca0b..3f20545 100644 (file)
@@ -20,6 +20,7 @@
 
 // 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
@@ -88,7 +89,7 @@ public:
    * @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.
@@ -103,7 +104,7 @@ public:
    * @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.
index 1bbe8e5..6621785 100644 (file)
@@ -29,15 +29,11 @@ const ImageAttributes ImageAttributes::DEFAULT_ATTRIBUTES;
 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)
   {
   }
 
@@ -46,15 +42,11 @@ struct ImageAttributes::ImageAttributesImpl
   }
 
   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 )
   {
   }
 
@@ -67,23 +59,16 @@ struct ImageAttributes::ImageAttributesImpl
       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.
 };
@@ -123,11 +108,6 @@ void ImageAttributes::SetSize( const Size& size )
   impl->height = size.height;
 }
 
-void ImageAttributes::SetPixelFormat(Pixel::Format format)
-{
-  impl->pixelformat = format;
-}
-
 void ImageAttributes::SetScalingMode(ScalingMode scale)
 {
   impl->scaling = scale;
@@ -158,11 +138,6 @@ Size ImageAttributes::GetSize() const
   return Size(impl->width, impl->height);
 }
 
-Pixel::Format ImageAttributes::GetPixelFormat() const
-{
-  return impl->pixelformat;
-}
-
 ImageAttributes::ScalingMode ImageAttributes::GetScalingMode() const
 {
   return impl->scaling;
@@ -173,21 +148,6 @@ ImageAttributes::FilterMode ImageAttributes::GetFilterMode() const
   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;
@@ -198,30 +158,11 @@ ImageAttributes ImageAttributes::New()
   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;
 }
 
@@ -253,11 +194,6 @@ bool operator<(const ImageAttributes& a, const ImageAttributes& b)
     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;
@@ -268,19 +204,6 @@ bool operator<(const ImageAttributes& a, const ImageAttributes& b)
     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;
 }
@@ -295,12 +218,8 @@ bool operator==(const ImageAttributes& a, const ImageAttributes& b)
   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;
 }
 
 /**
index d2b3a29..7ec5385 100644 (file)
@@ -150,27 +150,9 @@ public:
    *
    * @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.
@@ -196,14 +178,6 @@ public:
   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.
@@ -260,13 +234,6 @@ public:
   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
@@ -282,27 +249,6 @@ public:
   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
index ad394d0..e2682d3 100644 (file)
@@ -48,12 +48,6 @@ Image& Image::operator=(const Image& rhs)
   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()) );
index 3c719ae..1af2406 100644 (file)
@@ -33,8 +33,6 @@ namespace Internal DALI_INTERNAL
 class Image;
 }
 
-class NativeImage;
-
 /**
  * @brief An Image object represents an image resource that can be added to ImageActors.
  *
@@ -111,16 +109,6 @@ public:
   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
diff --git a/dali/public-api/images/native-image-interface.h b/dali/public-api/images/native-image-interface.h
new file mode 100644 (file)
index 0000000..a23fd8a
--- /dev/null
@@ -0,0 +1,108 @@
+#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__
diff --git a/dali/public-api/images/native-image.cpp b/dali/public-api/images/native-image.cpp
new file mode 100644 (file)
index 0000000..bb097b9
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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
index 550489f..69b5536 100644 (file)
@@ -1,8 +1,8 @@
-#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__
index 6eddb5c..031076b 100644 (file)
@@ -301,11 +301,12 @@ Image NewImage( const Property::Value& map )
     }
 
     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";
@@ -322,19 +323,19 @@ Image NewImage( const Property::Value& map )
       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);
       }
@@ -540,9 +541,11 @@ void CreatePropertyMap( Image image, Property::Map& map )
     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 ) )
     {
@@ -559,7 +562,6 @@ void CreatePropertyMap( Image image, Property::Map& map )
       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 );
     }