From 2a18c29f97e51139b4509691b321f6aeccacc2ea Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 4 Oct 2022 18:33:15 +0900 Subject: [PATCH] [Tizen] Rotate camera when screen orientation is changed. This reverts commit 4fed653d5f5822476348f0967eacc6fe6dba795d. Change-Id: Ia6af014aa3fe28b97878c5dbdf25c610a7594e1a --- .../controls/scene-view/scene-view-impl.cpp | 41 ++++++++++++++++++++-- .../internal/controls/scene-view/scene-view-impl.h | 12 +++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp index 61962b5..0c5b792 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -56,13 +58,15 @@ BaseHandle Create() DALI_TYPE_REGISTRATION_BEGIN(Scene3D::SceneView, Toolkit::Control, Create); DALI_TYPE_REGISTRATION_END() -Property::Index RENDERING_BUFFER = Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1; +Property::Index RENDERING_BUFFER = Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX + 1; +constexpr int32_t DEFAULT_ORIENTATION = 0; } // anonymous namespace SceneView::SceneView() : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)), - mIblLoadedCallback(nullptr) + mIblLoadedCallback(nullptr), + mScreenOrientation(DEFAULT_ORIENTATION) { } @@ -250,12 +254,25 @@ void SceneView::OnSceneConnection(int depth) { UpdateRenderTask(); + Window window = DevelWindow::Get(Self()); + if(window) + { + window.ResizeSignal().Connect(this, &SceneView::OnWindowResized); + } + Control::OnSceneConnection(depth); } void SceneView::OnSceneDisconnection() { mModels.clear(); + + Window window = DevelWindow::Get(Self()); + if(window) + { + window.ResizeSignal().Disconnect(this, &SceneView::OnWindowResized); + } + Control::OnSceneDisconnection(); } @@ -407,6 +424,26 @@ void SceneView::UpdateRenderTask() mTexture.Reset(); } } + + RotateCamera(); + } +} + +void SceneView::OnWindowResized(Window window, Window::WindowSize size) +{ + mScreenOrientation = DevelWindow::GetPhysicalOrientation(window); + RotateCamera(); +} + +void SceneView::RotateCamera() +{ + if(mUseFrameBuffer) + { + DevelCameraActor::RotateProjection(mSelectedCamera, DEFAULT_ORIENTATION); + } + else + { + DevelCameraActor::RotateProjection(mSelectedCamera, mScreenOrientation); } } diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.h b/dali-scene3d/internal/controls/scene-view/scene-view-impl.h index 07ceda4..8bb0f9f 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.h +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -214,6 +215,16 @@ private: */ void OnLoadComplete(); + /* + * @brief Callback that will be called when window is resized. + */ + void OnWindowResized(Window window, Window::WindowSize size); + + /** + * @brief Update camera's projection orientation according to the screen orientation. + */ + void RotateCamera(); + private: Toolkit::Visual::Base mVisual; @@ -230,6 +241,7 @@ private: CallbackBase* mIblLoadedCallback; std::string mDiffuseIblUrl; std::string mSpecularIblUrl; + int32_t mScreenOrientation; Layer mRootLayer; Dali::Texture mSpecularTexture; -- 2.7.4