return true;
}
-NativeImage& IndicatorBuffer::GetNativeImage() const
+NativeImageInterface& IndicatorBuffer::GetNativeImage() const
{
DALI_ASSERT_DEBUG(mNativeImage.Get());
return *mNativeImage;
* Returns the NativeImage used internally
* @return the NativeImage used internally
*/
- NativeImage& GetNativeImage() const;
+ NativeImageInterface& GetNativeImage() const;
/**
* Set currently used Adaptor
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
#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>
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);
{
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
{
return mHeight;
}
-Pixel::Format NativeBitmapBuffer::GetPixelFormat() const
+bool NativeBitmapBuffer::RequiresBlending() const
{
- return mPixelFormat;
+ return Pixel::HasAlpha( mPixelFormat );
}
} // namespace Adaptor
*/
// 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>
/**
* A Bitmap-based implementation of the NativeImage interface.
*/
-class NativeBitmapBuffer : public NativeImage
+class NativeBitmapBuffer : public NativeImageInterface
{
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
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 )
#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
* externally by X11 or ECORE-X11.
*
*/
-class DALI_IMPORT_API PixmapImage : public NativeImage
+class DALI_IMPORT_API PixmapImage : public NativeImageInterface
{
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:
: mWidth( width ),
mHeight( height ),
mOwnPixmap( true ),
- mPixelFormat( Pixel::RGB888 ),
mColorDepth( depth ),
mEglImageKHR( NULL ),
mEglImageExtensions( NULL )
DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
mEglImageExtensions = eglFactory.GetImageExtensions();
+ SetBlending( mColorDepth );
+
DALI_ASSERT_DEBUG( mEglImageExtensions );
}
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");
}
}
}
}
/**
- * @copydoc Dali::PixmapImage::GetPixelFormat()
+ * @copydoc Dali::PixmapImage::RequiresBlending()
*/
- Pixel::Format GetPixelFormat() const
+ bool RequiresBlending() const
{
- return mPixelFormat;
+ return mBlendingRequired;
}
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
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
mHeight( height ),
mOwnPixmap( true ),
mPixmap( 0 ),
- mPixelFormat( Pixel::RGB888 ),
+ mBlendingRequired( false ),
mColorDepth( depth ),
mEglImageKHR( NULL ),
mEglImageExtensions( NULL )
// 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();
}
}
-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())
// 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
}
/**
- * @copydoc Dali::PixmapImage::GetPixelFormat()
+ * @copydoc Dali::PixmapImage::RequiresBlending()
*/
- Pixel::Format GetPixelFormat() const
+ bool RequiresBlending() const
{
- return mPixelFormat;
+ return mBlendingRequired;
}
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
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
*/
// INTERNAL INCLUDES
-#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/native-image-interface.h>
namespace Dali
{
class TestNativeImage;
typedef IntrusivePtr<TestNativeImage> TestNativeImagePointer;
-class DALI_IMPORT_API TestNativeImage : public Dali::NativeImage
+class DALI_IMPORT_API TestNativeImage : public Dali::NativeImageInterface
{
public:
static TestNativeImagePointer New(int width, int height);
inline virtual void PrepareTexture() {};
inline virtual unsigned int GetWidth() const {return mWidth;};
inline virtual unsigned int GetHeight() const {return mHeight;};
- inline virtual Pixel::Format GetPixelFormat() const {return Pixel::RGBA8888;};
+ inline virtual bool RequiresBlending() const {return true;};
private:
TestNativeImage(int width, int height);
}
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;
}
}
attributes.SetSize( actualWidth, actualHeight );
- attributes.SetPixelFormat( pixelFormat );
finished = true;
memcpy(pixels, (unsigned char*)&surface[0], w * h * 4);
attributes.SetSize(w, h);
- attributes.SetPixelFormat(Pixel::RGBA8888);
return true;
}
}
attributes.SetSize( scaledPostXformWidth, scaledPostXformHeight );
- attributes.SetPixelFormat( Pixel::RGB888 );
const unsigned int bufferWidth = GetTextureDimension( scaledPreXformWidth );
const unsigned int bufferHeight = GetTextureDimension( scaledPreXformHeight );
// Ignore all input requests from image attributes and set the available metadata:
attributes.SetSize(width, height);
- attributes.SetPixelFormat(pixelFormat);
return true;
}
// set the attributes
attributes.SetSize( width, height );
- attributes.SetPixelFormat( pixelFormat );
free(rows);
memcpy(pixels, (unsigned char*)&surface[0], w * h );//w * h * 4
attributes.SetSize(w, h);
- attributes.SetPixelFormat(Pixel::L8);//Pixel::RGBA8888
return true;
}