Updates following NativeImage changes and Pixel Format clean up in core 94/35594/10
authorXiangyin Ma <x1.ma@samsung.com>
Wed, 18 Feb 2015 17:18:10 +0000 (17:18 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Tue, 24 Feb 2015 16:14:22 +0000 (16:14 +0000)
Change-Id: I0db26e56d32cfbb80568f3937af9af4389ceae15

19 files changed:
adaptors/common/indicator-buffer.cpp
adaptors/common/indicator-buffer.h
adaptors/common/indicator-impl.cpp
adaptors/common/native-bitmap-buffer-impl.cpp
adaptors/common/native-bitmap-buffer-impl.h
adaptors/public-api/adaptor-framework/pixmap-image.cpp
adaptors/public-api/adaptor-framework/pixmap-image.h
adaptors/wayland/pixmap-image-impl-wl.cpp
adaptors/wayland/pixmap-image-impl.h
adaptors/x11/pixmap-image-impl-x.cpp
adaptors/x11/pixmap-image-impl.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-native-image.h
platform-abstractions/slp/image-loaders/loader-bmp.cpp
platform-abstractions/slp/image-loaders/loader-gif.cpp
platform-abstractions/slp/image-loaders/loader-ico.cpp
platform-abstractions/slp/image-loaders/loader-jpeg-turbo.cpp
platform-abstractions/slp/image-loaders/loader-ktx.cpp
platform-abstractions/slp/image-loaders/loader-png.cpp
platform-abstractions/slp/image-loaders/loader-wbmp.cpp

index b108682..bcc2c29 100644 (file)
@@ -45,7 +45,7 @@ bool IndicatorBuffer::UpdatePixels( const unsigned char *src, size_t size )
   return true;
 }
 
