From 511ae6e260dfc6b58898069f9495bdf9f51f8bb9 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Wed, 21 Feb 2018 12:51:52 +0900 Subject: [PATCH] Fix scissor clipping Sibling case should be checked seperately. Change-Id: Ic8531d1c408a61c01ddd792a31b03734c1e95131 --- automated-tests/src/dali/utc-Dali-Actor.cpp | 12 ++++++++++-- dali/internal/render/common/render-algorithms.cpp | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 009280b..9a6f34f 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -4526,8 +4526,8 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) | ┌─────┐─────┐ A C D - | - B + | | + B E */ const Vector2 stageSize( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ); @@ -4535,12 +4535,14 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) const Vector2 sizeB{ stageSize.width, stageSize.height * 0.05f }; const Vector2 sizeC{ stageSize.width, stageSize.height * 0.25f }; const Vector2 sizeD{ stageSize.width, stageSize.height * 0.25f }; + const Vector2 sizeE{ stageSize.width, stageSize.height * 0.05f }; // Create a clipping actors. Actor clippingActorA = CreateActorWithContent( sizeA.width, sizeA.height ); Actor clippingActorB = CreateActorWithContent( sizeB.width, sizeB.height ); Actor clippingActorC = CreateActorWithContent( sizeC.width, sizeC.height ); Actor clippingActorD = CreateActorWithContent( sizeD.width, sizeD.height ); + Actor clippingActorE = CreateActorWithContent( sizeE.width, sizeE.height ); clippingActorA.SetParentOrigin( ParentOrigin::CENTER_LEFT ); clippingActorA.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); @@ -4558,15 +4560,20 @@ int UtcDaliActorPropertyScissorClippingActorNested02(void) clippingActorD.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); clippingActorD.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX ); + clippingActorE.SetParentOrigin( ParentOrigin::CENTER_LEFT ); + clippingActorE.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); + clippingActorA.SetPosition( 0.0f, -200.0f, 0.0f ); clippingActorB.SetPosition( 0.0f, 0.0f, 0.0f ); clippingActorC.SetPosition( 0.0f, 100.0f, 0.0f ); clippingActorD.SetPosition( 0.0f, 0.0f, 0.0f ); + clippingActorE.SetPosition( 0.0f, 0.0f, 0.0f ); Stage::GetCurrent().Add( clippingActorA ); clippingActorA.Add( clippingActorB ); Stage::GetCurrent().Add( clippingActorC ); Stage::GetCurrent().Add( clippingActorD ); + clippingActorD.Add( clippingActorE ); // Gather the call trace. GenerateTrace( application, enabledDisableTrace, scissorTrace ); @@ -4587,6 +4594,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. END_TEST; } diff --git a/dali/internal/render/common/render-algorithms.cpp b/dali/internal/render/common/render-algorithms.cpp index 94658ea..664eb6b 100644 --- a/dali/internal/render/common/render-algorithms.cpp +++ b/dali/internal/render/common/render-algorithms.cpp @@ -244,9 +244,9 @@ inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Cont // So we know if we are at depth 4 and the stackDepth is 5, that we have gone up. // If the depth is the same then we are effectively part of a different sub-tree from the parent, we must also remove the current clip. // Note: Stack depth must always be at least 1, as we will have the layer or stage size as the root value. - if( ( childStackDepth > 0u ) && ( scissorDepth <= childStackDepth ) ) + if( ( childStackDepth > 0u ) && ( scissorDepth < childStackDepth ) ) { - while( scissorDepth <= childStackDepth ) // Pop until sibling + while( scissorDepth < childStackDepth ) { mScissorStack.pop_back(); --childStackDepth; @@ -255,7 +255,7 @@ inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Cont // We traversed up the tree, we need to apply a new scissor rectangle (unless we are at the root). traversedUpTree = true; } - else if( clippingNode && childStackDepth > 0u && childStackDepth == scissorDepth ) // case of sibling clip area + if( clippingNode && childStackDepth > 0u && childStackDepth == scissorDepth ) // case of sibling clip area { mScissorStack.pop_back(); --childStackDepth; -- 2.7.4