From e936904101a177bd8ca931ef63ded869b65546c7 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 22 Nov 2018 17:19:28 +0900 Subject: [PATCH] [4.0] Change NativeImageSourceQueue - unsigned int -> uint32_t - Remove SetSource() - Add SetSize() Change-Id: I426ce69f2e6bd2510d4d409117efbbb2edf07cce --- adaptors/common/native-image-source-factory.h | 4 +- adaptors/common/native-image-source-impl.h | 12 +-- adaptors/common/native-image-source-queue-impl.h | 12 +-- .../native-image-source-queue.cpp | 14 +-- .../adaptor-framework/native-image-source-queue.h | 17 ++-- .../tizen/native-image-source-factory-tizen.cpp | 4 +- adaptors/tizen/native-image-source-factory-tizen.h | 4 +- adaptors/tizen/native-image-source-impl-tizen.cpp | 6 +- adaptors/tizen/native-image-source-impl-tizen.h | 18 ++-- .../tizen/native-image-source-queue-impl-tizen.cpp | 107 ++++++++++----------- .../tizen/native-image-source-queue-impl-tizen.h | 22 +++-- adaptors/x11/native-image-source-factory-x.cpp | 4 +- adaptors/x11/native-image-source-factory-x.h | 4 +- adaptors/x11/native-image-source-impl-x.cpp | 6 +- adaptors/x11/native-image-source-impl-x.h | 20 ++-- adaptors/x11/native-image-source-queue-impl-x.cpp | 10 +- adaptors/x11/native-image-source-queue-impl-x.h | 18 ++-- 17 files changed, 143 insertions(+), 139 deletions(-) diff --git a/adaptors/common/native-image-source-factory.h b/adaptors/common/native-image-source-factory.h index 5e0a420..69f1084 100644 --- a/adaptors/common/native-image-source-factory.h +++ b/adaptors/common/native-image-source-factory.h @@ -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; }; diff --git a/adaptors/common/native-image-source-impl.h b/adaptors/common/native-image-source-impl.h index 5175e2d..be0bf0f 100755 --- a/adaptors/common/native-image-source-impl.h +++ b/adaptors/common/native-image-source-impl.h @@ -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 &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const = 0; + virtual bool GetPixels(std::vector &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() diff --git a/adaptors/common/native-image-source-queue-impl.h b/adaptors/common/native-image-source-queue-impl.h index c726d45..22ed457 100755 --- a/adaptors/common/native-image-source-queue-impl.h +++ b/adaptors/common/native-image-source-queue-impl.h @@ -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() diff --git a/adaptors/devel-api/adaptor-framework/native-image-source-queue.cpp b/adaptors/devel-api/adaptor-framework/native-image-source-queue.cpp index 48b8359..665cd41 100755 --- a/adaptors/devel-api/adaptor-framework/native-image-source-queue.cpp +++ b/adaptors/devel-api/adaptor-framework/native-image-source-queue.cpp @@ -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 ); diff --git a/adaptors/devel-api/adaptor-framework/native-image-source-queue.h b/adaptors/devel-api/adaptor-framework/native-image-source-queue.h index 7e55b9b..c8a3273 100755 --- a/adaptors/devel-api/adaptor-framework/native-image-source-queue.h +++ b/adaptors/devel-api/adaptor-framework/native-image-source-queue.h @@ -73,7 +73,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. @@ -92,11 +92,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 @@ -113,7 +114,7 @@ private: // native image /** * @copydoc Dali::NativeImageInterface::TargetTexture() */ - virtual unsigned int TargetTexture(); + virtual uint32_t TargetTexture(); /** * @copydoc Dali::NativeImageInterface::PrepareTexture() @@ -123,12 +124,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() @@ -150,7 +151,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(). diff --git a/adaptors/tizen/native-image-source-factory-tizen.cpp b/adaptors/tizen/native-image-source-factory-tizen.cpp index 5fcccca..cace7b2 100644 --- a/adaptors/tizen/native-image-source-factory-tizen.cpp +++ b/adaptors/tizen/native-image-source-factory-tizen.cpp @@ -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 ) ); diff --git a/adaptors/tizen/native-image-source-factory-tizen.h b/adaptors/tizen/native-image-source-factory-tizen.h index 1913c08..f3250e0 100644 --- a/adaptors/tizen/native-image-source-factory-tizen.h +++ b/adaptors/tizen/native-image-source-factory-tizen.h @@ -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; }; diff --git a/adaptors/tizen/native-image-source-impl-tizen.cpp b/adaptors/tizen/native-image-source-impl-tizen.cpp index 33ff187..ea65232 100644 --- a/adaptors/tizen/native-image-source-impl-tizen.cpp +++ b/adaptors/tizen/native-image-source-impl-tizen.cpp @@ -66,7 +66,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." ); @@ -79,7 +79,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 ), @@ -436,7 +436,7 @@ void NativeImageSourceTizen::GlExtensionDestroy() } } -unsigned int NativeImageSourceTizen::TargetTexture() +uint32_t NativeImageSourceTizen::TargetTexture() { mEglImageExtensions->TargetTextureKHR(mEglImageKHR); diff --git a/adaptors/tizen/native-image-source-impl-tizen.h b/adaptors/tizen/native-image-source-impl-tizen.h index aa81ad4..6a31f19 100644 --- a/adaptors/tizen/native-image-source-impl-tizen.h +++ b/adaptors/tizen/native-image-source-impl-tizen.h @@ -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 &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override; + bool GetPixels(std::vector &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; } @@ -171,7 +171,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); @@ -184,8 +184,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; diff --git a/adaptors/tizen/native-image-source-queue-impl-tizen.cpp b/adaptors/tizen/native-image-source-queue-impl-tizen.cpp index 24f87f8..6033dcf 100644 --- a/adaptors/tizen/native-image-source-queue-impl-tizen.cpp +++ b/adaptors/tizen/native-image-source-queue-impl-tizen.cpp @@ -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 ), @@ -101,44 +102,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 @@ -163,21 +170,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() @@ -190,22 +192,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 ) ) @@ -271,25 +271,24 @@ void NativeImageSourceQueueTizen::SetDestructorNotification(void* notification) { } -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 ) diff --git a/adaptors/tizen/native-image-source-queue-impl-tizen.h b/adaptors/tizen/native-image-source-queue-impl-tizen.h index 28f77cd..4b228dc 100755 --- a/adaptors/tizen/native-image-source-queue-impl-tizen.h +++ b/adaptors/tizen/native-image-source-queue-impl-tizen.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -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; } @@ -153,11 +154,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; @@ -167,8 +168,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 diff --git a/adaptors/x11/native-image-source-factory-x.cpp b/adaptors/x11/native-image-source-factory-x.cpp index 9f6881b..d952a59 100644 --- a/adaptors/x11/native-image-source-factory-x.cpp +++ b/adaptors/x11/native-image-source-factory-x.cpp @@ -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 ) ); diff --git a/adaptors/x11/native-image-source-factory-x.h b/adaptors/x11/native-image-source-factory-x.h index 93c50fd..618a2a8 100644 --- a/adaptors/x11/native-image-source-factory-x.h +++ b/adaptors/x11/native-image-source-factory-x.h @@ -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; }; diff --git a/adaptors/x11/native-image-source-impl-x.cpp b/adaptors/x11/native-image-source-impl-x.cpp index edf0c21..f7dff9e 100644 --- a/adaptors/x11/native-image-source-impl-x.cpp +++ b/adaptors/x11/native-image-source-impl-x.cpp @@ -72,7 +72,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." ); @@ -86,7 +86,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 ), @@ -316,7 +316,7 @@ void NativeImageSourceX::GlExtensionDestroy() mEglImageKHR = NULL; } -unsigned int NativeImageSourceX::TargetTexture() +uint32_t NativeImageSourceX::TargetTexture() { mEglImageExtensions->TargetTextureKHR(mEglImageKHR); diff --git a/adaptors/x11/native-image-source-impl-x.h b/adaptors/x11/native-image-source-impl-x.h index 832d178..ed3d754 100644 --- a/adaptors/x11/native-image-source-impl-x.h +++ b/adaptors/x11/native-image-source-impl-x.h @@ -51,8 +51,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); /** @@ -63,7 +63,7 @@ public: /** * @copydoc Dali::NativeImageSource::GetPixels() */ - bool GetPixels(std::vector &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override; + bool GetPixels(std::vector &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override; /** * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& ) @@ -98,7 +98,7 @@ public: /** * @copydoc Dali::NativeImageSource::TargetTexture() */ - unsigned int TargetTexture() override; + uint32_t TargetTexture() override; /** * @copydoc Dali::NativeImageSource::PrepareTexture() @@ -108,7 +108,7 @@ public: /** * @copydoc Dali::NativeImageSource::GetWidth() */ - unsigned int GetWidth() const override + uint32_t GetWidth() const override { return mWidth; } @@ -116,7 +116,7 @@ public: /** * @copydoc Dali::NativeImageSource::GetHeight() */ - unsigned int GetHeight() const override + uint32_t GetHeight() const override { return mHeight; } @@ -146,8 +146,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); @@ -178,8 +178,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 diff --git a/adaptors/x11/native-image-source-queue-impl-x.cpp b/adaptors/x11/native-image-source-queue-impl-x.cpp index db3bb72..c10f38a 100644 --- a/adaptors/x11/native-image-source-queue-impl-x.cpp +++ b/adaptors/x11/native-image-source-queue-impl-x.cpp @@ -43,13 +43,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 ) { @@ -65,8 +65,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() @@ -78,7 +80,7 @@ void NativeImageSourceQueueX::GlExtensionDestroy() { } -unsigned int NativeImageSourceQueueX::TargetTexture() +uint32_t NativeImageSourceQueueX::TargetTexture() { return 0; } diff --git a/adaptors/x11/native-image-source-queue-impl-x.h b/adaptors/x11/native-image-source-queue-impl-x.h index f41702c..8b28cd9 100755 --- a/adaptors/x11/native-image-source-queue-impl-x.h +++ b/adaptors/x11/native-image-source-queue-impl-x.h @@ -51,7 +51,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() @@ -59,9 +59,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 @@ -81,7 +81,7 @@ public: /** * @copydoc Dali::NativeImageInterface::TargetTexture() */ - unsigned int TargetTexture() override; + uint32_t TargetTexture() override; /** * @copydoc Dali::NativeImageInterface::PrepareTexture() @@ -91,7 +91,7 @@ public: /** * @copydoc Dali::NativeImageInterface::GetWidth() */ - unsigned int GetWidth() const override + uint32_t GetWidth() const override { return mWidth; } @@ -99,7 +99,7 @@ public: /** * @copydoc Dali::NativeImageInterface::GetHeight() */ - unsigned int GetHeight() const override + uint32_t GetHeight() const override { return mHeight; } @@ -149,12 +149,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 }; -- 2.7.4