Internal dali window module has some variables and flags.
They are set by both main thread and render thread.
It has the effect of race condition when window is resized or rotated serval times.
This patch is to fix them.
Change-Id: I63ecc4a5d711569323a8f055e3b46ae878126235
renderTask.SetSourceActor(blue);
renderTask.SetViewportGuideActor(blue);
- application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_HEIGHT,
- TestApplication::DEFAULT_SURFACE_WIDTH,
- 90);
+ application.GetScene().SurfaceRotated(static_cast<float>(TestApplication::DEFAULT_SURFACE_HEIGHT),
+ static_cast<float>(TestApplication::DEFAULT_SURFACE_WIDTH),
+ 90, 0);
// Render and notify
application.SendNotification();
DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
END_TEST;
-}
\ No newline at end of file
+}
actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
application.GetScene().Add(actor);
+ // consume the orientating changing flag by first rendering
application.SendNotification();
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 0);
+ 0, 0);
- // Check current surface orientation
+ // Check current orientations
int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
- // Check current surface orientation
+ // Check current orientations
orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
END_TEST;
}
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 90);
+ 90, 90);
// Check current surface orientation
int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
- // Check current surface orientation
+ // Check current orientations
orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
DALI_TEST_EQUALS(orientation, 90, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 90, TEST_LOCATION);
END_TEST;
}
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 180);
+ 180, 180);
// Check current surface orientation
int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
- // Check current surface orientation
+ // Check current orientations
orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
DALI_TEST_EQUALS(orientation, 180, TEST_LOCATION);
+DALI_TEST_EQUALS(screenOrientation, 180, TEST_LOCATION);
END_TEST;
}
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 270);
+ 270, 270);
// Check current surface orientation
int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
- // Check current surface orientation
+ // Check current orientations
orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
DALI_TEST_EQUALS(orientation, 270, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 270, TEST_LOCATION);
END_TEST;
}
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 90);
+ 90, 90);
// Check current surface orientation
int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 0, TEST_LOCATION);
application.GetScene().SetRotationCompletedAcknowledgement();
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
- // Check current surface orientation
+ // Check current orientations
orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
DALI_TEST_EQUALS(orientation, 90, TEST_LOCATION);
+ DALI_TEST_EQUALS(screenOrientation, 90, TEST_LOCATION);
bool isSetRotationCompletedAcknowledgementSet = application.GetScene().IsRotationCompletedAcknowledgementSet();
DALI_TEST_EQUALS(isSetRotationCompletedAcknowledgementSet, true, TEST_LOCATION);
// Rotate surface
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_HEIGHT,
TestApplication::DEFAULT_SURFACE_WIDTH,
- 90);
+ 90, 0);
damagedRects.clear();
{
namespace Integration
{
-Scene Scene::New(Size size, int32_t orientation)
+Scene Scene::New(Size size, int32_t windowOrientation, int32_t screenOrientation)
{
- Internal::ScenePtr internal = Internal::Scene::New(size, orientation);
+ Internal::ScenePtr internal = Internal::Scene::New(size, windowOrientation, screenOrientation);
return Scene(internal.Get());
}
GetImplementation(*this).GetFramePresentedCallback(callbacks);
}
-void Scene::SurfaceRotated(float width, float height, int32_t orientation)
+void Scene::SurfaceRotated(float width, float height, int32_t windowOrientation, int32_t screenOrientation)
{
- GetImplementation(*this).SurfaceRotated(width, height, orientation);
+ GetImplementation(*this).SurfaceRotated(width, height, windowOrientation, screenOrientation);
}
int32_t Scene::GetCurrentSurfaceOrientation() const
return GetImplementation(*this).GetCurrentSurfaceOrientation();
}
+int32_t Scene::GetCurrentScreenOrientation() const
+{
+ return GetImplementation(*this).GetCurrentScreenOrientation();
+}
+
const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
{
return GetImplementation(*this).GetCurrentSurfaceRect();
* @brief Create an initialized Scene handle.
*
* @param[in] size The size of the set surface for this scene
- * @param[in] orientation The rotated angle of the set surface for this scene
+ * @param[in] windowOrientation The rotated angle of the set surface for this scene
+ * @param[in] screenOrientation The rotated angle of the screen
*
* @return a handle to a newly allocated Dali resource.
*/
- static Scene New(Size size, int32_t orientation = 0);
+ static Scene New(Size size, int32_t windowOrientation = 0, int32_t screenOrientation = 0);
/**
* @brief Downcast an Object handle to Scene handle.
*
* @param[in] width The width of rotated surface
* @param[in] height The height of rotated surface
- * @param[in] orientation The orientation of rotated surface
+ * @param[in] windowOrientation the current window orientation
+ * @param[in] screenOrientation the current screen orientation
*/
- void SurfaceRotated(float width, float height, int32_t orientation);
+ void SurfaceRotated(float width, float height, int32_t windowOrientation, int32_t screenOrientation);
/**
* @brief Gets the current surface orientation. It gets the value from the scene object.
int32_t GetCurrentSurfaceOrientation() const;
/**
+ * @brief Gets the current screen orientation. It gets the value from the scene object.
+ *
+ * @return The current screen orientation.
+ */
+ int32_t GetCurrentScreenOrientation() const;
+
+ /**
* @brief Gets the current surface rectangle. It gets the value from the scene object.
*
* @return The current surface rectangle
{
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)
{
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);
/**
* @copydoc Dali::Integration::Scene::New
*/
- static ScenePtr New(Size size, int32_t orientation = 0);
+ static ScenePtr New(Size size, int32_t windowOrientation = 0, int32_t screenOrientation = 0);
/**
* virtual destructor
*
* @param[in] width The width of rotated surface
* @param[in] height The height of rotated surface
- * @param[in] orientation The orientation of rotated surface
+ * @param[in] windowOrientation the current window orientation
+ * @param[in] screenOrientation the current screen orientation
*/
- void SurfaceRotated(float width, float height, int32_t orientation);
+ void SurfaceRotated(float width, float height, int32_t windowOrientation, int32_t screenOrientation);
/**
* @copydoc Dali::Integration::Scene::SetRotationCompletedAcknowledgement
int32_t GetCurrentSurfaceOrientation() const;
/**
+ * @copydoc Dali::Integration::Scene::GetCurrentScreenOrientation
+ */
+ int32_t GetCurrentScreenOrientation() const;
+
+ /**
* @copydoc Dali::Integration::Scene::GetCurrentSurfaceRect
*/
const Rect<int32_t>& GetCurrentSurfaceRect() const;
* Second-phase constructor.
*
* @param[in] size The size of the set surface
- * @param[in] orientation The orientation of the set surface for this scene
+ * @param[in] windowOrientation The rotated angle of the set surface for this scene
+ * @param[in] screenOrientation The rotated angle of the screen
*/
- void Initialize(Size size, int32_t orientation);
+ void Initialize(Size size, int32_t windowOrientation, int32_t screenOrientation);
// Undefined
Scene(const Scene&) = delete;
*
* @param[in] width The width of rotated surface
* @param[in] height The height of rotated surface
- * @param[in] orientation The orientation of rotated surface
+ * @param[in] windowOrientation the current window orientation
+ * @param[in] screenOrientation the current screen orientation
*/
- void ChangedSurface(float width, float height, int32_t orientation);
+ void ChangedSurface(float width, float height, int32_t windowOrientation, int32_t screenOrientation);
private:
Internal::SceneGraph::Scene* mSceneObject;
// The Surface's orientation
int32_t mSurfaceOrientation;
+ // The Screen's orientation
+ int32_t mScreenOrientation;
+
// The key event signal
Integration::Scene::KeyEventSignalType mKeyEventSignal;
Integration::Scene::KeyEventGeneratedSignalType mKeyEventGeneratedSignal;
mSkipRendering(false),
mSurfaceRect(),
mSurfaceOrientation(0),
+ mScreenOrientation(0),
mSurfaceRectChanged(false),
mRotationCompletedAcknowledgement(false)
{
mSurfaceRect = rect;
mSurfaceRectChanged = true;
+ DALI_LOG_RELEASE_INFO("update surfce rect in scene-graph, width[%d], height[%d]\n", mSurfaceRect.width, mSurfaceRect.height);
+
if(mRoot)
{
mRoot->SetUpdated(true);
return mSurfaceRect;
}
-void Scene::SetSurfaceOrientation(int32_t orientation)
+bool Scene::IsSurfaceRectChanged()
{
- mSurfaceOrientation = orientation;
+ bool surfaceRectChanged = mSurfaceRectChanged;
+ mSurfaceRectChanged = false;
+
+ return surfaceRectChanged;
+}
+
+void Scene::SetSurfaceOrientations(int32_t windowOrientation, int32_t screenOrienation)
+{
+ mSurfaceOrientation = windowOrientation;
+ mScreenOrientation = screenOrienation;
if(mRoot)
{
mRoot->SetUpdated(true);
}
+
+ DALI_LOG_RELEASE_INFO("update orientation in scene-graph, surface [%d], screen[%d]\n", mSurfaceOrientation, mScreenOrientation);
}
int32_t Scene::GetSurfaceOrientation() const
return mSurfaceOrientation;
}
-bool Scene::IsSurfaceRectChanged()
+int32_t Scene::GetScreenOrientation() const
{
- bool surfaceRectChanged = mSurfaceRectChanged;
- mSurfaceRectChanged = false;
-
- return surfaceRectChanged;
+ return mScreenOrientation;
}
void Scene::SetRotationCompletedAcknowledgement()
const Rect<int32_t>& GetSurfaceRect() const;
/**
- * Set the surface orientation when surface is rotated.
+ * Set the surface orientations when surface or screen is rotated.
*
- * @param[in] orientation The orientation value representing the surface.
+ * @param[in] windowOrientation The orientations value representing surface.
+ * @param[in] screenOrienation The orientations value representing screen.
*/
- void SetSurfaceOrientation(int32_t orientation);
+ void SetSurfaceOrientations(int32_t windowOrientation, int32_t screenOrienation);
/**
* Get the surface orientation.
int32_t GetSurfaceOrientation() const;
/**
+ * Get the screen orientation.
+ *
+ * @return the current screen orientation
+ */
+ int32_t GetScreenOrientation() const;
+
+ /**
* Query wheter the surface rect is changed or not.
* @return true if the surface rect is changed.
*/
Rect<int32_t> mSurfaceRect; ///< The rectangle of surface which is related ot this scene.
int32_t mSurfaceOrientation; ///< The orientation of surface which is related of this scene
- bool mSurfaceRectChanged; ///< The flag of surface's rectangle is changed when is resized, moved or rotated.
+ int32_t mScreenOrientation; ///< The orientation of screen
+ bool mSurfaceRectChanged; ///< The flag of surface's rectangle is changed when is resized or moved.
bool mRotationCompletedAcknowledgement; ///< The flag of sending the acknowledgement to complete window rotation.
// Render pass and render target
new(slot) LocalType(&scene, &Scene::SetSurfaceRect, rect);
}
-inline void SetSurfaceOrientationMessage(EventThreadServices& eventThreadServices, const Scene& scene, int32_t orientation)
+inline void SetSurfaceOrientationsMessage(EventThreadServices& eventThreadServices, const Scene& scene, const int32_t windowOrientation, const int32_t screenOrientation)
{
- using LocalType = MessageValue1<Scene, int32_t>;
+ using LocalType = MessageValue2<Scene, int32_t, int32_t>;
// Reserve some memory inside the message queue
uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new(slot) LocalType(&scene, &Scene::SetSurfaceOrientation, orientation);
+ new(slot) LocalType(&scene, &Scene::SetSurfaceOrientations, windowOrientation, screenOrientation);
}
inline void SetRotationCompletedAcknowledgementMessage(EventThreadServices& eventThreadServices, const Scene& scene)