/*
- * 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.
{
namespace Internal
{
-ScenePtr Scene::New(Size size, int32_t orientation)
+ScenePtr Scene::New(Size size, int32_t windowOrientation, int32_t screenOrientation)
{
ScenePtr scene = new Scene;
// Second-phase construction
- scene->Initialize(size, orientation);
+ scene->Initialize(size, windowOrientation, screenOrientation);
return scene;
}
mBackgroundColor(DEFAULT_BACKGROUND_COLOR),
mDepthTreeDirty(false),
mEventProcessor(*this, ThreadLocalStorage::GetInternal()->GetGestureEventProcessor()),
- mSurfaceOrientation(0)
+ mSurfaceOrientation(0),
+ mScreenOrientation(0)
{
}
// When this destructor is called, the scene has either already been removed from Core or Core has already been destroyed
}
-void Scene::Initialize(Size size, int32_t orientation)
+void Scene::Initialize(Size size, int32_t windowOrientation, int32_t screenOrientation)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
OwnerPointer<SceneGraph::Scene> transferOwnership(const_cast<SceneGraph::Scene*>(mSceneObject));
AddSceneMessage(updateManager, transferOwnership);
- SurfaceRotated(size.width, size.height, orientation);
+ SurfaceRotated(size.width, size.height, windowOrientation, screenOrientation);
}
void Scene::Add(Actor& actor)
return Dali::Layer(mLayerList->GetLayer(depth));
}
-CameraActor& Scene::GetDefaultCameraActor()
+CameraActor& Scene::GetDefaultCameraActor() const
{
return *mDefaultCamera;
}
{
if((fabsf(mSize.width - width) > Math::MACHINE_EPSILON_1) || (fabsf(mSize.height - height) > Math::MACHINE_EPSILON_1))
{
- ChangedSurface(width, height, mSurfaceOrientation);
+ ChangedSurface(width, height, mSurfaceOrientation, mScreenOrientation);
}
}
}
}
-void Scene::SurfaceRotated(float width, float height, int32_t orientation)
+void Scene::SurfaceRotated(float width, float height, int32_t windowOrientation, int32_t screenOrientation)
{
- mSurfaceOrientation = orientation;
- ChangedSurface(width, height, orientation);
+ ChangedSurface(width, height, windowOrientation, screenOrientation);
}
int32_t Scene::GetCurrentSurfaceOrientation() const
return mSceneObject->GetSurfaceOrientation();
}
+int32_t Scene::GetCurrentScreenOrientation() const
+{
+ return mSceneObject->GetScreenOrientation();
+}
+
const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
{
return mSceneObject->GetSurfaceRect();
}
-void Scene::ChangedSurface(float width, float height, int32_t orientation)
+void Scene::ChangedSurface(float width, float height, int32_t windowOrientation, int32_t screenOrientation)
{
+ bool changedOrientation = false;
Rect<int32_t> newSize(0, 0, static_cast<int32_t>(width), static_cast<int32_t>(height)); // truncated
mSize.width = width;
mSize.height = height;
+ if(mSurfaceOrientation != windowOrientation || mScreenOrientation != screenOrientation)
+ {
+ changedOrientation = true;
+ }
+
+ mSurfaceOrientation = windowOrientation;
+ mScreenOrientation = screenOrientation;
+
// Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
mDefaultCamera->SetPerspectiveProjection(mSize);
// Set the surface orientation to Default camera for window/screen rotation
- mDefaultCamera->RotateProjection(orientation);
+ if(changedOrientation)
+ {
+ int32_t orientation = (windowOrientation + screenOrientation) % 360;
+ mDefaultCamera->RotateProjection(orientation);
+ }
mRootLayer->SetSize(width, height);
// Send the surface rectangle/orientation to SceneGraph::Scene for calculating glViewport/Scissor
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
+ DALI_LOG_RELEASE_INFO("Send Surface Rect Message, width[%d], height[%d]\n", newSize.width, newSize.height);
SetSurfaceRectMessage(tls->GetEventThreadServices(), *mSceneObject, newSize);
- SetSurfaceOrientationMessage(tls->GetEventThreadServices(), *mSceneObject, static_cast<int32_t>(orientation));
+ if(changedOrientation)
+ {
+ DALI_LOG_RELEASE_INFO("Send Surface Orientation Message, surface orientation[%d], screen orientation[%d]\n", mSurfaceOrientation, mScreenOrientation);
+ SetSurfaceOrientationsMessage(tls->GetEventThreadServices(), *mSceneObject, mSurfaceOrientation, mScreenOrientation);
+ }
// set default render-task viewport parameters
RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask(0u);
SetRotationCompletedAcknowledgementMessage(tls->GetEventThreadServices(), *mSceneObject);
}
-void Scene::SetSurfaceRenderTarget(Graphics::RenderTarget* renderTarget)
+void Scene::SetSurfaceRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo)
{
// Send the surface render target to SceneGraph::Scene
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- SetSurfaceRenderTargetMessage(tls->GetEventThreadServices(), *mSceneObject, renderTarget);
+ SetSurfaceRenderTargetCreateInfoMessage(tls->GetEventThreadServices(), *mSceneObject, renderTargetCreateInfo);
}
bool Scene::EmitKeyEventGeneratedSignal(const Dali::KeyEvent& event)
return mKeyEventGeneratedSignal.Emit(event);
}
+bool Scene::EmitInterceptKeyEventSignal(const Dali::KeyEvent& event)
+{
+ // Emit the InterceptKeyEvent signal
+ Dali::Integration::Scene handle(this);
+ return mInterceptKeyEventSignal.Emit(event);
+}
+
void Scene::EmitEventProcessingFinishedSignal()
{
if(!mEventProcessingFinishedSignal.Empty())
}
}
+bool Scene::EmitWheelEventGeneratedSignal(const Dali::WheelEvent& event)
+{
+ // Emit the WheelEventGenerated signal when WheelEvent is generated
+ Dali::Integration::Scene handle(this);
+ return mWheelEventGeneratedSignal.Emit(event);
+}
+
void Scene::AddFrameRenderedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
return mKeyEventGeneratedSignal;
}
+Integration::Scene::KeyEventGeneratedSignalType& Scene::InterceptKeyEventSignal()
+{
+ return mInterceptKeyEventSignal;
+}
+
Integration::Scene::EventProcessingFinishedSignalType& Scene::EventProcessingFinishedSignal()
{
return mEventProcessingFinishedSignal;
return mWheelEventSignal;
}
-std::vector<Dali::Internal::SceneGraph::DirtyRect>& Scene::GetItemsDirtyRects()
+Integration::Scene::WheelEventGeneratedSignalType& Scene::WheelEventGeneratedSignal()
{
- return mItemsDirtyRects;
+ return mWheelEventGeneratedSignal;
}
} // namespace Internal