From 734fd93b257177602cb540dbde2c1dd97828c957 Mon Sep 17 00:00:00 2001 From: jmm Date: Tue, 2 Jul 2024 15:14:22 +0900 Subject: [PATCH] Revert "[Tizen] Revert "Use Texture for not file save case"" This reverts commit 2f7c84db2a15dd3e51b661e1bda9f20efbacac33. --- dali/internal/system/common/capture-impl.cpp | 33 +++++++++++++++++++++++----- dali/internal/system/common/capture-impl.h | 5 +++++ dali/public-api/capture/capture.cpp | 5 +++++ dali/public-api/capture/capture.h | 8 +++++++ 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/dali/internal/system/common/capture-impl.cpp b/dali/internal/system/common/capture-impl.cpp index fc947fd..b07500c 100644 --- a/dali/internal/system/common/capture-impl.cpp +++ b/dali/internal/system/common/capture-impl.cpp @@ -41,8 +41,8 @@ namespace Adaptor { namespace { -constexpr int32_t GL_VERSION_NATIVE_IMAGE_SOURCE_AVAILABLE = 30; -constexpr uint32_t TIME_OUT_DURATION = 1000; +constexpr int32_t SHADER_VERSION_NATIVE_IMAGE_SOURCE_AVAILABLE = 300; +constexpr uint32_t TIME_OUT_DURATION = 1000; } // namespace Capture::Capture() @@ -124,6 +124,11 @@ Dali::NativeImageSourcePtr Capture::GetNativeImageSource() const return mNativeImageSourcePtr; } +Dali::Texture Capture::GetTexture() const +{ + return mTexture; +} + Dali::Devel::PixelBuffer Capture::GetCapturedBuffer() { if(!mPixelBuffer || (mPixelBuffer && !mPixelBuffer.GetBuffer())) @@ -148,10 +153,17 @@ Dali::Capture::CaptureFinishedSignalType& Capture::FinishedSignal() void Capture::CreateTexture(const Vector2& size) { - if(!mNativeImageSourcePtr) + if(mFileSave) { - mNativeImageSourcePtr = Dali::NativeImageSource::New(size.width, size.height, Dali::NativeImageSource::COLOR_DEPTH_DEFAULT); - mTexture = Dali::Texture::New(*mNativeImageSourcePtr); + if(!mNativeImageSourcePtr) + { + mNativeImageSourcePtr = Dali::NativeImageSource::New(size.width, size.height, Dali::NativeImageSource::COLOR_DEPTH_DEFAULT); + mTexture = Dali::Texture::New(*mNativeImageSourcePtr); + } + } + else + { + mTexture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, unsigned(size.width), unsigned(size.height)); } } @@ -284,6 +296,16 @@ bool Capture::IsRenderTaskSetup() void Capture::SetupResources(const Dali::Vector2& position, const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source) { + Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get()); + GraphicsInterface* graphics = &adaptor.GetGraphicsInterface(); + auto eglGraphics = static_cast(graphics); + + if(mFileSave && Dali::Shader::GetShaderLanguageVersion() < SHADER_VERSION_NATIVE_IMAGE_SOURCE_AVAILABLE) + { + DALI_LOG_ERROR("GLES is 2.0, we can't use native image source \n"); + mFileSave = false; + } + CreateTexture(size); CreateFrameBuffer(); @@ -349,6 +371,7 @@ bool Capture::SaveFile() { return Dali::DevelNativeImageSource::EncodeToFile(*mNativeImageSourcePtr, mPath, mQuality); } + return false; } diff --git a/dali/internal/system/common/capture-impl.h b/dali/internal/system/common/capture-impl.h index 5f6e594..af143e2 100644 --- a/dali/internal/system/common/capture-impl.h +++ b/dali/internal/system/common/capture-impl.h @@ -91,6 +91,11 @@ public: Dali::Devel::PixelBuffer GetCapturedBuffer(); /** + * @copydoc Dali::Capture::GetTexture + */ + Dali::Texture GetTexture() const; + + /** * @copydoc Dali::Capture::FinishedSignal */ Dali::Capture::CaptureFinishedSignalType& FinishedSignal(); diff --git a/dali/public-api/capture/capture.cpp b/dali/public-api/capture/capture.cpp index faa5c1e..e19a88c 100644 --- a/dali/public-api/capture/capture.cpp +++ b/dali/public-api/capture/capture.cpp @@ -88,6 +88,11 @@ Dali::NativeImageSourcePtr Capture::GetNativeImageSource() const return GetImpl(*this).GetNativeImageSource(); } +Dali::Texture Capture::GetTexture() const +{ + return GetImpl(*this).GetTexture(); +} + Capture::CaptureFinishedSignalType& Capture::FinishedSignal() { return GetImpl(*this).FinishedSignal(); diff --git a/dali/public-api/capture/capture.h b/dali/public-api/capture/capture.h index 3dd9275..79b1a55 100644 --- a/dali/public-api/capture/capture.h +++ b/dali/public-api/capture/capture.h @@ -21,6 +21,7 @@ // EXTERNAL HEADERS #include #include +#include #include // INTERNAL INCLUDES @@ -260,6 +261,13 @@ public: Dali::NativeImageSourcePtr GetNativeImageSource() const; /** + * @brief Get Texture of captured image. + * + * @return Texture Captured result + */ + Dali::Texture GetTexture() const; + + /** * @brief Get finished signal. * * @SINCE_1_3_4 -- 2.7.4