From 1d0b9047813cb2e702e814f21f4db568bb0dd0f9 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Fri, 19 May 2023 19:02:59 +0900 Subject: [PATCH] [Tizen] Fix a clipping mode bug Clipping had a bug when it is used with the DrawMode::OVERLAY_2D. The node should be added to the overlayRenderables. Change-Id: I2464ec54551927249cdf8d23ed4e6ebf2a79615f --- automated-tests/src/dali/utc-Dali-Actor.cpp | 181 +++++++++++++++------ .../update/manager/render-task-processor.cpp | 5 +- 2 files changed, 138 insertions(+), 48 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 969f802..06f0dd7 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -297,6 +297,52 @@ struct CulledPropertyNotificationFunctor PropertyNotification& mPropertyNotification; }; +// Clipping test helper functions: +Actor CreateActorWithContent(uint32_t width, uint32_t 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. + actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); + actor.SetProperty(Actor::Property::SIZE, Vector2(width, height)); + actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + + return actor; +} + +Actor CreateActorWithContent16x16() +{ + return CreateActorWithContent(16, 16); +} + +void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& callTrace) +{ + enabledDisableTrace.Reset(); + callTrace.Reset(); + enabledDisableTrace.Enable(true); + callTrace.Enable(true); + + application.SendNotification(); + application.Render(); + + enabledDisableTrace.Enable(false); + callTrace.Enable(false); +} + +void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue) +{ + const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams(); + + DALI_TEST_EQUALS(colorMaskParams.red, maskValue, TEST_LOCATION); + DALI_TEST_EQUALS(colorMaskParams.green, maskValue, TEST_LOCATION); + DALI_TEST_EQUALS(colorMaskParams.blue, maskValue, TEST_LOCATION); + + // @todo only test alpha if the framebuffer has an alpha channel + //DALI_TEST_EQUALS(colorMaskParams.alpha, maskValue, TEST_LOCATION); +} + } // anonymous namespace //& purpose: Testing New API @@ -3389,6 +3435,95 @@ int UtcDaliActorSetDrawModeOverlayRender(void) END_TEST; } +int UtcDaliActorSetDrawModeOverlayWithClipping(void) +{ + TestApplication application; + tet_infoline(" UtcDaliActorSetDrawModeOverlayWithClipping"); + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + + const Vector2 surfaceSize(TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT); + const Vector2 imageSize(16.0f, 16.0f); + + std::vector ids; + ids.push_back(8); // first rendered actor + ids.push_back(9); // second rendered actor + ids.push_back(10); // third rendered actor + ids.push_back(11); // forth rendered actor + application.GetGlAbstraction().SetNextTextureIds(ids); + + Actor a = CreateActorWithContent16x16(); + Actor b = CreateActorWithContent16x16(); + Actor c = CreateActorWithContent16x16(); + Actor d = CreateActorWithContent16x16(); + + application.SendNotification(); + application.Render(); + + //Textures are bound when first created. Clear bound textures vector + application.GetGlAbstraction().ClearBoundTextures(); + + b[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT; + b[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT; + b[Actor::Property::DRAW_MODE] = DrawMode::OVERLAY_2D; + b[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX; + + c[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_LEFT; + c[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_LEFT; + c[Actor::Property::CLIPPING_MODE] = ClippingMode::CLIP_TO_BOUNDING_BOX; + c[Actor::Property::POSITION] = Vector2(100.0f, -100.0f); + + application.GetScene().Add(a); + application.GetScene().Add(b); + application.GetScene().Add(c); + b.Add(d); + + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + const std::vector& boundTextures = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE0); + typedef std::vector::size_type TextureSize; + DALI_TEST_EQUALS(boundTextures.size(), static_cast(4), TEST_LOCATION); + if(boundTextures.size() == 4) + { + DALI_TEST_CHECK(boundTextures[0] == 8u); + DALI_TEST_CHECK(boundTextures[1] == 10u); + DALI_TEST_CHECK(boundTextures[2] == 9u); + DALI_TEST_CHECK(boundTextures[3] == 11u); + } + + // 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. + DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area + DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16")); // Second compare with b area + + application.GetGlAbstraction().ClearBoundTextures(); + + // Remove a Renderer of overlay actor + Renderer renderer = b.GetRendererAt(0); + b.RemoveRenderer(renderer); + + GenerateTrace(application, enabledDisableTrace, scissorTrace); + + DALI_TEST_EQUALS(boundTextures.size(), static_cast(3), TEST_LOCATION); + if(boundTextures.size() == 3) + { + DALI_TEST_CHECK(boundTextures[0] == 8u); + DALI_TEST_CHECK(boundTextures[1] == 10u); + DALI_TEST_CHECK(boundTextures[2] == 11u); + } + + DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(0, "Scissor", "100, 100, 16, 16")); // First compare with c area + DALI_TEST_CHECK(scissorTrace.TestMethodAndParams(1, "Scissor", "0, 0, 16, 16")); // Second compare with b area + + END_TEST; +} + int UtcDaliActorGetCurrentWorldMatrix(void) { TestApplication application; @@ -4470,52 +4605,6 @@ int UtcDaliActorRemoveRendererN(void) END_TEST; } -// Clipping test helper functions: -Actor CreateActorWithContent(uint32_t width, uint32_t 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. - actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - actor.SetProperty(Actor::Property::SIZE, Vector2(width, height)); - actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); - - return actor; -} - -Actor CreateActorWithContent16x16() -{ - return CreateActorWithContent(16, 16); -} - -void GenerateTrace(TestApplication& application, TraceCallStack& enabledDisableTrace, TraceCallStack& stencilTrace) -{ - enabledDisableTrace.Reset(); - stencilTrace.Reset(); - enabledDisableTrace.Enable(true); - stencilTrace.Enable(true); - - application.SendNotification(); - application.Render(); - - enabledDisableTrace.Enable(false); - stencilTrace.Enable(false); -} - -void CheckColorMask(TestGlAbstraction& glAbstraction, bool maskValue) -{ - const TestGlAbstraction::ColorMaskParams& colorMaskParams = glAbstraction.GetColorMaskParams(); - - DALI_TEST_EQUALS(colorMaskParams.red, maskValue, TEST_LOCATION); - DALI_TEST_EQUALS(colorMaskParams.green, maskValue, TEST_LOCATION); - DALI_TEST_EQUALS(colorMaskParams.blue, 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) { // This test checks the clippingMode property. diff --git a/dali/internal/update/manager/render-task-processor.cpp b/dali/internal/update/manager/render-task-processor.cpp index 0da46fc..275229b 100644 --- a/dali/internal/update/manager/render-task-processor.cpp +++ b/dali/internal/update/manager/render-task-processor.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -156,7 +156,8 @@ bool AddRenderablesForTask(BufferIndex updateBufferIndex, // If we do not have any renderers, create one to house the scissor operation. if(count == 0u) { - layer->colorRenderables.PushBack(Renderable(&node, nullptr)); + RenderableContainer& target = (inheritedDrawMode == DrawMode::NORMAL) ? layer->colorRenderables : layer->overlayRenderables; + target.PushBack(Renderable(&node, nullptr)); } } else -- 2.7.4