Make Capture api common. 20/229020/14
authorSeungho, Baek <sbsh.baek@samsung.com>
Fri, 27 Mar 2020 06:06:31 +0000 (15:06 +0900)
committerSeungho, Baek <sbsh.baek@samsung.com>
Tue, 28 Apr 2020 05:45:44 +0000 (14:45 +0900)
 - Current implementation, Capture can be used only in the wearable profile

Change-Id: I269e5e5b604b6deba97980ce53493fd0ae9039c0
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
build/tizen/profiles/wearable-profile.cmake
dali/internal/system/common/capture-impl.cpp [moved from dali/internal/system/tizen-wayland/tizen-wearable/capture-impl-tizen.cpp with 79% similarity, mode: 0644]
dali/internal/system/common/capture-impl.h [moved from dali/internal/system/tizen-wayland/tizen-wearable/capture-impl.h with 90% similarity, mode: 0644]
dali/internal/system/file.list
dali/public-api/capture/capture.cpp [moved from dali/internal/system/tizen-wayland/tizen-wearable/capture.cpp with 96% similarity]
dali/public-api/capture/capture.h
dali/public-api/file.list

index 8488967..3682664 100644 (file)
@@ -30,6 +30,7 @@ SET( SOURCES
     ${adaptor_styling_common_src_files}
     ${adaptor_system_common_src_files}
     ${adaptor_system_linux_src_files}
+    ${adaptor_system_tizen_wayland_src_files}
     ${adaptor_system_tizen_wearable_src_files}
     ${adaptor_text_common_src_files}
     ${adaptor_resampler_src_files}
old mode 100755 (executable)
new mode 100644 (file)
similarity index 79%
rename from dali/internal/system/tizen-wayland/tizen-wearable/capture-impl-tizen.cpp
rename to dali/internal/system/common/capture-impl.cpp
index 0c9487e..1ba6f58
@@ -16,7 +16,7 @@
  */
 
 // CLASS HEADER
-#include <dali/internal/system/tizen-wayland/tizen-wearable/capture-impl.h>
+#include <dali/internal/system/common/capture-impl.h>
 
 // EXTERNAL INCLUDES
 #include <fstream>
@@ -46,8 +46,7 @@ namespace Adaptor
 Capture::Capture()
 : mTimer(),
   mPath(),
-  mNativeImageSourcePtr( NULL ),
-  mTbmSurface( NULL )
+  mNativeImageSourcePtr( NULL )
 {
 }
 
@@ -55,13 +54,13 @@ Capture::Capture( Dali::CameraActor cameraActor )
 : mCameraActor( cameraActor ),
   mTimer(),
   mPath(),
-  mNativeImageSourcePtr( NULL ),
-  mTbmSurface( NULL )
+  mNativeImageSourcePtr( NULL )
 {
 }
 
 Capture::~Capture()
 {
+  DeleteNativeImageSource();
 }
 
 CapturePtr Capture::New()
@@ -98,62 +97,16 @@ Dali::Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
   return mFinishedSignal;
 }
 
-void Capture::CreateSurface( const Vector2& size )
-{
-  DALI_ASSERT_ALWAYS(!mTbmSurface && "mTbmSurface is already created.");
-
-  mTbmSurface = tbm_surface_create( size.width, size.height, TBM_FORMAT_RGBA8888 );
-}
-
-void Capture::DeleteSurface()
-{
-  DALI_ASSERT_ALWAYS(mTbmSurface && "mTbmSurface is empty.");
-
-  tbm_surface_destroy( mTbmSurface );
-  mTbmSurface = NULL;
-}
-
-void Capture::ClearSurface( const Vector2& size )
-{
-  DALI_ASSERT_ALWAYS(mTbmSurface && "mTbmSurface is empty.");
-
-  tbm_surface_info_s surface_info;
-
-  if( tbm_surface_map( mTbmSurface, TBM_SURF_OPTION_WRITE, &surface_info ) == TBM_SURFACE_ERROR_NONE )
-  {
-    //DALI_ASSERT_ALWAYS(surface_info.bpp == 32 && "unsupported tbm format");
-
-    unsigned char* ptr = surface_info.planes[0].ptr;
-    memset( ptr, 0, surface_info.size ); // TODO: support color
-
-    if( tbm_surface_unmap( mTbmSurface ) != TBM_SURFACE_ERROR_NONE )
-    {
-      DALI_LOG_ERROR( "Fail to unmap tbm_surface\n" );
-    }
-  }
-  else
-  {
-     DALI_ASSERT_ALWAYS(0 && "tbm_surface_map failed");
-  }
-}
-
-bool Capture::IsSurfaceCreated()
-{
-  return mTbmSurface != 0;
-}
-
-void Capture::CreateNativeImageSource()
+void Capture::CreateNativeImageSource( const Vector2& size )
 {
   Dali::Adaptor& adaptor = Dali::Adaptor::Get();
 
   DALI_ASSERT_ALWAYS(adaptor.IsAvailable() && "Dali::Adaptor is not available.");
 
-  DALI_ASSERT_ALWAYS(mTbmSurface && "mTbmSurface is empty.");
-
   DALI_ASSERT_ALWAYS(!mNativeImageSourcePtr && "NativeImageSource is already created.");
 
   // create the NativeImageSource object with our surface
-  mNativeImageSourcePtr = Dali::NativeImageSource::New( mTbmSurface );
+  mNativeImageSourcePtr = Dali::NativeImageSource::New( size.width, size.height, Dali::NativeImageSource::COLOR_DEPTH_DEFAULT );
 }
 
 void Capture::DeleteNativeImageSource()
