[Tizen] support capture in gles 2.0 64/306064/1
authorsunghyun kim <scholb.kim@samsung.com>
Fri, 16 Feb 2024 02:49:48 +0000 (11:49 +0900)
committersunghyun kim <scholb.kim@samsung.com>
Fri, 16 Feb 2024 02:49:48 +0000 (11:49 +0900)
Change-Id: I8dfc77c70d2e04e5d60f73a1ec09a88c6ff9fd4e

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..7cf2aec 100644 (file)
@@ -52,7 +52,8 @@ Capture::Capture()
   mNativeImageSourcePtr(NULL),
   mFileSave(false),
   mUseDefaultCamera(true),
-  mSceneOffCameraAfterCaptureFinished(false)
+  mSceneOffCameraAfterCaptureFinished(false),
+  mIsNativeImageSourcePossible(true)
 {
 }
 
@@ -64,7 +65,8 @@ Capture::Capture(Dali::CameraActor cameraActor)
   mNativeImageSourcePtr(NULL),
   mFileSave(false),
   mUseDefaultCamera(!cameraActor),
-  mSceneOffCameraAfterCaptureFinished(false)
+  mSceneOffCameraAfterCaptureFinished(false),
+  mIsNativeImageSourcePossible(true)
 {
 }
 
@@ -124,6 +126,11 @@ Dali::NativeImageSourcePtr Capture::GetNativeImageSource() const
   return mNativeImageSourcePtr;
 }
 
+Dali::Texture Capture::GetTexture()
+{
+  return mTexture;
+}
+
 Dali::Devel::PixelBuffer Capture::GetCapturedBuffer()
 {
   if(!mPixelBuffer || (mPixelBuffer && !mPixelBuffer.GetBuffer()))
@@ -148,10 +155,17 @@ Dali::Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
 
 void Capture::CreateTexture(const Vector2& size)
 {
-  if(!mNativeImageSourcePtr)
+  if(mIsNativeImageSourcePossible)
   {
-    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::RGB888, unsigned(size.width), unsigned(size.height));
   }
 }
 
@@ -284,6 +298,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(eglGraphics->GetEglImplementation().GetGlesVersion() < GL_VERSION_NATIVE_IMAGE_SOURCE_AVAILABLE)
+  {
+    DALI_LOG_ERROR("GLES is 2.0, we can't use native image source \n");
+    mIsNativeImageSourcePossible = false;
+  }
+
   CreateTexture(size);
 
   CreateFrameBuffer();
@@ -345,10 +369,18 @@ bool Capture::OnTimeOut()
 
 bool Capture::SaveFile()
 {
-  if(mNativeImageSourcePtr)
+  if(mIsNativeImageSourcePossible)
+  {
+    if(mNativeImageSourcePtr)
+    {
+      return Dali::DevelNativeImageSource::EncodeToFile(*mNativeImageSourcePtr, mPath, mQuality);
+    }
+  }
+  else
   {
-    return Dali::DevelNativeImageSource::EncodeToFile(*mNativeImageSourcePtr, mPath, mQuality);
+    DALI_LOG_ERROR("can't use Capture::SavceFile(). we don't support this function in gles 2.0 \n");
   }
+
   return false;
 }
 
index 5f6e594..9f0690c 100644 (file)
@@ -91,6 +91,11 @@ public:
   Dali::Devel::PixelBuffer GetCapturedBuffer();
 
   /**
+   * @copydoc Dali::Capture::GetTexture
+   */
+  Dali::Texture GetTexture();
+
+  /**
    * @copydoc Dali::Capture::FinishedSignal
    */
   Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
@@ -211,6 +216,7 @@ private:
   bool                                     mFileSave;
   bool                                     mUseDefaultCamera;                   // Whether we use default generated camera, or use inputed camera.
   bool                                     mSceneOffCameraAfterCaptureFinished; // Whether we need to scene-off after capture finished.
+  bool                                     mIsNativeImageSourcePossible;
 };
 
 } // End of namespace Adaptor
index d8cb4f7..9e19bab 100644 (file)
@@ -88,6 +88,11 @@ Dali::NativeImageSourcePtr Capture::GetNativeImageSource() const
   return GetImpl(*this).GetNativeImageSource();
 }
 
+Dali::Texture Capture::GetTexture()
+{
+  return GetImpl(*this).GetTexture();
+}
+
 Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
 {
   return GetImpl(*this).FinishedSignal();
index 3a96515..7bd6f93 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();
+
+  /**
    * @brief Get finished signal.
    *
    * @SINCE_1_3_4