Bug 94050 - [chromium] set scissorRect per quad so that quads are correctly clipped
Summary: [chromium] set scissorRect per quad so that quads are correctly clipped
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Shawn Singh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-14 17:11 PDT by Shawn Singh
Modified: 2012-08-16 16:27 PDT (History)
6 users (show)

See Also:


Attachments
Patch (7.70 KB, patch)
2012-08-15 10:17 PDT, Shawn Singh
no flags Details | Formatted Diff | Diff
Addressed Dana's comment, still uses always-scissor approach (7.93 KB, patch)
2012-08-15 13:06 PDT, Shawn Singh
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from gce-cr-linux-04 (568.92 KB, application/zip)
2012-08-15 17:10 PDT, WebKit Review Bot
no flags Details
Patch for landing (8.85 KB, patch)
2012-08-16 01:37 PDT, Shawn Singh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Singh 2012-08-14 17:11:18 PDT
Currently, some quad types draw their entire contentBounds instead of only their visibleRect, and they rely on scissoring to correctly clip the layers.  This is proposed to be refactored in https://bugs.webkit.org/show_bug.cgi?id=94049, but in the meantime, for correctness we need to do per-quad scissoring so that all layer types are correctly clipped.   Before fixing this, after a recent refactor, scissoring is done only per-surface and results in incorrect unclipped layers for layers such as canvas.
Comment 1 Shawn Singh 2012-08-14 17:19:21 PDT
The fix is quite straightforward, but i'm not sure if we have a good way to unit test this.  So I'll see if a layout test can cover the issue instead.
Comment 2 Shawn Singh 2012-08-15 10:17:45 PDT
Created attachment 158586 [details]
Patch

passes all unit tests and layout tests on osx.  In this patch I opted for the always-scissor approach.  I felt like adding more logic to turn off scissoring was over-engineering the solution without enough evidence that it's worth the savings. If you want I can make a different solution that adds a bit more logic passed into drawQuad, so that the quad can decide for itself whether to turn off scissoring or not.  But, especially if we do intend to refactor quad types to draw only their clipped/visible bounds, then maybe this solution is better to keep things simple.
Comment 3 Dana Jansens 2012-08-15 10:21:51 PDT
Comment on attachment 158586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review

> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
> -    else
> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));

This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
Comment 4 Shawn Singh 2012-08-15 10:24:08 PDT
(In reply to comment #3)
> (From update of attachment 158586 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review
> 
> > Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
> > -    else
> > -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
> 
> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.

Thanks - good catch =)

But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
Comment 5 Shawn Singh 2012-08-15 10:24:50 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 158586 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review
> > 
> > > Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
> > > -    else
> > > -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
> > 
> > This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
> 
> Thanks - good catch =)
> 
> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.

to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.
Comment 6 Dana Jansens 2012-08-15 10:25:15 PDT
Comment on attachment 158586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review

>>>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
>>>> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
>>> 
>>> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
>> 
>> Thanks - good catch =)
>> 
>> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
> 
> to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.

Is that better? It differs from how the code was before I touched any of this, so I defer to enne on that.
Comment 7 Adrienne Walker 2012-08-15 10:44:28 PDT
Comment on attachment 158586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review

>>>>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
>>>>> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
>>>> 
>>>> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
>>> 
>>> Thanks - good catch =)
>>> 
>>> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
>> 
>> to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.
> 
> Is that better? It differs from how the code was before I touched any of this, so I defer to enne on that.

Why are you setting the scissor in two places?
Comment 8 Dana Jansens 2012-08-15 10:49:05 PDT
Comment on attachment 158586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review

>>>>>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
>>>>>> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
>>>>> 
>>>>> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
>>>> 
>>>> Thanks - good catch =)
>>>> 
>>>> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
>>> 
>>> to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.
>> 
>> Is that better? It differs from how the code was before I touched any of this, so I defer to enne on that.
> 
> Why are you setting the scissor in two places?

