Changeset 88496 in webkit


Ignore:
Timestamp:
Jun 9, 2011 3:53:53 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-09 James Robinson <jamesr@chromium.org>

Reviewed by Kenneth Russell.

[chromium] Scissor rect not set for clipping layers set offscreen
https://bugs.webkit.org/show_bug.cgi?id=62339

Tests that a layer that should clip its children actually does clip even when scrolled offscreen.

  • platform/chromium/compositing/scissor-out-of-viewport-expected.png: Added.
  • platform/chromium/compositing/scissor-out-of-viewport-expected.txt: Added.
  • platform/chromium/compositing/scissor-out-of-viewport.html: Added.

2011-06-09 James Robinson <jamesr@chromium.org>

Reviewed by Kenneth Russell.

[chromium] Scissor rect not set for clipping layers set offscreen
https://bugs.webkit.org/show_bug.cgi?id=62339

We set a scissorRect on each layer, but only layers with masksToBounds and their descendants should actually set
a scissor. Layers that didn't need to scissor had empty scissorRects. Unfortunately layers with masksToBounds
and their descendants that are scrolled offscreen also end up with an empty clipped scissor rect.

This patch sets an explicit bit on each layer that should scissor and then checks that bit instead of checking
for an empty scissor rect at draw time. RenderSurfaceChromiums have different requirements for
setScissorToRect, so the old behavior is still available with a flag. This can probably be cleaned up more.

