${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}
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/system/common/capture-impl.h>
+
+// EXTERNAL INCLUDES
+#include <fstream>
+#include <string.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+
+namespace
+{
+unsigned int TIME_OUT_DURATION = 1000;
+}
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Capture::Capture()
+: mTimer(),
+ mPath(),
+ mNativeImageSourcePtr( NULL )
+{
+}
+
+Capture::Capture( Dali::CameraActor cameraActor )
+: mCameraActor( cameraActor ),
+ mTimer(),
+ mPath(),
+ mNativeImageSourcePtr( NULL )
+{
+}
+
+Capture::~Capture()
+{
+ DeleteNativeImageSource();
+}
+
+CapturePtr Capture::New()
+{
+ CapturePtr pWorker = new Capture();
+
+ return pWorker;
+}
+
+CapturePtr Capture::New( Dali::CameraActor cameraActor )
+{
+ CapturePtr pWorker = new Capture( cameraActor );
+
+ return pWorker;
+}
+
+void Capture::Start( Dali::Actor source, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor )
+{
+ DALI_ASSERT_ALWAYS(path.size() > 4 && "Path is invalid.");
+
+ // Increase the reference count focely to avoid application mistake.
+ Reference();
+
+ mPath = path;
+
+ DALI_ASSERT_ALWAYS(source && "Source is NULL.");
+
+ UnsetResources();
+ SetupResources( size, clearColor, source );
+}
+
+Dali::Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
+{
+ return mFinishedSignal;
+}
+
+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(!mNativeImageSourcePtr && "NativeImageSource is already created.");
+
+ // create the NativeImageSource object with our surface
+ mNativeImageSourcePtr = Dali::NativeImageSource::New( size.width, size.height, Dali::NativeImageSource::COLOR_DEPTH_DEFAULT );
+}
+
+void Capture::DeleteNativeImageSource()
+{
+ DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "mNativeImageSource is NULL.");
+
+ mNativeImageSourcePtr.Reset();
+}
+
+bool Capture::IsNativeImageSourceCreated()
+{
+ return mNativeImageSourcePtr;
+}
+
+void Capture::CreateFrameBuffer()
+{
+ DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "NativeImageSource is NULL.");
+
+ DALI_ASSERT_ALWAYS(!mFrameBuffer && "FrameBuffer is already created.");
+
+ mNativeTexture = Dali::Texture::New( *mNativeImageSourcePtr );
+
+ // Create a FrameBuffer object with depth attachments.
+ mFrameBuffer = Dali::FrameBuffer::New( mNativeTexture.GetWidth(), mNativeTexture.GetHeight(), Dali::FrameBuffer::Attachment::DEPTH );
+ // Add a color attachment to the FrameBuffer object.
+ mFrameBuffer.AttachColorTexture( mNativeTexture );
+}
+
+void Capture::DeleteFrameBuffer()
+{
+ DALI_ASSERT_ALWAYS(mFrameBuffer && "FrameBuffer is NULL.");
+
+ mFrameBuffer.Reset();
+ mNativeTexture.Reset();
+}
+
+bool Capture::IsFrameBufferCreated()
+{
+ return mFrameBuffer;
+}
+
+void Capture::SetupRenderTask( Dali::Actor source, const Dali::Vector4& clearColor )
+{
+ DALI_ASSERT_ALWAYS(source && "Source is empty.");
+
+ mSource = source;
+
+ // Check the original parent about source.
+ mParent = mSource.GetParent();
+
+ Dali::Stage stage = Dali::Stage::GetCurrent();
+ Dali::Size stageSize = stage.GetSize();
+
+ // Add to stage for rendering the source. If source isn't on the stage then it never be rendered.
+ stage.Add( mSource );
+
+ if( !mCameraActor )
+ {
+ mCameraActor = Dali::CameraActor::New( stageSize );
+ mCameraActor.SetParentOrigin( ParentOrigin::CENTER );
+ mCameraActor.SetAnchorPoint( AnchorPoint::CENTER );
+ }
+
+ stage.Add( mCameraActor );
+
+ DALI_ASSERT_ALWAYS(mFrameBuffer && "Framebuffer is NULL.");
+
+ DALI_ASSERT_ALWAYS(!mRenderTask && "RenderTask is already created.");
+
+ Dali::RenderTaskList taskList = stage.GetRenderTaskList();
+ mRenderTask = taskList.CreateTask();
+ mRenderTask.SetRefreshRate( Dali::RenderTask::REFRESH_ONCE );
+ mRenderTask.SetSourceActor( source );
+ mRenderTask.SetCameraActor( mCameraActor );
+ mRenderTask.SetScreenToFrameBufferFunction( Dali::RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
+ mRenderTask.SetFrameBuffer( mFrameBuffer );
+ mRenderTask.SetClearColor( clearColor );
+ mRenderTask.SetClearEnabled( true );
+ mRenderTask.SetProperty( Dali::RenderTask::Property::REQUIRES_SYNC, true );
+ mRenderTask.FinishedSignal().Connect( this, &Capture::OnRenderFinished );
+ mRenderTask.GetCameraActor().SetInvertYAxis( true );
+
+ mTimer = Dali::Timer::New( TIME_OUT_DURATION );
+ mTimer.TickSignal().Connect( this, &Capture::OnTimeOut );
+ mTimer.Start();
+}
+
+void Capture::UnsetRenderTask()
+{
+ DALI_ASSERT_ALWAYS(mCameraActor && "CameraActor is NULL.");
+
+ if( mParent )
+ {
+ // Restore the parent of source.
+ mParent.Add( mSource );
+ mParent.Reset();
+ }
+ else
+ {
+ mSource.Unparent();
+ }
+
+ mSource.Reset();
+
+ mTimer.Reset();
+
+ mCameraActor.Unparent();
+ mCameraActor.Reset();
+
+ DALI_ASSERT_ALWAYS( mRenderTask && "RenderTask is NULL." );
+
+ Dali::RenderTaskList taskList = Dali::Stage::GetCurrent().GetRenderTaskList();
+ taskList.RemoveTask( mRenderTask );
+ mRenderTask.Reset();
+}
+
+bool Capture::IsRenderTaskSetup()
+{
+ return mCameraActor && mRenderTask;
+}
+
+void Capture::SetupResources( const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source )
+{
+ CreateNativeImageSource( size );
+
+ CreateFrameBuffer();
+
+ SetupRenderTask( source, clearColor );
+}
+
+void Capture::UnsetResources()
+{
+ if( IsRenderTaskSetup() )
+ {
+ UnsetRenderTask();
+ }
+
+ if( IsFrameBufferCreated() )
+ {
+ DeleteFrameBuffer();
+ }
+}
+
+void Capture::OnRenderFinished( Dali::RenderTask& task )
+{
+ Dali::Capture::FinishState state = Dali::Capture::FinishState::SUCCEEDED;
+
+ mTimer.Stop();
+
+ if( !Save() )
+ {
+ state = Dali::Capture::FinishState::FAILED;
+ DALI_LOG_ERROR("Fail to Capture Path[%s]", mPath.c_str());
+ }
+
+ Dali::Capture handle( this );
+ mFinishedSignal.Emit( handle, state );
+
+ UnsetResources();
+
+ // Decrease the reference count forcely. It is increased at Start().
+ Unreference();
+}
+
+bool Capture::OnTimeOut()
+{
+ Dali::Capture::FinishState state = Dali::Capture::FinishState::FAILED;
+
+ Dali::Capture handle( this );
+ mFinishedSignal.Emit( handle, state );
+
+ UnsetResources();
+
+ // Decrease the reference count forcely. It is increased at Start().
+ Unreference();
+
+ return false;
+}
+
+bool Capture::Save()
+{
+ DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "mNativeImageSourcePtr is NULL");
+
+ return mNativeImageSourcePtr->EncodeToFile( mPath );
+}
+
+} // End of namespace Adaptor
+
+} // End of namespace Internal
+
+} // End of namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_CAPTURE_H
+#define DALI_INTERNAL_CAPTURE_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <memory>
+#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>
+#include <dali/public-api/rendering/texture.h>
+#include <dali/public-api/rendering/frame-buffer.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+#include <dali/public-api/capture/capture.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/adaptor-framework/timer.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class Capture;
+typedef IntrusivePtr<Capture> CapturePtr;
+
+class Capture : public BaseObject, public ConnectionTracker
+{
+public:
+ /**
+ * @brief Constructor.
+ */
+ Capture();
+
+ Capture( Dali::CameraActor cameraActor );
+
+ /**
+ * @copydoc Dali::Capture::New
+ */
+ static CapturePtr New();
+
+ /**
+ * @copydoc Dali::Capture::New
+ */
+ static CapturePtr New( Dali::CameraActor cameraActor );
+
+ /**
+ * @copydoc Dali::Capture::Start
+ */
+ void Start( Dali::Actor source, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor );
+
+ /**
+ * @copydoc Dali::Capture::FinishedSignal
+ */
+ Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
+
+protected:
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Capture();
+
+private:
+ /**
+ * @brief Create native image source.
+ */
+ void CreateNativeImageSource( const Dali::Vector2& size );
+
+ /**
+ * @brief Delete native image source.
+ */
+ void DeleteNativeImageSource();
+
+ /**
+ * @brief Query whether native image source is created or not.
+ *
+ * @return True is native image source is created.
+ */
+ bool IsNativeImageSourceCreated();
+
+ /**
+ * @brief Create frame buffer.
+ */
+ void CreateFrameBuffer();
+
+ /**
+ * @brief Delete frame buffer.
+ */
+ void DeleteFrameBuffer();
+
+ /**
+ * @brief Query whether frame buffer is created or not.
+ *
+ * @return True is frame buffer is created.
+ */
+ bool IsFrameBufferCreated();
+
+ /**
+ * @brief Setup render task.
+ *
+ * @param[in] source is captured.
+ * @param[in] clearColor background color
+ */
+ void SetupRenderTask( Dali::Actor source, const Dali::Vector4& clearColor );
+
+ /**
+ * @brief Unset render task.
+ */
+ void UnsetRenderTask();
+
+ /**
+ * @brief Query whether render task is setup or not.
+ *
+ * @return True is render task is setup.
+ */
+ bool IsRenderTaskSetup();
+
+ /**
+ * @brief Setup resources for capture.
+ *
+ * @param[in] size is surface size.
+ * @param[in] clearColor is clear color of surface.
+ * @param[in] source is captured.
+ */
+ void SetupResources( const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source );
+
+ /**
+ * @brief Unset resources for capture.
+ */
+ void UnsetResources();
+
+ /**
+ * @brief Callback when render is finished.
+ *
+ * @param[in] task is used for capture.
+ */
+ void OnRenderFinished( Dali::RenderTask& task );
+
+ /**
+ * @brief Callback when timer is finished.
+ *
+ * @return True is timer start again.
+ */
+ bool OnTimeOut();
+
+ /**
+ * @brief Save framebuffer.
+ *
+ * @return True is success to save, false is fail.
+ */
+ bool Save();
+
+private:
+
+ // Undefined
+ Capture( const Capture& );
+
+ // Undefined
+ Capture& operator=( const Capture& rhs );
+
+private:
+ Dali::Texture mNativeTexture;
+ Dali::FrameBuffer mFrameBuffer;
+ Dali::RenderTask mRenderTask;
+ Dali::Actor mParent;
+ Dali::Actor mSource;
+ Dali::CameraActor mCameraActor;
+ Dali::Timer mTimer; ///< For timeout.
+ Dali::Capture::CaptureFinishedSignalType mFinishedSignal;
+ std::string mPath;
+ Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< pointer to surface image
+};
+
+} // End of namespace Adaptor
+} // End of namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::Capture& GetImpl( Dali::Capture& captureWorker)
+{
+ DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
+
+ BaseObject& handle = captureWorker.GetBaseObject();
+
+ return static_cast< Internal::Adaptor::Capture& >( handle );
+}
+
+inline const Internal::Adaptor::Capture& GetImpl( const Dali::Capture& captureWorker )
+{
+ DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
+
+ const BaseObject& handle = captureWorker.GetBaseObject();
+
+ return static_cast< const Internal::Adaptor::Capture& >( handle );
+}
+
+} // End of namespace Dali
+
+#endif // DALI_INTERNAL_CAPTURE_H
# 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
# 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
+++ /dev/null
-/*
- * Copyright (c) 2019 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/system/tizen-wayland/tizen-wearable/capture-impl.h>
-
-// EXTERNAL INCLUDES
-#include <fstream>
-#include <string.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/adaptor-framework/adaptor.h>
-
-namespace
-{
-unsigned int TIME_OUT_DURATION = 1000;
-}
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-Capture::Capture()
-: mTimer(),
- mPath(),
- mNativeImageSourcePtr( NULL ),
- mTbmSurface( NULL )
-{
-}
-
-Capture::Capture( Dali::CameraActor cameraActor )
-: mCameraActor( cameraActor ),
- mTimer(),
- mPath(),
- mNativeImageSourcePtr( NULL ),
- mTbmSurface( NULL )
-{
-}
-
-Capture::~Capture()
-{
-}
-
-CapturePtr Capture::New()
-{
- CapturePtr pWorker = new Capture();
-
- return pWorker;
-}
-
-CapturePtr Capture::New( Dali::CameraActor cameraActor )
-{
- CapturePtr pWorker = new Capture( cameraActor );
-
- return pWorker;
-}
-
-void Capture::Start( Dali::Actor source, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor )
-{
- DALI_ASSERT_ALWAYS(path.size() > 4 && "Path is invalid.");
-
- // Increase the reference count focely to avoid application mistake.
- Reference();
-
- mPath = path;
-
- DALI_ASSERT_ALWAYS(source && "Source is NULL.");
-
- UnsetResources();
- SetupResources( size, clearColor, source );
-}
-
-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()
-{
- 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 );
-}
-
-void Capture::DeleteNativeImageSource()
-{
- DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "mNativeImageSource is NULL.");
-
- mNativeImageSourcePtr.Reset();
-}
-
-bool Capture::IsNativeImageSourceCreated()
-{
- return mNativeImageSourcePtr;
-}
-
-void Capture::CreateFrameBuffer()
-{
- DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "NativeImageSource is NULL.");
-
- DALI_ASSERT_ALWAYS(!mFrameBuffer && "FrameBuffer is already created.");
-
- mNativeTexture = Dali::Texture::New( *mNativeImageSourcePtr );
-
- // Create a FrameBuffer object with depth attachments.
- mFrameBuffer = Dali::FrameBuffer::New( mNativeTexture.GetWidth(), mNativeTexture.GetHeight(), Dali::FrameBuffer::Attachment::DEPTH );
- // Add a color attachment to the FrameBuffer object.
- mFrameBuffer.AttachColorTexture( mNativeTexture );
-}
-
-void Capture::DeleteFrameBuffer()
-{
- DALI_ASSERT_ALWAYS(mFrameBuffer && "FrameBuffer is NULL.");
-
- mFrameBuffer.Reset();
- mNativeTexture.Reset();
-}
-
-bool Capture::IsFrameBufferCreated()
-{
- return mFrameBuffer;
-}
-
-void Capture::SetupRenderTask( Dali::Actor source, const Dali::Vector4& clearColor )
-{
- DALI_ASSERT_ALWAYS(source && "Source is empty.");
-
- mSource = source;
-
- // Check the original parent about source.
- mParent = mSource.GetParent();
-
- Dali::Stage stage = Dali::Stage::GetCurrent();
- Dali::Size stageSize = stage.GetSize();
-
- // Add to stage for rendering the source. If source isn't on the stage then it never be rendered.
- stage.Add( mSource );
-
- if( !mCameraActor )
- {
- mCameraActor = Dali::CameraActor::New( stageSize );
- mCameraActor.SetParentOrigin( ParentOrigin::CENTER );
- mCameraActor.SetAnchorPoint( AnchorPoint::CENTER );
- }
-
- stage.Add( mCameraActor );
-
- DALI_ASSERT_ALWAYS(mFrameBuffer && "Framebuffer is NULL.");
-
- DALI_ASSERT_ALWAYS(!mRenderTask && "RenderTask is already created.");
-
- Dali::RenderTaskList taskList = stage.GetRenderTaskList();
- mRenderTask = taskList.CreateTask();
- mRenderTask.SetRefreshRate( Dali::RenderTask::REFRESH_ONCE );
- mRenderTask.SetSourceActor( source );
- mRenderTask.SetCameraActor( mCameraActor );
- mRenderTask.SetScreenToFrameBufferFunction( Dali::RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
- mRenderTask.SetFrameBuffer( mFrameBuffer );
- mRenderTask.SetClearColor( clearColor );
- mRenderTask.SetClearEnabled( true );
- mRenderTask.SetProperty( Dali::RenderTask::Property::REQUIRES_SYNC, true );
- mRenderTask.FinishedSignal().Connect( this, &Capture::OnRenderFinished );
- mRenderTask.GetCameraActor().SetInvertYAxis( true );
-
- mTimer = Dali::Timer::New( TIME_OUT_DURATION );
- mTimer.TickSignal().Connect( this, &Capture::OnTimeOut );
- mTimer.Start();
-}
-
-void Capture::UnsetRenderTask()
-{
- DALI_ASSERT_ALWAYS(mCameraActor && "CameraActor is NULL.");
-
- if( mParent )
- {
- // Restore the parent of source.
- mParent.Add( mSource );
- mParent.Reset();
- }
- else
- {
- mSource.Unparent();
- }
-
- mSource.Reset();
-
- mTimer.Reset();
-
- mCameraActor.Unparent();
- mCameraActor.Reset();
-
- DALI_ASSERT_ALWAYS( mRenderTask && "RenderTask is NULL." );
-
- Dali::RenderTaskList taskList = Dali::Stage::GetCurrent().GetRenderTaskList();
- taskList.RemoveTask( mRenderTask );
- mRenderTask.Reset();
-}
-
-bool Capture::IsRenderTaskSetup()
-{
- return mCameraActor && mRenderTask;
-}
-
-void Capture::SetupResources( const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source )
-{
- CreateSurface( size );
- ClearSurface( size );
-
- CreateNativeImageSource();
-
- CreateFrameBuffer();
-
- SetupRenderTask( source, clearColor );
-}
-
-void Capture::UnsetResources()
-{
- if( IsRenderTaskSetup() )
- {
- UnsetRenderTask();
- }
-
- if( IsFrameBufferCreated() )
- {
- DeleteFrameBuffer();
- }
-
- if( IsNativeImageSourceCreated() )
- {
- DeleteNativeImageSource();
- }
-
- if( IsSurfaceCreated() )
- {
- DeleteSurface();
- }
-}
-
-void Capture::OnRenderFinished( Dali::RenderTask& task )
-{
- Dali::Capture::FinishState state = Dali::Capture::FinishState::SUCCEEDED;
-
- mTimer.Stop();
-
- if( !Save() )
- {
- state = Dali::Capture::FinishState::FAILED;
- DALI_LOG_ERROR("Fail to Capture mTbmSurface[%p] Path[%s]", mTbmSurface, mPath.c_str());
- }
-
- Dali::Capture handle( this );
- mFinishedSignal.Emit( handle, state );
-
- UnsetResources();
-
- // Decrease the reference count forcely. It is increased at Start().
- Unreference();
-}
-
-bool Capture::OnTimeOut()
-{
- Dali::Capture::FinishState state = Dali::Capture::FinishState::FAILED;
-
- Dali::Capture handle( this );
- mFinishedSignal.Emit( handle, state );
-
- UnsetResources();
-
- // Decrease the reference count forcely. It is increased at Start().
- Unreference();
-
- return false;
-}
-
-bool Capture::Save()
-{
- DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "mNativeImageSourcePtr is NULL");
-
- return mNativeImageSourcePtr->EncodeToFile( mPath );
-}
-
-} // End of namespace Adaptor
-
-} // End of namespace Internal
-
-} // End of namespace Dali
+++ /dev/null
-#ifndef DALI_INTERNAL_CAPTURE_H
-#define DALI_INTERNAL_CAPTURE_H
-
-/*
- * Copyright (c) 2018 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// 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>
-#include <dali/public-api/rendering/texture.h>
-#include <dali/public-api/rendering/frame-buffer.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
-#include <dali/public-api/capture/capture.h>
-#include <dali/public-api/adaptor-framework/native-image-source.h>
-#include <dali/public-api/adaptor-framework/timer.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class Capture;
-typedef IntrusivePtr<Capture> CapturePtr;
-
-class Capture : public BaseObject, public ConnectionTracker
-{
-public:
- /**
- * @brief Constructor.
- */
- Capture();
-
- Capture( Dali::CameraActor cameraActor );
-
- /**
- * @copydoc Dali::Capture::New
- */
- static CapturePtr New();
-
- /**
- * @copydoc Dali::Capture::New
- */
- static CapturePtr New( Dali::CameraActor cameraActor );
-
- /**
- * @copydoc Dali::Capture::Start
- */
- void Start( Dali::Actor source, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor );
-
- /**
- * @copydoc Dali::Capture::FinishedSignal
- */
- Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
-
-protected:
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Capture();
-
-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();
-
- /**
- * @brief Delete native image source.
- */
- void DeleteNativeImageSource();
-
- /**
- * @brief Query whether native image source is created or not.
- *
- * @return True is native image source is created.
- */
- bool IsNativeImageSourceCreated();
-
- /**
- * @brief Create frame buffer.
- */
- void CreateFrameBuffer();
-
- /**
- * @brief Delete frame buffer.
- */
- void DeleteFrameBuffer();
-
- /**
- * @brief Query whether frame buffer is created or not.
- *
- * @return True is frame buffer is created.
- */
- bool IsFrameBufferCreated();
-
- /**
- * @brief Setup render task.
- *
- * @param[in] source is captured.
- * @param[in] clearColor background color
- */
- void SetupRenderTask( Dali::Actor source, const Dali::Vector4& clearColor );
-
- /**
- * @brief Unset render task.
- */
- void UnsetRenderTask();
-
- /**
- * @brief Query whether render task is setup or not.
- *
- * @return True is render task is setup.
- */
- bool IsRenderTaskSetup();
-
- /**
- * @brief Setup resources for capture.
- *
- * @param[in] size is surface size.
- * @param[in] clearColor is clear color of surface.
- * @param[in] source is captured.
- */
- void SetupResources( const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source );
-
- /**
- * @brief Unset resources for capture.
- */
- void UnsetResources();
-
- /**
- * @brief Callback when render is finished.
- *
- * @param[in] task is used for capture.
- */
- void OnRenderFinished( Dali::RenderTask& task );
-
- /**
- * @brief Callback when timer is finished.
- *
- * @return True is timer start again.
- */
- bool OnTimeOut();
-
- /**
- * @brief Save framebuffer.
- *
- * @return True is success to save, false is fail.
- */
- bool Save();
-
-private:
-
- // Undefined
- Capture( const Capture& );
-
- // Undefined
- Capture& operator=( const Capture& rhs );
-
-private:
- Dali::Texture mNativeTexture;
- Dali::FrameBuffer mFrameBuffer;
- Dali::RenderTask mRenderTask;
- Dali::Actor mParent;
- Dali::Actor mSource;
- Dali::CameraActor mCameraActor;
- Dali::Timer mTimer; ///< For timeout.
- Dali::Capture::CaptureFinishedSignalType mFinishedSignal;
- std::string mPath;
- Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< pointer to surface image
- tbm_surface_h mTbmSurface;
-};
-
-} // End of namespace Adaptor
-} // End of namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::Capture& GetImpl( Dali::Capture& captureWorker)
-{
- DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
-
- BaseObject& handle = captureWorker.GetBaseObject();
-
- return static_cast< Internal::Adaptor::Capture& >( handle );
-}
-
-inline const Internal::Adaptor::Capture& GetImpl( const Dali::Capture& captureWorker )
-{
- DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
-
- const BaseObject& handle = captureWorker.GetBaseObject();
-
- return static_cast< const Internal::Adaptor::Capture& >( handle );
-}
-
-} // End of namespace Dali
-
-#endif // DALI_INTERNAL_CAPTURE_H
+++ /dev/null
-/*
- * Copyright (c) 2018 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/capture/capture.h>
-
-// INTERNAL HEADER
-#include <dali/internal/system/tizen-wayland/tizen-wearable/capture-impl.h>
-
-namespace Dali
-{
-
-Capture::Capture()
-{
-}
-
-Capture Capture::New()
-{
- Internal::Adaptor::CapturePtr internal = Internal::Adaptor::Capture::New();
-
- return Capture( internal.Get() );
-}
-
-Capture Capture::New( Dali::CameraActor cameraActor )
-{
- Internal::Adaptor::CapturePtr internal = Internal::Adaptor::Capture::New( cameraActor );
-
- return Capture( internal.Get() );
-}
-
-Capture Capture::DownCast( BaseHandle handle )
-{
- return Capture( dynamic_cast< Internal::Adaptor::Capture* >( handle.GetObjectPtr() ) );
-}
-
-Capture::~Capture()
-{
-}
-
-Capture::Capture( const Capture& copy )
-: BaseHandle(copy)
-{
-}
-
-Capture& Capture::operator=( const Capture& rhs )
-{
- BaseHandle::operator=( rhs );
- return *this;
-}
-
-void Capture::Start( Actor source, const Vector2& size, const std::string &path, const Vector4& clearColor )
-{
- GetImpl( *this ).Start( source, size, path, clearColor );
-}
-
-void Capture::Start( Actor source, const Vector2& size, const std::string &path )
-{
- GetImpl( *this ).Start( source, size, path, Dali::Color::TRANSPARENT );
-}
-
-Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
-{
- return GetImpl( *this ).FinishedSignal();
-}
-
-Capture::Capture( Internal::Adaptor::Capture* internal )
-: BaseHandle( internal )
-{
-}
-
-} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/public-api/capture/capture.h>
+
+// INTERNAL HEADER
+#include <dali/internal/system/common/capture-impl.h>
+
+namespace Dali
+{
+
+Capture::Capture()
+{
+}
+
+Capture Capture::New()
+{
+ Internal::Adaptor::CapturePtr internal = Internal::Adaptor::Capture::New();
+
+ return Capture( internal.Get() );
+}
+
+Capture Capture::New( Dali::CameraActor cameraActor )
+{
+ Internal::Adaptor::CapturePtr internal = Internal::Adaptor::Capture::New( cameraActor );
+
+ return Capture( internal.Get() );
+}
+
+Capture Capture::DownCast( BaseHandle handle )
+{
+ return Capture( dynamic_cast< Internal::Adaptor::Capture* >( handle.GetObjectPtr() ) );
+}
+
+Capture::~Capture()
+{
+}
+
+Capture::Capture( const Capture& copy )
+: BaseHandle(copy)
+{
+}
+
+Capture& Capture::operator=( const Capture& rhs )
+{
+ BaseHandle::operator=( rhs );
+ return *this;
+}
+
+void Capture::Start( Actor source, const Vector2& size, const std::string &path, const Vector4& clearColor )
+{
+ GetImpl( *this ).Start( source, size, path, clearColor );
+}
+
+void Capture::Start( Actor source, const Vector2& size, const std::string &path )
+{
+ GetImpl( *this ).Start( source, size, path, Dali::Color::TRANSPARENT );
+}
+
+Capture::CaptureFinishedSignalType& Capture::FinishedSignal()
+{
+ return GetImpl( *this ).FinishedSignal();
+}
+
+Capture::Capture( Internal::Adaptor::Capture* internal )
+: BaseHandle( internal )
+{
+}
+
+} // namespace Dali
#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.
/**
* @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 :
*
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