Changeset 91090 in webkit


Ignore:
Timestamp:
Jul 15, 2011 12:27:30 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Avoid rounded rect corner-drawing overhead if no corners are visible
https://bugs.webkit.org/show_bug.cgi?id=64584

Patch by Ian Henderson <ianh@apple.com> on 2011-07-15
Reviewed by Simon Fraser.

No new tests, rendering is visually identical.

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::paintBoxDecorations): Pass PaintInfo into
paintBorder.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::paintBoxDecorations): Ditto.

  • rendering/RenderBoxModelObject.cpp:

(WebCore::unroundClippedCorners):
(WebCore::RenderBoxModelObject::paintBorder):
Any invisible corner may be replaced with a corner of radius zero, as
long as the stroke style is solid. Change the GraphicsContext
parameter into a PaintInfo parameter so we can get the rect to be
drawn.

  • rendering/RenderBoxModelObject.h:
  • rendering/RenderFieldset.cpp:

(WebCore::RenderFieldset::paintBoxDecorations): Pass PaintInfo into
paintBorder.

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::paintBoxDecorations): Ditto.

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::paintBoxDecorations): Ditto.

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91088 r91090  
     12011-07-15  Ian Henderson  <ianh@apple.com>
     2
     3        Avoid rounded rect corner-drawing overhead if no corners are visible
     4        https://bugs.webkit.org/show_bug.cgi?id=64584
     5
     6        Reviewed by Simon Fraser.
     7
     8        No new tests, rendering is visually identical.
     9
     10        * rendering/InlineFlowBox.cpp:
     11        (WebCore::InlineFlowBox::paintBoxDecorations): Pass PaintInfo into
     12        paintBorder.
     13        * rendering/RenderBox.cpp:
     14        (WebCore::RenderBox::paintBoxDecorations): Ditto.
     15        * rendering/RenderBoxModelObject.cpp:
     16        (WebCore::unroundClippedCorners):
     17        (WebCore::RenderBoxModelObject::paintBorder):
     18        Any invisible corner may be replaced with a corner of radius zero, as
     19        long as the stroke style is solid.  Change the GraphicsContext
     20        parameter into a PaintInfo parameter so we can get the rect to be
     21        drawn.
     22        * rendering/RenderBoxModelObject.h:
     23        * rendering/RenderFieldset.cpp:
     24        (WebCore::RenderFieldset::paintBoxDecorations): Pass PaintInfo into
     25        paintBorder.
     26        * rendering/RenderTable.cpp:
     27        (WebCore::RenderTable::paintBoxDecorations): Ditto.
     28        * rendering/RenderTableCell.cpp:
     29        (WebCore::RenderTableCell::paintBoxDecorations): Ditto.
     30
    1312011-07-15  Jeff Miller  <jeffm@apple.com>
    232
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r90869 r91090  
    11351135            // cases only a single call to draw is required.
    11361136            if (!hasBorderImage || (!prevLineBox() && !nextLineBox()))
    1137                 boxModelObject()->paintBorder(context, paintRect, renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
     1137                boxModelObject()->paintBorder(paintInfo, paintRect, renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
    11381138            else {
    11391139                // We have a border image that spans multiple lines.
     
    11581158                GraphicsContextStateSaver stateSaver(*context);
    11591159                context->clip(paintRect);
    1160                 boxModelObject()->paintBorder(context, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
     1160                boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
    11611161            }
    11621162        }
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r90912 r91090  
    875875    // The theme will tell us whether or not we should also paint the CSS border.
    876876    if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, paintRect))) && style()->hasBorder())
    877         paintBorder(paintInfo.context, paintRect, style(), bleedAvoidance);
     877        paintBorder(paintInfo, paintRect, style(), bleedAvoidance);
    878878
    879879    if (bleedAvoidance == BackgroundBleedUseTransparencyLayer)
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r90955 r91090  
    13721372}
    13731373
    1374 void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, const IntRect& rect, const RenderStyle* style,
     1374static void unroundClippedCorners(RoundedRect& border, const LayoutRect& clipRect)
     1375{
     1376    LayoutRect boundingRect = border.rect();
     1377    if (!border.isRounded() || clipRect.contains(boundingRect))
     1378        return;
     1379
     1380    RoundedRect::Radii adjustedRadii = border.radii();
     1381    bool didAdjustRadii = false;
     1382
     1383    LayoutRect topLeftRect(boundingRect.location(), adjustedRadii.topLeft());
     1384    if (!clipRect.intersects(topLeftRect)) {
     1385        adjustedRadii.setTopLeft(IntSize());
     1386        didAdjustRadii = true;
     1387    }
     1388
     1389    LayoutRect topRightRect(boundingRect.location(), adjustedRadii.topRight());
     1390    topRightRect.setX(boundingRect.maxX() - topRightRect.width());
     1391    if (!clipRect.intersects(topRightRect)) {
     1392        adjustedRadii.setTopRight(IntSize());
     1393        didAdjustRadii = true;
     1394    }
     1395
     1396    LayoutRect bottomLeftRect(boundingRect.location(), adjustedRadii.bottomLeft());
     1397    bottomLeftRect.setY(boundingRect.maxY() - bottomLeftRect.height());
     1398    if (!clipRect.intersects(bottomLeftRect)) {
     1399        adjustedRadii.setBottomLeft(IntSize());
     1400        didAdjustRadii = true;
     1401    }
     1402
     1403    LayoutRect bottomRightRect(boundingRect.location(), adjustedRadii.bottomRight());
     1404    bottomRightRect.setX(boundingRect.maxX() - bottomRightRect.width());
     1405    bottomRightRect.setY(boundingRect.maxY() - bottomRightRect.height());
     1406    if (!clipRect.intersects(bottomRightRect)) {
     1407        adjustedRadii.setBottomRight(IntSize());
     1408        didAdjustRadii = true;
     1409    }
     1410
     1411    if (didAdjustRadii)
     1412        border.setRadii(adjustedRadii);
     1413}
     1414
     1415void RenderBoxModelObject::paintBorder(const PaintInfo& info, const IntRect& rect, const RenderStyle* style,
    13751416                                       BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    13761417{
     1418    GraphicsContext* graphicsContext = info.context;
    13771419    // border-image is not affected by border-radius.
    13781420    if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage()))
     
    14211463            haveAllSolidEdges = false;
    14221464    }
    1423    
     1465
     1466    // If one of the corners falls outside the clip region, pretend it has no
     1467    // radius to improve performance.
     1468    if (haveAllSolidEdges)
     1469        unroundClippedCorners(outerBorder, info.rect);
     1470
    14241471    // isRenderable() check avoids issue described in https://bugs.webkit.org/show_bug.cgi?id=38787
    14251472    if (haveAllSolidEdges && allEdgesVisible && allEdgesShareColor && innerBorder.isRenderable()) {
     
    16141661}
    16151662#else
    1616 void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, const IntRect& rect, const RenderStyle* style,
     1663void RenderBoxModelObject::paintBorder(const PaintInfo& info, const IntRect& rect, const RenderStyle* style,
    16171664                                       BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
    16181665{
     1666    GraphicsContext* graphicsContext = info.context;
    16191667    // FIXME: This old version of paintBorder should be removed when all ports implement
    16201668    // GraphicsContext::clipConvexPolygon()!! This should happen soon.
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r90955 r91090  
    117117    virtual void childBecameNonInline(RenderObject* /*child*/) { }
    118118
    119     void paintBorder(GraphicsContext*, const IntRect&, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
     119    void paintBorder(const PaintInfo&, const IntRect&, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
    120120    bool paintNinePieceImage(GraphicsContext*, const IntRect&, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
    121121    void paintBoxShadow(GraphicsContext*, const LayoutRect&, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
  • trunk/Source/WebCore/rendering/RenderFieldset.cpp

    r89979 r91090  
    166166    }
    167167
    168     paintBorder(paintInfo.context, paintRect, style());
     168    paintBorder(paintInfo, paintRect, style());
    169169}
    170170
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r90955 r91090  
    570570
    571571    if (style()->hasBorder() && !collapseBorders())
    572         paintBorder(paintInfo.context, rect, style());
     572        paintBorder(paintInfo, rect, style());
    573573}
    574574
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r90955 r91090  
    10181018        return;
    10191019
    1020     paintBorder(paintInfo.context, paintRect, style());
     1020    paintBorder(paintInfo, paintRect, style());
    10211021}
    10221022
Note: See TracChangeset for help on using the changeset viewer.