@@ -277,10 +230,7 @@ bool Capture::IsRenderTaskSetup()
 
 void Capture::SetupResources( const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source )
 {
-  CreateSurface( size );
-  ClearSurface( size );
-
-  CreateNativeImageSource();
+  CreateNativeImageSource( size );
 
   CreateFrameBuffer();
 
@@ -298,16 +248,6 @@ void Capture::UnsetResources()
   {
     DeleteFrameBuffer();
   }
-
-  if( IsNativeImageSourceCreated() )
-  {
-    DeleteNativeImageSource();
-  }
-
-  if( IsSurfaceCreated() )
-  {
-    DeleteSurface();
-  }
 }
 
 void Capture::OnRenderFinished( Dali::RenderTask& task )
@@ -319,7 +259,7 @@ void Capture::OnRenderFinished( Dali::RenderTask& task )
   if( !Save() )
   {
     state = Dali::Capture::FinishState::FAILED;
-    DALI_LOG_ERROR("Fail to Capture mTbmSurface[%p] Path[%s]", mTbmSurface, mPath.c_str());
+    DALI_LOG_ERROR("Fail to Capture Path[%s]", mPath.c_str());
   }
 
   Dali::Capture handle( this );
old mode 100755 (executable)
new mode 100644 (file)
similarity index 90%
rename from dali/internal/system/tizen-wayland/tizen-wearable/capture-impl.h
rename to dali/internal/system/common/capture-impl.h
index 4eae7f6..69d97e2
@@ -21,7 +21,6 @@
 // EXTERNAL INCLUDES
 #include <string>
 #include <memory>
-#include <tbm_surface.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/render-tasks/render-task.h>
@@ -85,35 +84,9 @@ protected:
 
 private:
   /**
-   * @brief Create surface.
-   *
-   * @param[in] size of surface.
-   */
-  void CreateSurface( const Dali::Vector2& size );
-
-  /**
-   * @brief Delete surface.
-   */
-  void DeleteSurface();
-
-  /**
-   * @brief Clear surface with color.
-   *
-   * @param[in] size of clear aread.
-   */
-  void ClearSurface( const Dali::Vector2& size );
-
-  /**
-   * @brief Query whether surface is created or not.
-   *
-   * @return True is surface is created.
-   */
-  bool IsSurfaceCreated();
-
-  /**
    * @brief Create native image source.
    */
