Revert "Merge "[3.0] Change PixmapImage class to NativeImageSource class" into tizen" 59/55859/2
authortaeyoon <taeyoon0.lee@samsung.com>
Wed, 30 Dec 2015 02:30:51 +0000 (11:30 +0900)
committertaeyoon <taeyoon0.lee@samsung.com>
Fri, 15 Jan 2016 02:26:47 +0000 (11:26 +0900)
This reverts commit f6364c126062e48bfb3bd4b6d1ea61e211bfa7b7, reversing
changes made to 0fadbd50e9cd62d8513be7ee41a160a82b6f06f2.

Change-Id: Ice2dc184e331344d0631d2b6314019eb6a460e6d

21 files changed:
adaptors/common/indicator-buffer.h
adaptors/common/indicator-impl.cpp
adaptors/public-api/adaptor-framework/native-image-source.cpp [deleted file]
adaptors/public-api/adaptor-framework/native-image-source.h [deleted file]
adaptors/public-api/adaptor-framework/pixmap-image.cpp [new file with mode: 0644]
adaptors/public-api/adaptor-framework/pixmap-image.h [new file with mode: 0644]
adaptors/public-api/dali.h
adaptors/public-api/file.list
adaptors/wayland/file.list
adaptors/wayland/native-image-source-impl-wl.cpp [deleted file]
adaptors/wayland/native-image-source-impl.h [deleted file]
adaptors/wayland/pixmap-image-impl-wl.cpp [new file with mode: 0644]
adaptors/wayland/pixmap-image-impl.h [new file with mode: 0644]
adaptors/x11/file.list
adaptors/x11/native-image-source-impl-x.cpp [deleted file]
adaptors/x11/native-image-source-impl.h [deleted file]
adaptors/x11/pixmap-image-impl-x.cpp [new file with mode: 0644]
adaptors/x11/pixmap-image-impl.h [new file with mode: 0644]
automated-tests/src/dali-adaptor/CMakeLists.txt
automated-tests/src/dali-adaptor/utc-Dali-NativeImageSource.cpp [deleted file]
automated-tests/src/dali-adaptor/utc-Dali-PixmapImage.cpp [new file with mode: 0644]

index f32bd3287f9af1c471b3067c2fe7045ed185da9f..4a43c3d0f6059ba04f74b3395deadf663e7546bb 100644 (file)
@@ -40,7 +40,7 @@ typedef IntrusivePtr<IndicatorBuffer> IndicatorBufferPtr;
 
 /**
  * The IndicatorBuffer class uses the best available implementation for rendering indicator data.
- * On platforms where EglImage is available it uses either SharedGlBuffer or NativeImageSource, on older
+ * On platforms where EglImage is available it uses either SharedGlBuffer or PixmapImage, on older
  * platforms it falls back to using a bitmap buffer based solution.
  */
 class IndicatorBuffer : public RefObject
index 23d4b816970960dfdb7e6402b6b7bcea1ea7681f..141d78a2820e856dae3e8a608a3474450f1519db 100644 (file)
@@ -41,7 +41,7 @@
 // INTERNAL INCLUDES
 #include <adaptor-impl.h>
 #include <accessibility-adaptor-impl.h>
-#include <native-image-source.h>
+#include <pixmap-image.h>
 
 using Dali::Vector4;
 