Test: platform/chromium/compositing/scissor-out-of-viewport.html

  • platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces): (WebCore::LayerRendererChromium::drawLayer): (WebCore::LayerRendererChromium::setScissorToRect):
  • platform/graphics/chromium/LayerRendererChromium.h:
  • platform/graphics/chromium/RenderSurfaceChromium.cpp: (WebCore::RenderSurfaceChromium::draw):
  • platform/graphics/chromium/cc/CCLayerImpl.cpp: (WebCore::CCLayerImpl::CCLayerImpl):
  • platform/graphics/chromium/cc/CCLayerImpl.h: (WebCore::CCLayerImpl::setUsesLayerScissor): (WebCore::CCLayerImpl::usesLayerScissor):
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r88490 r88496  
     12011-06-09  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [chromium] Scissor rect not set for clipping layers set offscreen
     6        https://bugs.webkit.org/show_bug.cgi?id=62339
     7
     8        Tests that a layer that should clip its children actually does clip even when scrolled offscreen.
     9
     10        * platform/chromium/compositing/scissor-out-of-viewport-expected.png: Added.
     11        * platform/chromium/compositing/scissor-out-of-viewport-expected.txt: Added.
     12        * platform/chromium/compositing/scissor-out-of-viewport.html: Added.
     13
    1142011-06-09  Sheriff Bot  <webkit.review.bot@gmail.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r88490 r88496  
     12011-06-09  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [chromium] Scissor rect not set for clipping layers set offscreen
     6        https://bugs.webkit.org/show_bug.cgi?id=62339
     7
     8        We set a scissorRect on each layer, but only layers with masksToBounds and their descendants should actually set
     9        a scissor.  Layers that didn't need to scissor had empty scissorRects.  Unfortunately layers with masksToBounds
     10        and their descendants that are scrolled offscreen also end up with an empty clipped scissor rect.
     11
     12        This patch sets an explicit bit on each layer that should scissor and then checks that bit instead of checking
     13        for an empty scissor rect at draw time.  RenderSurfaceChromiums have different requirements for
     14        setScissorToRect, so the old behavior is still available with a flag.  This can probably be cleaned up more.
     15
     16        Test: platform/chromium/compositing/scissor-out-of-viewport.html
     17
     18        * platform/graphics/chromium/LayerRendererChromium.cpp:
     19        (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
     20        (WebCore::LayerRendererChromium::drawLayer):
     21        (WebCore::LayerRendererChromium::setScissorToRect):
     22        * platform/graphics/chromium/LayerRendererChromium.h:
     23        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
     24        (WebCore::RenderSurfaceChromium::draw):
     25        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
     26        (WebCore::CCLayerImpl::CCLayerImpl):
     27        * platform/graphics/chromium/cc/CCLayerImpl.h:
     28        (WebCore::CCLayerImpl::setUsesLayerScissor):
     29        (WebCore::CCLayerImpl::usesLayerScissor):
     30
    1312011-06-09  Sheriff Bot  <webkit.review.bot@gmail.com>
    232
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r87762 r88496  
    659659    IntRect transformedLayerRect;
    660660
     661    // FIXME: This seems like the wrong place to set this
     662    layer->setUsesLayerScissor(false);
     663
    661664    // The layer and its descendants render on a new RenderSurface if any of
    662665    // these conditions hold:
     
    695698        layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
    696699        renderSurface->m_originTransform = layerOriginTransform;
    697         layer->setScissorRect(IntRect());
    698700
    699701        // The render surface scissor rect is the scissor rect that needs to
     
    727729            // Layers inherit the scissor rect from their parent.
    728730            layer->setScissorRect(layer->parent()->scissorRect());
     731            if (layer->parent()->usesLayerScissor())
     732                layer->setUsesLayerScissor(true);
    729733
    730734            layer->setTargetRenderSurface(layer->parent()->targetRenderSurface());
     
    739743                scissor.intersect(layer->scissorRect());
    740744            layer->setScissorRect(scissor);
     745            layer->setUsesLayerScissor(true);
    741746        }
    742747    }
     
    974979    }
    975980
    976     setScissorToRect(layer->scissorRect());
    977 
     981    if (layer->usesLayerScissor())
     982        setScissorToRect(layer->scissorRect());
     983    else
     984        GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
    978985    IntRect targetSurfaceRect = m_currentRenderSurface ? m_currentRenderSurface->contentRect() : m_defaultRenderSurface->contentRect();
    979     IntRect scissorRect = layer->scissorRect();
    980     if (!scissorRect.isEmpty())
    981         targetSurfaceRect.intersect(scissorRect);
    982986
    983987    // Check if the layer falls within the visible bounds of the page.
     
    10151019// Sets the scissor region to the given rectangle. The coordinate system for the
    10161020// scissorRect has its origin at the top left corner of the current visible rect.
    1017 void LayerRendererChromium::setScissorToRect(const IntRect& requestedScissor)
     1021void LayerRendererChromium::setScissorToRect(const IntRect& scissorRect)
    10181022{
    10191023    IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->m_contentRect : m_defaultRenderSurface->m_contentRect);
    10201024
    1021     const IntRect scissorRect = requestedScissor.isEmpty() ? contentRect : requestedScissor;
     1025    GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
    10221026
    10231027    // The scissor coordinates must be supplied in viewport space so we need to offset
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

    r86975 r88496  
    153153        replicaMaskLayer = m_owningLayer->replicaLayer()->maskLayer();
    154154
    155     layerRenderer()->setScissorToRect(m_scissorRect);
     155    if (m_owningLayer->parent() && m_owningLayer->parent()->usesLayerScissor())
     156        layerRenderer()->setScissorToRect(m_scissorRect);
     157    else
     158        GLC(layerRenderer()->context(), layerRenderer()->context()->disable(GraphicsContext3D::SCISSOR_TEST));
     159
    156160
    157161    // Reflection draws before the layer.
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp

    r87752 r88496  
    7171    , m_opacity(1.0)
    7272    , m_preserves3D(false)
     73    , m_usesLayerScissor(false)
    7374    , m_targetRenderSurface(0)
    7475    , m_drawDepth(0)
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h

    r86652 r88496  
    101101    bool preserves3D() const { return m_preserves3D; }
    102102
     103    void setUsesLayerScissor(bool usesLayerScissor) { m_usesLayerScissor = usesLayerScissor; }
     104    bool usesLayerScissor() const { return m_usesLayerScissor; }
     105
    103106    void setSublayerTransform(const TransformationMatrix& sublayerTransform) { m_sublayerTransform = sublayerTransform; }
    104107    const TransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
     
    184187    TransformationMatrix m_sublayerTransform;
    185188    TransformationMatrix m_transform;
     189    bool m_usesLayerScissor;
    186190
    187191    // Properties owned exclusively by this CCLayerImpl.
Note: See TracChangeset for help on using the changeset viewer.