From 1823d866b90e66014305b3a512d1cd3a8186bdf7 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Tue, 9 Mar 2021 16:38:09 +0900 Subject: [PATCH] Implement CameraView. Change-Id: I94e99034374c224238d66a05579e733a5c3b8209 --- .../src/dali-toolkit/CMakeLists.txt | 1 + .../src/dali-toolkit/utc-Dali-CameraView.cpp | 246 ++++++++++++++++++ dali-toolkit/dali-toolkit.h | 3 +- .../controls/camera-view/camera-view-impl.cpp | 199 ++++++++++++++ .../controls/camera-view/camera-view-impl.h | 144 ++++++++++ dali-toolkit/internal/file.list | 1 + .../controls/camera-view/camera-view.cpp | 72 +++++ .../controls/camera-view/camera-view.h | 152 +++++++++++ dali-toolkit/public-api/file.list | 6 + 9 files changed, 823 insertions(+), 1 deletion(-) create mode 100755 automated-tests/src/dali-toolkit/utc-Dali-CameraView.cpp create mode 100644 dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp create mode 100644 dali-toolkit/internal/controls/camera-view/camera-view-impl.h create mode 100644 dali-toolkit/public-api/controls/camera-view/camera-view.cpp create mode 100644 dali-toolkit/public-api/controls/camera-view/camera-view.h diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index ea6c3fcb7c..47fb5a555b 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -45,6 +45,7 @@ SET(TC_SOURCES utc-Dali-Tooltip.cpp utc-Dali-TransitionData.cpp utc-Dali-Button.cpp + utc-Dali-CameraView.cpp utc-Dali-Control.cpp utc-Dali-ControlImpl.cpp utc-Dali-ItemLayout.cpp diff --git a/automated-tests/src/dali-toolkit/utc-Dali-CameraView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-CameraView.cpp new file mode 100755 index 0000000000..24149f5479 --- /dev/null +++ b/automated-tests/src/dali-toolkit/utc-Dali-CameraView.cpp @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2021 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. + * + */ + +#include +#include +#include +#include +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +// Negative test case for a method +int UtcDaliCameraViewUninitialized(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliCameraViewUninitialized"); + + Toolkit::CameraView view; + + try + { + // New() must be called to create a CameraView or it wont be valid. + Actor a = Actor::New(); + view.Add( a ); + DALI_TEST_CHECK( false ); + } + catch (Dali::DaliException& e) + { + // Tests that a negative test of an assertion succeeds + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_CHECK(!view); + } + END_TEST; +} + +// Positive test case for a method +int UtcDaliCameraViewNew(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliCameraViewNew"); + Any dummy( 0 ); + Toolkit::CameraView view = Toolkit::CameraView::New(dummy); + DALI_TEST_CHECK( view ); + END_TEST; +} + +// Positive test case for a method +int UtcDaliCameraViewDownCast(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliCameraViewDownCast"); + + Any dummy( 0 ); + Toolkit::CameraView view = Toolkit::CameraView::New(dummy); + BaseHandle handle(view); + + Toolkit::CameraView view2 = Toolkit::CameraView::DownCast( handle ); + DALI_TEST_CHECK( view ); + DALI_TEST_CHECK( view2 ); + DALI_TEST_CHECK( view == view2 ); + END_TEST; +} + +int UtcDaliCameraViewCopyAndAssignment(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewCopyAndAssignment"); + + Any dummy( 0 ); + CameraView view = Toolkit::CameraView::New(dummy); + DALI_TEST_CHECK( view ); + + CameraView copy( view ); + DALI_TEST_CHECK( view == copy ); + + CameraView assign; + DALI_TEST_CHECK( !assign ); + + assign = copy; + DALI_TEST_CHECK( assign == view ); + + END_TEST; +} + +int UtcDaliCameraViewMoveAssignment(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewMoveAssignment"); + + Any dummy( 0 ); + CameraView view = Toolkit::CameraView::New(dummy); + DALI_TEST_EQUALS( 1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + + CameraView moved; + moved = std::move( view ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( !view ); + + END_TEST; +} + +int UtcDaliCameraViewTypeRegistry(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewTypeRegistry"); + + TypeRegistry typeRegistry = TypeRegistry::Get(); + DALI_TEST_CHECK( typeRegistry ); + + TypeInfo typeInfo = typeRegistry.GetTypeInfo( "CameraView" ); + DALI_TEST_CHECK( typeInfo ); + + BaseHandle handle = typeInfo.CreateInstance(); + DALI_TEST_CHECK( handle ); + + CameraView view = CameraView::DownCast( handle ); + DALI_TEST_CHECK( view ); + + END_TEST; +} + +int UtcDaliCameraViewWindowDisplayType(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewWindowDisplayType"); + + Any dummy( 0 ); + CameraView cameraView = CameraView::New(dummy, Dali::Toolkit::CameraView::DisplayType::WINDOW); + DALI_TEST_CHECK( cameraView ); + + application.GetScene().Add( cameraView ); + + try + { + cameraView.Update(); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( true ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_CHECK(false); + } + + END_TEST; +} + +int UtcDaliCameraViewImageDisplayType(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewImageDisplayType"); + + Any dummy( 0 ); + CameraView cameraView = CameraView::New(dummy, Dali::Toolkit::CameraView::DisplayType::IMAGE); + DALI_TEST_CHECK( cameraView ); + + application.GetScene().Add( cameraView ); + + try + { + cameraView.Update(); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK( true ); + } + catch (Dali::DaliException& e) + { + DALI_TEST_PRINT_ASSERT( e ); + DALI_TEST_CHECK(false); + } + + END_TEST; +} + +int UtcDaliCameraViewCoverUpdateDisplayArea1(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewUpdateDisplayArea1"); + + Any dummy( 0 ); + CameraView view = CameraView::New(dummy, Dali::Toolkit::CameraView::DisplayType::WINDOW); + DALI_TEST_CHECK( view ); + + application.GetScene().Add( view ); + + application.SendNotification(); + application.Render(); + + Vector3 vector(100.0f, 100.0f, 0.0f); + view.SetProperty( Actor::Property::SIZE, vector ); + + application.SendNotification(); + application.Render(); + + // Check the size in the new frame + DALI_TEST_CHECK(vector == view.GetCurrentProperty< Vector3 >( Actor::Property::SIZE )); + + application.GetScene().Remove(view); + + END_TEST; +} + +int UtcDaliCameraViewCoverUpdateDisplayArea2(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliCameraViewUpdateDisplayArea2"); + + Any dummy( 0 ); + CameraView view = CameraView::New(dummy, Dali::Toolkit::CameraView::DisplayType::WINDOW); + DALI_TEST_CHECK( view ); + + application.GetScene().Add( view ); + + application.SendNotification(); + application.Render(); + + Vector3 vector(100.0f, 100.0f, 0.0f); + view.SetProperty( Actor::Property::SIZE, vector ); + + application.SendNotification(); + application.Render(); + + // Check the size in the new frame + DALI_TEST_CHECK(vector == view.GetCurrentProperty< Vector3 >( Actor::Property::SIZE )); + + application.GetScene().Remove(view); + + END_TEST; +} diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 26f96a69f3..1cf4adc56f 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp b/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp new file mode 100644 index 0000000000..9ca121b9fc --- /dev/null +++ b/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2021 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 "camera-view-impl.h" + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ +namespace Toolkit +{ +namespace Internal +{ +namespace +{ +BaseHandle Create() +{ + return Toolkit::CameraView::New(NULL); +} + +DALI_TYPE_REGISTRATION_BEGIN(Toolkit::CameraView, Toolkit::Control, Create) +DALI_TYPE_REGISTRATION_END() +} // namespace + +CameraView::CameraView(Dali::Toolkit::CameraView::DisplayType displayType) +: Control(ControlBehaviour(ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)), + mDisplayType(displayType) +{ +} + +CameraView::~CameraView() +{ +} + +Toolkit::CameraView CameraView::New(Any cameraHandle, Dali::Toolkit::CameraView::DisplayType type) +{ + CameraView* impl = new CameraView(type); + Toolkit::CameraView handle = Toolkit::CameraView(*impl); + impl->mCameraPlayer = Dali::CameraPlayer::New(); + impl->Initialize(); + if(impl->mCameraPlayer) + { + impl->mCameraPlayer.SetCameraPlayer(cameraHandle); + } + return handle; +} + +void CameraView::Update() +{ + UpdateDisplayArea(mSizeUpdateNotification); +} + +void CameraView::OnSceneConnection(int depth) +{ + Control::OnSceneConnection(depth); + if(mDisplayType == Dali::Toolkit::CameraView::DisplayType::WINDOW) + { + SetWindowSurfaceTarget(); + } + else if(mDisplayType == Dali::Toolkit::CameraView::DisplayType::IMAGE) + { + SetNativeImageTarget(); + } + RelayoutRequest(); +} + +void CameraView::OnSceneDisconnection() +{ + Control::OnSceneDisconnection(); + Actor self = Self(); + if(mTextureRenderer) + { + self.RemoveRenderer(mTextureRenderer); + mTextureRenderer.Reset(); + } + + if(mOverlayRenderer) + { + self.RemoveRenderer(mOverlayRenderer); + mOverlayRenderer.Reset(); + } +} + +void CameraView::SetWindowSurfaceTarget() +{ + Actor self = Self(); + + mPositionUpdateNotification = self.AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f)); + mSizeUpdateNotification = self.AddPropertyNotification(Actor::Property::SIZE, StepCondition(1.0f, 1.0f)); + mScaleUpdateNotification = self.AddPropertyNotification(Actor::Property::WORLD_SCALE, StepCondition(0.1f, 1.0f)); + mPositionUpdateNotification.NotifySignal().Connect(this, &CameraView::UpdateDisplayArea); + mSizeUpdateNotification.NotifySignal().Connect(this, &CameraView::UpdateDisplayArea); + mScaleUpdateNotification.NotifySignal().Connect(this, &CameraView::UpdateDisplayArea); + + // For underlay rendering mode, camera display area have to be transparent. + Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); + Shader shader = Shader::New(SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG); + mOverlayRenderer = Renderer::New(geometry, shader); + mOverlayRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF); + + Self().AddRenderer(mOverlayRenderer); + + // Note CameraPlayer::SetWindowRenderingTarget + mCameraPlayer.SetWindowRenderingTarget(DevelWindow::Get(self)); +} + +void CameraView::SetNativeImageTarget() +{ + Actor self(Self()); + + self.RemovePropertyNotification(mPositionUpdateNotification); + self.RemovePropertyNotification(mSizeUpdateNotification); + self.RemovePropertyNotification(mScaleUpdateNotification); + + Any source; + Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New(source); + mNativeTexture = Dali::Texture::New(*nativeImageSourcePtr); + + Dali::Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); + Dali::Shader shader = CreateShader(nativeImageSourcePtr->GetCustomFragmentPrefix()); + Dali::TextureSet textureSet = Dali::TextureSet::New(); + textureSet.SetTexture(0u, mNativeTexture); + + mTextureRenderer = Renderer::New(geometry, shader); + mTextureRenderer.SetTextures(textureSet); + + Self().AddRenderer(mTextureRenderer); + + // Note CameraPlayer::SetNativeImageRenderingTarget. + mCameraPlayer.SetNativeImageRenderingTarget(nativeImageSourcePtr); +} + +void CameraView::UpdateDisplayArea(Dali::PropertyNotification& source) +{ + if(mDisplayType != Dali::Toolkit::CameraView::DisplayType::WINDOW) + { + return; + } + + Actor self(Self()); + + bool positionUsesAnchorPoint = self.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get(); + Vector3 actorSize = self.GetCurrentProperty(Actor::Property::SIZE) * self.GetCurrentProperty(Actor::Property::WORLD_SCALE); + Vector3 anchorPointOffSet = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); + + Vector2 screenPosition = self.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + + mDisplayArea.x = screenPosition.x - anchorPointOffSet.x; + mDisplayArea.y = screenPosition.y - anchorPointOffSet.y; + mDisplayArea.width = actorSize.x; + mDisplayArea.height = actorSize.y; + + mCameraPlayer.SetDisplayArea(mDisplayArea); +} + +Dali::Shader CameraView::CreateShader(const char* fragmentPrefix) +{ + std::string fragmentShader = fragmentPrefix; + std::string vertexShader; + + vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data(); + fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data(); + + return Dali::Shader::New(vertexShader, fragmentShader); +} + +} // namespace Internal + +} // namespace Toolkit + +} // namespace Dali \ No newline at end of file diff --git a/dali-toolkit/internal/controls/camera-view/camera-view-impl.h b/dali-toolkit/internal/controls/camera-view/camera-view-impl.h new file mode 100644 index 0000000000..6c77889301 --- /dev/null +++ b/dali-toolkit/internal/controls/camera-view/camera-view-impl.h @@ -0,0 +1,144 @@ +#ifndef DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H +#define DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H + +/* + * Copyright (c) 2021 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 +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Toolkit +{ +class CameraView; + +namespace Internal +{ +class CameraView : public Control +{ +protected: + /** + * @brief Constructor. + * @param[in] type Where it is an overlay type or a native image type + */ + CameraView(Dali::Toolkit::CameraView::DisplayType type); + + /** + * @brief Destructor + */ + virtual ~CameraView(); + +public: + /** + * @brief Creates an initialized CameraView. + * @param[in] handle Multimedia camera player handle + * @param[in] type Where it is an overlay type or a native image type + */ + static Toolkit::CameraView New(Any handle, Dali::Toolkit::CameraView::DisplayType type); + + /** + * @brief Update camera player. + */ + void Update(); + +private: // From Control + /** + * @copydoc Toolkit::Control::OnSceneConnection() + */ + void OnSceneConnection(int depth) override; + + /** + * @copydoc Toolkit::Control::OnSceneDisconnection() + */ + void OnSceneDisconnection() override; + +private: + /** + * @brief Construct a new CameraView. + */ + CameraView(const CameraView& cameraView); + + // Undefined assignment operator. + CameraView& operator=(const CameraView& cameraView); + + /** + * @brief Updates camera display area for window rendering target + * @param[in] source PropertyNotification + */ + void UpdateDisplayArea(Dali::PropertyNotification& source); + + /** + * @brief SetWindowSurfaceTarget for underlay camera preview. + */ + void SetWindowSurfaceTarget(); + + /** + * @brief SetNativeImageTarget for native image camera preview. + */ + void SetNativeImageTarget(); + + /** + * @brief CreateShader for native image target + * @param[in] fragmentPrefix prefix of fragment + * @return Returns the shader for NativeImage. + */ + Dali::Shader CreateShader(const char* fragmentPrefix); + +private: + Dali::CameraPlayer mCameraPlayer; + Dali::Texture mNativeTexture; + + Dali::DisplayArea mDisplayArea; + Dali::Renderer mOverlayRenderer; + Dali::Renderer mTextureRenderer; + + Dali::PropertyNotification mPositionUpdateNotification; + Dali::PropertyNotification mSizeUpdateNotification; + Dali::PropertyNotification mScaleUpdateNotification; + + Dali::Toolkit::CameraView::DisplayType mDisplayType; +}; + +} // namespace Internal + +inline Toolkit::Internal::CameraView& GetImpl(Toolkit::CameraView& handle) +{ + DALI_ASSERT_ALWAYS(handle); + Dali::RefObject& impl = handle.GetImplementation(); + return static_cast(impl); +} + +inline const Toolkit::Internal::CameraView& GetImpl(const Toolkit::CameraView& handle) +{ + DALI_ASSERT_ALWAYS(handle); + const Dali::RefObject& impl = handle.GetImplementation(); + return static_cast(impl); +} + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H \ No newline at end of file diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index c26fc7c4c6..470375204a 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -106,6 +106,7 @@ SET( toolkit_src_files ${toolkit_src_dir}/controls/tooltip/tooltip.cpp ${toolkit_src_dir}/controls/video-view/video-view-impl.cpp ${toolkit_src_dir}/controls/web-view/web-view-impl.cpp + ${toolkit_src_dir}/controls/camera-view/camera-view-impl.cpp ${toolkit_src_dir}/accessibility-manager/accessibility-manager-impl.cpp ${toolkit_src_dir}/feedback/feedback-style.cpp diff --git a/dali-toolkit/public-api/controls/camera-view/camera-view.cpp b/dali-toolkit/public-api/controls/camera-view/camera-view.cpp new file mode 100644 index 0000000000..297521ea2e --- /dev/null +++ b/dali-toolkit/public-api/controls/camera-view/camera-view.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 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 + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Toolkit +{ +CameraView::CameraView() +{ +} + +CameraView::CameraView(const CameraView& cameraView) = default; + +CameraView::CameraView(CameraView&& rhs) = default; + +CameraView& CameraView::operator=(const CameraView& cameraView) = default; + +CameraView& CameraView::operator=(CameraView&& rhs) = default; + +CameraView::~CameraView() +{ +} + +CameraView CameraView::New(Any handle, DisplayType type) +{ + return Internal::CameraView::New(handle, type); +} + +CameraView CameraView::DownCast(BaseHandle handle) +{ + return Control::DownCast(handle); +} + +void CameraView::Update() +{ + Dali::Toolkit::GetImpl(*this).Update(); +} + +CameraView::CameraView(Internal::CameraView& implementation) +: Control(implementation) +{ +} + +CameraView::CameraView(Dali::Internal::CustomActor* internal) +: Control(internal) +{ + VerifyCustomActorPointer(internal); +} + +} // namespace Toolkit + +} // namespace Dali \ No newline at end of file diff --git a/dali-toolkit/public-api/controls/camera-view/camera-view.h b/dali-toolkit/public-api/controls/camera-view/camera-view.h new file mode 100644 index 0000000000..3cf9845d2f --- /dev/null +++ b/dali-toolkit/public-api/controls/camera-view/camera-view.h @@ -0,0 +1,152 @@ +#ifndef DALI_TOOLKIT_CAMERA_VIEW_H +#define DALI_TOOLKIT_CAMERA_VIEW_H + +/* + * Copyright (c) 2021 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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ +class Any; + +namespace Toolkit +{ +namespace Internal DALI_INTERNAL +{ +class CameraView; +} // namespace DALI_INTERNAL + +/** + * @addtogroup dali_toolkit_controls_camera_view + * @{ + */ + +/** + * @brief CameraView is a control for camera display. + * + * For working CameraView, a camera plugin for a platform should be provided. + */ +class DALI_TOOLKIT_API CameraView : public Control +{ +public: + /** + * @brief Camera display type + */ + enum class DisplayType + { + WINDOW = 0, // Overlay type + IMAGE // Native Image type + }; + + /** + * @brief Creates an initialized CameraView. + * @param[in] handle Multimedia camera player handle + * @param[in] type Where it is an overlay type or a native image type + * @return A handle to a newly allocated Dali ImageView + */ + static CameraView New(Any handle, DisplayType type = DisplayType::WINDOW); + + /** + * @brief Creates an uninitialized CameraView. + */ + CameraView(); + + /** + * @brief Destructor. + * + * This is non-virtual since derived Handel types must not contain data or virtual methods. + */ + ~CameraView(); + + /** + * @brief Copy constructor. + * + * @param[in] CameraView CameraView to copy. The copied CameraView will point at the same implementation + */ + CameraView(const CameraView& CameraView); + + /** + * @brief Move constructor + * + * @param[in] rhs A reference to the moved handle + */ + CameraView(CameraView&& rhs); + + /** + * @brief Update camera view + * + * Multimedia camera operation is work outside the view. + * So, This must be called when the view needs to be updated after camera operation. + */ + void Update(); + + /** + * @brief Assignment operator. + * + * @param[in] CameraView The CameraView to assign from + * @return The updated CameraView + */ + CameraView& operator=(const CameraView& CameraView); + + /** + * @brief Move assignment + * + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + CameraView& operator=(CameraView&& rhs); + + /** + * @brief Downcasts a handle to CameraView handle. + * + * If handle points to a CameraView, the downcast produces valid handle. + * If not, the returned handle is left uninitialized. + * + * @param[in] handle Handle to an object + * @return Handle to a CameraView or an uninitialized handle + */ + static CameraView DownCast(BaseHandle handle); + +public: // Not intended for application developers + /// @cond internal + /** + * @brief Creates a handle using the Toolkit::Internal implementation. + * + * @param[in] implementation The CameraView implementation + */ + DALI_INTERNAL CameraView(Internal::CameraView& implementation); + + /** + * @brief Allows the creation of this CameraView from an Internal::CustomActor pointer. + * + * @param[in] internal A pointer to the internal CustomActor + */ + DALI_INTERNAL CameraView(Dali::Internal::CustomActor* internal); + /// @endcond +}; + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_CAMERA_VIEW_H diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index df039c8ed3..76863a7bbb 100644 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -26,6 +26,7 @@ SET( public_api_src_files ${public_api_src_dir}/controls/text-controls/text-label.cpp ${public_api_src_dir}/controls/text-controls/text-field.cpp ${public_api_src_dir}/controls/video-view/video-view.cpp + ${public_api_src_dir}/controls/camera-view/camera-view.cpp ${public_api_src_dir}/image-loader/image.cpp ${public_api_src_dir}/image-loader/async-image-loader.cpp ${public_api_src_dir}/image-loader/sync-image-loader.cpp @@ -127,6 +128,10 @@ SET( public_api_video_view_header_files ${public_api_src_dir}/controls/video-view/video-view.h ) +SET( public_api_camera_view_header_files + ${public_api_src_dir}/controls/camera-view/camera-view.h +) + SET( public_api_visuals_header_files ${public_api_src_dir}/visuals/border-visual-properties.h ${public_api_src_dir}/visuals/color-visual-properties.h @@ -161,4 +166,5 @@ SET( PUBLIC_API_HEADERS ${PUBLIC_API_HEADERS} ${public_api_text_header_files} ${public_api_video_view_header_files} ${public_api_visuals_header_files} + ${public_api_camera_view_header_files} ) -- 2.34.1