X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fimaging%2Fwindows%2Fnative-image-source-impl-win.cpp;h=44742ee59fd53ff0a2932509ee3b175c21b4f41c;hb=d36025775e8a5dc1c06ca357b55ef1cf11dc51c9;hp=ad4851bcbebe01420ff73303683ab3de491e0ebb;hpb=4ba10008351ceeb433f61a8629e4f9ff300754ce;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/imaging/windows/native-image-source-impl-win.cpp b/dali/internal/imaging/windows/native-image-source-impl-win.cpp old mode 100755 new mode 100644 index ad4851b..44742ee --- a/dali/internal/imaging/windows/native-image-source-impl-win.cpp +++ b/dali/internal/imaging/windows/native-image-source-impl-win.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -22,26 +22,24 @@ #include // INTERNAL INCLUDES +#include +#include #include #include -#include #include -#include namespace Dali { - namespace Internal { - namespace Adaptor { using Dali::Integration::PixelBuffer; -NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) +NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) { - NativeImageSourceWin* image = new NativeImageSourceWin( width, height, depth, nativeImageSource ); - DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." ); + NativeImageSourceWin* image = new NativeImageSourceWin(width, height, depth, nativeImageSource); + DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed."); // 2nd phase construction if(image) //< Defensive in case we ever compile without exceptions. @@ -52,24 +50,25 @@ NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int return image; } -NativeImageSourceWin::NativeImageSourceWin( 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 ) +NativeImageSourceWin::NativeImageSourceWin(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), + mResourceDestructionCallback() { - DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() ); + DALI_ASSERT_ALWAYS(Adaptor::IsAvailable()); - GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() ); - auto eglGraphics = static_cast(graphics); + GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface()); + auto eglGraphics = static_cast(graphics); mEglImageExtensions = eglGraphics->GetImageExtensions(); - DALI_ASSERT_DEBUG( mEglImageExtensions ); + DALI_ASSERT_DEBUG(mEglImageExtensions); // assign the pixmap mPixmap = GetPixmapFromAny(nativeImageSource); @@ -78,7 +77,7 @@ NativeImageSourceWin::NativeImageSourceWin( unsigned int width, unsigned int hei void NativeImageSourceWin::Initialize() { // if pixmap has been created outside of Windows Image we can return - if (mPixmap) + if(mPixmap) { // we don't own the pixmap mOwnPixmap = false; @@ -96,7 +95,7 @@ void NativeImageSourceWin::Initialize() If depth = 8, Pixel::A8; If depth = 16, Pixel::RGB565; If depth = 32, Pixel::RGBA8888 */ - mBlendingRequired = ( depth == 32 || depth == 8 ); + mBlendingRequired = (depth == 32 || depth == 8); } NativeImageSourceWin::~NativeImageSourceWin() @@ -112,17 +111,17 @@ bool NativeImageSourceWin::GetPixels(std::vector& pixbuf, unsigned& wid { DALI_ASSERT_DEBUG(sizeof(unsigned) == 4); bool success = false; - width = mWidth; - height = mHeight; + width = mWidth; + height = mHeight; return success; } -void NativeImageSourceWin::SetSource( Any source ) +void NativeImageSourceWin::SetSource(Any source) { - mPixmap = GetPixmapFromAny( source ); + mPixmap = GetPixmapFromAny(source); - if (mPixmap) + if(mPixmap) { // we don't own the pixmap mOwnPixmap = false; @@ -132,7 +131,7 @@ void NativeImageSourceWin::SetSource( Any source ) } } -bool NativeImageSourceWin::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) +bool NativeImageSourceWin::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) { return true; } @@ -140,16 +139,16 @@ bool NativeImageSourceWin::IsColorDepthSupported( Dali::NativeImageSource::Color bool NativeImageSourceWin::CreateResource() { // if the image existed previously delete it. - if (mEglImageKHR != NULL) + if(mEglImageKHR != NULL) { DestroyResource(); } // 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); + EGLClientBuffer eglBuffer = reinterpret_cast(mPixmap); - mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer ); + mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer); return mEglImageKHR != NULL; } @@ -159,6 +158,11 @@ void NativeImageSourceWin::DestroyResource() mEglImageExtensions->DestroyImageKHR(mEglImageKHR); mEglImageKHR = NULL; + + if(mResourceDestructionCallback) + { + mResourceDestructionCallback->Trigger(); + } } unsigned int NativeImageSourceWin::TargetTexture() @@ -174,7 +178,7 @@ void NativeImageSourceWin::PrepareTexture() int NativeImageSourceWin::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const { - switch (depth) + switch(depth) { case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT: { @@ -206,13 +210,13 @@ int NativeImageSourceWin::GetPixelDepth(Dali::NativeImageSource::ColorDepth dept unsigned int NativeImageSourceWin::GetPixmapFromAny(Any pixmap) const { - if (pixmap.Empty()) + if(pixmap.Empty()) { return 0; } // see if it is of type Windows pixmap - if (pixmap.GetType() == typeid ( unsigned int )) + if(pixmap.GetType() == typeid(unsigned int)) { // get the Windows pixmap type unsigned int xpixmap = AnyCast(pixmap); @@ -230,9 +234,9 @@ void NativeImageSourceWin::GetPixmapDetails() { } -const char* NativeImageSourceWin::GetCustomFragmentPrefix() const +bool NativeImageSourceWin::ApplyNativeFragmentShader(std::string& shader) { - return nullptr; + return false; } const char* NativeImageSourceWin::GetCustomSamplerTypename() const @@ -255,19 +259,23 @@ bool NativeImageSourceWin::SourceChanged() const return false; } -uint8_t* NativeImageSourceWin::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) +uint8_t* NativeImageSourceWin::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) { return NULL; } - bool NativeImageSourceWin::ReleaseBuffer() { return false; } +void NativeImageSourceWin::SetResourceDestructionCallback(EventThreadCallback* callback) +{ + mResourceDestructionCallback = std::unique_ptr(callback); +} + } // namespace Adaptor -} // namespace internal +} // namespace Internal } // namespace Dali