From: Eunki, Hong Date: Fri, 2 Sep 2022 14:06:17 +0000 (+0900) Subject: (Capture) Don't scene-off camera when we use inputed camera X-Git-Tag: dali_2.1.41~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af179fd306874337eb41db76da4daf671449b224;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git (Capture) Don't scene-off camera when we use inputed camera If we create capture with our own camera, App can add/remove this camera actor. But current capture API automatically dettach the camera. If we use DALi's default camera, than this default camera dettached from the window, and the rendering broken. This patch protect some kind of this scenario. We will dettach the camera from window only if we use capture-impl generated camera, and don't dettach if we use inputed camera. Change-Id: I902fbe3a4d933165de87cff7d420438e66c2fdd2 Signed-off-by: Eunki, Hong --- diff --git a/dali/internal/system/common/capture-impl.cpp b/dali/internal/system/common/capture-impl.cpp index 21169fe..fc947fd 100644 --- a/dali/internal/system/common/capture-impl.cpp +++ b/dali/internal/system/common/capture-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -50,7 +50,9 @@ Capture::Capture() mTimer(), mPath(), mNativeImageSourcePtr(NULL), - mFileSave(false) + mFileSave(false), + mUseDefaultCamera(true), + mSceneOffCameraAfterCaptureFinished(false) { } @@ -60,7 +62,9 @@ Capture::Capture(Dali::CameraActor cameraActor) mTimer(), mPath(), mNativeImageSourcePtr(NULL), - mFileSave(false) + mFileSave(false), + mUseDefaultCamera(!cameraActor), + mSceneOffCameraAfterCaptureFinished(false) { } @@ -202,7 +206,8 @@ void Capture::SetupRenderTask(const Dali::Vector2& position, const Dali::Vector2 if(!mCameraActor) { - mCameraActor = Dali::CameraActor::New(size); + mUseDefaultCamera = true; + mCameraActor = Dali::CameraActor::New(size); // Because input position and size are for 2 dimentional area, // default z-directional position of the camera is required to be used for the new camera position. float cameraDefaultZPosition = mCameraActor.GetProperty(Dali::Actor::Property::POSITION_Z); @@ -212,7 +217,16 @@ void Capture::SetupRenderTask(const Dali::Vector2& position, const Dali::Vector2 mCameraActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); } - window.Add(mCameraActor); + // Camera must be scene on. Add camera to window. + if(!mCameraActor.GetProperty(Dali::Actor::Property::CONNECTED_TO_SCENE)) + { + if(!mUseDefaultCamera) + { + DALI_LOG_ERROR("Camera must be on scene. Camera is connected to window now.\n"); + } + window.Add(mCameraActor); + mSceneOffCameraAfterCaptureFinished = true; + } if(!mFrameBuffer) { @@ -242,8 +256,13 @@ void Capture::UnsetRenderTask() { mTimer.Reset(); - if(mCameraActor) + if(mSceneOffCameraAfterCaptureFinished && mCameraActor) { + if(!mUseDefaultCamera) + { + DALI_LOG_ERROR("Camera is disconnected from window now.\n"); + } + mSceneOffCameraAfterCaptureFinished = false; mCameraActor.Unparent(); mCameraActor.Reset(); } diff --git a/dali/internal/system/common/capture-impl.h b/dali/internal/system/common/capture-impl.h index 6de3a90..5f6e594 100644 --- a/dali/internal/system/common/capture-impl.h +++ b/dali/internal/system/common/capture-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_CAPTURE_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -28,11 +28,11 @@ #include // INTERNAL INCLUDES +#include #include #include #include #include -#include namespace Dali { @@ -209,6 +209,8 @@ private: Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< pointer to surface image Dali::Devel::PixelBuffer mPixelBuffer; 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. }; } // End of namespace Adaptor