-NativeImage& IndicatorBuffer::GetNativeImage() const
+NativeImageInterface& IndicatorBuffer::GetNativeImage() const
 {
   DALI_ASSERT_DEBUG(mNativeImage.Get());
   return *mNativeImage;
index 0043b61..4a43c3d 100644 (file)
@@ -64,7 +64,7 @@ public:
    * Returns the NativeImage used internally
    * @return the NativeImage used internally
    */
-  NativeImage& GetNativeImage() const;
+  NativeImageInterface& GetNativeImage() const;
 
   /**
    * Set currently used Adaptor
@@ -73,7 +73,7 @@ public:
   void SetAdaptor( Adaptor* adaptor );
 
 private:
-  NativeImagePtr mNativeImage; ///< Image buffer created for shared file copy
+  NativeImageInterfacePtr mNativeImage; ///< Image buffer created for shared file copy
 
   NativeBitmapBufferPtr mBitmapBuffer;    ///< Image buffer created for shared file copy if extension not available
 
index 5cf7daa..3cfd24d 100644 (file)
@@ -29,6 +29,7 @@
 #include <errno.h>
 
 #include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/native-image.h>
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/events/touch-point.h>
@@ -990,7 +991,7 @@ void Indicator::CreateNewPixmapImage()
 
   if( pixmapImage )
   {
-    mIndicatorImageActor.SetImage( Dali::Image::New(*pixmapImage) );
+    mIndicatorImageActor.SetImage( Dali::NativeImage::New(*pixmapImage) );
     mIndicatorImageActor.SetSize( mImageWidth, mImageHeight );
     mIndicatorActor.SetSize( mImageWidth, mImageHeight );
     mEventActor.SetSize(mImageWidth, mImageHeight);
@@ -1018,7 +1019,7 @@ void Indicator::CreateNewImage()
 {
   DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d\n", mImageWidth, mImageHeight );
   mIndicatorBuffer = new IndicatorBuffer( mAdaptor, mImageWidth, mImageHeight, Pixel::BGRA8888 );
-  Dali::Image image = Dali::Image::New( mIndicatorBuffer->GetNativeImage() );
+  Dali::Image image = Dali::NativeImage::New( mIndicatorBuffer->GetNativeImage() );
 
   if( CopyToBuffer() ) // Only create images if we have valid image buffer
   {
index 0424b07..0806755 100644 (file)
@@ -98,9 +98,9 @@ unsigned int NativeBitmapBuffer::GetHeight() const
   return mHeight;
 }
 
-Pixel::Format NativeBitmapBuffer::GetPixelFormat() const
+bool NativeBitmapBuffer::RequiresBlending() const
 {
-  return mPixelFormat;
+  return Pixel::HasAlpha( mPixelFormat );
 }
 
 } // namespace Adaptor
index d504493..b7f4dc3 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL HEADERS
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
 #include <dali/public-api/images/pixel.h>
 #include <dali/integration-api/gl-abstraction.h>
 #include <dali/integration-api/lockless-buffer.h>
@@ -43,7 +43,7 @@ typedef IntrusivePtr<NativeBitmapBuffer> NativeBitmapBufferPtr;
 /**
  * A Bitmap-based implementation of the NativeImage interface.
  */
-class NativeBitmapBuffer : public NativeImage
+class NativeBitmapBuffer : public NativeImageInterface
 {
 
 public:
@@ -71,39 +71,39 @@ public:
 
 public:
   /**
-   * @copydoc Dali::NativeImage::GlExtensionCreate()
+   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
    */
   virtual bool GlExtensionCreate();
 
   /**
-   * @copydoc Dali::NativeImage::GlExtensionDestroy()
+   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
    */
   virtual void GlExtensionDestroy();
 
   /**
-   * @copydoc Dali::NativeImage::TargetTexture()
+   * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
   virtual unsigned int TargetTexture();
 
   /**
-   * @copydoc Dali::NativeImage::PrepareTexture()
+   * @copydoc Dali::NativeImageInterface::PrepareTexture()
    */
   virtual void PrepareTexture();
 
   /**
-   * @copydoc Dali::NativeImage::GetWidth()
+   * @copydoc Dali::NativeImageInterface::GetWidth()
    */
   virtual unsigned int GetWidth() const;
 
   /**
-   * @copydoc Dali::NativeImage::GetHeight()
+   * @copydoc Dali::NativeImageInterface::GetHeight()
    */
   virtual unsigned int GetHeight() const;
 
   /**
-   * @copydoc Dali::NativeImage::GetPixelFormat()
+   * @copydoc Dali::NativeImageInterface::RequiresBlending()
    */
-  virtual Pixel::Format GetPixelFormat() const;
+  virtual bool RequiresBlending() const;
 
 private:
   NativeBitmapBuffer( const NativeBitmapBuffer& );             ///< not defined
index ae6f74a..734216d 100644 (file)
@@ -85,9 +85,9 @@ unsigned int PixmapImage::GetHeight() const
   return mImpl->GetHeight();
 }
 
-Pixel::Format PixmapImage::GetPixelFormat() const
+bool PixmapImage::RequiresBlending() const
 {
-  return mImpl->GetPixelFormat();
+  return mImpl->RequiresBlending();
 }
 
 PixmapImage::PixmapImage( unsigned int width, unsigned int height, ColorDepth depth, Any pixmap )
index 4960a65..237c37e 100644 (file)
@@ -22,7 +22,8 @@
 #include <string>
 
 #include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
+#include <dali/public-api/images/pixel.h>
 #include <dali/public-api/object/any.h>
 
 namespace Dali
@@ -49,7 +50,7 @@ typedef IntrusivePtr<PixmapImage> PixmapImagePtr;
  * externally by X11 or ECORE-X11.
  *
  */
-class DALI_IMPORT_API PixmapImage : public NativeImage
+class DALI_IMPORT_API PixmapImage : public NativeImageInterface
 {
 public:
 
@@ -118,39 +119,39 @@ public:
 private:   // native image
 
   /**
-   * @copydoc Dali::NativeImage::GlExtensionCreate()
+   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
    */
   virtual bool GlExtensionCreate();
 
   /**
-   * @copydoc Dali::NativeImage::GlExtensionDestroy()
+   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
    */
   virtual void GlExtensionDestroy();
 
   /**
-   * @copydoc Dali::NativeImage::TargetTexture()
+   * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
   virtual unsigned int TargetTexture();
 
   /**
-   * @copydoc Dali::NativeImage::PrepareTexture()
+   * @copydoc Dali::NativeImageInterface::PrepareTexture()
    */
   virtual void PrepareTexture();
 
   /**
-   * @copydoc Dali::NativeImage::GetWidth()
+   * @copydoc Dali::NativeImageInterface::GetWidth()
    */
   virtual unsigned int GetWidth() const;
 
   /**
-   * @copydoc Dali::NativeImage::GetHeight()
+   * @copydoc Dali::NativeImageInterface::GetHeight()
    */
   virtual unsigned int GetHeight() const;
 
   /**
-   * @copydoc Dali::NativeImage::GetPixelFormat()
+   * @copydoc Dali::NativeImageInterface::RequiresBlending()
    */
-  virtual Pixel::Format GetPixelFormat() const;
+  virtual bool RequiresBlending() const;
 
 private:
 
index fc5936f..38c13a1 100644 (file)
@@ -59,7 +59,6 @@ PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapI
 : mWidth( width ),
   mHeight( height ),
   mOwnPixmap( true ),
-  mPixelFormat( Pixel::RGB888 ),
   mColorDepth( depth ),
   mEglImageKHR( NULL ),
   mEglImageExtensions( NULL )
@@ -67,6 +66,8 @@ PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapI
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
   EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
   mEglImageExtensions = eglFactory.GetImageExtensions();
+  SetBlending( mColorDepth );
+
   DALI_ASSERT_DEBUG( mEglImageExtensions );
 }
 
@@ -121,59 +122,25 @@ unsigned int PixmapImage::TargetTexture()
   return 0;
 }
 
