void Indicator::CreateNewPixmapImage()
{
DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d\n", mImageWidth, mImageHeight );
- Dali::PixmapImagePtr pixmapImage = Dali::PixmapImage::New(mPixmap, Dali::Adaptor::Get());
+ Dali::PixmapImagePtr pixmapImage = Dali::PixmapImage::New( mPixmap );
if( pixmapImage )
{
namespace Dali
{
-PixmapImagePtr PixmapImage::New(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor)
+PixmapImagePtr PixmapImage::New( unsigned int width, unsigned int height, ColorDepth depth )
{
Any empty;
- PixmapImagePtr image = new PixmapImage(width, height, depth, adaptor, empty);
+ PixmapImagePtr image = new PixmapImage( width, height, depth, empty );
return image;
}
-PixmapImagePtr PixmapImage::New(Any pixmap, Adaptor& adaptor)
+PixmapImagePtr PixmapImage::New( Any pixmap )
{
- PixmapImagePtr image = new PixmapImage(0, 0, COLOR_DEPTH_DEFAULT, adaptor, pixmap);
+ PixmapImagePtr image = new PixmapImage(0, 0, COLOR_DEPTH_DEFAULT, pixmap);
return image;
}
-Any PixmapImage::GetPixmap(PixmapAPI api)
-{
- return mImpl->GetPixmap(api);
-}
-
-Any PixmapImage::GetDisplay()
-{
- return mImpl->GetDisplay();
-}
-
-bool PixmapImage::GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
+bool PixmapImage::GetPixels( std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
{
return mImpl->GetPixels( pixbuf, width, height, pixelFormat );
}
return mImpl->GetPixelFormat();
}
-PixmapImage::PixmapImage(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor, Any pixmap)
+PixmapImage::PixmapImage( unsigned int width, unsigned int height, ColorDepth depth, Any pixmap )
{
- mImpl = Internal::Adaptor::PixmapImage::New( width, height, depth, adaptor, pixmap);
+ mImpl = Internal::Adaptor::PixmapImage::New( width, height, depth, pixmap );
}
PixmapImage::~PixmapImage()
namespace Dali
{
-class Adaptor;
namespace Internal DALI_INTERNAL
{
public:
/**
- * @brief PixmapImage can use pixmaps created by X11 or ECORE X11.
- */
- enum PixmapAPI
- {
- X11, ///< X types
- ECORE_X11, ///< EFL e-core x11 types
- };
-
- /**
* @brief When creating a pixmap the color depth has to be specified.
*/
enum ColorDepth
* @param[in] width The width of the image.
* @param[in] height The height of the image.
* @param[in] depth color depth of the pixmap
- * @param[in] adaptor reference to dali adaptor
* @return A smart-pointer to a newly allocated image.
*/
- static PixmapImagePtr New( unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor );
+ static PixmapImagePtr New( unsigned int width, unsigned int height, ColorDepth depth );
/**
* @brief Create a new PixmapImage from an existing pixmap.
*
* @param[in] pixmap must be a X11 pixmap or a Ecore_X_Pixmap
- * @param[in] adaptor reference to dali adaptor
* @return A smart-pointer to a newly allocated image.
*/
- static PixmapImagePtr New( Any pixmap, Adaptor& adaptor );
-
- /**
- * @brief Retrieve the internal pixmap
- *
- * @param api whether to return a pixmap that can be used with X11 or EFL
- * @return pixmap any object containing a pixmap of the type specified PixmapAPI
- */
- Any GetPixmap( PixmapAPI api );
-
- /**
- * @brief Retrieve the display used to create the pixmap.
- *
- * If the pixmap was created outside of Dali, then this display
- * is the one Dali uses internally.
- * @return Any object containing the display
- */
- Any GetDisplay();
+ static PixmapImagePtr New( Any pixmap );
/**
* @brief Get a copy of the pixels used by PixmapImage.
* @param[in] width The width of the image.
* @param[in] height The height of the image.
* @param[in] depth color depth of the pixmap
- * @param[in] adaptor a reference to Dali adaptor
* @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- DALI_INTERNAL PixmapImage(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor, Any pixmap);
+ DALI_INTERNAL PixmapImage( unsigned int width, unsigned int height, ColorDepth depth, Any pixmap );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
#include "pixmap-image-impl.h"
// EXTERNAL INCLUDES
-#include <Ecore.h>
-#include <Ecore_Wayland.h>
#include <dali/integration-api/debug.h>
#include <render-surface.h>
{
using Dali::Integration::PixelBuffer;
-PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap )
+PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
{
- PixmapImage* image = new PixmapImage( width, height, depth, adaptor, pixmap );
+ PixmapImage* image = new PixmapImage( width, height, depth, pixmap );
DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
// 2nd phase construction
return image;
}
-PixmapImage::PixmapImage(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap)
-: mWidth(width),
- mHeight(height),
- mOwnPixmap(true),
- mPixelFormat(Pixel::RGB888),
- mColorDepth(depth),
- mAdaptor(Internal::Adaptor::Adaptor::GetImplementation(adaptor)),
- mEglImageKHR(NULL)
-{
+PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
+: 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();
+ DALI_ASSERT_DEBUG( mEglImageExtensions );
}
void PixmapImage::Initialize()
PixmapImage::~PixmapImage()
{
- // Lost the opportunity to call GlExtensionDestroy() if Adaptor is destroyed first
- if( Adaptor::IsAvailable() )
- {
- // GlExtensionDestroy() called from GLCleanup on the render thread. Checking this is done here.
- // (mEglImageKHR is now read/written from different threads although ref counted destruction
- // should mean this isnt concurrent)
- DALI_ASSERT_ALWAYS( NULL == mEglImageKHR && "NativeImage GL resources have not been properly cleaned up" );
- }
-}
-
-Any PixmapImage::GetPixmap(Dali::PixmapImage::PixmapAPI api) const
-{
- return NULL;
-}
-
-Any PixmapImage::GetDisplay() const
-{
- return NULL;
}
bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
void PixmapImage::GlExtensionDestroy()
{
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- eglImageExtensions->DestroyImageKHR(mEglImageKHR);
+ mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
}
unsigned int PixmapImage::TargetTexture()
{
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- eglImageExtensions->TargetTextureKHR(mEglImageKHR);
+ mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
return 0;
}
{
}
-EglImageExtensions* PixmapImage::GetEglImageExtensions() const
-{
- EglFactory& factory = mAdaptor.GetEGLFactory();
- EglImageExtensions* egl = factory.GetImageExtensions();
- DALI_ASSERT_DEBUG( egl && "EGL Image Extensions not initialized" );
- return egl;
-}
-
} // namespace Adaptor
} // namespace internal
*/
// EXTERNAL INCLUDES
-#include <Ecore.h>
-#include <Ecore_Wayland.h>
-#include <pixmap-image.h>
// INTERNAL INCLUDES
+#include <pixmap-image.h>
namespace Dali
{
namespace Adaptor
{
-class Adaptor;
class EglImageExtensions;
/**
* @param[in] width The width of the image.
* @param[in] height The height of the image.
* @param[in] depth color depth of the pixmap
- * @param[in] adaptor reference to dali adaptor
* @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
* @return A smart-pointer to a newly allocated image.
*/
static PixmapImage* New(unsigned int width,
unsigned int height,
Dali::PixmapImage::ColorDepth depth,
- Dali::Adaptor& adaptor,
Any pixmap);
- /**
- * @copydoc Dali::PixmapImage::GetPixmap()
- */
- Any GetPixmap(Dali::PixmapImage::PixmapAPI api) const;
-
- /**
- * @copydoc Dali::PixmapImage::GetDisplay()
- */
- Any GetDisplay() const;
-
/**
* @copydoc Dali::PixmapImage::GetPixels()
*/
* @param[in] width The width of the image.
* @param[in] height The height of the image.
* @param[in] colour depth of the pixmap
- * @param[in] adaptor a reference to Dali adaptor
* @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
PixmapImage(unsigned int width,
unsigned int height,
Dali::PixmapImage::ColorDepth depth,
- Dali::Adaptor &adaptor,
Any pixmap);
/**
*/
void GetPixmapDetails();
- /**
- * Returns the egl image extensions class from the adaptor
- * @return reference to egl image extensionsa
- */
- EglImageExtensions* GetEglImageExtensions() const;
-
private:
unsigned int mWidth; ///< pixmap width
bool mOwnPixmap; ///< Whether we created pixmap or not
Pixel::Format mPixelFormat; ///< pixmap pixel format
Dali::PixmapImage::ColorDepth mColorDepth; ///< color depth of pixmap
- Adaptor& mAdaptor; ///< adaptor
void* mEglImageKHR; ///< From EGL extension
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
};
} // namespace Adaptor
// EXTERNAL INCLUDES
#include <Ecore_X.h>
#include <X11/Xutil.h>
+#include <X11/Xlib.h>
#include <dali/integration-api/debug.h>
-#include <render-surface.h>
// INTERNAL INCLUDES
#include <gl/egl-image-extensions.h>
#include <gl/egl-factory.h>
#include <adaptor-impl.h>
#include <bitmap-saver.h>
+#include <render-surface.h>
namespace Dali
{
};
}
-PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap )
+PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
{
- PixmapImage* image = new PixmapImage( width, height, depth, adaptor, pixmap );
+ PixmapImage* image = new PixmapImage( width, height, depth, pixmap );
DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
// 2nd phase construction
return image;
}
-PixmapImage::PixmapImage(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap)
-: mWidth(width),
- mHeight(height),
- mOwnPixmap(true),
- mPixmap(0),
- mDisplay(NULL),
- mPixelFormat(Pixel::RGB888),
- mColorDepth(depth),
- mAdaptor(Internal::Adaptor::Adaptor::GetImplementation(adaptor)),
- mEglImageKHR(NULL)
+PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
+: mWidth( width ),
+ mHeight( height ),
+ mOwnPixmap( true ),
+ mPixmap( 0 ),
+ mPixelFormat( Pixel::RGB888 ),
+ mColorDepth( depth ),
+ mEglImageKHR( NULL ),
+ mEglImageExtensions( NULL )
{
+ DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
+ mEglImageExtensions = eglFactory.GetImageExtensions();
+ DALI_ASSERT_DEBUG( mEglImageExtensions );
+
// assign the pixmap
mPixmap = GetPixmapFromAny(pixmap);
}
void PixmapImage::Initialize()
{
- // Get render-surface being used by Dali
- Dali::RenderSurface& surface = mAdaptor.GetSurface();
-
- // get the X11 display pointer and store it
- // it is used by eglCreateImageKHR, and XFreePixmap
- // Any other display (x-connection) will fail in eglCreateImageKHR
- Any display = surface.GetDisplay();
-
- // the dali display pointer is needed
- mDisplay = AnyCast<Ecore_X_Display*>(display);
-
// if pixmap has been created outside of X11 Image we can return
if (mPixmap)
{
// set the pixel format
SetPixelFormat(depth);
- // Get the X-Renderable for which the pixmap is created on
- Any renderableSurface = surface.GetSurface();
-
- // if Dali is using a Pixmap or Window to render to it doesn't matter because they have the same
- // underlying type of unsigned long
- Ecore_X_Window daliWindow = AnyCast< Ecore_X_Window >(renderableSurface);
-
- mPixmap = ecore_x_pixmap_new(daliWindow, mWidth, mHeight, depth);
+ mPixmap = ecore_x_pixmap_new( 0, mWidth, mHeight, depth );
ecore_x_sync();
}
PixmapImage::~PixmapImage()
{
- // Lost the opportunity to call GlExtensionDestroy() if Adaptor is destroyed first
- if( Adaptor::IsAvailable() )
- {
- // GlExtensionDestroy() called from GLCleanup on the render thread. Checking this is done here.
- // (mEglImageKHR is now read/written from different threads although ref counted destruction
- // should mean this isnt concurrent)
- DALI_ASSERT_ALWAYS( NULL == mEglImageKHR && "NativeImage GL resources have not been properly cleaned up" );
- }
-
if (mOwnPixmap && mPixmap)
{
ecore_x_pixmap_free(mPixmap);
}
}
-Any PixmapImage::GetPixmap(Dali::PixmapImage::PixmapAPI api) const
-{
- if (api == Dali::PixmapImage::ECORE_X11)
- {
- // return ecore x11 type
- return Any(mPixmap);
- }
- else
- {
- // return x11 type after casting it
- Pixmap pixmap= static_cast<Pixmap>(mPixmap);
- return Any(pixmap);
- }
-}
-
-Any PixmapImage::GetDisplay() const
-{
- // return ecore x11 type
- return Any(mDisplay);
-}
-
bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
{
DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
width = mWidth;
height = mHeight;
- XImageJanitor xImageJanitor( XGetImage(static_cast<Display*>(mDisplay),
- mPixmap,
- 0, 0, // x,y of subregion to extract.
- width, height, // of suregion to extract.
- 0xFFFFFFFF,
- ZPixmap));
+ // Open a display connection
+ Display* displayConnection = XOpenDisplay( 0 );
+
+ XImageJanitor xImageJanitor( XGetImage( displayConnection,
+ mPixmap,
+ 0, 0, // x,y of subregion to extract.
+ width, height, // of suregion to extract.
+ 0xFFFFFFFF,
+ ZPixmap ) );
XImage* const pXImage = xImageJanitor.mXImage;
DALI_ASSERT_DEBUG(pXImage && "XImage (from pixmap) could not be retrieved from the server");
if(!pXImage)
width = 0;
height = 0;
}
+
+ // Close the display connection
+ XCloseDisplay( displayConnection );
+
return success;
}
GlExtensionDestroy();
}
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
- mEglImageKHR = eglImageExtensions->CreateImageKHR( eglBuffer );
+ mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
return mEglImageKHR != NULL;
}
void PixmapImage::GlExtensionDestroy()
{
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- eglImageExtensions->DestroyImageKHR(mEglImageKHR);
+ mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
}
unsigned int PixmapImage::TargetTexture()
{
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- eglImageExtensions->TargetTextureKHR(mEglImageKHR);
+ mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
return 0;
}
SetPixelFormat(ecore_x_pixmap_depth_get(mPixmap));
}
-EglImageExtensions* PixmapImage::GetEglImageExtensions() const
-{
- EglFactory& factory = mAdaptor.GetEGLFactory();
- EglImageExtensions* egl = factory.GetImageExtensions();
- DALI_ASSERT_DEBUG( egl && "EGL Image Extensions not initialized" );
- return egl;
-}
-
} // namespace Adaptor
} // namespace internal
// EXTERNAL INCLUDES
#include <Ecore_X.h>
-#include <pixmap-image.h>
// INTERNAL INCLUDES
+#include <pixmap-image.h>
namespace Dali
{
namespace Adaptor
{
-class Adaptor;
class EglImageExtensions;
/**
* @param[in] width The width of the image.
* @param[in] height The height of the image.
* @param[in] depth color depth of the pixmap
- * @param[in] adaptor reference to dali adaptor
* @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
* @return A smart-pointer to a newly allocated image.
*/
static PixmapImage* New(unsigned int width,
unsigned int height,
Dali::PixmapImage::ColorDepth depth,
- Dali::Adaptor& adaptor,
Any pixmap);
- /**
- * @copydoc Dali::PixmapImage::GetPixmap()
- */
- Any GetPixmap(Dali::PixmapImage::PixmapAPI api) const;
-
- /**
- * @copydoc Dali::PixmapImage::GetDisplay()
- */
- Any GetDisplay() const;
-
/**
* @copydoc Dali::PixmapImage::GetPixels()
*/
* @param[in] width The width of the image.
* @param[in] height The height of the image.
* @param[in] colour depth of the pixmap
- * @param[in] adaptor a reference to Dali adaptor
* @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
PixmapImage(unsigned int width,
unsigned int height,
Dali::PixmapImage::ColorDepth depth,
- Dali::Adaptor &adaptor,
Any pixmap);
/**
*/
void GetPixmapDetails();
- /**
- * Returns the egl image extensions class from the adaptor
- * @return reference to egl image extensionsa
- */
- EglImageExtensions* GetEglImageExtensions() const;
-
private:
unsigned int mWidth; ///< pixmap width
unsigned int mHeight; ///< pixmap heights
bool mOwnPixmap; ///< Whether we created pixmap or not
Ecore_X_Pixmap mPixmap; ///< From Xlib
- Ecore_X_Display* mDisplay; ///< x-connection used to create pixmap (if it was not created outside of PixmapImage)
Pixel::Format mPixelFormat; ///< pixmap pixel format
Dali::PixmapImage::ColorDepth mColorDepth; ///< color depth of pixmap
- Adaptor& mAdaptor; ///< adaptor
void* mEglImageKHR; ///< From EGL extension
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
};
} // namespace Adaptor