/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 0, 0);
+ 0,
+ 0);
// Check current orientations
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 90, 0);
+ 90,
+ 0);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 0, 90);
+ 0,
+ 90);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 90, 90);
+ 90,
+ 90);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 180, 0);
+ 180,
+ 0);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 0, 180);
+ 0,
+ 180);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 180, 180);
+ 180,
+ 180);
// Check current orientations
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 270, 0);
+ 270,
+ 0);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 0, 270);
+ 0,
+ 270);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 270, 270);
+ 270,
+ 270);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 90, 0);
+ 90,
+ 0);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 0, 90);
+ 0,
+ 90);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
TestApplication::DEFAULT_SURFACE_HEIGHT,
- 90, 90);
+ 90,
+ 90);
// Check current surface orientation
- int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ int32_t orientation = application.GetScene().GetCurrentSurfaceOrientation();
int32_t screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should not be changed yet.
DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
// Check current orientations
- orientation = application.GetScene().GetCurrentSurfaceOrientation();
+ orientation = application.GetScene().GetCurrentSurfaceOrientation();
screenOrientation = application.GetScene().GetCurrentScreenOrientation();
// It should be changed.
// Rotate surface
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_HEIGHT,
TestApplication::DEFAULT_SURFACE_WIDTH,
- 90, 0);
+ 90,
+ 0);
damagedRects.clear();
DALI_TEST_EQUALS(scene.GetRootLayer(), defaultTask.GetSourceActor(), TEST_LOCATION);
// Ensure stage size matches the scene size
- auto stage = Stage::GetCurrent();
- Vector2 sceneSize = stage.GetSize();
+ auto stage = Stage::GetCurrent();
+ Vector2 sceneSize = stage.GetSize();
Viewport sceneViewport(0, 0, sceneSize.x, sceneSize.y);
DALI_TEST_EQUALS(stage.GetSize(), scene.GetSize(), TEST_LOCATION);
Viewport defaultViewport = defaultTask.GetViewport();
Layer layer = scene.GetOverlayLayer();
// There should be 2 task by default.
DALI_TEST_EQUALS(tasks.GetTaskCount(), 2u, TEST_LOCATION);
- RenderTask overlayTask = tasks.GetTask(1u);
- Viewport overlayViewport = overlayTask.GetViewport();
+ RenderTask overlayTask = tasks.GetTask(1u);
+ Viewport overlayViewport = overlayTask.GetViewport();
DALI_TEST_EQUALS(defaultViewport, overlayViewport, TEST_LOCATION);
// Resize the scene
END_TEST;
}
+
+int UtcDaliSceneKeepRendering(void)
+{
+ tet_infoline("Test keep rendering");
+
+ TestApplication application;
+
+ auto scene = application.GetScene();
+ DALI_TEST_CHECK(scene);
+
+ Actor actor = CreateRenderableActor();
+ scene.Add(actor);
+
+ // Run core until it wants to sleep
+ bool keepUpdating(true);
+ while(keepUpdating)
+ {
+ application.SendNotification();
+ keepUpdating = application.Render(1000.0f /*1 second*/);
+ }
+
+ // Force rendering for the next 5 seconds
+ scene.KeepRendering(5.0f);
+
+ application.SendNotification();
+
+ keepUpdating = application.Render(1000.0f /*1 second*/);
+ DALI_TEST_CHECK(keepUpdating);
+ keepUpdating = application.Render(1000.0f /*2 seconds*/);
+ DALI_TEST_CHECK(keepUpdating);
+ keepUpdating = application.Render(1000.0f /*3 seconds*/);
+ DALI_TEST_CHECK(keepUpdating);
+ keepUpdating = application.Render(1000.0f /*4 seconds*/);
+ DALI_TEST_CHECK(keepUpdating);
+ keepUpdating = application.Render(1000.0f /*5 seconds*/);
+ DALI_TEST_CHECK(keepUpdating);
+ keepUpdating = application.Render(1000.0f /*6 seconds*/); // After 5 sec
+ DALI_TEST_CHECK(!keepUpdating);
+
+ END_TEST;
+}
+
+int UtcDaliSceneKeepRenderingMultipleScene(void)
+{
+ tet_infoline("Test keep rendering - multiple scene");
+
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+ TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
+
+ auto defaultScene = application.GetScene();
+ DALI_TEST_CHECK(defaultScene);
+
+ Actor actor1 = CreateRenderableActor();
+ actor1.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ actor1.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
+ defaultScene.Add(actor1);
+
+ // Create a Scene
+ Dali::Integration::Scene scene = Dali::Integration::Scene::New(Size(480.0f, 800.0f));
+ DALI_TEST_CHECK(scene);
+
+ application.AddScene(scene);
+
+ Actor actor2 = CreateRenderableActor();
+ actor2.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ actor2.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
+ scene.Add(actor2);
+
+ // Run core until it wants to sleep
+ bool keepUpdating(true);
+ while(keepUpdating)
+ {
+ application.SendNotification();
+ keepUpdating = application.RenderWithPartialUpdate(1000.0f /*1 second*/);
+ }
+
+ drawTrace.Enable(true);
+
+ // Force rendering of the default scene for the next 5 seconds (0sec ~ 5sec)
+ defaultScene.KeepRendering(5.0f);
+
+ application.SendNotification();
+ keepUpdating = application.RenderWithPartialUpdate(1000.0f /*1 second*/);
+
+ DALI_TEST_CHECK(keepUpdating);
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); // Only default scene should be drawn
+
+ drawTrace.Reset();
+
+ // Force rendering of the new scene for the next 5 seconds (1sec ~ 6sec)
+ scene.KeepRendering(5.0f);
+
+ application.SendNotification();
+ keepUpdating = application.RenderWithPartialUpdate(3000.0f /*4 second*/);
+
+ DALI_TEST_CHECK(keepUpdating);
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION); // Both scenes should be drawn
+
+ drawTrace.Reset();
+
+ keepUpdating = application.RenderWithPartialUpdate(1000.0f /*5 second*/);
+
+ DALI_TEST_CHECK(keepUpdating);
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION); // Still both scenes should be drawn
+
+ drawTrace.Reset();
+
+ keepUpdating = application.RenderWithPartialUpdate(1000.0f /*6 second*/);
+
+ DALI_TEST_CHECK(keepUpdating);
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); // Only the new scenes should be drawn
+
+ drawTrace.Reset();
+
+ keepUpdating = application.RenderWithPartialUpdate(1000.0f /*7 second*/);
+
+ DALI_TEST_CHECK(!keepUpdating);
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION); // Nothing drawn
+
+ END_TEST;
+}