Revert "[Tizen] Revert "Use Texture for not file save case""
authorsunghyun kim <scholb.kim@samsung.com>
Wed, 10 Jul 2024 07:04:01 +0000 (16:04 +0900)
committersunghyun kim <scholb.kim@samsung.com>
Wed, 10 Jul 2024 07:04:01 +0000 (16:04 +0900)
This reverts commit 2166770939b2224c1e48896d78d814b957a08862.

dali/internal/system/common/capture-impl.cpp
dali/internal/system/common/capture-impl.h
dali/public-api/capture/capture.cpp
dali/public-api/capture/capture.h

index fc947fd..b07500c 100644 (file)
@@ -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<EglGraphics*>(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;
 }
 
index 5f6e594..af143e2 100644 (file)
@@ -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();
index faa5c1e..e19a88c 100644 (file)
@@ -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();
index 3dd9275..79b1a55 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL HEADERS
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/actors/camera-actor.h>
+#include <dali/public-api/rendering/texture.h>
 #include <dali/public-api/signals/dali-signal.h>
 
 // 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