-int PixmapImage::GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const
-{
-  switch (depth)
-  {
-    case Dali::PixmapImage::COLOR_DEPTH_8:
-    {
-      return 8;
-    }
-    case Dali::PixmapImage::COLOR_DEPTH_16:
-    {
-      return 16;
-    }
-    case Dali::PixmapImage::COLOR_DEPTH_24:
-    {
-      return 24;
-    }
-    case Dali::PixmapImage::COLOR_DEPTH_32:
-    {
-      return 32;
-    }
-    default:
-    {
-      DALI_ASSERT_DEBUG(0 && "unknown color enum");
-      return 0;
-    }
-  }
-}
-
-void PixmapImage::SetPixelFormat(int depth)
+void PixmapImage::SetBlending(Dali::PixmapImage::ColorDepth depth)
 {
-  // store the pixel format based on the depth
   switch (depth)
   {
-    case 8:
-    {
-      mPixelFormat = Pixel::A8;
-      break;
-    }
-    case 16:
+    case Dali::PixmapImage::COLOR_DEPTH_16: //Pixel::RGB565
+    case Dali::PixmapImage::COLOR_DEPTH_24: // Pixel::RGB888
     {
-      mPixelFormat = Pixel::RGB565;
+      mBlendingRequired = false;
       break;
     }
-    case 32:
+    case Dali::PixmapImage::COLOR_DEPTH_8: //Pixel::A8
+    case Dali::PixmapImage::COLOR_DEPTH_32: // Pixel::RGBA8888
     {
-      mPixelFormat = Pixel::RGBA8888;
+      mBlendingRequired = true;
       break;
     }
-    case 24:
     default:
     {
-      mPixelFormat = Pixel::RGB888;
-      break;
+      DALI_ASSERT_DEBUG(0 && "unknown color enum");
     }
   }
 }
index 7ef1fed..4fd9044 100644 (file)
@@ -106,11 +106,11 @@ public:
   }
 
   /**
-   * @copydoc Dali::PixmapImage::GetPixelFormat()
+   * @copydoc Dali::PixmapImage::RequiresBlending()
    */
-  Pixel::Format GetPixelFormat() const
+  bool RequiresBlending() const
   {
-    return mPixelFormat;
+    return mBlendingRequired;
   }
 
 private:
@@ -133,17 +133,10 @@ private:
   void Initialize();
 
   /**
-   * Uses X11 to get the default depth.
+   * Decide whether blending is required based on the color depth.
    * @param depth the PixelImage depth enum
-   * @return default x11 pixel depth
    */
