Make capture return Buffer. 56/229856/17
authorSeungho, Baek <sbsh.baek@samsung.com>
Mon, 6 Apr 2020 05:00:21 +0000 (14:00 +0900)
committerSeungho, Baek <sbsh.baek@samsung.com>
Tue, 28 Apr 2020 05:47:50 +0000 (14:47 +0900)
 - If developer want to use saved buffer, Dali::Capture can return it.

Change-Id: I03213cec5e54edf8f0e79f00e02a77f70fe16e51
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
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 1ba6f58..8dc77b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -46,7 +46,8 @@ namespace Adaptor
 Capture::Capture()
 : mTimer(),
   mPath(),
-  mNativeImageSourcePtr( NULL )
+  mNativeImageSourcePtr( NULL ),
+  mFileSave( false )
 {
 }
 
@@ -54,7 +55,8 @@ Capture::Capture( Dali::CameraActor cameraActor )
 : mCameraActor( cameraActor ),
   mTimer(),
   mPath(),
-  mNativeImageSourcePtr( NULL )
+  mNativeImageSourcePtr( NULL ),
+  mFileSave( false )
 {
 }
 
@@ -85,6 +87,10 @@ void Capture::Start( Dali::Actor source, const Dali::Vector2& size, const std::s
   Reference();
 
   mPath = path;
+  if( mPath.size() > 0 )
+  {
+    mFileSave = true;
+  }
 
   DALI_ASSERT_ALWAYS(source && "Source is NULL.");
 
@@ -92,6 +98,13 @@ void Capture::Start( Dali::Actor source, const Dali::Vector2& size, const std::s
   SetupResources( size, clearColor, source );
 }
 
+Dali::NativeImageSourcePtr Capture::GetNativeImageSource() const
+{
+  DALI_ASSERT_ALWAYS( mNativeImageSourcePtr && "mNativeImageSourcePtr is NULL.");
+
+  return mNativeImageSourcePtr;
+}
+
 Dali::Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
 {
   return mFinishedSignal;
@@ -256,10 +269,13 @@ void Capture::OnRenderFinished( Dali::RenderTask& task )
 
   mTimer.Stop();
 
-  if( !Save() )
+  if( mFileSave )
   {
-    state = Dali::Capture::FinishState::FAILED;
-    DALI_LOG_ERROR("Fail to Capture Path[%s]", mPath.c_str());
+    if( !SaveFile() )
+    {
+      state = Dali::Capture::FinishState::FAILED;
+      DALI_LOG_ERROR( "Fail to Capture Path[%s]", mPath.c_str() );
+    }
   }
 
   Dali::Capture handle( this );
@@ -286,7 +302,7 @@ bool Capture::OnTimeOut()
   return false;
 }
 
-bool Capture::Save()
+bool Capture::SaveFile()
 {
   DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "mNativeImageSourcePtr is NULL");
 
index 69d97e2..61e116a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_CAPTURE_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -71,6 +71,11 @@ public:
   void Start( Dali::Actor source, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor );
 
   /**
+   * @copydoc Dali::Capture::GetNativeImageSource
+   */
+  Dali::NativeImageSourcePtr GetNativeImageSource() const;
+
+  /**
    * @copydoc Dali::Capture::FinishedSignal
    */
   Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
@@ -170,7 +175,7 @@ private:
    *
    * @return True is success to save, false is fail.
    */
-  bool Save();
+  bool SaveFile();
 
 private:
 
@@ -191,6 +196,7 @@ private:
   Dali::Capture::CaptureFinishedSignalType    mFinishedSignal;
   std::string                                 mPath;
   Dali::NativeImageSourcePtr                  mNativeImageSourcePtr;  ///< pointer to surface image
+  bool                                        mFileSave;
 };
 
 }  // End of namespace Adaptor
index 1cc768c..701db7d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -72,6 +72,11 @@ void Capture::Start( Actor source, const Vector2& size, const std::string &path
   GetImpl( *this ).Start( source, size, path, Dali::Color::TRANSPARENT );
 }
 
+Dali::NativeImageSourcePtr Capture::GetNativeImageSource() const
+{
+  return GetImpl( *this ).GetNativeImageSource();
+}
+
 Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
 {
   return GetImpl( *this ).FinishedSignal();
index c58dd1c..b3ec14f 100755 (executable)
@@ -25,6 +25,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/dali-adaptor-common.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
 
 namespace Dali
 {
@@ -192,6 +193,13 @@ public:
   void Start( Actor source, const Vector2& size, const std::string &path );
 
   /**
+   * @brief Get NativeImageSourcePtr that is saved captured image.
+   *
+   * @SINCE_1_9.10
+   */
+  Dali::NativeImageSourcePtr GetNativeImageSource() const;
+
+  /**
    * @brief Get finished signal.
    *
    * @SINCE_1_3_4