Change NativeImageSourceQueue 15/193615/3
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 22 Nov 2018 08:19:28 +0000 (17:19 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 10 Dec 2018 01:19:33 +0000 (10:19 +0900)
- unsigned int -> uint32_t
- Remove SetSource()
- Add SetSize()

Change-Id: I426ce69f2e6bd2510d4d409117efbbb2edf07cce

17 files changed:
dali/devel-api/adaptor-framework/native-image-source-queue.cpp
dali/devel-api/adaptor-framework/native-image-source-queue.h
dali/internal/imaging/common/native-image-source-factory.h
dali/internal/imaging/common/native-image-source-impl.h
dali/internal/imaging/common/native-image-source-queue-impl.h
dali/internal/imaging/tizen/native-image-source-factory-tizen.cpp
dali/internal/imaging/tizen/native-image-source-factory-tizen.h
dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-impl-tizen.h
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h
dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.h
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h
dali/internal/imaging/ubuntu-x11/native-image-source-queue-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-queue-impl-x.h

index 1538f66..297fd2a 100755 (executable)
@@ -25,7 +25,7 @@
 namespace Dali
 {
 
-NativeImageSourceQueuePtr NativeImageSourceQueue::New( unsigned int width, unsigned int height, ColorDepth depth )
+NativeImageSourceQueuePtr NativeImageSourceQueue::New( uint32_t width, uint32_t height, ColorDepth depth )
 {
   Any empty;
   NativeImageSourceQueuePtr image = new NativeImageSourceQueue( width, height, depth, empty );
@@ -51,9 +51,9 @@ Any NativeImageSourceQueue::GetNativeImageSourceQueue()
   return mImpl->GetNativeImageSourceQueue();
 }
 
-void NativeImageSourceQueue::SetSource( Any source )
+void NativeImageSourceQueue::SetSize( uint32_t width, uint32_t height )
 {
-  mImpl->SetSource( source );
+  return mImpl->SetSize( width, height );
 }
 
 bool NativeImageSourceQueue::GlExtensionCreate()
@@ -66,7 +66,7 @@ void NativeImageSourceQueue::GlExtensionDestroy()
   mImpl->GlExtensionDestroy();
 }
 
-unsigned int NativeImageSourceQueue::TargetTexture()
+uint32_t NativeImageSourceQueue::TargetTexture()
 {
   return mImpl->TargetTexture();
 }
@@ -76,12 +76,12 @@ void NativeImageSourceQueue::PrepareTexture()
   mImpl->PrepareTexture();
 }
 
-unsigned int NativeImageSourceQueue::GetWidth() const
+uint32_t NativeImageSourceQueue::GetWidth() const
 {
   return mImpl->GetWidth();
 }
 
-unsigned int NativeImageSourceQueue::GetHeight() const
+uint32_t NativeImageSourceQueue::GetHeight() const
 {
   return mImpl->GetHeight();
 }
@@ -96,7 +96,7 @@ NativeImageInterface::Extension* NativeImageSourceQueue::GetExtension()
   return mImpl->GetNativeImageInterfaceExtension();
 }
 
