Bug 135483

Summary: TextureMapperGL stencil bug
Product: WebKit Reporter: abaldeva
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: hw1008.kim, ryuan.choi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
GTK Screen shot of Falling Leaves none

Description abaldeva 2014-07-31 17:19:45 PDT
Hi,

Going through the TextureMapperGL implementation, I see that BeginClip advances the bit plane to the next 

clipStack().setStencilIndex(stencilIndex * 2);

However, EndClip does not revert it back before calling clipStack().applyIfNeeded(m_context3D.get());

The applyIfNeeded disables stencil test only if stencilIndex is 1.

if (clipState.stencilIndex == 1)
        context->disable(GraphicsContext3D::STENCIL_TEST);
    else
        context->enable(GraphicsContext3D::STENCIL_TEST); 

There is no place in the code that is attempting to reverse the impact of BeginClip. Isn’t a right bit shift required in the EndClip call before the applyIfNeeded call? Otherwise, I don’t see how EndClip will disable stenciling test ever. The problem is probably more obvious if you have nested clipping. 

You can also see the problem on classing falling leaves demo. The leaves are visible outside the center container.You'll first need to disable the scissor based clipping otherwise the stencil path would be optimized and never hit. 

Previous related changes - http://trac.webkit.org/changeset/108696 

--Arpit
Comment 1 abaldeva 2014-07-31 18:08:24 PDT
I don't have GTK port running but looking closer, I think .pop will do the trick of lowering the bit plane.

I'll continue to investigate on my implementation and let you know the result.
Comment 2 Byungseon(Sun) Shin 2014-07-31 18:17:13 PDT
Created attachment 235865 [details]
GTK Screen shot of Falling Leaves

FYI, I have tested GTK build based on latest upstream master branch and couldn't found any issues.
Comment 3 abaldeva 2014-08-05 10:19:37 PDT
After further investigation, the bug report was a mistake on my end. My apologies.

--Arpit