auto stage = Stage::GetCurrent();
DALI_TEST_EQUALS(stage.GetSize(), defaultScene.GetSize(), TEST_LOCATION);
+ Rect<int32_t> surfaceRect = defaultScene.GetCurrentSurfaceRect();
+
bool surfaceResized;
// check resized flag before surface is resized.
surfaceResized = defaultScene.IsSurfaceRectChanged();
DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
+ // Check current surface rect
+ Rect<int32_t> newSurfaceRect = defaultScene.GetCurrentSurfaceRect();
+
+ // It should not be changed yet.
+ DALI_TEST_CHECK(surfaceRect == newSurfaceRect);
+
// Render after resizing surface
application.SendNotification();
application.Render(0);
// Check that the viewport is handled properly
DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("Viewport", viewportParams));
+ // Check current surface rect
+ newSurfaceRect = defaultScene.GetCurrentSurfaceRect();
+
+ // It should be changed
+ DALI_TEST_EQUALS(newSurfaceRect.x, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(newSurfaceRect.y, 0, TEST_LOCATION);
+ DALI_TEST_EQUALS(newSurfaceRect.width, 1000, TEST_LOCATION);
+ DALI_TEST_EQUALS(newSurfaceRect.height, 2000, TEST_LOCATION);
+
END_TEST;
}
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
0);
+
+ // Check current surface orientation
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should not be changed yet.
+ DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+ // Check current surface orientation
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should be changed.
+ DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+
END_TEST;
}
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
90);
+
+ // Check current surface orientation
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should not be changed yet.
+ DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+ // Check current surface orientation
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should be changed.
+ DALI_TEST_EQUALS(orientation, 90, TEST_LOCATION);
+
END_TEST;
}
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
180);
+
+ // Check current surface orientation
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should not be changed yet.
+ DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+ // Check current surface orientation
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should be changed.
+ DALI_TEST_EQUALS(orientation, 180, TEST_LOCATION);
+
END_TEST;
}
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
270);
+
+ // Check current surface orientation
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should not be changed yet.
+ DALI_TEST_EQUALS(orientation, 0, TEST_LOCATION);
+
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+ // Check current surface orientation
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
+
+ // It should be changed.
+ DALI_TEST_EQUALS(orientation, 270, TEST_LOCATION);
+
END_TEST;
}
/*
- * 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.
{
namespace Integration
{
-Scene Scene::New(Size size, int orientation)
+Scene Scene::New(Size size, int32_t orientation)
{
Internal::ScenePtr internal = Internal::Scene::New(size, orientation);
return Scene(internal.Get());
GetImplementation(*this).GetFramePresentedCallback(callbacks);
}
-void Scene::SurfaceRotated(float width, float height, int orientation)
+void Scene::SurfaceRotated(float width, float height, int32_t orientation)
{
GetImplementation(*this).SurfaceRotated(width, height, orientation);
}
+int32_t Scene::GetCurrentSurfaceOrientation() const
+{
+ return GetImplementation(*this).GetCurrentSurfaceOrientation();
+}
+
+const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
+{
+ return GetImplementation(*this).GetCurrentSurfaceRect();
+}
+
bool Scene::IsSurfaceRectChanged() const
{
return GetImplementation(*this).IsSurfaceRectChanged();
#define DALI_SCENE_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.
*
* @return a handle to a newly allocated Dali resource.
*/
- static Scene New(Size size, int orientation = 0);
+ static Scene New(Size size, int32_t orientation = 0);
/**
* @brief Downcast an Object handle to Scene handle.
*
* @note A callback of the following type may be used:
* @code
- * void MyFunction( int frameId );
+ * void MyFunction( int32_t frameId );
* @endcode
* This callback will be deleted once it is called.
*
*
* @note A callback of the following type may be used:
* @code
- * void MyFunction( int frameId );
+ * void MyFunction( int32_t frameId );
* @endcode
* This callback will be deleted once it is called.
*
* @param[in] height The height of rotated surface
* @param[in] orientation The orientation of rotated surface
*/
- void SurfaceRotated(float width, float height, int orientation);
+ void SurfaceRotated(float width, float height, int32_t orientation);
+
+ /**
+ * @brief Gets the current surface orientation. It gets the value from the scene object.
+ *
+ * @return The current surface orientation.
+ */
+ int32_t GetCurrentSurfaceOrientation() const;
+
+ /**
+ * @brief Gets the current surface rectangle. It gets the value from the scene object.
+ *
+ * @return The current surface rectangle
+ */
+ const Rect<int32_t>& GetCurrentSurfaceRect() const;
/**
* Query wheter the surface rect is changed or not.
{
namespace Internal
{
-ScenePtr Scene::New(Size size, int orientation)
+ScenePtr Scene::New(Size size, int32_t orientation)
{
ScenePtr scene = new Scene;
// 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, int orientation)
+void Scene::Initialize(Size size, int32_t orientation)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
}
}
-void Scene::SurfaceRotated(float width, float height, int orientation)
+void Scene::SurfaceRotated(float width, float height, int32_t orientation)
{
mSurfaceOrientation = orientation;
ChangedSurface(width, height, orientation);
}
-int Scene::GetSurfaceOrientation()
+int32_t Scene::GetCurrentSurfaceOrientation() const
{
- return mSurfaceOrientation;
+ return mSceneObject->GetSurfaceOrientation();
}
-void Scene::ChangedSurface(float width, float height, int orientation)
+const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
+{
+ return mSceneObject->GetSurfaceRect();
+}
+
+void Scene::ChangedSurface(float width, float height, int32_t orientation)
{
Rect<int32_t> newSize(0, 0, static_cast<int32_t>(width), static_cast<int32_t>(height)); // truncated
mSize.width = width;
struct DirtyRect
{
- DirtyRect(Node* node, Render::Renderer* renderer, int frame, Rect<int>& rect)
+ DirtyRect(Node* node, Render::Renderer* renderer, int32_t frame, Rect<int>& rect)
: node(node),
renderer(renderer),
frame(frame),
Node* node;
Render::Renderer* renderer;
- int frame;
+ int32_t frame;
- Rect<int> rect;
- bool visited;
+ Rect<int32_t> rect;
+ bool visited;
};
} // namespace SceneGraph
/**
* @copydoc Dali::Integration::Scene::New
*/
- static ScenePtr New(Size size, int orientation = 0);
+ static ScenePtr New(Size size, int32_t orientation = 0);
/**
* virtual destructor
* @param[in] height The height of rotated surface
* @param[in] orientation The orientation of rotated surface
*/
- void SurfaceRotated(float width, float height, int orientation);
+ void SurfaceRotated(float width, float height, int32_t orientation);
/**
- * @brief Get surface's current orientation
- *
- * @return surface orientation
+ * @copydoc Dali::Integration::Scene::GetCurrentSurfaceOrientation
+ */
+ int32_t GetCurrentSurfaceOrientation() const;
+
+ /**
+ * @copydoc Dali::Integration::Scene::GetCurrentSurfaceRect
*/
- int GetSurfaceOrientation();
+ const Rect<int32_t>& GetCurrentSurfaceRect() const;
/**
* @copydoc Dali::Integration::Scene::IsSurfaceRectChanged
* @param[in] size The size of the set surface
* @param[in] orientation The orientation of the set surface for this scene
*/
- void Initialize(Size size, int orientation);
+ void Initialize(Size size, int32_t orientation);
// Undefined
Scene(const Scene&) = delete;
* @param[in] height The height of rotated surface
* @param[in] orientation The orientation of rotated surface
*/
- void ChangedSurface(float width, float height, int orientation);
+ void ChangedSurface(float width, float height, int32_t orientation);
private:
Internal::SceneGraph::Scene* mSceneObject;
EventProcessor mEventProcessor;
// The Surface's orientation
- int mSurfaceOrientation;
+ int32_t mSurfaceOrientation;
// The key event signal
Integration::Scene::KeyEventSignalType mKeyEventSignal;