/*
- * Copyright (c) 2021 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.
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();
application.Render(16);
std::string viewportParams1("50, 100, 300, 400"); // to match newSize
- std::string viewportParams2("0, 0, 480, 800"); // to match newSize
+ std::string viewportParams2("0, 0, 480, 800"); // to match newSize
// Check that the viewport is handled properly
DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliRenderTaskViewportGuideActor03(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& callStack = glAbstraction.GetViewportTrace();
+ glAbstraction.EnableViewportCallTrace(true);
+ tet_infoline("Testing that adding a viewport guide actor to RenderTask will change the viewport");
+
+ Stage stage = Stage::GetCurrent();
+ Vector2 stageSize(stage.GetSize());
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(16);
+ glAbstraction.ResetViewportCallStack();
+
+ Geometry geometry = Geometry::New();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor blue = Actor::New();
+ blue[Dali::Actor::Property::NAME] = "Blue";
+ blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+ blue[Dali::Actor::Property::SIZE] = Vector2(400, 300);
+ blue[Dali::Actor::Property::POSITION] = Vector2(100, 50);
+ blue.AddRenderer(renderer);
+ stage.Add(blue);
+
+ Actor green = Actor::New();
+ green[Dali::Actor::Property::NAME] = "Green";
+ green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+ green[Dali::Actor::Property::SIZE] = Vector2(400, 300);
+ green[Dali::Actor::Property::POSITION] = Vector2(100, 50);
+ green.AddRenderer(renderer);
+ stage.Add(green);
+
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask renderTask = renderTaskList.CreateTask();
+
+ Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize);
+ cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ stage.Add(cameraActor);
+
+ renderTask.SetExclusive(true);
+ renderTask.SetInputEnabled(true);
+ renderTask.SetCameraActor(cameraActor);
+ renderTask.SetSourceActor(green);
+
+ Viewport viewport(75, 55, 150, 250);
+ renderTask.SetViewport(viewport);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(16);
+
+ // Note Y pos: 800 - (250+55) = 495
+ std::string viewportParams1("75, 495, 150, 250");
+ DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
+ glAbstraction.ResetViewportCallStack();
+
+ // Update to use viewport guide actor instead.
+ renderTask.SetViewportGuideActor(blue);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(16);
+
+ // Note: Y pos: 800 - (300+50) = 450
+ std::string viewportParams2("100, 450, 400, 300");
+ DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
+ tet_infoline("Testing that removing viewport guide actor from RenderTask will revert the viewport");
+ glAbstraction.ResetViewportCallStack();
+
+ // Remove guide actor, expect that the viewport is reset to its original values
+ renderTask.SetViewportGuideActor(Actor());
+ application.SendNotification();
+ application.Render(16);
+
+ // Currently, update manager does not consider that added Resetters should cause another
+ // update; this is probably right. But, we have to then force another update for the resetter to trigger, and this will register as un-necessary in the test output.
+ //
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
+
+ END_TEST;
+}
+
+int UtcDaliRenderTaskViewportGuideActor04(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& callStack = glAbstraction.GetViewportTrace();
+ glAbstraction.EnableViewportCallTrace(true);
+ tet_infoline("Testing that adding a viewport guide actor to RenderTask will change the viewport");
+
+ Stage stage = Stage::GetCurrent();
+ Vector2 stageSize(stage.GetSize());
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(16);
+ glAbstraction.ResetViewportCallStack();
+
+ Geometry geometry = Geometry::New();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor blue = Actor::New();
+ blue[Dali::Actor::Property::NAME] = "Blue";
+ blue[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ blue[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+ blue[Dali::Actor::Property::SIZE] = Vector2(400, 300);
+ blue[Dali::Actor::Property::POSITION] = Vector2(100, 50);
+ blue.AddRenderer(renderer);
+ stage.Add(blue);
+
+ Actor green = Actor::New();
+ green[Dali::Actor::Property::NAME] = "Green";
+ green[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT;
+ green[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::TOP_LEFT;
+ green[Dali::Actor::Property::SIZE] = Vector2(400, 300);
+ green[Dali::Actor::Property::POSITION] = Vector2(100, 50);
+ green.AddRenderer(renderer);
+ stage.Add(green);
+
+ RenderTaskList renderTaskList = stage.GetRenderTaskList();
+ RenderTask renderTask = renderTaskList.CreateTask();
+
+ Dali::CameraActor cameraActor = Dali::CameraActor::New(stageSize);
+ cameraActor[Dali::Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
+ cameraActor[Dali::Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
+ stage.Add(cameraActor);
+
+ renderTask.SetExclusive(true);
+ renderTask.SetInputEnabled(true);
+ renderTask.SetCameraActor(cameraActor);
+ renderTask.SetSourceActor(green);
+
+ Viewport viewport(75, 55, 150, 250);
+ renderTask.SetViewport(viewport);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(16);
+
+ // Note Y pos: 800 - (250+55) = 495
+ std::string viewportParams1("75, 495, 150, 250");
+ DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
+ glAbstraction.ResetViewportCallStack();
+
+ // Update to use viewport guide actor instead.
+ renderTask.SetViewportGuideActor(blue);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render(16);
+
+ std::string viewportParams2("100, 450, 400, 300");
+ DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams2) >= 0);
+ tet_infoline("Testing that removing viewport guide actor from RenderTask will revert the viewport");
+
+ glAbstraction.ResetViewportCallStack();
+
+ // Remove guide actor, expect that the viewport is reset to it's original values
+ renderTask.ResetViewportGuideActor();
+ application.SendNotification();
+ application.Render(16);
+
+ // Currently, update manager does not consider that added Resetters should cause another
+ // update; this is probably right. But, we have to then force another update for the resetter
+ // to trigger, and this will register as un-necessary in the test output.
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_CHECK(callStack.FindIndexFromMethodAndParams("Viewport", viewportParams1) >= 0);
+
+ // This should remove the baking resetters, but is again going to show up
+ // as unnecessary. Also try and figure out if we can test the dirty flags
+ // here, somehow (Can at least check the property's dirty flags in the debugger).
+ application.SendNotification();
+ application.Render(16);
+
+ END_TEST;
+}
+
+int UtcDaliRenderTaskSetPartialUpdate(void)
+{
+ TestApplication application(
+ TestApplication::DEFAULT_SURFACE_WIDTH,
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ TestApplication::DEFAULT_HORIZONTAL_DPI,
+ TestApplication::DEFAULT_VERTICAL_DPI,
+ true,
+ true);
+
+ tet_infoline("Check the damaged rects with render task");
+
+ const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
+
+ Actor actor = CreateRenderableActor();
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
+ actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
+ actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(actor);
+
+ Actor rootActor = CreateRenderableActor();
+ rootActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ rootActor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
+ rootActor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
+ rootActor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
+ application.GetScene().Add(rootActor);
+
+ CameraActor cameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT));
+ cameraActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ cameraActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ application.GetScene().Add(cameraActor);
+
+ Texture frameBufferTexture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGB888, 16, 16);
+ FrameBuffer frameBuffer = FrameBuffer::New(frameBufferTexture.GetWidth(), frameBufferTexture.GetHeight());
+ frameBuffer.AttachColorTexture(frameBufferTexture);
+
+ // Create a RenderTask and set a framebuffer
+ RenderTaskList taskList = application.GetScene().GetRenderTaskList();
+ RenderTask newTask = taskList.CreateTask();
+ newTask.SetCameraActor(cameraActor);
+ newTask.SetSourceActor(rootActor);
+ newTask.SetInputEnabled(false);
+ newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
+ newTask.SetClearEnabled(true);
+ newTask.SetExclusive(true);
+ newTask.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
+ newTask.SetFrameBuffer(frameBuffer);
+
+ application.SendNotification();
+
+ std::vector<Rect<int>> damagedRects;
+ Rect<int> clippingRect;
+
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Full update if there is off-screen rendering
+ clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+ DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
+ DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
+
+ // Remove framebuffer
+ newTask.SetFrameBuffer(FrameBuffer());
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Full update
+ clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Set invalid viewport of the render task
+ newTask.SetViewportSize(Vector2(-100.0f, -100.0f));
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Full update because the camera orientation is changed
+ clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ newTask.SetViewportSize(Vector2(0.0f, 0.0f));
+
+ // Change orientation of offscreen camera
+ cameraActor.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::XAXIS));
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Full update because the camera orientation is changed
+ clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ // Change camera target
+ cameraActor.SetTargetPosition(Vector3(10.0f, 10.0f, 0.0f));
+
+ application.SendNotification();
+
+ damagedRects.clear();
+ application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
+
+ // Full update because the camera is moved
+ clippingRect = Rect<int>(0, 0, TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT);
+ DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS<Rect<int>>(clippingRect, damagedRects[0], TEST_LOCATION);
+
+ application.RenderWithPartialUpdate(damagedRects, clippingRect);
+
+ END_TEST;
+}