X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-Actor.cpp;h=5a2f803585ff7b2ee8e8eb90888d010a8d2e2264;hb=6348e5bb26d2f42f92246ae849974ee430b57297;hp=75835a4dd72b777e3717c1fd149858781d62b683;hpb=a9016c993fd9abe44735ffc58a6e425039773737;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 75835a4..5a2f803 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.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. @@ -26,6 +26,7 @@ #include #include #include +#include #include // For FLT_MAX #include @@ -636,6 +637,32 @@ int UtcDaliActorRemoveP(void) END_TEST; } +int UtcDaliActorSwitchParentN(void) +{ + tet_infoline("Testing Actor::UtcDaliActorSwitchParentN"); + TestApplication application; + + Actor parent1 = Actor::New(); + Actor child = Actor::New(); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION); + + parent1.Add(child); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION); + + Actor parent2 = Actor::New(); + + DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION); + + // Try switch parent with that both of parent1 and parent2 are off scene. + DevelActor::SwitchParent(child, parent2); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(parent2.GetChildCount(), 0u, TEST_LOCATION); + END_TEST; +} + int UtcDaliActorGetChildCount(void) { TestApplication application; @@ -2523,6 +2550,54 @@ int UtcDaliActorIsKeyboardFocusable(void) END_TEST; } +int UtcDaliActorSetKeyboardFocusableChildren(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, true); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true); + + actor.SetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN, false); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == false); + END_TEST; +} + +int UtcDaliActorAreChildrenKeyBoardFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) == true); + END_TEST; +} + +int UtcDaliActorSetTouchFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == true); + + actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == false); + END_TEST; +} + +int UtcDaliActorIsTouchFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == false); + END_TEST; +} + int UtcDaliActorRemoveConstraints(void) { tet_infoline(" UtcDaliActorRemoveConstraints"); @@ -2963,9 +3038,9 @@ int UtcDaliActorSetDrawModeOverlayRender(void) ids.push_back(10); // third rendered actor application.GetGlAbstraction().SetNextTextureIds(ids); - Texture imageA = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); - Texture imageB = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); - Texture imageC = Texture::New(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); + Texture imageA = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); + Texture imageB = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); + Texture imageC = CreateTexture(TextureType::TEXTURE_2D, Pixel::Format::RGBA8888, 16, 16); Actor a = CreateRenderableActor(imageA); Actor b = CreateRenderableActor(imageB); Actor c = CreateRenderableActor(imageC); @@ -4104,7 +4179,7 @@ int UtcDaliActorRemoveRendererN(void) // Clipping test helper functions: Actor CreateActorWithContent(uint32_t width, uint32_t height) { - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height); + Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height); Actor actor = CreateRenderableActor(image); // Setup dimensions and position so actor is not skipped by culling. @@ -4142,7 +4217,9 @@ void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue) DALI_TEST_EQUALS(colorMaskParams.red, maskValue, TEST_LOCATION); DALI_TEST_EQUALS(colorMaskParams.green, maskValue, TEST_LOCATION); DALI_TEST_EQUALS(colorMaskParams.blue, maskValue, TEST_LOCATION); - DALI_TEST_EQUALS(colorMaskParams.alpha, maskValue, TEST_LOCATION); + + // @todo only test alpha if the framebuffer has an alpha channel + //DALI_TEST_EQUALS(colorMaskParams.alpha, maskValue, TEST_LOCATION); } int UtcDaliActorPropertyClippingP(void) @@ -4251,7 +4328,9 @@ int UtcDaliActorPropertyClippingActor(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream oss; + oss << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str())); // Check the stencil buffer was cleared. DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex)); @@ -4287,7 +4366,9 @@ int UtcDaliActorPropertyClippingActorEnableThenDisable(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream oss; + oss << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str())); // Check the stencil buffer was cleared. DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("ClearStencil", "0", startIndex)); @@ -4304,7 +4385,9 @@ int UtcDaliActorPropertyClippingActorEnableThenDisable(void) GenerateTrace(application, enabledDisableTrace, stencilTrace); // Check the stencil buffer was disabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream stencil; + stencil << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Disable", stencil.str())); // Ensure all values in stencil-mask are set to 1. startIndex = 0u; @@ -4351,7 +4434,9 @@ int UtcDaliActorPropertyClippingNestedChildren(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream oss; + oss << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", oss.str())); // Perform the test twice, once for 2D layer, and once for 3D. for(unsigned int i = 0u; i < 2u; ++i) @@ -4412,7 +4497,7 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void) Actor actors[5]; for(int i = 0; i < 5; ++i) { - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u); + Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u); Actor actor = CreateRenderableActor(image); // Setup dimensions and position so actor is not skipped by culling. @@ -4458,10 +4543,15 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void) Note: Correct enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 StackTrace: Index:2, Function:Disable, ParamList:2960 Incorrect enable call trace: StackTrace: Index:0, Function:Enable, ParamList:3042 StackTrace: Index:1, Function:Enable, ParamList:2960 */ - size_t startIndex = 0u; - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "3042", startIndex)); - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); // 2960 is GL_STENCIL_TEST - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex)); + size_t startIndex = 0u; + std::ostringstream blend; + blend << std::hex << GL_BLEND; + std::ostringstream stencil; + stencil << std::hex << GL_STENCIL_TEST; + + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", blend.str(), startIndex)); + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex)); + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex)); // Swap the clipping actor from top of left branch to top of right branch. actors[1].SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED); @@ -4477,13 +4567,13 @@ int UtcDaliActorPropertyClippingActorDrawOrder(void) // Check stencil is enabled but NOT disabled again (as right-hand branch of tree is drawn). // This proves the draw order has remained the same. startIndex = 0u; - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", "2960", startIndex)); - DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", "2960", startIndex)); + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParamsFromStartIndex("Enable", stencil.str(), startIndex)); + DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParamsFromStartIndex("Disable", stencil.str(), startIndex)); END_TEST; } -int UtcDaliActorPropertyScissorClippingActor(void) +int UtcDaliActorPropertyScissorClippingActor01(void) { // This test checks that an actor is correctly setup for clipping. tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor"); @@ -4512,7 +4602,10 @@ int UtcDaliActorPropertyScissorClippingActor(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. std::stringstream compareParametersString; @@ -4534,6 +4627,68 @@ int UtcDaliActorPropertyScissorClippingActor(void) END_TEST; } +int UtcDaliActorPropertyScissorClippingActor02(void) +{ + // This test checks that an actor is correctly setup for clipping. + tet_infoline("Testing Actor::Property::ClippingMode: CLIP_TO_BOUNDING_BOX actor with a transparent renderer"); + TestApplication application; + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + + const Vector2 stageSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + const Vector2 actorSize(16.0f, 16.0f); + + // Create a clipping actor. + Actor clippingActorA = CreateRenderableActor(); + clippingActorA[Actor::Property::SIZE] = actorSize; + + Renderer renderer = clippingActorA.GetRendererAt(0); + DALI_TEST_CHECK(renderer); + + // Make Renderer opacity 0. + renderer[DevelRenderer::Property::OPACITY] = 0.0f; + + // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system. + // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test. + clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_LEFT); + clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_LEFT); + clippingActorA.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX); + application.GetScene().Add(clippingActorA); + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check we are writing to the color buffer. + CheckColorMask(glAbstraction, true); + + // Check scissor test was enabled. + + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); + + // Check the scissor was set, and the coordinates are correct. + std::stringstream compareParametersString; + compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16 + + clippingActorA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_RIGHT); + clippingActorA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_RIGHT); + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check the scissor was set, and the coordinates are correct. + compareParametersString.str(std::string()); + compareParametersString.clear(); + compareParametersString << (stageSize.x - actorSize.x) << ", " << (stageSize.y - actorSize.y) << ", " << actorSize.x << ", " << actorSize.y; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 464, 784, 16, 16 + + END_TEST; +} + int UtcDaliActorPropertyScissorClippingActorSiblings(void) { // This test checks that an actor is correctly setup for clipping. @@ -4573,7 +4728,9 @@ int UtcDaliActorPropertyScissorClippingActorSiblings(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. std::stringstream compareParametersString; @@ -4652,7 +4809,9 @@ int UtcDaliActorPropertyScissorClippingActorNested01(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. const Vector4& expectResults(expect[test]); @@ -4736,7 +4895,9 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) CheckColorMask(glAbstraction, true); // Check scissor test was enabled. - DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); // Check the scissor was set, and the coordinates are correct. std::string clipA("0, 500, 480, 200"); @@ -4748,7 +4909,7 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipB)); DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipC)); DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", clipD)); - DALI_TEST_CHECK(scissorTrace.CountMethod("Scissor") == 4); // Scissor rect should not be changed in clippingActorE case. So count should be 4. + DALI_TEST_EQUALS(scissorTrace.CountMethod("Scissor"), 4, TEST_LOCATION); // Scissor rect should not be changed in clippingActorE case. So count should be 4. END_TEST; } @@ -4778,12 +4939,14 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void) CheckColorMask(glAbstraction, true); // Check the stencil buffer was not enabled. - DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "2960")); // 2960 is GL_STENCIL_TEST + std::ostringstream stencil; + stencil << std::hex << GL_STENCIL_TEST; + DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", stencil.str())); // Check stencil functions are not called. DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilFunc")); // TODO: Temporarily commented out the line below when caching is disabled. Will need to add it back. -// DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask")); + // DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilMask")); DALI_TEST_CHECK(!stencilTrace.FindMethod("StencilOp")); // Check that scissor clipping is overriden by the renderer properties. @@ -4795,13 +4958,73 @@ int UtcDaliActorPropertyClippingActorWithRendererOverride(void) GenerateTrace(application, enabledDisableTrace, scissorTrace); // Check the stencil buffer was not enabled. - DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", "3089")); // 3089 = 0xC11 (GL_SCISSOR_TEST) + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(!enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); DALI_TEST_CHECK(!scissorTrace.FindMethod("StencilFunc")); END_TEST; } +int UtcDaliActorPropertyClippingActorCulled(void) +{ + // This test checks that child actors are clipped by an culled parent actor. + tet_infoline("Testing child actors are clipped by an culled parent actor"); + TestApplication application; + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + + const Vector2 actorSize(160.0f, 160.0f); + + // Create a clipping actor. + Actor clippingActorA = CreateRenderableActor(); + clippingActorA[Actor::Property::SIZE] = actorSize; + + // Note: Scissor coords are have flipped Y values compared with DALi's coordinate system. + // We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test. + clippingActorA[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT; + clippingActorA[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT; + clippingActorA[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX; + application.GetScene().Add(clippingActorA); + + // Create a child actor + Actor childActor = CreateRenderableActor(); + childActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT; + childActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT; + childActor[Actor::Property::SIZE] = Vector2(50.0f, 50.0f); + childActor[Actor::Property::INHERIT_POSITION] = false; + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check scissor test was enabled. + std::ostringstream scissor; + scissor << std::hex << GL_SCISSOR_TEST; + DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", scissor.str())); + + // Check the scissor was set, and the coordinates are correct. + std::stringstream compareParametersString; + compareParametersString << "0, 0, " << actorSize.x << ", " << actorSize.y; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Compare with 0, 0, 16, 16 + + // Move the clipping actor out of screen + clippingActorA[Actor::Property::POSITION] = Vector2(2000.0f, 2000.0f); + + // Gather the call trace. + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + // Check the scissor was set, and the coordinates are correct. + compareParametersString.str(std::string()); + compareParametersString.clear(); + compareParametersString << 2000 << ", " << 0 << ", " << 0 << ", " << 0; + DALI_TEST_CHECK(scissorTrace.FindMethodAndParams("Scissor", compareParametersString.str())); // Clipping area should be empty. + + END_TEST; +} + int UtcDaliGetPropertyN(void) { tet_infoline("Testing Actor::GetProperty returns a non valid value if property index is out of range"); @@ -5025,9 +5248,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace Output:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); bool CBA = (indexC > indexB) && (indexB > indexA); @@ -5069,8 +5292,7 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5078,9 +5300,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing A above C and B at bottom\n"); bool ACB = (indexA > indexC) && (indexC > indexB); @@ -5106,8 +5328,7 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5115,9 +5336,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing B above A and C at bottom\n"); bool BAC = (indexB > indexA) && (indexA > indexC); @@ -5154,8 +5375,7 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5163,9 +5383,9 @@ int UtcDaliActorRaiseToTopLowerToBottom(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing C above A and B at bottom\n"); bool CAB = (indexC > indexA) && (indexA > indexB); @@ -5482,14 +5702,12 @@ int UtcDaliActorLowerBelow(void) application.SendNotification(); application.Render(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); - tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing C above B and A at bottom\n"); bool CBA = (indexC > indexB) && (indexB > indexA); @@ -5536,8 +5754,7 @@ int UtcDaliActorLowerBelow(void) application.ProcessEvent(touchEvent); // touch event - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5545,9 +5762,9 @@ int UtcDaliActorLowerBelow(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing render order is A, C, B"); DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION); @@ -5574,16 +5791,15 @@ int UtcDaliActorLowerBelow(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.Render(); tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION); @@ -5609,16 +5825,15 @@ int UtcDaliActorLowerBelow(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.Render(); tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION); DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); @@ -5707,14 +5922,12 @@ int UtcDaliActorLowerBelow2(void) application.SendNotification(); application.Render(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); - tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + int indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + int indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + int indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing C above B and A at bottom\n"); bool CBA = (indexC > indexB) && (indexB > indexA); @@ -5761,8 +5974,7 @@ int UtcDaliActorLowerBelow2(void) application.ProcessEvent(touchEvent); // touch event - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.SendNotification(); application.Render(); @@ -5770,9 +5982,9 @@ int UtcDaliActorLowerBelow2(void) tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); tet_infoline("Testing render order is A, C, B"); DALI_TEST_EQUALS(indexC > indexA, true, TEST_LOCATION); @@ -5799,16 +6011,15 @@ int UtcDaliActorLowerBelow2(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.Render(); tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); DALI_TEST_EQUALS(indexB > indexA, true, TEST_LOCATION); @@ -5834,16 +6045,15 @@ int UtcDaliActorLowerBelow2(void) application.ProcessEvent(touchEvent); - glAbstraction.ResetSetUniformCallStack(); - glSetUniformStack = glAbstraction.GetSetUniformTrace(); + glSetUniformStack.Reset(); application.Render(); tet_printf("Trace:%s \n", glSetUniformStack.GetTraceString().c_str()); // Test order of uniforms in stack - indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3"); - indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2"); - indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1"); + indexC = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "3.000000"); + indexB = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "2.000000"); + indexA = glSetUniformStack.FindIndexFromMethodAndParams("uRendererColor", "1.000000"); DALI_TEST_EQUALS(indexC > indexB, true, TEST_LOCATION); DALI_TEST_EQUALS(indexA > indexC, true, TEST_LOCATION); @@ -7559,6 +7769,61 @@ int UtcDaliChildMovedSignalP(void) END_TEST; } +int UtcDaliActorSwitchParentP(void) +{ + tet_infoline("Testing Actor::UtcDaliActorSwitchParentP"); + TestApplication application; + + Actor parent1 = Actor::New(); + Actor child = Actor::New(); + + application.GetScene().Add(parent1); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION); + + child.OnSceneSignal().Connect(OnSceneCallback); + child.OffSceneSignal().Connect(OffSceneCallback); + + // sanity check + DALI_TEST_CHECK(gOnSceneCallBackCalled == 0); + DALI_TEST_CHECK(gOffSceneCallBackCalled == 0); + + parent1.Add(child); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 1u, TEST_LOCATION); + + DALI_TEST_CHECK(gOnSceneCallBackCalled == 1); + DALI_TEST_CHECK(gOffSceneCallBackCalled == 0); + + Actor parent2 = Actor::New(); + application.GetScene().Add(parent2); + + bool addSignalReceived = false; + ChildAddedSignalCheck addedSignal(addSignalReceived, child); + DevelActor::ChildAddedSignal(application.GetScene().GetRootLayer()).Connect(&application, addedSignal); + DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION); + + bool removedSignalReceived = false; + ChildRemovedSignalCheck removedSignal(removedSignalReceived, child); + DevelActor::ChildRemovedSignal(application.GetScene().GetRootLayer()).Connect(&application, removedSignal); + DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION); + + DevelActor::SwitchParent(child, parent2); + + DALI_TEST_EQUALS(addSignalReceived, false, TEST_LOCATION); + DALI_TEST_EQUALS(removedSignalReceived, false, TEST_LOCATION); + + DALI_TEST_EQUALS(parent1.GetChildCount(), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(parent2.GetChildCount(), 1u, TEST_LOCATION); + + DALI_TEST_CHECK(gOnSceneCallBackCalled == 1); + DALI_TEST_CHECK(gOffSceneCallBackCalled == 0); + DALI_TEST_CHECK(child.GetProperty(Dali::Actor::Property::CONNECTED_TO_SCENE)); + DALI_TEST_CHECK(child.GetParent() == parent2); + + END_TEST; +} + int utcDaliActorCulled(void) { TestApplication application; @@ -7858,6 +8123,139 @@ int utcDaliActorGetSizeAfterAnimation(void) END_TEST; } +int utcDaliActorRelayoutAndAnimation(void) +{ + TestApplication application; + tet_infoline("Check the actor size when relayoutting and playing animation"); + + Vector3 parentSize(300.0f, 300.0f, 0.0f); + Vector3 actorSize(100.0f, 100.0f, 0.0f); + + { + Actor parentA = Actor::New(); + parentA.SetProperty(Actor::Property::SIZE, parentSize); + parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentA); + + Actor parentB = Actor::New(); + parentB.SetProperty(Actor::Property::SIZE, parentSize); + parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentB); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, actorSize); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parentA.Add(actor); + + Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 targetValue(200.0f, 200.0f, 0.0f); + + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue); + animation.Play(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(1100); // After the animation + + // Size and current size should be updated. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // Trigger relayout + parentB.Add(actor); + + application.SendNotification(); + application.Render(); + + // Size and current size should be same. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + actor.Unparent(); + parentA.Unparent(); + parentB.Unparent(); + } + + { + Actor parentA = Actor::New(); + parentA.SetProperty(Actor::Property::SIZE, parentSize); + parentA.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentA); + + Actor parentB = Actor::New(); + parentB.SetProperty(Actor::Property::SIZE, parentSize); + parentB.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parentB); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, actorSize); + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parentA.Add(actor); + + Vector3 size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, actorSize, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + Vector3 targetValue(200.0f, 200.0f, 0.0f); + + // Make an animation + Animation animation = Animation::New(1.0f); + animation.AnimateTo(Property(actor, Actor::Property::SIZE), targetValue); + animation.Play(); + + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + application.SendNotification(); + application.Render(1100); // After the animation + + // Size and current size should be updated. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + // Trigger relayout + parentB.Add(actor); + + application.SendNotification(); + application.Render(); + + // Size and current size should be same. + size = actor.GetProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(size, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + currentSize = actor.GetCurrentProperty(Actor::Property::SIZE).Get(); + DALI_TEST_EQUALS(currentSize, targetValue, Math::MACHINE_EPSILON_0, TEST_LOCATION); + + actor.Unparent(); + parentA.Unparent(); + parentB.Unparent(); + } + + END_TEST; +} + int utcDaliActorPartialUpdate(void) { TestApplication application( @@ -7879,6 +8277,8 @@ int utcDaliActorPartialUpdate(void) // First render pass, nothing to render, adaptor would just do swap buffer. DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); Actor actor = CreateRenderableActor(); @@ -7984,6 +8384,8 @@ int utcDaliActorPartialUpdateSetColor(void) // First render pass, nothing to render, adaptor would just do swap buffer. DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); Actor actor = CreateRenderableActor(); @@ -8079,9 +8481,11 @@ int utcDaliActorPartialUpdateSetProperty(void) // First render pass, nothing to render, adaptor would just do swap buffer. DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); - Texture image = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u); + Texture image = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 4u, 4u); Actor actor = CreateRenderableActor(image, RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE); actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f)); @@ -8191,6 +8595,31 @@ int utcDaliActorPartialUpdateTwoActors(void) DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION); DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION); + // Change a Renderer of actor1 + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer newRenderer = Renderer::New(geometry, shader); + Renderer renderer = actor.GetRendererAt(0); + + actor.RemoveRenderer(renderer); + actor.AddRenderer(newRenderer); + + damagedRects.clear(); + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::DEFAULT_RENDER_INTERVAL, nullptr, damagedRects); + + DALI_TEST_CHECK(damagedRects.size() > 0); + DALI_TEST_EQUALS>(Rect(64, 672, 64, 64), damagedRects[0], TEST_LOCATION); + + // in screen coordinates, adaptor would calculate it using previous frames information + 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); + END_TEST; } @@ -8275,9 +8704,11 @@ int utcDaliActorPartialUpdateAnimation(void) DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); DALI_TEST_EQUALS>(expectedRect2, damagedRects[1], TEST_LOCATION); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); damagedRects.clear(); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8289,6 +8720,7 @@ int utcDaliActorPartialUpdateAnimation(void) application.SendNotification(); damagedRects.clear(); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8296,6 +8728,7 @@ int utcDaliActorPartialUpdateAnimation(void) damagedRects.clear(); // In animation deley time + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8306,6 +8739,7 @@ int utcDaliActorPartialUpdateAnimation(void) damagedRects.clear(); // Also in animation deley time + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.PreRenderWithPartialUpdate(100, nullptr, damagedRects); application.RenderWithPartialUpdate(damagedRects, clippingRect); @@ -8333,20 +8767,614 @@ int utcDaliActorPartialUpdateAnimation(void) DALI_TEST_EQUALS>(expectedRect2, damagedRects[0], TEST_LOCATION); DALI_TEST_EQUALS>(expectedRect1, damagedRects[1], TEST_LOCATION); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); - // Finished animation, but the actior was already unparented + // Finished animation, but the actor was already unparented damagedRects.clear(); application.PreRenderWithPartialUpdate(500, nullptr, damagedRects); DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); DALI_TEST_EQUALS>(expectedRect2, damagedRects[0], TEST_LOCATION); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; application.RenderWithPartialUpdate(damagedRects, clippingRect); END_TEST; } +int utcDaliActorPartialUpdateChangeVisibility(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 partial update and visibility change"); + + 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); + + application.SendNotification(); + + std::vector> damagedRects; + Rect clippingRect; + + // 1. 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 + 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); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // 2. Make the Actor invisible + actor.SetProperty(Actor::Property::VISIBLE, false); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + 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); + + // 3. Make the Actor visible again + actor.SetProperty(Actor::Property::VISIBLE, true); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + 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); + + END_TEST; +} + +int utcDaliActorPartialUpdateOnOffScene(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 partial update and on/off scene"); + + 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); + + application.SendNotification(); + + std::vector> damagedRects; + Rect clippingRect; + + // 1. 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 + 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); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // 2. Remove the Actor from the Scene + actor.Unparent(); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + 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); + + // 3. Add the Actor to the Scene again + application.GetScene().Add(actor); + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + DALI_TEST_CHECK(damagedRects.size() > 0); + 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); + + END_TEST; +} + +int utcDaliActorPartialUpdateSkipRendering(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Check to skip rendering in case of the empty damaged rect"); + + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + drawTrace.Reset(); + + Actor actor1 = CreateRenderableActor(); + actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f)); + application.GetScene().Add(actor1); + + std::vector> damagedRects; + Rect clippingRect; + Rect expectedRect1; + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + // Aligned by 16 + expectedRect1 = Rect(0, 720, 96, 96); // in screen coordinates, includes 3 last frames updates + DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + damagedRects.clear(); + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Remove the actor + actor1.Unparent(); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Render again without any change + damagedRects.clear(); + drawTrace.Reset(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + clippingRect = Rect(); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Skip rendering + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION); + + // Add the actor again + application.GetScene().Add(actor1); + + application.SendNotification(); + + damagedRects.clear(); + drawTrace.Reset(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS>(expectedRect1, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdate3DNode(void) +{ + TestApplication application( + TestApplication::DEFAULT_SURFACE_WIDTH, + TestApplication::DEFAULT_SURFACE_HEIGHT, + TestApplication::DEFAULT_HORIZONTAL_DPI, + TestApplication::DEFAULT_VERTICAL_DPI, + true, + true); + + tet_infoline("Partial update should be ignored in case of 3d layer of 3d node"); + + TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); + drawTrace.Enable(true); + drawTrace.Reset(); + + Actor actor1 = CreateRenderableActor(); + actor1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + actor1.SetProperty(Actor::Property::SIZE, Vector3(80.0f, 80.0f, 0.0f)); + application.GetScene().Add(actor1); + + std::vector> damagedRects; + Rect clippingRect; + + application.SendNotification(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + // Change the layer to 3D + application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + drawTrace.Reset(); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + // Change the layer to 2D + application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_UI); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + // Make 3D transform + actor1.SetProperty(Actor::Property::ORIENTATION, Quaternion(Degree(90.0f), Vector3::YAXIS)); + + application.SendNotification(); + + damagedRects.clear(); + application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects); + + DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION); + DALI_TEST_EQUALS>(TestApplication::DEFAULT_SURFACE_RECT, damagedRects[0], TEST_LOCATION); + + clippingRect = TestApplication::DEFAULT_SURFACE_RECT; + drawTrace.Reset(); + application.RenderWithPartialUpdate(damagedRects, clippingRect); + + DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateNotRenderableActor(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 not renderable parent actor"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor parent = Actor::New(); + parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parent); + + Actor child = CreateRenderableActor(); + child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parent.Add(child); + + application.SendNotification(); + + std::vector> damagedRects; + + // 1. 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); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + END_TEST; +} + +int utcDaliActorPartialUpdateChangeTransparency(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 changing transparency"); + + 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); + + // Make the actor transparent by changing opacity of the Renderer + // It changes a uniform value + Renderer renderer = actor.GetRendererAt(0); + renderer[DevelRenderer::Property::OPACITY] = 0.0f; + + application.SendNotification(); + + // The damaged rect should be same + 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); + + // Make the actor opaque again + renderer[DevelRenderer::Property::OPACITY] = 1.0f; + + application.SendNotification(); + + // The damaged rect should not be empty + 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); + + 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); + + // Make the actor culled + actor[Actor::Property::SIZE] = Vector3(0.0f, 0.0f, 0.0f); + + application.SendNotification(); + + // The damaged rect should be same + 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); + + // Make the actor not culled again + actor[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 16.0f); + + application.SendNotification(); + + // The damaged rect should not be empty + 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 utcDaliActorPartialUpdateChangeParentOpacity(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 changing parent's opacity"); + + const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams()); + + Actor parent = Actor::New(); + parent[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + parent[Actor::Property::POSITION] = Vector3(16.0f, 16.0f, 0.0f); + parent[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + parent.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + application.GetScene().Add(parent); + + Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 16u, 16u); + Actor child = CreateRenderableActor(texture); + child[Actor::Property::ANCHOR_POINT] = AnchorPoint::TOP_LEFT; + child[Actor::Property::SIZE] = Vector3(16.0f, 16.0f, 0.0f); + child.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + parent.Add(child); + + 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); + + // Ensure the damaged rect is empty + DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION); + + // Change the parent's opacity + parent[Actor::Property::OPACITY] = 0.5f; + + application.SendNotification(); + + // The damaged rect should be same + 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); + + END_TEST; +} + int UtcDaliActorCaptureAllTouchAfterStartPropertyP(void) { TestApplication application; @@ -8387,20 +9415,20 @@ int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void) END_TEST; } -int UtcDaliActorTouchAreaPropertyP(void) +int UtcDaliActorTouchAreaOffsetPropertyP(void) { TestApplication application; - Actor actor = Actor::New(); - Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get(); - DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f)); - touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get(); - DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION); + Actor actor = Actor::New(); + Rect touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get>(); + DALI_TEST_EQUALS(Rect(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect(10, 20, 30, 40)); + touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get>(); + DALI_TEST_EQUALS(Rect(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION); END_TEST; } -int UtcDaliActorTouchAreaPropertyN(void) +int UtcDaliActorTouchAreaOffsetPropertyN(void) { TestApplication application; @@ -8409,12 +9437,12 @@ int UtcDaliActorTouchAreaPropertyN(void) // Make sure setting invalid types does not cause a crash try { - actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map()); - actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array()); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map()); + actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array()); tet_result(TET_PASS); } catch(...)