-  void CreateNativeImageSource();
+  void CreateNativeImageSource( const Dali::Vector2& size );
 
   /**
    * @brief Delete native image source.
@@ -218,7 +191,6 @@ private:
   Dali::Capture::CaptureFinishedSignalType    mFinishedSignal;
   std::string                                 mPath;
   Dali::NativeImageSourcePtr                  mNativeImageSourcePtr;  ///< pointer to surface image
-  tbm_surface_h                               mTbmSurface;
 };
 
 }  // End of namespace Adaptor
index 3c5be55..42bef31 100644 (file)
@@ -2,6 +2,7 @@
 # module: system, backend: common
 SET( adaptor_system_common_src_files
     ${adaptor_system_dir}/common/abort-handler.cpp
+    ${adaptor_system_dir}/common/capture-impl.cpp
     ${adaptor_system_dir}/common/color-controller-impl.cpp
     ${adaptor_system_dir}/common/command-line-options.cpp
     ${adaptor_system_dir}/common/configuration-manager.cpp
@@ -50,16 +51,7 @@ SET( adaptor_system_tizen_wayland_src_files
 
 # module: system, backend: tizen-wearable
 SET( adaptor_system_tizen_wearable_src_files
-    ${adaptor_system_dir}/common/shared-file.cpp
-    ${adaptor_system_dir}/common/trigger-event.cpp
-    ${adaptor_system_dir}/common/trigger-event-factory.cpp
-    ${adaptor_system_dir}/tizen-wayland/logging-tizen.cpp
-    ${adaptor_system_dir}/tizen-wayland/tizen-wearable/capture.cpp
-    ${adaptor_system_dir}/tizen-wayland/tizen-wearable/capture-impl-tizen.cpp
     ${adaptor_system_dir}/tizen-wayland/tizen-wearable/watch-time.cpp
-    ${adaptor_system_dir}/tizen-wayland/system-settings-tizen.cpp
-    ${adaptor_system_dir}/tizen-wayland/widget-application-impl-tizen.cpp
-    ${adaptor_system_dir}/tizen-wayland/widget-controller-tizen.cpp
 )
 
 # module: system, backend: ubuntu-x11
@@ -19,7 +19,7 @@
 #include <dali/public-api/capture/capture.h>
 
 // INTERNAL HEADER
-#include <dali/internal/system/tizen-wayland/tizen-wearable/capture-impl.h>
+#include <dali/internal/system/common/capture-impl.h>
 
 namespace Dali
 {
index 5119203..c58dd1c 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_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.
@@ -45,7 +45,7 @@ class Capture;
 /**
  * @brief Capture snapshots the current scene and save as a file.
  *
- * @SINCE_1_3_4
+ * @SINCE_1_3.4
  *
  * Applications should follow the example below to create capture :
  *
index 219b9c4..71866f1 100644 (file)
@@ -1,55 +1,57 @@
 
 
 SET( adaptor_public_api_src_files
-  ${adaptor_public_api_dir}/adaptor-framework/application.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/key.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/window.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/timer.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/tts-player.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/native-image-source.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/widget.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/widget-application.cpp 
-  ${adaptor_public_api_dir}/adaptor-framework/widget-impl.cpp 
+  ${adaptor_public_api_dir}/adaptor-framework/application.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/key.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/window.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/timer.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/tts-player.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/native-image-source.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/widget.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/widget-application.cpp
+  ${adaptor_public_api_dir}/adaptor-framework/widget-impl.cpp
+  ${adaptor_public_api_dir}/capture/capture.cpp
   ${adaptor_public_api_dir}/dali-adaptor-version.cpp
 )
 
 
 SET( public_api_header_files
-  ${adaptor_public_api_dir}/dali-adaptor-version.h 
+  ${adaptor_public_api_dir}/dali-adaptor-version.h
   ${adaptor_public_api_dir}/dali-adaptor-common.h
 )
 
 
 SET( public_api_adaptor_framework_header_files
-  ${adaptor_public_api_dir}/adaptor-framework/application.h 
-  ${adaptor_public_api_dir}/adaptor-framework/application-configuration.h 
-  ${adaptor_public_api_dir}/adaptor-framework/device-status.h 
-  ${adaptor_public_api_dir}/adaptor-framework/input-method.h 
-  ${adaptor_public_api_dir}/adaptor-framework/key.h 
-  ${adaptor_public_api_dir}/adaptor-framework/key-grab.h 
-  ${adaptor_public_api_dir}/adaptor-framework/style-change.h 
-  ${adaptor_public_api_dir}/adaptor-framework/timer.h 
-  ${adaptor_public_api_dir}/adaptor-framework/tts-player.h 
-  ${adaptor_public_api_dir}/adaptor-framework/native-image-source.h 
-  ${adaptor_public_api_dir}/adaptor-framework/window.h 
-  ${adaptor_public_api_dir}/adaptor-framework/widget.h 
-  ${adaptor_public_api_dir}/adaptor-framework/widget-application.h 
+  ${adaptor_public_api_dir}/adaptor-framework/application.h
+  ${adaptor_public_api_dir}/adaptor-framework/application-configuration.h
+  ${adaptor_public_api_dir}/adaptor-framework/device-status.h
+  ${adaptor_public_api_dir}/adaptor-framework/input-method.h
+  ${adaptor_public_api_dir}/adaptor-framework/key.h
+  ${adaptor_public_api_dir}/adaptor-framework/key-grab.h
+  ${adaptor_public_api_dir}/adaptor-framework/style-change.h
+  ${adaptor_public_api_dir}/adaptor-framework/timer.h
+  ${adaptor_public_api_dir}/adaptor-framework/tts-player.h
+  ${adaptor_public_api_dir}/adaptor-framework/native-image-source.h
+  ${adaptor_public_api_dir}/adaptor-framework/window.h
+  ${adaptor_public_api_dir}/adaptor-framework/widget.h
+  ${adaptor_public_api_dir}/adaptor-framework/widget-application.h
   ${adaptor_public_api_dir}/adaptor-framework/widget-impl.h
 )
 
+
+SET( public_dali_capture_header_files
+  ${adaptor_public_api_dir}/capture/capture.h
+)
+
+
 # wearable and watch extra public headers
 SET( adaptor_dali_wearable_header_file
   ${adaptor_public_api_dir}/watch/dali-wearable.h
 )
 
+
 # wearable and watch extra public headers
 SET( public_dali_watch_header_files
-  ${adaptor_public_api_dir}/watch/watch-application.h 
+  ${adaptor_public_api_dir}/watch/watch-application.h
   ${adaptor_public_api_dir}/watch/watch-time.h
-)
-
-# wearable and watch extra public headers
-SET( public_dali_capture_header_files
-  ${adaptor_public_api_dir}/capture/capture.h
-)
-
+)
\ No newline at end of file