From 3aa3eaf2d3ef5419119baea0b7c4c0f918b45803 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Fri, 6 Jan 2017 09:39:03 +0000 Subject: [PATCH] Ensure clipping gets disabled properly when previously enabled The clipping sort modifier is used to retrieve the clipping ID but is not cleared when we disable clipping. Change-Id: Icfea7d7115fe24574edd5a058d65229621e75ae8 --- automated-tests/src/dali/utc-Dali-Actor.cpp | 50 +++++++++++++++++++++++++++++ dali/internal/update/nodes/node.h | 7 +++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index b5f360a..74be89d 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -3729,6 +3729,56 @@ int UtcDaliActorPropertyClippingActor(void) END_TEST; } +int UtcDaliActorPropertyClippingActorEnableThenDisable(void) +{ + // This test checks that an actor is correctly setup for clipping and then correctly setup when clipping is disabled + tet_infoline( "Testing Actor::Property::CLIPPING_MODE actor enable and then disable" ); + TestApplication application; + + TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); + TraceCallStack& stencilTrace = glAbstraction.GetStencilFunctionTrace(); + TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace(); + size_t startIndex = 0u; + + // Create a clipping actor. + Actor actorDepth1Clip = CreateActorWithContent(); + actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); + Stage::GetCurrent().Add( actorDepth1Clip ); + + // Gather the call trace. + GenerateTrace( application, enabledDisableTrace, stencilTrace ); + + // Check we are writing to the color buffer. + CheckColorMask( glAbstraction, true ); + + // Check the stencil buffer was enabled. + DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2960" ) ); // 2960 is GL_STENCIL_TEST + + // Check the stencil buffer was cleared. + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "ClearStencil", "0", startIndex ) ); + + // Check the correct setup was done to write to the first bit-plane (only) of the stencil buffer. + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilFunc", "514, 1, 0", startIndex ) ); // 514 is GL_EQUAL, But testing no bit-planes for the first clipping node. + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "1", startIndex ) ); + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilOp", "7680, 7681, 7681", startIndex ) ); // GL_KEEP, GL_REPLACE, GL_REPLACE + + // Now disable the clipping + actorDepth1Clip.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::DISABLED ); + + // Gather the call trace. + GenerateTrace( application, enabledDisableTrace, stencilTrace ); + + // Check the stencil buffer was disabled. + DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Disable", "2960" ) ); // 2960 is GL_STENCIL_TEST + + // Ensure all values in stencil-mask are set to 1. + startIndex = 0u; + DALI_TEST_CHECK( stencilTrace.FindMethodAndParamsFromStartIndex( "StencilMask", "255", startIndex ) ); + + END_TEST; +} + + int UtcDaliActorPropertyClippingNestedChildren(void) { // This test checks that a hierarchy of actors are clipped correctly by diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index 6e3f98d..fab6e7e 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_NODE_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -164,6 +164,11 @@ public: // clipping enabled flag and set it as the least significant bit. mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u ); } + else + { + // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either. + mClippingSortModifier = 0u; + } } /** -- 2.7.4