-NativeImageSourceQueue::NativeImageSourceQueue( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueue::NativeImageSourceQueue( uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue )
 {
   auto factory = Dali::Internal::Adaptor::GetNativeImageSourceFactory();
   mImpl = factory->CreateNativeImageSourceQueue( width, height, depth, nativeImageSourceQueue );
index 0a6f4fe..a6fdf38 100755 (executable)
@@ -76,7 +76,7 @@ public:
    * @param[in] depth color depth of the image
    * @return A smart-pointer to a newly allocated image
    */
-  static NativeImageSourceQueuePtr New( unsigned int width, unsigned int height, ColorDepth depth );
+  static NativeImageSourceQueuePtr New( uint32_t width, uint32_t height, ColorDepth depth );
 
   /**
    * @brief Creates a new NativeImageSourceQueue from an existing native image source.
@@ -95,11 +95,12 @@ public:
   Any GetNativeImageSourceQueue();
 
   /**
-   * @brief Sets an existing source.
+   * @brief Sets the size of the image.
    *
-   * @param[in] source Any handle with the source
+   * @param[in] width The width of the image
+   * @param[in] height The height of the image
    */
-  void SetSource( Any source );
+  void SetSize( uint32_t width, uint32_t height );
 
 private:   // native image
 
@@ -116,7 +117,7 @@ private:   // native image
   /**
    * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
-  virtual unsigned int TargetTexture();
+  virtual uint32_t TargetTexture();
 
   /**
    * @copydoc Dali::NativeImageInterface::PrepareTexture()
@@ -126,12 +127,12 @@ private:   // native image
   /**
    * @copydoc Dali::NativeImageInterface::GetWidth()
    */
-  virtual unsigned int GetWidth() const;
+  virtual uint32_t GetWidth() const;
 
   /**
    * @copydoc Dali::NativeImageInterface::GetHeight()
    */
-  virtual unsigned int GetHeight() const;
+  virtual uint32_t GetHeight() const;
 
   /**
    * @copydoc Dali::NativeImageInterface::RequiresBlending()
@@ -153,7 +154,7 @@ private:
    * @param[in] depth color depth of the image
    * @param[in] nativeImageSourceQueue contains either: native image source or is empty
    */
-  DALI_INTERNAL NativeImageSourceQueue( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSourceQueue );
+  DALI_INTERNAL NativeImageSourceQueue( uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue );
 
   /**
    * @brief A reference counted object may only be deleted by calling Unreference().
index 0ea3db5..f334f65 100644 (file)
@@ -42,10 +42,10 @@ public:
   NativeImageSourceFactory() = default;
   virtual ~NativeImageSourceFactory() = default;
 
-  virtual std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+  virtual std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
                                                                         Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) = 0;
 
-  virtual std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+  virtual std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
                                                                                   Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) = 0;
 
 };
index ada807f..2b26e9a 100755 (executable)
@@ -46,8 +46,8 @@ public:
    * @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,
+  static NativeImageSource* New(uint32_t width,
+                                uint32_t height,
                                 Dali::NativeImageSource::ColorDepth depth,
                                 Any nativeImageSource);
   /**
@@ -58,7 +58,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetPixels()
    */
-  virtual bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const = 0;
+  virtual bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
@@ -93,7 +93,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::TargetTexture()
    */
-  virtual unsigned int TargetTexture() = 0;
+  virtual uint32_t TargetTexture() = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::PrepareTexture()
@@ -103,12 +103,12 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetWidth()
    */
-  virtual unsigned int GetWidth() const = 0;
+  virtual uint32_t GetWidth() const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::GetHeight()
    */
-  virtual unsigned int GetHeight() const = 0;
+  virtual uint32_t GetHeight() const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::RequiresBlending()
index 3caf002..889935e 100755 (executable)
@@ -40,7 +40,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSourceQueue::New()
    */
-  static NativeImageSourceQueue* New( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+  static NativeImageSourceQueue* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
 
   /**
    * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
@@ -48,9 +48,9 @@ public:
   virtual Any GetNativeImageSourceQueue() const = 0;
 
   /**
-   * @copydoc Dali::NativeImageSourceQueue::SetSource( Any source )
+   * @copydoc Dali::NativeImageSourceQueue::SetSize
    */
-  virtual void SetSource( Any source ) = 0;
+  virtual void SetSize( uint32_t width, uint32_t height ) = 0;
 
   /**
    * destructor
@@ -70,7 +70,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
-  virtual unsigned int TargetTexture() = 0;
+  virtual uint32_t TargetTexture() = 0;
 
   /**
    * @copydoc Dali::NativeImageInterface::PrepareTexture()
@@ -80,12 +80,12 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::GetWidth()
    */
-  virtual unsigned int GetWidth() const = 0;
+  virtual uint32_t GetWidth() const = 0;
 
   /**
    * @copydoc Dali::NativeImageInterface::GetHeight()
    */
-  virtual unsigned int GetHeight() const = 0;
+  virtual uint32_t GetHeight() const = 0;
 
   /**
    * @copydoc Dali::NativeImageInterface::RequiresBlending()
index 66f1d36..8214508 100644 (file)
@@ -29,13 +29,13 @@ namespace Internal
 namespace Adaptor
 {
 
-std::unique_ptr< NativeImageSource > NativeImageSourceFactoryTizen::CreateNativeImageSource( unsigned int width, unsigned int height,
+std::unique_ptr< NativeImageSource > NativeImageSourceFactoryTizen::CreateNativeImageSource( uint32_t width, uint32_t height,
                                                                                              Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 {
   return std::unique_ptr< NativeImageSource >( NativeImageSourceTizen::New( width, height, depth, nativeImageSource ) );
 }
 
-std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryTizen::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryTizen::CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
                                                                                                        Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 {
   return std::unique_ptr< NativeImageSourceQueue >( NativeImageSourceQueueTizen::New( width, height, depth, nativeImageSourceQueue ) );
index 2ca3658..165954e 100644 (file)
@@ -32,10 +32,10 @@ class NativeImageSourceFactoryTizen : public NativeImageSourceFactory
 {
 public:
 
-  std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+  std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
                                                                 Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
 
-  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
                                                                           Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
 
 };
index 401a33a..57c2f60 100644 (file)
@@ -65,7 +65,7 @@ const int NUM_FORMATS_BLENDING_REQUIRED = 18;
 
 using Dali::Integration::PixelBuffer;
 
-NativeImageSourceTizen* NativeImageSourceTizen::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen* NativeImageSourceTizen::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 {
   NativeImageSourceTizen* image = new NativeImageSourceTizen( width, height, depth, nativeImageSource );
   DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
@@ -78,7 +78,7 @@ NativeImageSourceTizen* NativeImageSourceTizen::New(unsigned int width, unsigned
   return image;
 }
 
-NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen::NativeImageSourceTizen( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 : mWidth( width ),
   mHeight( height ),
   mOwnTbmSurface( false ),
@@ -425,7 +425,7 @@ void NativeImageSourceTizen::GlExtensionDestroy()
   }
 }
 
-unsigned int NativeImageSourceTizen::TargetTexture()
+uint32_t NativeImageSourceTizen::TargetTexture()
 {
   mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
 
index fdf1ed0..7a746e8 100755 (executable)
@@ -55,8 +55,8 @@ public:
    * @param[in] nativeImageSource contains tbm_surface_h or is empty
    * @return A smart-pointer to a newly allocated image.
    */
-  static NativeImageSourceTizen* New(unsigned int width,
-                          unsigned int height,
+  static NativeImageSourceTizen* New(uint32_t width,
+                          uint32_t height,
                           Dali::NativeImageSource::ColorDepth depth,
                           Any nativeImageSource);
 
@@ -68,7 +68,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetPixels()
    */
-  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const  override;
+  bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const  override;
 
   /**
    * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
@@ -103,7 +103,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::TargetTexture()
    */
-  unsigned int TargetTexture() override;
+  uint32_t TargetTexture() override;
 
   /**
    * @copydoc Dali::NativeImageSource::PrepareTexture()
@@ -113,7 +113,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetWidth()
    */
-  unsigned int GetWidth() const override
+  uint32_t GetWidth() const override
   {
     return mWidth;
   }
@@ -121,7 +121,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetHeight()
    */
-  unsigned int GetHeight() const override
+  uint32_t GetHeight() const override
   {
     return mHeight;
   }
@@ -166,7 +166,7 @@ private:
    * @param[in] colour depth of the image.
    * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
    */
-  NativeImageSourceTizen(unsigned int width,
+  NativeImageSourceTizen(uint32_t width,
               unsigned  int height,
               Dali::NativeImageSource::ColorDepth depth,
               Any nativeImageSource);
@@ -179,8 +179,8 @@ private:
 
 private:
 
-  unsigned int mWidth;                        ///< image width
-  unsigned int mHeight;                       ///< image height
+  uint32_t mWidth;                        ///< image width
+  uint32_t mHeight;                       ///< image height
   bool mOwnTbmSurface;                        ///< Whether we created pixmap or not
   tbm_surface_h mTbmSurface;
   tbm_format mTbmFormat;
index b72f743..9288c40 100644 (file)
@@ -60,7 +60,7 @@ const int NUM_FORMATS_BLENDING_REQUIRED = 18;
 
 }
 
-NativeImageSourceQueueTizen* NativeImageSourceQueueTizen::New( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueTizen* NativeImageSourceQueueTizen::New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 {
   NativeImageSourceQueueTizen* image = new NativeImageSourceQueueTizen( width, height, depth, nativeImageSourceQueue );
   DALI_ASSERT_DEBUG( image && "NativeImageSourceQueueTizen allocation failed." );
@@ -73,8 +73,9 @@ NativeImageSourceQueueTizen* NativeImageSourceQueueTizen::New( unsigned int widt
   return image;
 }
 
-NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
-: mWidth( width ),
+NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+: mMutex(),
+  mWidth( width ),
   mHeight( height ),
   mTbmQueue( NULL ),
   mConsumeSurface( NULL ),
@@ -103,44 +104,50 @@ NativeImageSourceQueueTizen::~NativeImageSourceQueueTizen()
 {
   if( mOwnTbmQueue )
   {
-    DestroyQueue();
+    if( mTbmQueue != NULL )
+    {
+      tbm_surface_queue_destroy( mTbmQueue );
+    }
   }
 }
 
 void NativeImageSourceQueueTizen::Initialize( Dali::NativeImageSourceQueue::ColorDepth depth )
 {
-  if( mTbmQueue != NULL || mWidth == 0 || mHeight == 0 )
+  if( mWidth == 0 || mHeight == 0 )
   {
     return;
   }
 
-  int format = TBM_FORMAT_ARGB8888;
-
-  switch( depth )
+  if( mTbmQueue == NULL )
   {
-    case Dali::NativeImageSourceQueue::COLOR_DEPTH_DEFAULT:
-    case Dali::NativeImageSourceQueue::COLOR_DEPTH_32:
-    {
-      format = TBM_FORMAT_ARGB8888;
-      mBlendingRequired = true;
-      break;
-    }
-    case Dali::NativeImageSourceQueue::COLOR_DEPTH_24:
-    {
-      format = TBM_FORMAT_RGB888;
-      mBlendingRequired = false;
-      break;
-    }
-    default:
+    int format = TBM_FORMAT_ARGB8888;
+
+    switch( depth )
     {
-      DALI_LOG_WARNING( "Wrong color depth.\n" );
-      return;
+      case Dali::NativeImageSourceQueue::COLOR_DEPTH_DEFAULT:
+      case Dali::NativeImageSourceQueue::COLOR_DEPTH_32:
+      {
+        format = TBM_FORMAT_ARGB8888;
+        mBlendingRequired = true;
+        break;
+      }
+      case Dali::NativeImageSourceQueue::COLOR_DEPTH_24:
+      {
+        format = TBM_FORMAT_RGB888;
+        mBlendingRequired = false;
+        break;
+      }
+      default:
+      {
+        DALI_LOG_WARNING( "Wrong color depth.\n" );
+        return;
+      }
     }
-  }
 
-  mTbmQueue = tbm_surface_queue_create( TBM_SURFACE_QUEUE_SIZE, mWidth, mHeight, format, 0 );
+    mTbmQueue = tbm_surface_queue_create( TBM_SURFACE_QUEUE_SIZE, mWidth, mHeight, format, 0 );
 
-  mOwnTbmQueue = true;
+    mOwnTbmQueue = true;
+  }
 }
 
 tbm_surface_queue_h NativeImageSourceQueueTizen::GetSurfaceFromAny( Any source ) const
@@ -165,21 +172,16 @@ Any NativeImageSourceQueueTizen::GetNativeImageSourceQueue() const
   return Any( mTbmQueue );
 }
 
-void NativeImageSourceQueueTizen::SetSource( Any source )
+void NativeImageSourceQueueTizen::SetSize( uint32_t width, uint32_t height )
 {
-  if( mOwnTbmQueue )
-  {
-    DestroyQueue();
-  }
+  Dali::Mutex::ScopedLock lock( mMutex );
 
-  mTbmQueue = GetSurfaceFromAny( source );
+  tbm_surface_queue_reset( mTbmQueue, width, height, tbm_surface_queue_get_format( mTbmQueue ) );
 
-  if( mTbmQueue != NULL )
-  {
-    mBlendingRequired = CheckBlending( tbm_surface_queue_get_format( mTbmQueue ) );
-    mWidth = tbm_surface_queue_get_width( mTbmQueue );
-    mHeight = tbm_surface_queue_get_height( mTbmQueue );
-  }
+  mWidth = width;
+  mHeight = height;
+
+  ResetEglImageList();
 }
 
 bool NativeImageSourceQueueTizen::GlExtensionCreate()
@@ -192,22 +194,20 @@ bool NativeImageSourceQueueTizen::GlExtensionCreate()
 
 void NativeImageSourceQueueTizen::GlExtensionDestroy()
 {
-  for( auto&& iter : mEglImages )
-  {
-    mEglImageExtensions->DestroyImageKHR( iter.second );
+  Dali::Mutex::ScopedLock lock( mMutex );
 
-    tbm_surface_internal_unref( iter.first );
-  }
-  mEglImages.clear();
+  ResetEglImageList();
 }
 
-unsigned int NativeImageSourceQueueTizen::TargetTexture()
+uint32_t NativeImageSourceQueueTizen::TargetTexture()
 {
   return 0;
 }
 
 void NativeImageSourceQueueTizen::PrepareTexture()
 {
+  Dali::Mutex::ScopedLock lock( mMutex );
+
   tbm_surface_h oldSurface = mConsumeSurface;
 
   if( tbm_surface_queue_can_acquire( mTbmQueue, 0 ) )
@@ -269,25 +269,24 @@ int NativeImageSourceQueueTizen::GetEglImageTextureTarget()
   return GL_TEXTURE_EXTERNAL_OES;
 }
 
-void NativeImageSourceQueueTizen::DestroyQueue()
+void NativeImageSourceQueueTizen::ResetEglImageList()
 {
   if( mConsumeSurface )
   {
-    tbm_surface_internal_unref( mConsumeSurface );
-
     if( tbm_surface_internal_is_valid( mConsumeSurface ) )
     {
       tbm_surface_queue_release( mTbmQueue, mConsumeSurface );
     }
+    mConsumeSurface = NULL;
   }
 
-  if( mTbmQueue != NULL )
+  for( auto&& iter : mEglImages )
   {
-    tbm_surface_queue_destroy( mTbmQueue );
-  }
+    mEglImageExtensions->DestroyImageKHR( iter.second );
 
-  mTbmQueue = NULL;
-  mOwnTbmQueue = false;
+    tbm_surface_internal_unref( iter.first );
+  }
+  mEglImages.clear();
 }
 
 bool NativeImageSourceQueueTizen::CheckBlending( int format )
index 19e50a7..88b27cb 100755 (executable)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/images/native-image-interface-extension.h>
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/public-api/common/vector-wrapper.h>
 #include <tbm_surface.h>
 #include <tbm_surface_queue.h>
@@ -55,7 +56,7 @@ public:
    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
    * @return A smart-pointer to a newly allocated image.
    */
-  static NativeImageSourceQueueTizen* New(unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+  static NativeImageSourceQueueTizen* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
 
   /**
    * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
@@ -63,9 +64,9 @@ public:
   Any GetNativeImageSourceQueue() const override;
 
   /**
-   * @copydoc Dali::NativeImageSourceQueue::SetSource( Any source )
+   * @copydoc Dali::NativeImageSourceQueue::SetSize
    */
-  void SetSource( Any source ) override;
+  void SetSize( uint32_t width, uint32_t height ) override;
 
   /**
    * destructor
@@ -85,7 +86,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
-  unsigned int TargetTexture() override;
+  uint32_t TargetTexture() override;
 
   /**
    * @copydoc Dali::NativeImageInterface::PrepareTexture()
@@ -95,7 +96,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::GetWidth()
    */
-  unsigned int GetWidth() const override
+  uint32_t GetWidth() const override
   {
     return mWidth;
   }
@@ -103,7 +104,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::GetHeight()
    */
-  unsigned int GetHeight() const override
+  uint32_t GetHeight() const override
   {
     return mHeight;
   }
@@ -148,11 +149,11 @@ private:
    * @param[in] colour depth of the image.
    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
    */
-  NativeImageSourceQueueTizen( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+  NativeImageSourceQueueTizen( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
 
   void Initialize( Dali::NativeImageSourceQueue::ColorDepth depth );
 
-  void DestroyQueue();
+  void ResetEglImageList();
 
   tbm_surface_queue_h GetSurfaceFromAny( Any source ) const;
 
@@ -162,8 +163,9 @@ private:
 
   typedef std::pair< tbm_surface_h, void* > EglImagePair;
 
-  unsigned int                     mWidth;                ///< image width
-  unsigned int                     mHeight;               ///< image height
+  Dali::Mutex                      mMutex;                ///< Mutex
+  uint32_t                         mWidth;                ///< image width
+  uint32_t                         mHeight;               ///< image height
   tbm_surface_queue_h              mTbmQueue;             ///< Tbm surface queue handle
   tbm_surface_h                    mConsumeSurface;       ///< The current tbm surface
   std::vector< EglImagePair >      mEglImages;            ///< EGL Image vector
index 76969b9..42b6c39 100644 (file)
@@ -29,13 +29,13 @@ namespace Internal
 namespace Adaptor
 {
 
-std::unique_ptr< NativeImageSource > NativeImageSourceFactoryX::CreateNativeImageSource( unsigned int width, unsigned int height,
+std::unique_ptr< NativeImageSource > NativeImageSourceFactoryX::CreateNativeImageSource( uint32_t width, uint32_t height,
                                                                                          Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 {
   return std::unique_ptr< NativeImageSource >( NativeImageSourceX::New( width, height, depth, nativeImageSource ) );
 }
 
-std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryX::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryX::CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
                                                                                                    Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 {
   return std::unique_ptr< NativeImageSourceQueue >( NativeImageSourceQueueX::New( width, height, depth, nativeImageSourceQueue ) );
index 6c35f9a..303d689 100644 (file)
@@ -32,10 +32,10 @@ class NativeImageSourceFactoryX : public NativeImageSourceFactory
 {
 public:
 
-  std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+  std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
                                                                 Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
 
-  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
                                                                           Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
 
 };
index f3bd587..18e8f1c 100644 (file)
@@ -73,7 +73,7 @@ namespace
   };
 }
 
-NativeImageSourceX* NativeImageSourceX::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceX* NativeImageSourceX::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 {
   NativeImageSourceX* image = new NativeImageSourceX( width, height, depth, nativeImageSource );
   DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
@@ -87,7 +87,7 @@ NativeImageSourceX* NativeImageSourceX::New(unsigned int width, unsigned int hei
   return image;
 }
 
-NativeImageSourceX::NativeImageSourceX( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceX::NativeImageSourceX( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 : mWidth( width ),
   mHeight( height ),
   mOwnPixmap( true ),
@@ -321,7 +321,7 @@ void NativeImageSourceX::GlExtensionDestroy()
   mEglImageKHR = NULL;
 }
 
-unsigned int NativeImageSourceX::TargetTexture()
+uint32_t NativeImageSourceX::TargetTexture()
 {
   mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
 
index 9b74b2a..0cb3bca 100755 (executable)
@@ -54,8 +54,8 @@ public:
    * @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 NativeImageSourceX* New(unsigned int width,
-                          unsigned int height,
+  static NativeImageSourceX* New( uint32_t width,
+                          uint32_t height,
                           Dali::NativeImageSource::ColorDepth depth,
                           Any nativeImageSource);
   /**
@@ -66,7 +66,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetPixels()
    */
-  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
+  bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override;
 
   /**
    * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
@@ -101,7 +101,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::TargetTexture()
    */
-  unsigned int TargetTexture() override;
+  uint32_t TargetTexture() override;
 
   /**
    * @copydoc Dali::NativeImageSource::PrepareTexture()
@@ -111,7 +111,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetWidth()
    */
-  unsigned int GetWidth() const override
+  uint32_t GetWidth() const override
   {
     return mWidth;
   }
@@ -119,7 +119,7 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetHeight()
    */
-  unsigned int GetHeight() const override
+  uint32_t GetHeight() const override
   {
     return mHeight;
   }
@@ -149,8 +149,8 @@ private:
    * @param[in] colour depth of the image.
    * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
    */
-  NativeImageSourceX(unsigned int width,
-              unsigned  int height,
+  NativeImageSourceX( uint32_t width,
+              uint32_t height,
               Dali::NativeImageSource::ColorDepth depth,
               Any nativeImageSource);
 
@@ -181,8 +181,8 @@ private:
 
 private:
 
-  unsigned int mWidth;                        ///< image width
-  unsigned int mHeight;                       ///< image heights
+  uint32_t mWidth;                            ///< image width
+  uint32_t mHeight;                           ///< image heights
   bool mOwnPixmap;                            ///< Whether we created pixmap or not
   Ecore_X_Pixmap mPixmap;                     ///< From Xlib
   bool mBlendingRequired;                      ///< Whether blending is required
index 1ed1421..4bd539b 100644 (file)
@@ -45,13 +45,13 @@ const char* SAMPLER_TYPE = "sampler2D";
 
 }
 
-NativeImageSourceQueueX* NativeImageSourceQueueX::New( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueX* NativeImageSourceQueueX::New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 {
   NativeImageSourceQueueX* image = new NativeImageSourceQueueX( width, height, depth, nativeImageSourceQueue );
   return image;
 }
 
-NativeImageSourceQueueX::NativeImageSourceQueueX( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueX::NativeImageSourceQueueX( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 : mWidth( width ),
   mHeight( height )
 {
@@ -67,8 +67,10 @@ Any NativeImageSourceQueueX::GetNativeImageSourceQueue() const
   return Any();
 }
 
-void NativeImageSourceQueueX::SetSource( Any source )
+void NativeImageSourceQueueX::SetSize( uint32_t width, uint32_t height )
 {
+  mWidth = width;
+  mHeight = height;
 }
 
 bool NativeImageSourceQueueX::GlExtensionCreate()
@@ -80,7 +82,7 @@ void NativeImageSourceQueueX::GlExtensionDestroy()
 {
 }
 
-unsigned int NativeImageSourceQueueX::TargetTexture()
+uint32_t NativeImageSourceQueueX::TargetTexture()
 {
   return 0;
 }
index c53b51d..c252bec 100755 (executable)
@@ -52,7 +52,7 @@ public:
    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
    * @return A smart-pointer to a newly allocated image.
    */
-  static NativeImageSourceQueueX* New(unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+  static NativeImageSourceQueueX* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
 
   /**
    * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
@@ -60,9 +60,9 @@ public:
   Any GetNativeImageSourceQueue() const override;
 
   /**
-   * @copydoc Dali::NativeImageSourceQueue::SetSource( Any source )
+   * @copydoc Dali::NativeImageSourceQueue::SetSize
    */
-  void SetSource( Any source ) override;
+  void SetSize( uint32_t width, uint32_t height ) override;
 
   /**
    * destructor
@@ -82,7 +82,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::TargetTexture()
    */
-  unsigned int TargetTexture() override;
+  uint32_t TargetTexture() override;
 
   /**
    * @copydoc Dali::NativeImageInterface::PrepareTexture()
@@ -92,7 +92,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::GetWidth()
    */
-  unsigned int GetWidth() const override
+  uint32_t GetWidth() const override
   {
     return mWidth;
   }
@@ -100,7 +100,7 @@ public:
   /**
    * @copydoc Dali::NativeImageInterface::GetHeight()
    */
-  unsigned int GetHeight() const override
+  uint32_t GetHeight() const override
   {
     return mHeight;
   }
@@ -145,12 +145,12 @@ private:
    * @param[in] colour depth of the image.
    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
    */
-  NativeImageSourceQueueX( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+  NativeImageSourceQueueX( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
 
 private:
 
-  unsigned int    mWidth;                ///< image width
-  unsigned int    mHeight;               ///< image height
+  uint32_t    mWidth;                ///< image width
+  uint32_t    mHeight;               ///< image height
 
 };