Changeset 179771 in webkit


Ignore:
Timestamp:
Feb 6, 2015 5:11:07 PM (9 years ago)
Author:
Simon Fraser
Message:

Convert the compositing overlap map to use LayoutRects
https://bugs.webkit.org/show_bug.cgi?id=141346
Source/WebCore:

rdar://problem/18206365

Reviewed by Zalan Bujtas.

If two compositing layers were adjoining but not overlapping, but happened to
have non-integral offsets, then using enclosing IntRects in the overlap map
would cause us to think they are overlapping, and create unnecessary backing store.

Fix by converting the overlap map to use LayoutRects.

Test: compositing/layer-creation/subpixel-adjacent-layers-overlap.html

  • rendering/RenderLayerCompositor.cpp:

(WebCore::OverlapMapContainer::add):
(WebCore::OverlapMapContainer::overlapsLayers):
(WebCore::RenderLayerCompositor::OverlapMap::add):
(WebCore::RenderLayerCompositor::OverlapMap::overlapsLayers):
(WebCore::RenderLayerCompositor::OverlapMap::RectList::append):
(WebCore::RenderLayerCompositor::OverlapMap::RectList::intersects):
(WebCore::RenderLayerCompositor::logLayerInfo):
(WebCore::RenderLayerCompositor::addToOverlapMap):
(WebCore::RenderLayerCompositor::addToOverlapMapRecursive):
(WebCore::RenderLayerCompositor::computeCompositingRequirements):

  • rendering/RenderLayerCompositor.h:

LayoutTests:

Reviewed by Zalan Bujtas.