@@ -931,11 +931,11 @@ bool Indicator::CopyToBuffer( int bufferNumber )
 void Indicator::CreateNewPixmapImage()
 {
   DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d", mImageWidth, mImageHeight );
-  Dali::NativeImageSourcePtr nativeImageSource = Dali::NativeImageSource::New( mPixmap );
+  Dali::PixmapImagePtr pixmapImage = Dali::PixmapImage::New( mPixmap );
 
-  if( nativeImageSource )
+  if( pixmapImage )
   {
-    mIndicatorImageActor.SetImage( Dali::NativeImage::New(*nativeImageSource) );
+    mIndicatorImageActor.SetImage( Dali::NativeImage::New(*pixmapImage) );
     mIndicatorImageActor.SetSize( mImageWidth, mImageHeight );
     mIndicatorActor.SetSize( mImageWidth, mImageHeight );
     mEventActor.SetSize(mImageWidth, mImageHeight);
diff --git a/adaptors/public-api/adaptor-framework/native-image-source.cpp b/adaptors/public-api/adaptor-framework/native-image-source.cpp
deleted file mode 100644 (file)
index ba9a914..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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 <native-image-source.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/any.h>
-
-// INTERNAL INCLUDES
-#include <native-image-source-impl.h>
-
-namespace Dali
-{
-
-NativeImageSourcePtr NativeImageSource::New( unsigned int width, unsigned int height, ColorDepth depth )
-{
-  Any empty;
-  NativeImageSourcePtr image = new NativeImageSource( width, height, depth, empty );
-  return image;
-}
-
-Any NativeImageSource::GetNativeImageSource()
-{
-  return mImpl->GetNativeImageSource();
-}
-
-NativeImageSourcePtr NativeImageSource::New( Any nativeImageSource )
-{
-  NativeImageSourcePtr image = new NativeImageSource(0, 0, COLOR_DEPTH_DEFAULT, nativeImageSource);
-  return image;
-}
-
-bool NativeImageSource::GetPixels( std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
-{
-  return mImpl->GetPixels( pixbuf, width, height, pixelFormat );
-}
-
-bool NativeImageSource::EncodeToFile(const std::string& filename) const
-{
-  return mImpl->EncodeToFile(filename);
-}
-
-bool NativeImageSource::GlExtensionCreate()
-{
-  return mImpl->GlExtensionCreate();
-}
-
-void NativeImageSource::GlExtensionDestroy()
-{
-  mImpl->GlExtensionDestroy();
-}
-
-unsigned int NativeImageSource::TargetTexture()
-{
-  return mImpl->TargetTexture();
-}
-
-void NativeImageSource::PrepareTexture()
-{
-
-}
-
-unsigned int NativeImageSource::GetWidth() const
-{
-  return mImpl->GetWidth();
-}
-
-unsigned int NativeImageSource::GetHeight() const
-{
-  return mImpl->GetHeight();
-}
-
-bool NativeImageSource::RequiresBlending() const
-{
-  return mImpl->RequiresBlending();
-}
-
-NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSource )
-{
-   mImpl = Internal::Adaptor::NativeImageSource::New( width, height, depth, nativeImageSource );
-}
-
-NativeImageSource::~NativeImageSource()
-{
-  delete mImpl;
-}
-
-} // namespace Dali
diff --git a/adaptors/public-api/adaptor-framework/native-image-source.h b/adaptors/public-api/adaptor-framework/native-image-source.h
deleted file mode 100644 (file)
index dea2a14..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-#ifndef __DALI_NATIVE_IMAGE_SOURCE_H__
-#define __DALI_NATIVE_IMAGE_SOURCE_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-#include <dali/public-api/common/vector-wrapper.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
-{
-/**
- * @addtogroup dali_adaptor_framework
- * @{
- */
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class NativeImageSource;
-}
-}
-
-class NativeImageSource;
-/**
- * @brief Pointer to Dali::NativeImageSource.
- */
-typedef IntrusivePtr<NativeImageSource> NativeImageSourcePtr;
-
-/**
- * @brief Used for displaying native images.
- *
- * The native image source can be created internally or
- * externally by X11 or ECORE-X11.
- *
- * @since DALi 1.1.4
- */
-class DALI_IMPORT_API NativeImageSource : public NativeImageInterface
-{
-public:
-
-   /**
-    * @brief When creating a native image the color depth has to be specified.
-    */
-   enum ColorDepth
-   {
-     COLOR_DEPTH_DEFAULT,     ///< Uses the current X screen default depth (recommended)
-     COLOR_DEPTH_8,           ///< 8 bits per pixel
-     COLOR_DEPTH_16,          ///< 16 bits per pixel
-     COLOR_DEPTH_24,          ///< 24 bits per pixel
-     COLOR_DEPTH_32           ///< 32 bits per pixel
-   };
-
-  /**
-   * @brief Create a new NativeImageSource.
-   *
-   * Depending on hardware the width and height may have to be a power of two.
-   * @param[in] width The width of the image.
-   * @param[in] height The height of the image.
-   * @param[in] depth color depth of the image.
-   * @return A smart-pointer to a newly allocated image.
-   */
-  static NativeImageSourcePtr New( unsigned int width, unsigned int height, ColorDepth depth );
-
-  /**
-   * @brief Create a new NativeImageSource from an existing native image.
-   *
-   * @param[in] nativeImageSource must be a X11 pixmap or a Ecore_X_Pixmap
-   * @return A smart-pointer to a newly allocated image.
-   */
-  static NativeImageSourcePtr New( Any nativeImageSource );
-
-  /**
-   * @brief Retrieve the internal native image.
-   *
-   * @return Any object containing the internal native image.
-   */
-  Any GetNativeImageSource();
-
-  /**
-   * @brief Get a copy of the pixels used by NativeImageSource.
-   *
-   * This is only supported for 24 bit RGB and 32 bit RGBA internal formats
-   * (COLOR_DEPTH_24 and COLOR_DEPTH_32).
-   * @param[out] pixbuf a vector to store the pixels in
-   * @param[out] width  width of image
-   * @param[out] height height of image
-   * @param[out] pixelFormat pixel format used by image
-   * @return     True if the pixels were gotten, and false otherwise.
-   */
-  bool GetPixels( std::vector<unsigned char>& pixbuf, unsigned int& width, unsigned int& height, Pixel::Format& pixelFormat ) const;
-
-  /**
-   * @brief Convert the current pixel contents to either a JPEG or PNG format
-   * and write that to the filesytem.
-   *
-   * @param[in] filename Identify the filesytem location at which to write the
-   *                     encoded image. The extension determines the encoding used.
-   *                     The two valid encoding are (".jpeg"|".jpg") and ".png".
-   * @return    True if the pixels were written, and false otherwise.
-   */
-  bool EncodeToFile(const std::string& filename) const;
-
-private:   // native image
-
-  /**
-   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
-   */
-  virtual bool GlExtensionCreate();
-
-  /**
-   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
-   */
-  virtual void GlExtensionDestroy();
-
-  /**
-   * @copydoc Dali::NativeImageInterface::TargetTexture()
-   */
-  virtual unsigned int TargetTexture();
-
-  /**
-   * @copydoc Dali::NativeImageInterface::PrepareTexture()
-   */
-  virtual void PrepareTexture();
-
-  /**
-   * @copydoc Dali::NativeImageInterface::GetWidth()
-   */
-  virtual unsigned int GetWidth() const;
-
-  /**
-   * @copydoc Dali::NativeImageInterface::GetHeight()
-   */
-  virtual unsigned int GetHeight() const;
-
-  /**
-   * @copydoc Dali::NativeImageInterface::RequiresBlending()
-   */
-  virtual bool RequiresBlending() const;
-
-private:
-
-  /**
-   * @brief Private constructor
-   * @param[in] width The width of the image.
-   * @param[in] height The height of the image.
-   * @param[in] depth color depth of the image.
-   * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
-   */
-  DALI_INTERNAL NativeImageSource( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSource );
-
-  /**
-   * @brief A reference counted object may only be deleted by calling Unreference().
-   *
-   * The implementation should destroy the NativeImage resources.
-   */
-  DALI_INTERNAL virtual ~NativeImageSource();
-
-  /**
-   * @brief Undefined copy constructor
-   *
-   * This avoids accidental calls to a default copy constructor.
-   * @param[in] nativeImageSource A reference to the object to copy.
-   */
-  DALI_INTERNAL NativeImageSource( const NativeImageSource& nativeImageSource );
-
-  /**
-   * @brief Undefined assignment operator.
-   *
-   * This avoids accidental calls to a default assignment operator.
-   * @param[in] rhs A reference to the object to copy.
-   */
-  DALI_INTERNAL NativeImageSource& operator=(const NativeImageSource& rhs);
-
-private:
-
-  Internal::Adaptor::NativeImageSource* mImpl; ///< Implementation pointer
-};
-
-/**
- * @}
- */
-} // namespace Dali
-
-#endif // __DALI_NATIVE_IMAGE_SOURCE_H__
diff --git a/adaptors/public-api/adaptor-framework/pixmap-image.cpp b/adaptors/public-api/adaptor-framework/pixmap-image.cpp
new file mode 100644 (file)
index 0000000..05fe7e8
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * 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 <pixmap-image.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+// INTERNAL INCLUDES
+#include <pixmap-image-impl.h>
+
+namespace Dali
+{
+
+PixmapImagePtr PixmapImage::New( unsigned int width, unsigned int height, ColorDepth depth )
+{
+  Any empty;
+  PixmapImagePtr image = new PixmapImage( width, height, depth, empty );
+  return image;
+}
+
+Any PixmapImage::GetPixmap()
+{
+  return mImpl->GetPixmap();
+}
+
+PixmapImagePtr PixmapImage::New( Any pixmap )
+{
+  PixmapImagePtr image = new PixmapImage(0, 0, COLOR_DEPTH_DEFAULT, pixmap);
+  return image;
+}
+
+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 );
+}
+
+bool PixmapImage::EncodeToFile(const std::string& filename) const
+{
+  return mImpl->EncodeToFile(filename);
+}
+
+bool PixmapImage::GlExtensionCreate()
+{
+  return mImpl->GlExtensionCreate();
+}
+
+void PixmapImage::GlExtensionDestroy()
+{
+  mImpl->GlExtensionDestroy();
+}
+
+unsigned int PixmapImage::TargetTexture()
+{
+  return mImpl->TargetTexture();
+}
+
+void PixmapImage::PrepareTexture()
+{
+
+}
+
+unsigned int PixmapImage::GetWidth() const
+{
+  return mImpl->GetWidth();
+}
+
+unsigned int PixmapImage::GetHeight() const
+{
+  return mImpl->GetHeight();
+}
+
+bool PixmapImage::RequiresBlending() const
+{
+  return mImpl->RequiresBlending();
+}
+
+PixmapImage::PixmapImage( unsigned int width, unsigned int height, ColorDepth depth, Any pixmap )
+{
+   mImpl = Internal::Adaptor::PixmapImage::New( width, height, depth, pixmap );
+}
+
+PixmapImage::~PixmapImage()
+{
+  delete mImpl;
+}
+
+} // namespace Dali
diff --git a/adaptors/public-api/adaptor-framework/pixmap-image.h b/adaptors/public-api/adaptor-framework/pixmap-image.h
new file mode 100644 (file)
index 0000000..8dd3c46
--- /dev/null
@@ -0,0 +1,205 @@
+#ifndef __DALI_PIXMAP_IMAGE_H__
+#define __DALI_PIXMAP_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+#include <dali/public-api/common/vector-wrapper.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
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class PixmapImage;
+}
+}
+
+class PixmapImage;
+/**
+ * @brief Pointer to Dali::PixmapImage.
+ */
+typedef IntrusivePtr<PixmapImage> PixmapImagePtr;
+
+/**
+ * @brief Used for displaying native Pixmap images.
+ *
+ * The native pixmap can be created internally or
+ * externally by X11 or ECORE-X11.
+ *
+ * @since DALi 1.1.4
+ */
+class DALI_IMPORT_API PixmapImage : public NativeImageInterface
+{
+public:
+
+   /**
+    * @brief When creating a pixmap the color depth has to be specified.
+    */
+   enum ColorDepth
+   {
+     COLOR_DEPTH_DEFAULT,     ///< Uses the current X screen default depth (recommended)
+     COLOR_DEPTH_8,           ///< 8 bits per pixel
+     COLOR_DEPTH_16,          ///< 16 bits per pixel
+     COLOR_DEPTH_24,          ///< 24 bits per pixel
+     COLOR_DEPTH_32           ///< 32 bits per pixel
+   };
+
+  /**
+   * @brief Create a new PixmapImage.
+   *
+   * Depending on hardware the width and height may have to be a power of two.
+   * @param[in] width The width of the image.
+   * @param[in] height The height of the image.
+   * @param[in] depth color depth of the pixmap
+   * @return A smart-pointer to a newly allocated image.
+   */
+  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
+   * @return A smart-pointer to a newly allocated image.
+   */
+  static PixmapImagePtr New( Any pixmap );
+
+  /**
+   * @brief Retrieve the internal pixmap
+   *
+   * @return pixmap any object containing the internal pixmap
+   */
+  Any GetPixmap();
+
+  /**
+   * @brief Get a copy of the pixels used by PixmapImage.
+   *
+   * This is only supported for 24 bit RGB and 32 bit RGBA internal formats
+   * (COLOR_DEPTH_24 and COLOR_DEPTH_32).
+   * @param[out] pixbuf a vector to store the pixels in
+   * @param[out] width  width of image
+   * @param[out] height height of image
+   * @param[out] pixelFormat pixel format used by image
+   * @return     True if the pixels were gotten, and false otherwise.
+   */
+  bool GetPixels( std::vector<unsigned char>& pixbuf, unsigned int& width, unsigned int& height, Pixel::Format& pixelFormat ) const;
+
+  /**
+   * @brief Convert the current pixel contents to either a JPEG or PNG format
+   * and write that to the filesytem.
+   *
+   * @param[in] filename Identify the filesytem location at which to write the
+   *                     encoded image. The extension determines the encoding used.
+   *                     The two valid encoding are (".jpeg"|".jpg") and ".png".
+   * @return    True if the pixels were written, and false otherwise.
+   */
+  bool EncodeToFile(const std::string& filename) const;
+
+private:   // native image
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
+   */
+  virtual bool GlExtensionCreate();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
+   */
+  virtual void GlExtensionDestroy();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::TargetTexture()
+   */
+  virtual unsigned int TargetTexture();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::PrepareTexture()
+   */
+  virtual void PrepareTexture();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetWidth()
+   */
+  virtual unsigned int GetWidth() const;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetHeight()
+   */
+  virtual unsigned int GetHeight() const;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::RequiresBlending()
+   */
+  virtual bool RequiresBlending() const;
+
+private:
+
+  /**
+   * @brief Private constructor
+   * @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] 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, Any pixmap );
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference().
+   *
+   * The implementation should destroy the NativeImage resources.
+   */
+  DALI_INTERNAL virtual ~PixmapImage();
+
+  /**
+   * @brief Undefined copy constructor
+   *
+   * This avoids accidental calls to a default copy constructor.
+   * @param[in] pixmapImage A reference to the object to copy.
+   */
+  DALI_INTERNAL PixmapImage( const PixmapImage& pixmapImage );
+
+  /**
+   * @brief Undefined assignment operator.
+   *
+   * This avoids accidental calls to a default assignment operator.
+   * @param[in] rhs A reference to the object to copy.
+   */
+  DALI_INTERNAL PixmapImage& operator=(const PixmapImage& rhs);
+
+private:
+
+  Internal::Adaptor::PixmapImage* mImpl; ///< Implementation pointer
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // __DALI_PIXMAP_IMAGE_H__
index 240215eedca50f88e7aba7ae43e14afc73807f8b..8ed599fca56b141c4f5fca19cf83c6d55f30b6af 100644 (file)
@@ -26,7 +26,7 @@
 #include <dali/public-api/adaptor-framework/key.h>
 #include <dali/public-api/adaptor-framework/timer.h>
 #include <dali/public-api/adaptor-framework/tts-player.h>
-#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/adaptor-framework/pixmap-image.h>
 #include <dali/public-api/dali-adaptor-version.h>
 
 #endif //__DALI_H__
index dbf643ffce9d3f97d26ec91de9cc07c0ac4b8a09..90e1144612f331331939c6b055e891f171787293 100644 (file)
@@ -4,7 +4,7 @@ public_api_src_files = \
   $(adaptor_public_api_dir)/adaptor-framework/window.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/timer.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/tts-player.cpp \
-  $(adaptor_public_api_dir)/adaptor-framework/native-image-source.cpp \
+  $(adaptor_public_api_dir)/adaptor-framework/pixmap-image.cpp \
   $(adaptor_public_api_dir)/dali-adaptor-version.cpp
 
 
@@ -20,7 +20,7 @@ public_api_adaptor_framework_header_files = \
   $(adaptor_public_api_dir)/adaptor-framework/style-change.h \
   $(adaptor_public_api_dir)/adaptor-framework/timer.h \
   $(adaptor_public_api_dir)/adaptor-framework/tts-player.h \
-  $(adaptor_public_api_dir)/adaptor-framework/native-image-source.h \
+  $(adaptor_public_api_dir)/adaptor-framework/pixmap-image.h \
   $(adaptor_public_api_dir)/adaptor-framework/window.h
 
 adaptor_dali_header_file = \
index 0d66f49ca8774fe1b98a33a2e690768dd22dcef9..f383295ffdbb94e5115d52fcc8a5705559254aa9 100644 (file)
@@ -6,7 +6,7 @@ adaptor_wayland_tizen_internal_src_files = \
   $(adaptor_wayland_dir)/display-connection-impl-wl.cpp \
   $(adaptor_wayland_dir)/framework-wl.cpp \
   $(adaptor_wayland_dir)/imf-manager-impl-wl.cpp \
-  $(adaptor_wayland_dir)/native-image-source-impl-wl.cpp \
+  $(adaptor_wayland_dir)/pixmap-image-impl-wl.cpp \
   $(adaptor_wayland_dir)/virtual-keyboard-impl-wl.cpp \
   $(adaptor_wayland_dir)/window-impl-wl.cpp \
   $(adaptor_wayland_dir)/event-handler-wl.cpp \
diff --git a/adaptors/wayland/native-image-source-impl-wl.cpp b/adaptors/wayland/native-image-source-impl-wl.cpp
deleted file mode 100644 (file)
index e32aec9..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include "native-image-source-impl.h"
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <gl/egl-image-extensions.h>
-#include <gl/egl-factory.h>
-#include <adaptor-impl.h>
-#include <render-surface.h>
-
-// Allow this to be encoded and saved:
-#include <platform-abstractions/tizen/resource-loader/resource-loader.h>
-#include <bitmap-saver.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-using Dali::Integration::PixelBuffer;
-
-NativeImageSource* NativeImageSource::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-{
-  NativeImageSource* image = new NativeImageSource( width, height, depth, nativeImageSource );
-  DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
-
-  // 2nd phase construction
-  if(image) //< Defensive in case we ever compile without exceptions.
-  {
-    image->Initialize();
-  }
-
-  return image;
-}
-
-NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
-  mHeight( height ),
-  mOwnPixmap( true ),
-  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 );
-}
-
-void NativeImageSource::Initialize()
-{
-}
-
-NativeImageSource::~NativeImageSource()
-{
-}
-
-Any NativeImageSource::GetNativeImageSource() const
-{
-  DALI_ASSERT_ALWAYS( false && "NativeImageSource::GetNativeImageSource() is not supported for Wayland." );
-  return Any();
-}
-
-bool NativeImageSource::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
-{
-    return false;
-}
-
-bool NativeImageSource::EncodeToFile(const std::string& filename) const
-{
-  std::vector< unsigned char > pixbuf;
-  unsigned int width(0), height(0);
-  Pixel::Format pixelFormat;
-
-  if(GetPixels(pixbuf, width, height, pixelFormat))
-  {
-    return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
-  }
-  return false;
-}
-
-bool NativeImageSource::GlExtensionCreate()
-{
-    return false;
-}
-
-void NativeImageSource::GlExtensionDestroy()
-{
-  mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
-
-  mEglImageKHR = NULL;
-}
-
-unsigned int NativeImageSource::TargetTexture()
-{
-  mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
-
-  return 0;
-}
-
-void NativeImageSource::SetBlending(Dali::NativeImageSource::ColorDepth depth)
-{
-  switch (depth)
-  {
-    case Dali::NativeImageSource::COLOR_DEPTH_16: //Pixel::RGB565
-    case Dali::NativeImageSource::COLOR_DEPTH_24: // Pixel::RGB888
-    {
-      mBlendingRequired = false;
-      break;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_8: //Pixel::A8
-    case Dali::NativeImageSource::COLOR_DEPTH_32: // Pixel::RGBA8888
-    {
-      mBlendingRequired = true;
-      break;
-    }
-    default:
-    {
-      DALI_ASSERT_DEBUG(0 && "unknown color enum");
-    }
-  }
-}
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
diff --git a/adaptors/wayland/native-image-source-impl.h b/adaptors/wayland/native-image-source-impl.h
deleted file mode 100644 (file)
index 3870416..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-#ifndef __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
-#define __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_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.
- *
- */
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <native-image-source.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class EglImageExtensions;
-
-/**
- * Dali internal NativeImageSource.
- */
-class NativeImageSource
-{
-public:
-
-  /**
-   * Create a new NativeImageSource internally.
-   * Depending on hardware the width and height may have to be a power of two.
-   * @param[in] width The width of the image.
-   * @param[in] height The height of the image.
-   * @param[in] depth color depth of the image.
-   * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
-   * @return A smart-pointer to a newly allocated image.
-   */
-  static NativeImageSource* New(unsigned int width,
-                          unsigned int height,
-                          Dali::NativeImageSource::ColorDepth depth,
-                          Any nativeImageSource);
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetNativeImageSource()
-   */
-  Any GetNativeImageSource() const;
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetPixels()
-   */
-  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
-
-  /**
-   * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
-   */
-  bool EncodeToFile(const std::string& filename) const;
-
-  /**
-   * destructor
-   */
-  ~NativeImageSource();
-
-  /**
-   * @copydoc Dali::NativeImageSource::GlExtensionCreate()
-   */
-  bool GlExtensionCreate();
-
-  /**
-   * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
-   */
-  void GlExtensionDestroy();
-
-  /**
-   * @copydoc Dali::NativeImageSource::TargetTexture()
-   */
-  unsigned int TargetTexture();
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetWidth()
-   */
-  unsigned int GetWidth() const
-  {
-    return mWidth;
-  }
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetHeight()
-   */
-  unsigned int GetHeight() const
-  {
-    return mHeight;
-  }
-
-  /**
-   * @copydoc Dali::NativeImageSource::RequiresBlending()
-   */
-  bool RequiresBlending() const
-  {
-    return mBlendingRequired;
-  }
-
-private:
-
-  /**
-   * Private constructor; @see NativeImageSource::New()
-   * @param[in] width The width of the image.
-   * @param[in] height The height of the image.
-   * @param[in] colour depth of the image.
-   * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
-   */
-  NativeImageSource(unsigned int width,
-              unsigned  int height,
-              Dali::NativeImageSource::ColorDepth depth,
-              Any nativeImageSource);
-
-  /**
-   * 2nd phase construction.
-   */
-  void Initialize();
-
-  /**
-   * Decide whether blending is required based on the color depth.
-   * @param depth the PixelImage depth enum
-   */
-  void SetBlending(Dali::NativeImageSource::ColorDepth depth);
-
-private:
-
-  unsigned int mWidth;                        ///< image width
-  unsigned int mHeight;                       ///< image heights
-  bool mOwnPixmap;                            ///< Whether we created pixmap or not
-  bool mBlendingRequired;                      ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
-  void* mEglImageKHR;                         ///< From EGL extension
-  EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
diff --git a/adaptors/wayland/pixmap-image-impl-wl.cpp b/adaptors/wayland/pixmap-image-impl-wl.cpp
new file mode 100644 (file)
index 0000000..3ebc0e7
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include "pixmap-image-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <gl/egl-image-extensions.h>
+#include <gl/egl-factory.h>
+#include <adaptor-impl.h>
+#include <render-surface.h>
+
+// Allow this to be encoded and saved:
+#include <platform-abstractions/tizen/resource-loader/resource-loader.h>
+#include <bitmap-saver.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+using Dali::Integration::PixelBuffer;
+
+PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
+{
+  PixmapImage* image = new PixmapImage( width, height, depth, pixmap );
+  DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
+
+  // 2nd phase construction
+  if(image) //< Defensive in case we ever compile without exceptions.
+  {
+    image->Initialize();
+  }
+
+  return image;
+}
+
+PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
+: mWidth( width ),
+  mHeight( height ),
+  mOwnPixmap( true ),
+  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 );
+}
+
+void PixmapImage::Initialize()
+{
+}
+
+PixmapImage::~PixmapImage()
+{
+}
+
+Any PixmapImage::GetPixmap() const
+{
+  DALI_ASSERT_ALWAYS( false && "PixmapImage::GetPixmap() is not supported for Wayland." );
+  return Any();
+}
+
+bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+{
+    return false;
+}
+
+bool PixmapImage::EncodeToFile(const std::string& filename) const
+{
+  std::vector< unsigned char > pixbuf;
+  unsigned int width(0), height(0);
+  Pixel::Format pixelFormat;
+
+  if(GetPixels(pixbuf, width, height, pixelFormat))
+  {
+    return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
+  }
+  return false;
+}
+
+bool PixmapImage::GlExtensionCreate()
+{
+    return false;
+}
+
+void PixmapImage::GlExtensionDestroy()
+{
+  mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
+
+  mEglImageKHR = NULL;
+}
+
+unsigned int PixmapImage::TargetTexture()
+{
+  mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
+
+  return 0;
+}
+
+void PixmapImage::SetBlending(Dali::PixmapImage::ColorDepth depth)
+{
+  switch (depth)
+  {
+    case Dali::PixmapImage::COLOR_DEPTH_16: //Pixel::RGB565
+    case Dali::PixmapImage::COLOR_DEPTH_24: // Pixel::RGB888
+    {
+      mBlendingRequired = false;
+      break;
+    }
+    case Dali::PixmapImage::COLOR_DEPTH_8: //Pixel::A8
+    case Dali::PixmapImage::COLOR_DEPTH_32: // Pixel::RGBA8888
+    {
+      mBlendingRequired = true;
+      break;
+    }
+    default:
+    {
+      DALI_ASSERT_DEBUG(0 && "unknown color enum");
+    }
+  }
+}
+
+void PixmapImage::GetPixmapDetails()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
diff --git a/adaptors/wayland/pixmap-image-impl.h b/adaptors/wayland/pixmap-image-impl.h
new file mode 100644 (file)
index 0000000..4fd9044
--- /dev/null
@@ -0,0 +1,164 @@
+#ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
+#define __DALI_INTERNAL_PIXMAP_IMAGE_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <pixmap-image.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class EglImageExtensions;
+
+/**
+ * Dali internal PixmapImage.
+ */
+class PixmapImage
+{
+public:
+
+  /**
+   * Create a new PixmapImage internally.
+   * Depending on hardware the width and height may have to be a power of two.
+   * @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] 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,
+                          Any pixmap);
+
+  /**
+   * @copydoc Dali::PixmapImage::GetPixmap()
+   */
+  Any GetPixmap() const;
+
+  /**
+   * @copydoc Dali::PixmapImage::GetPixels()
+   */
+  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+
+  /**
+   * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
+   */
+  bool EncodeToFile(const std::string& filename) const;
+
+  /**
+   * destructor
+   */
+  ~PixmapImage();
+
+  /**
+   * @copydoc Dali::PixmapImage::GlExtensionCreate()
+   */
+  bool GlExtensionCreate();
+
+  /**
+   * @copydoc Dali::PixmapImage::GlExtensionDestroy()
+   */
+  void GlExtensionDestroy();
+
+  /**
+   * @copydoc Dali::PixmapImage::TargetTexture()
+   */
+  unsigned int TargetTexture();
+
+  /**
+   * @copydoc Dali::PixmapImage::GetWidth()
+   */
+  unsigned int GetWidth() const
+  {
+    return mWidth;
+  }
+
+  /**
+   * @copydoc Dali::PixmapImage::GetHeight()
+   */
+  unsigned int GetHeight() const
+  {
+    return mHeight;
+  }
+
+  /**
+   * @copydoc Dali::PixmapImage::RequiresBlending()
+   */
+  bool RequiresBlending() const
+  {
+    return mBlendingRequired;
+  }
+
+private:
+
+  /**
+   * Private constructor; @see PixmapImage::New()
+   * @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] 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,
+              Any pixmap);
+
+  /**
+   * 2nd phase construction.
+   */
+  void Initialize();
+
+  /**
+   * Decide whether blending is required based on the color depth.
+   * @param depth the PixelImage depth enum
+   */
+  void SetBlending(Dali::PixmapImage::ColorDepth depth);
+
+  /**
+   * Given an existing pixmap, the function uses X to find out
+   * the width, heigth and depth of that pixmap.
+   */
+  void GetPixmapDetails();
+
+private:
+
+  unsigned int mWidth;                        ///< pixmap width
+  unsigned int mHeight;                       ///< pixmap heights
+  bool mOwnPixmap;                            ///< Whether we created pixmap or not
+  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
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__
index 03052b415c3c8fdad7b4b6d89545d333445e89f1..a716f3eabcab5289f8e4662cc9f0c291af55e45d 100644 (file)
@@ -4,7 +4,7 @@ _adaptor_x11_internal_src_files = \
   $(adaptor_x11_dir)/clipboard-impl-x.cpp \
   $(adaptor_x11_dir)/display-connection-impl-x.cpp \
   $(adaptor_x11_dir)/imf-manager-impl-x.cpp \
-  $(adaptor_x11_dir)/native-image-source-impl-x.cpp \
+  $(adaptor_x11_dir)/pixmap-image-impl-x.cpp \
   $(adaptor_x11_dir)/virtual-keyboard-impl-x.cpp \
   $(adaptor_x11_dir)/window-impl-x.cpp \
   $(adaptor_x11_dir)/egl-implementation-x.cpp \
diff --git a/adaptors/x11/native-image-source-impl-x.cpp b/adaptors/x11/native-image-source-impl-x.cpp
deleted file mode 100644 (file)
index b58057b..0000000
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include "native-image-source-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore_X.h>
-#include <X11/Xutil.h>
-#include <X11/Xlib.h>
-#include <dali/integration-api/debug.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
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-using Dali::Integration::PixelBuffer;
-
-// Pieces needed to save compressed images (temporary location while plumbing):
-namespace
-{
-
-  /**
-   * Free an allocated XImage on destruction.
-   */
-  struct XImageJanitor
-  {
-    XImageJanitor( XImage* const  pXImage ) : mXImage( pXImage )
-    {
-      DALI_ASSERT_DEBUG(pXImage != 0 && "Null pointer to XImage.");
-    }
-
-    ~XImageJanitor()
-    {
-      if( mXImage )
-      {
-        if( !XDestroyImage(mXImage) )
-        {
-          DALI_ASSERT_DEBUG("XImage deallocation failure");
-        }
-      }
-    }
-    XImage* const  mXImage;
-  private:
-    XImageJanitor( const XImageJanitor& rhs );
-    XImageJanitor& operator = ( const XImageJanitor& rhs );
-  };
-}
-
-NativeImageSource* NativeImageSource::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-{
-  NativeImageSource* image = new NativeImageSource( width, height, depth, nativeImageSource );
-  DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
-
-  // 2nd phase construction
-  if(image) //< Defensive in case we ever compile without exceptions.
-  {
-    image->Initialize();
-  }
-
-  return image;
-}
-
-NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
-  mHeight( height ),
-  mOwnPixmap( true ),
-  mPixmap( 0 ),
-  mBlendingRequired( false ),
-  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(nativeImageSource);
-}
-
-void NativeImageSource::Initialize()
-{
-  // if pixmap has been created outside of X11 Image we can return
-  if (mPixmap)
-  {
-    // we don't own the pixmap
-    mOwnPixmap = false;
-
-    // find out the pixmap width / height and color depth
-    GetPixmapDetails();
-    return;
-  }
-
-  // get the pixel depth
-  int depth = GetPixelDepth(mColorDepth);
-
-  // 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();
-}
-
-NativeImageSource::~NativeImageSource()
-{
-  if (mOwnPixmap && mPixmap)
-  {
-    ecore_x_pixmap_free(mPixmap);
-  }
-}
-
-Any NativeImageSource::GetNativeImageSource() const
-{
-  // return ecore x11 type
-  return Any(mPixmap);
-}
-
-bool NativeImageSource::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
-{
-  DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
-  bool success = false;
-  width  = mWidth;
-  height = mHeight;
-
-  // 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)
-  {
-    DALI_LOG_ERROR("Could not retrieve Ximage.");
-  }
-  else
-  {
-    switch(pXImage->depth)
-    {
-      // Note, depth is a logical value. On target the framebuffer is still 32bpp
-      // (see pXImage->bits_per_pixel) so we go through XGetPixel() and swizzle.
-      // Note, this could be the default, fallback case for all depths if *pXImage
-      // didn't have blank RGB masks (X bug), but we have to hardcode the masks and
-      // shifts instead.
-      case 24:
-      {
-        pixelFormat = Pixel::RGB888;
-        pixbuf.resize(width*height*3);
-        unsigned char* bufPtr = &pixbuf[0];
-
-        for(unsigned y = height-1; y < height; --y)
-        {
-          for(unsigned x = 0; x < width; ++x, bufPtr+=3)
-          {
-            const unsigned pixel = XGetPixel(pXImage,x,y);
-
-            // store as RGB
-            const unsigned blue  =  pixel & 0xFFU;
-            const unsigned green = (pixel >> 8)  & 0xFFU;
-            const unsigned red   = (pixel >> 16) & 0xFFU;
-
-            *bufPtr = red;
-            *(bufPtr+1) = green;
-            *(bufPtr+2) = blue;
-          }
-        }
-        success = true;
-        break;
-      }
-      case 32:
-      {
-        if(pXImage->data)
-        {
-          // Sweep through the image, doing a vertical flip, but handling each scanline as
-          // an inlined intrinsic/builtin memcpy (should be fast):
-          pixbuf.resize(width*height*4);
-          unsigned * bufPtr = reinterpret_cast<unsigned *>(&pixbuf[0]);
-          const unsigned xDataLineSkip = pXImage->bytes_per_line;
-          const size_t copy_count = width * 4;
-          pixelFormat = Pixel::BGRA8888;
-
-          for(unsigned y = height-1; y < height; --y, bufPtr += width)
-          {
-            const char * const in = pXImage->data + xDataLineSkip * y;
-
-            // Copy a whole scanline at a time:
-            DALI_ASSERT_DEBUG( size_t( bufPtr ) >= size_t( &pixbuf[0] ));
-            DALI_ASSERT_DEBUG( reinterpret_cast<size_t>( bufPtr ) + copy_count <= reinterpret_cast<size_t>( &pixbuf[pixbuf.size()] ) );
-            DALI_ASSERT_DEBUG( in >= pXImage->data );
-            DALI_ASSERT_DEBUG( in + copy_count <= pXImage->data + xDataLineSkip * height );
-            __builtin_memcpy( bufPtr, in, copy_count );
-          }
-          success = true;
-        }
-        else
-        {
-          DALI_LOG_ERROR("XImage has null data pointer.");
-        }
-        break;
-      }
-      // Make a case for 16 bit modes especially to remember that the only reason we don't support them is a bug in X:
-      case 16:
-      {
-        DALI_ASSERT_DEBUG(pXImage->red_mask && pXImage->green_mask && pXImage->blue_mask && "No image masks mean 16 bit modes are not possible.");
-        ///! If the above assert doesn't fail in a debug build, the X bug may have been fixed, so revisit this function.
-        ///! No break, fall through to the general unsupported format warning below.
-      }
-      default:
-      {
-        DALI_LOG_WARNING("Pixmap has unsupported bit-depth for getting pixels: %u", pXImage->depth);
-      }
-    }
-  }
-  if(!success)
-  {
-    DALI_LOG_ERROR("Failed to get pixels from NativeImageSource.");
-    pixbuf.resize(0);
-    width = 0;
-    height = 0;
-  }
-
-  // Close the display connection
-  XCloseDisplay( displayConnection );
-
-  return success;
-}
-
-bool NativeImageSource::EncodeToFile(const std::string& filename) const
-{
-  std::vector< unsigned char > pixbuf;
-  unsigned int width(0), height(0);
-  Pixel::Format pixelFormat;
-
-  if(GetPixels(pixbuf, width, height, pixelFormat))
-  {
-    return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
-  }
-  return false;
-}
-
-bool NativeImageSource::GlExtensionCreate()
-{
-  // if the image existed previously delete it.
-  if (mEglImageKHR != NULL)
-  {
-    GlExtensionDestroy();
-  }
-
-  // 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 = mEglImageExtensions->CreateImageKHR( eglBuffer );
-
-  return mEglImageKHR != NULL;
-}
-
-void NativeImageSource::GlExtensionDestroy()
-{
-  mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
-
-  mEglImageKHR = NULL;
-}
-
-unsigned int NativeImageSource::TargetTexture()
-{
-  mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
-
-  return 0;
-}
-
-int NativeImageSource::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
-{
-  switch (depth)
-  {
-    case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
-    {
-      // Get the default screen depth
-      return ecore_x_default_depth_get(ecore_x_display_get(), ecore_x_default_screen_get());
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_8:
-    {
-      return 8;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_16:
-    {
-      return 16;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_24:
-    {
-      return 24;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_32:
-    {
-      return 32;
-    }
-    default:
-    {
-      DALI_ASSERT_DEBUG(0 && "unknown color enum");
-      return 0;
-    }
-  }
-}
-
-Ecore_X_Pixmap NativeImageSource::GetPixmapFromAny(Any pixmap) const
-{
-  if (pixmap.Empty())
-  {
-    return 0;
-  }
-
-  // see if it is of type x11 pixmap
-  if (pixmap.GetType() == typeid (Pixmap))
-  {
-    // get the x pixmap type
-    Pixmap xpixmap = AnyCast<Pixmap>(pixmap);
-
-    // cast it to a ecore pixmap type
-    return static_cast<Ecore_X_Pixmap>(xpixmap);
-  }
-  else
-  {
-    return AnyCast<Ecore_X_Pixmap>(pixmap);
-  }
-}
-
-void NativeImageSource::GetPixmapDetails()
-{
-  int x, y;
-
-  // get the width, height and depth
-  ecore_x_pixmap_geometry_get(mPixmap, &x, &y, (int*)&mWidth, (int*)&mHeight);
-
-  // 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
-
-} // namespace internal
-
-} // namespace Dali
diff --git a/adaptors/x11/native-image-source-impl.h b/adaptors/x11/native-image-source-impl.h
deleted file mode 100644 (file)
index a97bfe1..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-#ifndef __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
-#define __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <Ecore_X.h>
-
-// INTERNAL INCLUDES
-#include <native-image-source.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class EglImageExtensions;
-
-/**
- * Dali internal NativeImageSource.
- */
-class NativeImageSource
-{
-public:
-
-  /**
-   * Create a new NativeImageSource internally.
-   * Depending on hardware the width and height may have to be a power of two.
-   * @param[in] width The width of the image.
-   * @param[in] height The height of the image.
-   * @param[in] depth color depth of the image.
-   * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
-   * @return A smart-pointer to a newly allocated image.
-   */
-  static NativeImageSource* New(unsigned int width,
-                          unsigned int height,
-                          Dali::NativeImageSource::ColorDepth depth,
-                          Any nativeImageSource);
-  /**
-   * @copydoc Dali::NativeImageSource::GetNativeImageSource()
-   */
-  Any GetNativeImageSource() const;
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetPixels()
-   */
-  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
-
-  /**
-   * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
-   */
-  bool EncodeToFile(const std::string& filename) const;
-
-  /**
-   * destructor
-   */
-  ~NativeImageSource();
-
-  /**
-   * @copydoc Dali::NativeImageSource::GlExtensionCreate()
-   */
-  bool GlExtensionCreate();
-
-  /**
-   * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
-   */
-  void GlExtensionDestroy();
-
-  /**
-   * @copydoc Dali::NativeImageSource::TargetTexture()
-   */
-  unsigned int TargetTexture();
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetWidth()
-   */
-  unsigned int GetWidth() const
-  {
-    return mWidth;
-  }
-
-  /**
-   * @copydoc Dali::NativeImageSource::GetHeight()
-   */
-  unsigned int GetHeight() const
-  {
-    return mHeight;
-  }
-
-  /**
-   * @copydoc Dali::NativeImageSource::RequiresBlending()
-   */
-  bool RequiresBlending() const
-  {
-    return mBlendingRequired;
-  }
-
-private:
-
-  /**
-   * Private constructor; @see NativeImageSource::New()
-   * @param[in] width The width of the image.
-   * @param[in] height The height of the image.
-   * @param[in] colour depth of the image.
-   * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
-   */
-  NativeImageSource(unsigned int width,
-              unsigned  int height,
-              Dali::NativeImageSource::ColorDepth depth,
-              Any nativeImageSource);
-
-  /**
-   * 2nd phase construction.
-   */
-  void Initialize();
-
-  /**
-   * Uses X11 to get the default depth.
-   * @param depth the PixelImage depth enum
-   * @return default x11 pixel depth
-   */
-  int GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const;
-
-  /**
-   * 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
-   */
-  Ecore_X_Pixmap GetPixmapFromAny(Any pixmap) const;
-
-  /**
-   * Given an existing pixmap, the function uses X to find out
-   * the width, heigth and depth of that pixmap.
-   */
-  void GetPixmapDetails();
-
-private:
-
-  unsigned int mWidth;                        ///< image width
-  unsigned int mHeight;                       ///< image heights
-  bool mOwnPixmap;                            ///< Whether we created pixmap or not
-  Ecore_X_Pixmap mPixmap;                     ///< From Xlib
-  bool mBlendingRequired;                      ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
-  void* mEglImageKHR;                         ///< From EGL extension
-  EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
diff --git a/adaptors/x11/pixmap-image-impl-x.cpp b/adaptors/x11/pixmap-image-impl-x.cpp
new file mode 100644 (file)
index 0000000..4fbc237
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include "pixmap-image-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore_X.h>
+#include <X11/Xutil.h>
+#include <X11/Xlib.h>
+#include <dali/integration-api/debug.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
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+using Dali::Integration::PixelBuffer;
+
+// Pieces needed to save compressed images (temporary location while plumbing):
+namespace
+{
+
+  /**
+   * Free an allocated XImage on destruction.
+   */
+  struct XImageJanitor
+  {
+    XImageJanitor( XImage* const  pXImage ) : mXImage( pXImage )
+    {
+      DALI_ASSERT_DEBUG(pXImage != 0 && "Null pointer to XImage.");
+    }
+
+    ~XImageJanitor()
+    {
+      if( mXImage )
+      {
+        if( !XDestroyImage(mXImage) )
+        {
+          DALI_ASSERT_DEBUG("XImage deallocation failure");
+        }
+      }
+    }
+    XImage* const  mXImage;
+  private:
+    XImageJanitor( const XImageJanitor& rhs );
+    XImageJanitor& operator = ( const XImageJanitor& rhs );
+  };
+}
+
+PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
+{
+  PixmapImage* image = new PixmapImage( width, height, depth, pixmap );
+  DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
+
+  // 2nd phase construction
+  if(image) //< Defensive in case we ever compile without exceptions.
+  {
+    image->Initialize();
+  }
+
+  return image;
+}
+
+PixmapImage::PixmapImage( unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Any pixmap )
+: mWidth( width ),
+  mHeight( height ),
+  mOwnPixmap( true ),
+  mPixmap( 0 ),
+  mBlendingRequired( false ),
+  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()
+{
+  // if pixmap has been created outside of X11 Image we can return
+  if (mPixmap)
+  {
+    // we don't own the pixmap
+    mOwnPixmap = false;
+
+    // find out the pixmap width / height and color depth
+    GetPixmapDetails();
+    return;
+  }
+
+  // get the pixel depth
+  int depth = GetPixelDepth(mColorDepth);
+
+  // 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();
+}
+
+PixmapImage::~PixmapImage()
+{
+  if (mOwnPixmap && mPixmap)
+  {
+    ecore_x_pixmap_free(mPixmap);
+  }
+}
+
+Any PixmapImage::GetPixmap() const
+{
+  // return ecore x11 type
+  return Any(mPixmap);
+}
+
+bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+{
+  DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
+  bool success = false;
+  width  = mWidth;
+  height = mHeight;
+
+  // 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)
+  {
+    DALI_LOG_ERROR("Could not retrieve Ximage.");
+  }
+  else
+  {
+    switch(pXImage->depth)
+    {
+      // Note, depth is a logical value. On target the framebuffer is still 32bpp
+      // (see pXImage->bits_per_pixel) so we go through XGetPixel() and swizzle.
+      // Note, this could be the default, fallback case for all depths if *pXImage
+      // didn't have blank RGB masks (X bug), but we have to hardcode the masks and
+      // shifts instead.
+      case 24:
+      {
+        pixelFormat = Pixel::RGB888;
+        pixbuf.resize(width*height*3);
+        unsigned char* bufPtr = &pixbuf[0];
+
+        for(unsigned y = height-1; y < height; --y)
+        {
+          for(unsigned x = 0; x < width; ++x, bufPtr+=3)
+          {
+            const unsigned pixel = XGetPixel(pXImage,x,y);
+
+            // store as RGB
+            const unsigned blue  =  pixel & 0xFFU;
+            const unsigned green = (pixel >> 8)  & 0xFFU;
+            const unsigned red   = (pixel >> 16) & 0xFFU;
+
+            *bufPtr = red;
+            *(bufPtr+1) = green;
+            *(bufPtr+2) = blue;
+          }
+        }
+        success = true;
+        break;
+      }
+      case 32:
+      {
+        if(pXImage->data)
+        {
+          // Sweep through the image, doing a vertical flip, but handling each scanline as
+          // an inlined intrinsic/builtin memcpy (should be fast):
+          pixbuf.resize(width*height*4);
+          unsigned * bufPtr = reinterpret_cast<unsigned *>(&pixbuf[0]);
+          const unsigned xDataLineSkip = pXImage->bytes_per_line;
+          const size_t copy_count = width * 4;
+          pixelFormat = Pixel::BGRA8888;
+
+          for(unsigned y = height-1; y < height; --y, bufPtr += width)
+          {
+            const char * const in = pXImage->data + xDataLineSkip * y;
+
+            // Copy a whole scanline at a time:
+            DALI_ASSERT_DEBUG( size_t( bufPtr ) >= size_t( &pixbuf[0] ));
+            DALI_ASSERT_DEBUG( reinterpret_cast<size_t>( bufPtr ) + copy_count <= reinterpret_cast<size_t>( &pixbuf[pixbuf.size()] ) );
+            DALI_ASSERT_DEBUG( in >= pXImage->data );
+            DALI_ASSERT_DEBUG( in + copy_count <= pXImage->data + xDataLineSkip * height );
+            __builtin_memcpy( bufPtr, in, copy_count );
+          }
+          success = true;
+        }
+        else
+        {
+          DALI_LOG_ERROR("XImage has null data pointer.");
+        }
+        break;
+      }
+      // Make a case for 16 bit modes especially to remember that the only reason we don't support them is a bug in X:
+      case 16:
+      {
+        DALI_ASSERT_DEBUG(pXImage->red_mask && pXImage->green_mask && pXImage->blue_mask && "No image masks mean 16 bit modes are not possible.");
+        ///! If the above assert doesn't fail in a debug build, the X bug may have been fixed, so revisit this function.
+        ///! No break, fall through to the general unsupported format warning below.
+      }
+      default:
+      {
+        DALI_LOG_WARNING("Pixmap has unsupported bit-depth for getting pixels: %u", pXImage->depth);
+      }
+    }
+  }
+  if(!success)
+  {
+    DALI_LOG_ERROR("Failed to get pixels from PixmapImage.");
+    pixbuf.resize(0);
+    width = 0;
+    height = 0;
+  }
+
+  // Close the display connection
+  XCloseDisplay( displayConnection );
+
+  return success;
+}
+
+bool PixmapImage::EncodeToFile(const std::string& filename) const
+{
+  std::vector< unsigned char > pixbuf;
+  unsigned int width(0), height(0);
+  Pixel::Format pixelFormat;
+
+  if(GetPixels(pixbuf, width, height, pixelFormat))
+  {
+    return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
+  }
+  return false;
+}
+
+bool PixmapImage::GlExtensionCreate()
+{
+  // if the image existed previously delete it.
+  if (mEglImageKHR != NULL)
+  {
+    GlExtensionDestroy();
+  }
+
+  // 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 = mEglImageExtensions->CreateImageKHR( eglBuffer );
+
+  return mEglImageKHR != NULL;
+}
+
+void PixmapImage::GlExtensionDestroy()
+{
+  mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
+
+  mEglImageKHR = NULL;
+}
+
+unsigned int PixmapImage::TargetTexture()
+{
+  mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
+
+  return 0;
+}
+
+int PixmapImage::GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const
+{
+  switch (depth)
+  {
+    case Dali::PixmapImage::COLOR_DEPTH_DEFAULT:
+    {
+      // Get the default screen depth
+      return ecore_x_default_depth_get(ecore_x_display_get(), ecore_x_default_screen_get());
+    }
+    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;
+    }
+  }
+}
+
+Ecore_X_Pixmap PixmapImage::GetPixmapFromAny(Any pixmap) const
+{
+  if (pixmap.Empty())
+  {
+    return 0;
+  }
+
+  // see if it is of type x11 pixmap
+  if (pixmap.GetType() == typeid (Pixmap))
+  {
+    // get the x pixmap type
+    Pixmap xpixmap = AnyCast<Pixmap>(pixmap);
+
+    // cast it to a ecore pixmap type
+    return static_cast<Ecore_X_Pixmap>(xpixmap);
+  }
+  else
+  {
+    return AnyCast<Ecore_X_Pixmap>(pixmap);
+  }
+}
+
+void PixmapImage::GetPixmapDetails()
+{
+  int x, y;
+
+  // get the width, height and depth
+  ecore_x_pixmap_geometry_get(mPixmap, &x, &y, (int*)&mWidth, (int*)&mHeight);
+
+  // 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
+
+} // namespace internal
+
+} // namespace Dali
diff --git a/adaptors/x11/pixmap-image-impl.h b/adaptors/x11/pixmap-image-impl.h
new file mode 100644 (file)
index 0000000..3e897f1
--- /dev/null
@@ -0,0 +1,173 @@
+#ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
+#define __DALI_INTERNAL_PIXMAP_IMAGE_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore_X.h>
+
+// INTERNAL INCLUDES
+#include <pixmap-image.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class EglImageExtensions;
+
+/**
+ * Dali internal PixmapImage.
+ */
+class PixmapImage
+{
+public:
+
+  /**
+   * Create a new PixmapImage internally.
+   * Depending on hardware the width and height may have to be a power of two.
+   * @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] 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,
+                          Any pixmap);
+  /**
+   * @copydoc Dali::PixmapImage::GetPixmap()
+   */
+  Any GetPixmap() const;
+
+  /**
+   * @copydoc Dali::PixmapImage::GetPixels()
+   */
+  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+
+  /**
+   * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
+   */
+  bool EncodeToFile(const std::string& filename) const;
+
+  /**
+   * destructor
+   */
+  ~PixmapImage();
+
+  /**
+   * @copydoc Dali::PixmapImage::GlExtensionCreate()
+   */
+  bool GlExtensionCreate();
+
+  /**
+   * @copydoc Dali::PixmapImage::GlExtensionDestroy()
+   */
+  void GlExtensionDestroy();
+
+  /**
+   * @copydoc Dali::PixmapImage::TargetTexture()
+   */
+  unsigned int TargetTexture();
+
+  /**
+   * @copydoc Dali::PixmapImage::GetWidth()
+   */
+  unsigned int GetWidth() const
+  {
+    return mWidth;
+  }
+
+  /**
+   * @copydoc Dali::PixmapImage::GetHeight()
+   */
+  unsigned int GetHeight() const
+  {
+    return mHeight;
+  }
+
+  /**
+   * @copydoc Dali::PixmapImage::RequiresBlending()
+   */
+  bool RequiresBlending() const
+  {
+    return mBlendingRequired;
+  }
+
+private:
+
+  /**
+   * Private constructor; @see PixmapImage::New()
+   * @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] 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,
+              Any pixmap);
+
+  /**
+   * 2nd phase construction.
+   */
+  void Initialize();
+
+  /**
+   * Uses X11 to get the default depth.
+   * @param depth the PixelImage depth enum
+   * @return default x11 pixel depth
+   */
+  int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
+
+  /**
+   * 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
+   */
+  Ecore_X_Pixmap GetPixmapFromAny(Any pixmap) const;
+
+  /**
+   * Given an existing pixmap, the function uses X to find out
+   * the width, heigth and depth of that pixmap.
+   */
+  void GetPixmapDetails();
+
+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
+  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
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__
index ae49b4740ee79d16ec137314e1e0e88cf4fce937..f711d28aad09c45bb1c74c05eb58311a65df51e6 100644 (file)
@@ -6,7 +6,7 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 SET(CAPI_LIB "dali-adaptor")
 SET(TC_SOURCES
     utc-Dali-Key.cpp
-    utc-Dali-NativeImageSource.cpp
+    utc-Dali-PixmapImage.cpp
     utc-Dali-SingletonService.cpp
     utc-Dali-Window.cpp
     utc-Dali-Timer.cpp
diff --git a/automated-tests/src/dali-adaptor/utc-Dali-NativeImageSource.cpp b/automated-tests/src/dali-adaptor/utc-Dali-NativeImageSource.cpp
deleted file mode 100644 (file)
index 679409a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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 <dali/dali.h>
-#include <dali-test-suite-utils.h>
-
-#include <Ecore_X.h>
-
-using namespace Dali;
-
-
-void utc_dali_native_image_source_startup(void)
-{
-  test_return_value = TET_UNDEF;
-}
-
-void utc_dali_native_image_source_cleanup(void)
-{
-  test_return_value = TET_PASS;
-}
-
-int UtcDaliNativeImageSourceNewN(void)
-{
-  unsigned int width = 256u;
-  unsigned int heigth = 256u;
-
-  try
-  {
-    NativeImageSourcePtr nativeImageSource = NativeImageSource::New(width, heigth, NativeImageSource::COLOR_DEPTH_DEFAULT );
-  }
-  catch(Dali::DaliException& e)
-  {
-    DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
-  }
-  catch(...)
-  {
-    tet_printf("Assertion test failed - wrong Exception\n" );
-    tet_result(TET_FAIL);
-  }
-
-  END_TEST;
-}
diff --git a/automated-tests/src/dali-adaptor/utc-Dali-PixmapImage.cpp b/automated-tests/src/dali-adaptor/utc-Dali-PixmapImage.cpp
new file mode 100644 (file)
index 0000000..1ed3120
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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 <dali/dali.h>
+#include <dali-test-suite-utils.h>
+
+#include <Ecore_X.h>
+
+using namespace Dali;
+
+
+void utc_dali_pixmap_image_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_pixmap_image_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliPixmapImageNewN(void)
+{
+  unsigned int width = 256u;
+  unsigned int heigth = 256u;
+
+  try
+  {
+    PixmapImagePtr pixmapImage = PixmapImage::New(width, heigth, PixmapImage::COLOR_DEPTH_DEFAULT );
+  }
+  catch(Dali::DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    DALI_TEST_ASSERT(e, "Adaptor::IsAvailable()", TEST_LOCATION);
+  }
+  catch(...)
+  {
+    tet_printf("Assertion test failed - wrong Exception\n" );
+    tet_result(TET_FAIL);
+  }
+
+  END_TEST;
+}