-  int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
-
-  /**
-   * Sets the pixel format based on the bit depth
-   * @param depth depth in bytes
-   */
-  void SetPixelFormat(int depth);
+  void SetBlending(Dali::PixmapImage::ColorDepth depth);
 
   /**
    * Given an existing pixmap, the function uses X to find out
@@ -156,7 +149,7 @@ private:
   unsigned int mWidth;                        ///< pixmap width
   unsigned int mHeight;                       ///< pixmap heights
   bool mOwnPixmap;                            ///< Whether we created pixmap or not
-  Pixel::Format mPixelFormat;                 ///< pixmap pixel format
+  bool mBlendingRequired;                      ///< Whether blending is required
   Dali::PixmapImage::ColorDepth mColorDepth;  ///< color depth of pixmap
   void* mEglImageKHR;                         ///< From EGL extension
   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
index 3f96cc6..4fbc237 100644 (file)
@@ -91,7 +91,7 @@ PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapI
   mHeight( height ),
   mOwnPixmap( true ),
   mPixmap( 0 ),
-  mPixelFormat( Pixel::RGB888 ),
+  mBlendingRequired( false ),
   mColorDepth( depth ),
   mEglImageKHR( NULL ),
   mEglImageExtensions( NULL )
@@ -121,8 +121,12 @@ void PixmapImage::Initialize()
   // get the pixel depth
   int depth = GetPixelDepth(mColorDepth);
 
-  // set the pixel format
-  SetPixelFormat(depth);
+  // set whether blending is required according to pixel format based on the depth
+  /* default pixel format is RGB888
+     If depth = 8, Pixel::A8;
+     If depth = 16, Pixel::RGB565;
+     If depth = 32, Pixel::RGBA8888 */
+  mBlendingRequired = ( depth == 32 || depth == 8 );
 
   mPixmap = ecore_x_pixmap_new( 0, mWidth, mHeight, depth );
   ecore_x_sync();
@@ -333,35 +337,6 @@ int PixmapImage::GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const
   }
 }
 
-void PixmapImage::SetPixelFormat(int depth)
-{
-  // store the pixel format based on the depth
-  switch (depth)
-  {
-    case 8:
-    {
-      mPixelFormat = Pixel::A8;
-      break;
-    }
-    case 16:
-    {
-      mPixelFormat = Pixel::RGB565;
-      break;
-    }
-    case 32:
-    {
-      mPixelFormat = Pixel::RGBA8888;
-      break;
-    }
-    case 24:
-    default:
-    {
-      mPixelFormat = Pixel::RGB888;
-      break;
-    }
-  }
-}
-
 Ecore_X_Pixmap PixmapImage::GetPixmapFromAny(Any pixmap) const
 {
   if (pixmap.Empty())
@@ -391,8 +366,13 @@ void PixmapImage::GetPixmapDetails()
   // get the width, height and depth
   ecore_x_pixmap_geometry_get(mPixmap, &x, &y, (int*)&mWidth, (int*)&mHeight);
 
-  // set the pixel format
-  SetPixelFormat(ecore_x_pixmap_depth_get(mPixmap));
+  // set whether blending is required according to pixel format based on the depth
+  /* default pixel format is RGB888
+     If depth = 8, Pixel::A8;
+     If depth = 16, Pixel::RGB565;
+     If depth = 32, Pixel::RGBA8888 */
+  int depth = ecore_x_pixmap_depth_get(mPixmap);
+  mBlendingRequired = ( depth == 32 || depth == 8 );
 }
 
 } // namespace Adaptor
index 215323d..3e897f1 100644 (file)
@@ -106,11 +106,11 @@ public:
   }
 
   /**
-   * @copydoc Dali::PixmapImage::GetPixelFormat()
+   * @copydoc Dali::PixmapImage::RequiresBlending()
    */
-  Pixel::Format GetPixelFormat() const
+  bool RequiresBlending() const
   {
-    return mPixelFormat;
+    return mBlendingRequired;
   }
 
 private:
