From e6f830e5fa5008c7ec90c8025a7aa0cb361da68f Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Tue, 15 Feb 2022 19:23:23 +0900 Subject: [PATCH] (Partial Update) Set the updated flag when the Renderer is added/removed Change-Id: I586777f0bda8dde74ee04d461b54e7165e74b35c --- automated-tests/src/dali/utc-Dali-Actor.cpp | 82 +++++++++++++++++++++++++++++ dali/internal/update/nodes/node.cpp | 5 +- 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 5a2f803..05b5732 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -9375,6 +9375,88 @@ int utcDaliActorPartialUpdateChangeParentOpacity(void) END_TEST; } +int utcDaliActorPartialAddRemoveRenderer(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 rect with adding / removing renderer"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor actor = CreateRenderableActor(); + actor[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + actor[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(actor); + + application.SendNotification(); + + std::vector> damagedRects; + + // Actor added, damaged rect is added size of actor + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + Rect clippingRect = Rect(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates + DALI_TEST_EQUALS>(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); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Remove the Renderer + Renderer renderer = actor.GetRendererAt(0); + actor.RemoveRenderer(renderer); + + application.SendNotification(); + + // The damaged rect should be the actor area + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Add the Renderer again + actor.AddRenderer(renderer); + + application.SendNotification(); + + // The damaged rect should be the actor area + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(clippingRect, damagedRects[0], TEST_LOCATION); + + END_TEST; +} + int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void) { TestApplication application; diff --git a/dali/internal/update/nodes/node.cpp b/dali/internal/update/nodes/node.cpp index 459473c..60f1c44 100644 --- a/dali/internal/update/nodes/node.cpp +++ b/dali/internal/update/nodes/node.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -281,6 +281,8 @@ void Node::AddRenderer(Renderer* renderer) } } + SetUpdated(true); + mRenderer.PushBack(renderer); } @@ -291,6 +293,7 @@ void Node::RemoveRenderer(const Renderer* renderer) { if(mRenderer[i] == renderer) { + SetUpdated(true); mRenderer.Erase(mRenderer.Begin() + i); return; } -- 2.7.4