Implement CameraView. 39/254239/35
authorJoogab Yun <joogab.yun@samsung.com>
Tue, 9 Mar 2021 07:38:09 +0000 (16:38 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Fri, 19 Mar 2021 02:43:10 +0000 (11:43 +0900)
Change-Id: I94e99034374c224238d66a05579e733a5c3b8209

automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/utc-Dali-CameraView.cpp [new file with mode: 0755]
dali-toolkit/dali-toolkit.h
dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp [new file with mode: 0644]
dali-toolkit/internal/controls/camera-view/camera-view-impl.h [new file with mode: 0644]
dali-toolkit/internal/file.list
dali-toolkit/public-api/controls/camera-view/camera-view.cpp [new file with mode: 0644]
dali-toolkit/public-api/controls/camera-view/camera-view.h [new file with mode: 0644]
dali-toolkit/public-api/file.list

index ea6c3fc..47fb5a5 100755 (executable)
@@ -45,6 +45,7 @@ SET(TC_SOURCES
   utc-Dali-Tooltip.cpp
   utc-Dali-TransitionData.cpp
   utc-Dali-Button.cpp
   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
   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 (executable)
index 0000000..24149f5
--- /dev/null
@@ -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 <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/public-api/controls/camera-view/camera-view.h>
+
+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;
+}
index 26f96a6..1cf4adc 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_H
 
 /*
 #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.
  *
  * 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 <dali-toolkit/public-api/controls/buttons/check-box-button.h>
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
 #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
 #include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
 #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
+#include <dali-toolkit/public-api/controls/camera-view/camera-view.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali-toolkit/public-api/controls/flex-container/flex-container.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali-toolkit/public-api/controls/flex-container/flex-container.h>
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 (file)
index 0000000..9ca121b
--- /dev/null
@@ -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 <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/object/type-registry.h>
+#include <cstring>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/public-api/controls/camera-view/camera-view.h>
+
+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<bool>();
+  Vector3 actorSize               = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
+  Vector3 anchorPointOffSet       = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+
+  Vector2 screenPosition = self.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
+
+  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 (file)
index 0000000..6c77889
--- /dev/null
@@ -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 <dali/devel-api/adaptor-framework/camera-player.h>
+#include <dali/public-api/object/property-notification.h>
+#include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/rendering/texture.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/camera-view/camera-view.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+
+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<Toolkit::Internal::CameraView&>(impl);
+}
+
+inline const Toolkit::Internal::CameraView& GetImpl(const Toolkit::CameraView& handle)
+{
+  DALI_ASSERT_ALWAYS(handle);
+  const Dali::RefObject& impl = handle.GetImplementation();
+  return static_cast<const Toolkit::Internal::CameraView&>(impl);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_CAMERA_VIEW_H
\ No newline at end of file
index c26fc7c..4703752 100644 (file)
@@ -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/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
    ${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 (file)
index 0000000..297521e
--- /dev/null
@@ -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 <dali-toolkit/public-api/controls/camera-view/camera-view.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/camera-view/camera-view-impl.h>
+
+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<CameraView, Internal::CameraView>(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::CameraView>(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 (file)
index 0000000..3cf9845
--- /dev/null
@@ -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 <dali-toolkit/public-api/controls/control.h>
+
+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
index df039c8..76863a7 100644 (file)
@@ -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/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
   ${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
 )
 
   ${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
 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_text_header_files}
   ${public_api_video_view_header_files}
   ${public_api_visuals_header_files}
+  ${public_api_camera_view_header_files}
 )
 )