X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Ftizen%2Fnative-image-source-impl-tizen.cpp;h=ea65232799f3371c880ad276de695b3d67e69453;hb=e936904101a177bd8ca931ef63ded869b65546c7;hp=3afb87bce7a2d8f8c82bf782982c0cc1b0afe43e;hpb=5c2f973a1f5564a49f20d05c81e75c6b7cff52df;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/tizen/native-image-source-impl-tizen.cpp b/adaptors/tizen/native-image-source-impl-tizen.cpp old mode 100755 new mode 100644 index 3afb87b..ea65232 --- a/adaptors/tizen/native-image-source-impl-tizen.cpp +++ b/adaptors/tizen/native-image-source-impl-tizen.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include "native-image-source-impl.h" +#include // EXTERNAL INCLUDES #include @@ -29,6 +29,7 @@ #include #include #include +#include // Allow this to be encoded and saved: #include @@ -65,9 +66,9 @@ const int NUM_FORMATS_BLENDING_REQUIRED = 18; using Dali::Integration::PixelBuffer; -NativeImageSource* NativeImageSource::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 ) { - NativeImageSource* image = new NativeImageSource( width, height, depth, nativeImageSource ); + NativeImageSourceTizen* image = new NativeImageSourceTizen( width, height, depth, nativeImageSource ); DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." ); if( image ) @@ -78,7 +79,7 @@ NativeImageSource* NativeImageSource::New(unsigned int width, unsigned int heigh return image; } -NativeImageSource::NativeImageSource( 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 ), @@ -87,13 +88,13 @@ NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, D mBlendingRequired( false ), mColorDepth( depth ), mEglImageKHR( NULL ), + mEglFactory( NULL ), mEglImageExtensions( NULL ), - mSetSource( false ) + mSetSource( false ), + mNotification( NULL ) { DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() ); - EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory(); - mEglImageExtensions = eglFactory.GetImageExtensions(); - DALI_ASSERT_DEBUG( mEglImageExtensions ); + mEglFactory = &( Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory() ); mTbmSurface = GetSurfaceFromAny( nativeImageSource ); @@ -106,7 +107,7 @@ NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, D } } -void NativeImageSource::Initialize() +void NativeImageSourceTizen::Initialize() { if( mTbmSurface != NULL || mWidth == 0 || mHeight == 0 ) { @@ -166,7 +167,7 @@ void NativeImageSource::Initialize() mOwnTbmSurface = true; } -tbm_surface_h NativeImageSource::GetSurfaceFromAny( Any source ) const +tbm_surface_h NativeImageSourceTizen::GetSurfaceFromAny( Any source ) const { if( source.Empty() ) { @@ -183,7 +184,7 @@ tbm_surface_h NativeImageSource::GetSurfaceFromAny( Any source ) const } } -NativeImageSource::~NativeImageSource() +NativeImageSourceTizen::~NativeImageSourceTizen() { if( mOwnTbmSurface ) { @@ -197,16 +198,27 @@ NativeImageSource::~NativeImageSource() if( mTbmSurface != NULL ) { tbm_surface_internal_unref( mTbmSurface ); + + if (mNotification != NULL) { + TriggerEventInterface* triggerEvent = static_cast(mNotification); + triggerEvent->Trigger(); + } } } } -Any NativeImageSource::GetNativeImageSource() const +Any NativeImageSourceTizen::GetNativeImageSource() const { return Any( mTbmSurface ); } -bool NativeImageSource::GetPixels(std::vector& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const + +void NativeImageSourceTizen::SetDestructorNotification(void* notification) +{ + mNotification = notification; +} + +bool NativeImageSourceTizen::GetPixels(std::vector& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const { if( mTbmSurface != NULL ) { @@ -299,7 +311,7 @@ bool NativeImageSource::GetPixels(std::vector& pixbuf, unsigned& return false; } -bool NativeImageSource::EncodeToFile(const std::string& filename) const +bool NativeImageSourceTizen::EncodeToFile(const std::string& filename) const { std::vector< unsigned char > pixbuf; unsigned int width(0), height(0); @@ -312,7 +324,7 @@ bool NativeImageSource::EncodeToFile(const std::string& filename) const return false; } -void NativeImageSource::SetSource( Any source ) +void NativeImageSourceTizen::SetSource( Any source ) { if( mOwnTbmSurface ) { @@ -345,7 +357,7 @@ void NativeImageSource::SetSource( Any source ) } } -bool NativeImageSource::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) +bool NativeImageSourceTizen::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) { uint32_t* formats; uint32_t formatNum; @@ -396,7 +408,7 @@ bool NativeImageSource::IsColorDepthSupported( Dali::NativeImageSource::ColorDep return false; } -bool NativeImageSource::GlExtensionCreate() +bool NativeImageSourceTizen::GlExtensionCreate() { // casting from an unsigned int to a void *, which should then be cast back // to an unsigned int in the driver. @@ -406,12 +418,15 @@ bool NativeImageSource::GlExtensionCreate() return false; } + mEglImageExtensions = mEglFactory->GetImageExtensions(); + DALI_ASSERT_DEBUG( mEglImageExtensions ); + mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer ); return mEglImageKHR != NULL; } -void NativeImageSource::GlExtensionDestroy() +void NativeImageSourceTizen::GlExtensionDestroy() { if( mEglImageKHR ) { @@ -421,14 +436,14 @@ void NativeImageSource::GlExtensionDestroy() } } -unsigned int NativeImageSource::TargetTexture() +uint32_t NativeImageSourceTizen::TargetTexture() { mEglImageExtensions->TargetTextureKHR(mEglImageKHR); return 0; } -void NativeImageSource::PrepareTexture() +void NativeImageSourceTizen::PrepareTexture() { if( mSetSource ) { @@ -445,55 +460,22 @@ void NativeImageSource::PrepareTexture() } } -int NativeImageSource::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const -{ - switch (depth) - { - case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT: - { - // ToDo: Get the default screen depth - return 32; - } - 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; - } - } -} - -const char* NativeImageSource::GetCustomFragmentPreFix() +const char* NativeImageSourceTizen::GetCustomFragmentPreFix() { return FRAGMENT_PREFIX; } -const char* NativeImageSource::GetCustomSamplerTypename() +const char* NativeImageSourceTizen::GetCustomSamplerTypename() { return SAMPLER_TYPE; } -int NativeImageSource::GetEglImageTextureTarget() +int NativeImageSourceTizen::GetEglImageTextureTarget() { return GL_TEXTURE_EXTERNAL_OES; } -bool NativeImageSource::CheckBlending( tbm_format format ) +bool NativeImageSourceTizen::CheckBlending( tbm_format format ) { if( mTbmFormat != format ) {