@@ -140,12 +140,6 @@ private:
   int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
 
   /**
-   * Sets the pixel format based on the bit depth
-   * @param depth depth in bytes
-   */
-  void SetPixelFormat(int depth);
-
-  /**
    * Gets the pixmap from the Any parameter
    * @param pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
    * @return pixmap x11 pixmap
@@ -164,7 +158,7 @@ private:
   unsigned int mHeight;                       ///< pixmap heights
   bool mOwnPixmap;                            ///< Whether we created pixmap or not
   Ecore_X_Pixmap mPixmap;                     ///< From Xlib
-  Pixel::Format mPixelFormat;                 ///< pixmap pixel format
+  bool mBlendingRequired;                      ///< Whether blending is required
   Dali::PixmapImage::ColorDepth mColorDepth;  ///< color depth of pixmap
   void* mEglImageKHR;                         ///< From EGL extension
   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
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 66df868..7c3ce41 100644 (file)
@@ -1356,27 +1356,6 @@ bool LoadBitmapFromBmp( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, c
   }
 
   attributes.SetSize(infoHeader.width, infoHeader.height);
-  attributes.SetPixelFormat(pixelFormat);
-
-  switch(customizedFormat)
-  {
-    case BMP_RLE8:
-    case BMP_RGB8:
-    case BMP_RGB4:
-    case BMP_RGB1:
-    case BMP_RLE4:
-    case BMP_RGB555:
-    case BMP_BITFIELDS555:
-    case BMP_RGB24V5:
-      attributes.SetPixelFormat(Pixel::RGB888);
-      break;
-    case BMP_BITFIELDS32:
-    case BMP_BITFIELDS32V4:
-      attributes.SetPixelFormat(Pixel::RGB8888);
-      break;
-    default:
-      break;
-  }
   return true;
 }
 
index c000f1c..be0cc59 100644 (file)
@@ -232,7 +232,6 @@ bool HandleImageDescriptionRecordType( Bitmap& bitmap, ImageAttributes& attribut
   }
 
   attributes.SetSize( actualWidth, actualHeight );
-  attributes.SetPixelFormat( pixelFormat );
 
   finished = true;
 
index 20986a2..70cbf14 100644 (file)
@@ -734,7 +734,6 @@ bool LoadBitmapFromIco( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
   memcpy(pixels, (unsigned char*)&surface[0], w * h * 4);
 
   attributes.SetSize(w, h);
-  attributes.SetPixelFormat(Pixel::RGBA8888);
 
   return true;
 }
index b1f5ef7..8d76329 100755 (executable)
@@ -352,7 +352,6 @@ bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes,
   }
 
   attributes.SetSize( scaledPostXformWidth, scaledPostXformHeight );
-  attributes.SetPixelFormat( Pixel::RGB888 );
 
   const unsigned int  bufferWidth  = GetTextureDimension( scaledPreXformWidth );
   const unsigned int  bufferHeight = GetTextureDimension( scaledPreXformHeight );
index 8a1590a..04e08d4 100755 (executable)
@@ -371,7 +371,6 @@ bool LoadBitmapFromKtx( FILE * const fp, Bitmap& bitmap, ImageAttributes& attrib
 
   // Ignore all input requests from image attributes and set the available metadata:
   attributes.SetSize(width, height);
-  attributes.SetPixelFormat(pixelFormat);
 
   return true;
 }
index 07aed12..95a9f40 100644 (file)
@@ -311,7 +311,6 @@ bool LoadBitmapFromPng( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, c
 
   // set the attributes
   attributes.SetSize( width, height );
-  attributes.SetPixelFormat( pixelFormat );
 
   free(rows);
 
index a3a071c..e7d49a2 100755 (executable)
@@ -211,7 +211,6 @@ bool LoadBitmapFromWbmp( FILE *fp, Integration::Bitmap& bitmap, ImageAttributes&
 
   memcpy(pixels, (unsigned char*)&surface[0], w * h );//w * h * 4
   attributes.SetSize(w, h);
-  attributes.SetPixelFormat(Pixel::L8);//Pixel::RGBA8888
 
   return true;
 }