One's for the whole render surface for clear.
Comment 9 Shawn Singh 2012-08-15 10:49:41 PDT
(In reply to comment #7)
> (From update of attachment 158586 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review
> 
> >>>>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
> >>>>> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
> >>>> 
> >>>> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
> >>> 
> >>> Thanks - good catch =)
> >>> 
> >>> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
> >> 
> >> to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.
> > 
> > Is that better? It differs from how the code was before I touched any of this, so I defer to enne on that.
> 
> Why are you setting the scissor in two places?

So that clearing the renderSurface gets correctly scissored, too.   I think we need that for when partial swap is enabled, we can't avoid scissoring there.
Comment 10 Adrienne Walker 2012-08-15 12:53:19 PDT
Comment on attachment 158586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review

>>>>>>>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
>>>>>>>> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
>>>>>>> 
>>>>>>> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
>>>>>> 
>>>>>> Thanks - good catch =)
>>>>>> 
>>>>>> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
>>>>> 
>>>>> to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.
>>>> 
>>>> Is that better? It differs from how the code was before I touched any of this, so I defer to enne on that.
>>> 
>>> Why are you setting the scissor in two places?
>> 
>> One's for the whole render surface for clear.
> 
> So that clearing the renderSurface gets correctly scissored, too.   I think we need that for when partial swap is enabled, we can't avoid scissoring there.

Ok, sure.

Re: original if statement.  I'd prefer to leave it as is.  Maybe unconditionally setting the scissor is also correct, but why change it?
Comment 11 Shawn Singh 2012-08-15 13:05:38 PDT
(In reply to comment #10)
> (From update of attachment 158586 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=158586&action=review
> 
> >>>>>>>> Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp:-425
> >>>>>>>> -        GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST));
> >>>>>>> 
> >>>>>>> This shouldn't go away. Else the last layer's scissor could apply to the clear here when it shouldn't.
> >>>>>> 
> >>>>>> Thanks - good catch =)
> >>>>>> 
> >>>>>> But, if you're ok with it, I think it's better to remove the if statement instead, to keep the always-scissor approach.
> >>>>> 
> >>>>> to be clear, I meant, literally remove the if (...), and always set the scissor, even if it's the same as the surface's rect.
> >>>> 
> >>>> Is that better? It differs from how the code was before I touched any of this, so I defer to enne on that.
> >>> 
> >>> Why are you setting the scissor in two places?
> >> 
> >> One's for the whole render surface for clear.
> > 
> > So that clearing the renderSurface gets correctly scissored, too.   I think we need that for when partial swap is enabled, we can't avoid scissoring there.
> 
> Ok, sure.
> 
> Re: original if statement.  I'd prefer to leave it as is.  Maybe unconditionally setting the scissor is also correct, but why change it?

The logic is as follows:

1. if scissor is different than contentRect, set it accordingly
2. if scissor is not different, then disable it
3. clear the framebuffer, only in the scissored region
4. (new in this patch) enable scissor and set it to the correct rect so that quads are correctly clipped.

It feels a bit unclean to keep doing step 2 if we are always doing step 4.  I felt it's better to keep the code simple rather than keeping the patch simple just because the patch works...
Comment 12 Shawn Singh 2012-08-15 13:06:43 PDT
Created attachment 158623 [details]
Addressed Dana's comment, still uses always-scissor approach

I had this patch just before your questions, so feel free to r- it if you still want that if-statement back =)
Comment 13 Adrienne Walker 2012-08-15 16:27:26 PDT
Comment on attachment 158623 [details]
Addressed Dana's comment, still uses always-scissor approach

R=me.
Comment 14 WebKit Review Bot 2012-08-15 17:10:25 PDT
Comment on attachment 158623 [details]
Addressed Dana's comment, still uses always-scissor approach

Attachment 158623 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13512262

New failing tests:
compositing/overflow/overflow-hidden-canvas-layer.html
Comment 15 WebKit Review Bot 2012-08-15 17:10:29 PDT
Created attachment 158665 [details]
Archive of layout-test-results from gce-cr-linux-04

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: gce-cr-linux-04  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Comment 16 Shawn Singh 2012-08-16 01:37:26 PDT
Created attachment 158748 [details]
Patch for landing
Comment 17 Shawn Singh 2012-08-16 01:50:40 PDT
Committed r125758: <http://trac.webkit.org/changeset/125758>
Comment 18 Adrienne Walker 2012-08-16 16:27:42 PDT
Committed r125824: <http://trac.webkit.org/changeset/125824>