Test with adjacent layers on non-pixel boundaries.

  • compositing/layer-creation/subpixel-adjacent-layers-overlap-expected.txt: Added.
  • compositing/layer-creation/subpixel-adjacent-layers-overlap.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r179762 r179771  
     12015-02-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert the compositing overlap map to use LayoutRects
     4        https://bugs.webkit.org/show_bug.cgi?id=141346
     5
     6        Reviewed by Zalan Bujtas.
     7       
     8        Test with adjacent layers on non-pixel boundaries.
     9
     10        * compositing/layer-creation/subpixel-adjacent-layers-overlap-expected.txt: Added.
     11        * compositing/layer-creation/subpixel-adjacent-layers-overlap.html: Added.
     12
    1132015-02-06  Bartlomiej Gajda  <b.gajda@samsung.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r179770 r179771  
     12015-02-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert the compositing overlap map to use LayoutRects
     4        https://bugs.webkit.org/show_bug.cgi?id=141346
     5        rdar://problem/18206365
     6
     7        Reviewed by Zalan Bujtas.
     8       
     9        If two compositing layers were adjoining but not overlapping, but happened to
     10        have non-integral offsets, then using enclosing IntRects in the overlap map
     11        would cause us to think they are overlapping, and create unnecessary backing store.
     12       
     13        Fix by converting the overlap map to use LayoutRects.
     14
     15        Test: compositing/layer-creation/subpixel-adjacent-layers-overlap.html
     16
     17        * rendering/RenderLayerCompositor.cpp:
     18        (WebCore::OverlapMapContainer::add):
     19        (WebCore::OverlapMapContainer::overlapsLayers):
     20        (WebCore::RenderLayerCompositor::OverlapMap::add):
     21        (WebCore::RenderLayerCompositor::OverlapMap::overlapsLayers):
     22        (WebCore::RenderLayerCompositor::OverlapMap::RectList::append):
     23        (WebCore::RenderLayerCompositor::OverlapMap::RectList::intersects):
     24        (WebCore::RenderLayerCompositor::logLayerInfo):
     25        (WebCore::RenderLayerCompositor::addToOverlapMap):
     26        (WebCore::RenderLayerCompositor::addToOverlapMapRecursive):
     27        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
     28        * rendering/RenderLayerCompositor.h:
     29
    1302015-02-06  Andreas Kling  <akling@apple.com>
    231
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r179432 r179771  
    6969#if PLATFORM(IOS)
    7070#include "LegacyTileCache.h"
    71 #include "MainFrame.h"
    72 #include "Region.h"
    7371#include "RenderScrollbar.h"
    7472#endif
     
    105103class OverlapMapContainer {
    106104public:
    107     void add(const IntRect& bounds)
     105    void add(const LayoutRect& bounds)
    108106    {
    109107        m_layerRects.append(bounds);
     
    111109    }
    112110
    113     bool overlapsLayers(const IntRect& bounds) const
     111    bool overlapsLayers(const LayoutRect& bounds) const
    114112    {
    115113        // Checking with the bounding box will quickly reject cases when
     
    131129    }
    132130private:
    133     Vector<IntRect> m_layerRects;
    134     IntRect m_boundingBox;
     131    Vector<LayoutRect> m_layerRects;
     132    LayoutRect m_boundingBox;
    135133};
    136134
     
    147145    }
    148146
    149     void add(const RenderLayer* layer, const IntRect& bounds)
     147    void add(const RenderLayer* layer, const LayoutRect& bounds)
    150148    {
    151149        // Layers do not contribute to overlap immediately--instead, they will
     
    162160    }
    163161
    164     bool overlapsLayers(const IntRect& bounds) const
     162    bool overlapsLayers(const LayoutRect& bounds) const
    165163    {
    166164        return m_overlapStack.last().overlapsLayers(bounds);
     
    187185private:
    188186    struct RectList {
    189         Vector<IntRect> rects;
    190         IntRect boundingRect;
     187        Vector<LayoutRect> rects;
     188        LayoutRect boundingRect;
    191189       
    192         void append(const IntRect& rect)
     190        void append(const LayoutRect& rect)
    193191        {
    194192            rects.append(rect);
     
    202200        }
    203201       
    204         bool intersects(const IntRect& rect) const
     202        bool intersects(const LayoutRect& rect) const
    205203        {
    206204            if (!rects.size() || !boundingRect.intersects(rect))
     
    828826    }
    829827
     828    LayoutRect absoluteBounds = backing->compositedBounds();
     829    absoluteBounds.move(layer.offsetFromAncestor(m_renderView.layer()));
     830   
    830831    StringBuilder logString;
    831     logString.append(String::format("%*p %dx%d %.2fKB", 12 + depth * 2, &layer,
    832         backing->compositedBounds().width().round(), backing->compositedBounds().height().round(),
     832    logString.append(String::format("%*p (%.6f,%.6f-%.6f,%.6f) %.2fKB", 12 + depth * 2, &layer,
     833        absoluteBounds.x().toFloat(), absoluteBounds.y().toFloat(), absoluteBounds.maxX().toFloat(), absoluteBounds.maxY().toFloat(),
    833834        backing->backingStoreMemoryEstimate() / 1024));
    834835   
     
    11061107}
    11071108
    1108 void RenderLayerCompositor::addToOverlapMap(OverlapMap& overlapMap, RenderLayer& layer, IntRect& layerBounds, bool& boundsComputed)
     1109void RenderLayerCompositor::addToOverlapMap(OverlapMap& overlapMap, RenderLayer& layer, LayoutRect& layerBounds, bool& boundsComputed)
    11091110{
    11101111    if (layer.isRootLayer())
     
    11141115        // FIXME: If this layer's overlap bounds include its children, we don't need to add its
    11151116        // children's bounds to the overlap map.
    1116         layerBounds = enclosingIntRect(overlapMap.geometryMap().absoluteRect(layer.overlapBounds()));
     1117        layerBounds = enclosingLayoutRect(overlapMap.geometryMap().absoluteRect(layer.overlapBounds()));
    11171118        // Empty rects never intersect, but we need them to for the purposes of overlap testing.
    11181119        if (layerBounds.isEmpty())
    1119             layerBounds.setSize(IntSize(1, 1));
     1120            layerBounds.setSize(LayoutSize(1, 1));
    11201121        boundsComputed = true;
    11211122    }
    11221123
    1123     IntRect clipRect = snappedIntRect(layer.backgroundClipRect(RenderLayer::ClipRectsContext(&rootRenderLayer(), AbsoluteClipRects)).rect()); // FIXME: Incorrect for CSS regions.
     1124    LayoutRect clipRect = layer.backgroundClipRect(RenderLayer::ClipRectsContext(&rootRenderLayer(), AbsoluteClipRects)).rect(); // FIXME: Incorrect for CSS regions.
    11241125
    11251126    // On iOS, pageScaleFactor() is not applied by RenderView, so we should not scale here.
     
    11431144        overlapMap.geometryMap().pushMappingsToAncestor(&layer, ancestorLayer);
    11441145   
    1145     IntRect bounds;
     1146    LayoutRect bounds;
    11461147    bool haveComputedBounds = false;
    11471148    addToOverlapMap(overlapMap, layer, bounds, haveComputedBounds);
     
    12281229    RenderLayer::IndirectCompositingReason compositingReason = compositingState.m_subtreeIsCompositing ? RenderLayer::IndirectCompositingReason::Stacking : RenderLayer::IndirectCompositingReason::None;
    12291230    bool haveComputedBounds = false;
    1230     IntRect absBounds;
     1231    LayoutRect absBounds;
    12311232
    12321233    // If we know for sure the layer is going to be composited, don't bother looking it up in the overlap map
    12331234    if (!willBeComposited && !overlapMap.isEmpty() && compositingState.m_testingOverlap) {
    12341235        // If we're testing for overlap, we only need to composite if we overlap something that is already composited.
    1235         absBounds = enclosingIntRect(overlapMap.geometryMap().absoluteRect(layer.overlapBounds()));
     1236        absBounds = enclosingLayoutRect(overlapMap.geometryMap().absoluteRect(layer.overlapBounds()));
    12361237
    12371238        // Empty rects never intersect, but we need them to for the purposes of overlap testing.
    12381239        if (absBounds.isEmpty())
    1239             absBounds.setSize(IntSize(1, 1));
     1240            absBounds.setSize(LayoutSize(1, 1));
    12401241        haveComputedBounds = true;
    12411242        compositingReason = overlapMap.overlapsLayers(absBounds) ? RenderLayer::IndirectCompositingReason::Overlap : RenderLayer::IndirectCompositingReason::None;
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r176915 r179771  
    334334    void recursiveRepaintLayer(RenderLayer&);
    335335
    336     void addToOverlapMap(OverlapMap&, RenderLayer&, IntRect& layerBounds, bool& boundsComputed);
     336    void addToOverlapMap(OverlapMap&, RenderLayer&, LayoutRect& layerBounds, bool& boundsComputed);
    337337    void addToOverlapMapRecursive(OverlapMap&, RenderLayer&, RenderLayer* ancestorLayer = nullptr);
    338338
Note: See TracChangeset for help on using the changeset viewer.