Changeset 162732 in webkit


Ignore:
Timestamp:
Jan 24, 2014 3:35:07 PM (10 years ago)
Author:
Alan Bujtas
Message:

Subpixel rendering: Make PaintInfo layout unit aware.
https://bugs.webkit.org/show_bug.cgi?id=127562

Reviewed by Simon Fraser.

Replace PaintInfo's IntRect with LayoutRect to be able to render to
subpixel positions.

No functional changes.

  • platform/graphics/LayoutRect.h:
  • rendering/PaintInfo.h:

(WebCore::PaintInfo::PaintInfo):
(WebCore::PaintInfo::applyTransform):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::paint):

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended):

  • rendering/RenderLayer.cpp:

(WebCore::cornerRect):
(WebCore::RenderLayer::scrollCornerRect):
(WebCore::resizerCornerRect):
(WebCore::RenderLayer::scrollCornerAndResizerRect):
(WebCore::RenderLayer::horizontalScrollbarStart):
(WebCore::RenderLayer::drawPlatformResizerImage):
(WebCore::RenderLayer::paintResizer):
(WebCore::RenderLayer::hitTestOverflowControls):

  • rendering/RenderLayer.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::paintContents):

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::paintScrollbar):

  • rendering/RenderWidget.cpp:

(WebCore::RenderWidget::paintContents):

  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::fillWithExtensionGlyph):

  • rendering/svg/SVGRenderingContext.h:
Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r162731 r162732  
     12014-01-24  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Make PaintInfo layout unit aware.
     4        https://bugs.webkit.org/show_bug.cgi?id=127562
     5
     6        Reviewed by Simon Fraser.
     7
     8        Replace PaintInfo's IntRect with LayoutRect to be able to render to
     9        subpixel positions.
     10
     11        No functional changes.
     12
     13        * platform/graphics/LayoutRect.h:
     14        * rendering/PaintInfo.h:
     15        (WebCore::PaintInfo::PaintInfo):
     16        (WebCore::PaintInfo::applyTransform):
     17        * rendering/RenderBlock.cpp:
     18        (WebCore::RenderBlock::paint):
     19        * rendering/RenderBoxModelObject.cpp:
     20        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     21        * rendering/RenderLayer.cpp:
     22        (WebCore::cornerRect):
     23        (WebCore::RenderLayer::scrollCornerRect):
     24        (WebCore::resizerCornerRect):
     25        (WebCore::RenderLayer::scrollCornerAndResizerRect):
     26        (WebCore::RenderLayer::horizontalScrollbarStart):
     27        (WebCore::RenderLayer::drawPlatformResizerImage):
     28        (WebCore::RenderLayer::paintResizer):
     29        (WebCore::RenderLayer::hitTestOverflowControls):
     30        * rendering/RenderLayer.h:
     31        * rendering/RenderLayerBacking.cpp:
     32        (WebCore::RenderLayerBacking::paintContents):
     33        * rendering/RenderListBox.cpp:
     34        (WebCore::RenderListBox::paintScrollbar):
     35        * rendering/RenderWidget.cpp:
     36        (WebCore::RenderWidget::paintContents):
     37        * rendering/mathml/RenderMathMLOperator.cpp:
     38        (WebCore::RenderMathMLOperator::fillWithExtensionGlyph):
     39        * rendering/svg/SVGRenderingContext.h:
     40
    1412014-01-24  Simon Fraser  <simon.fraser@apple.com>
    242
  • trunk/Source/WebCore/platform/LayoutUnit.h

    r159159 r162732  
    119119#endif
    120120
     121    static LayoutUnit fromPixel(int value)
     122    {
     123        return LayoutUnit(value);
     124    }
     125
    121126    static LayoutUnit fromFloatCeil(float value)
    122127    {
  • trunk/Source/WebCore/platform/graphics/LayoutRect.h

    r154858 r162732  
    4040namespace WebCore {
    4141
    42 class FloatRect;
    43 
    4442class LayoutRect {
    4543public:
  • trunk/Source/WebCore/rendering/PaintInfo.h

    r161381 r162732  
    5454 */
    5555struct PaintInfo {
    56     PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior,
     56    PaintInfo(GraphicsContext* newContext, const LayoutRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior,
    5757        RenderObject* newSubtreePaintRoot = nullptr, RenderRegion* region = nullptr, ListHashSet<RenderInline*>* newOutlineObjects = nullptr,
    5858        OverlapTestRequestMap* overlapTestRequests = nullptr, const RenderLayerModelObject* newPaintContainer = nullptr)
     
    9999        context->concatCTM(localToAncestorTransform);
    100100
    101         if (rect.isInfinite())
     101        if (rect == LayoutRect::infiniteRect())
    102102            return;
    103103
    104         rect = localToAncestorTransform.inverse().mapRect(rect);
     104        FloatRect tranformedRect(localToAncestorTransform.inverse().mapRect(rect));
     105        rect.setLocation(LayoutPoint(tranformedRect.location()));
     106        rect.setSize(LayoutSize(tranformedRect.size()));
    105107    }
    106108#endif
    107109
    108110    GraphicsContext* context;
    109     IntRect rect;
     111    LayoutRect rect;
    110112    PaintPhase phase;
    111113    PaintBehavior paintBehavior;
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r162726 r162732  
    21882188    // sit above the background/border.
    21892189    if (hasOverflowClip() && style().visibility() == VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.shouldPaintWithinRoot(*this) && !paintInfo.paintRootBackgroundOnly())
    2190         layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
     2190        layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjustedPaintOffset), pixelSnappedIntRect(paintInfo.rect));
    21912191}
    21922192
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r162480 r162732  
    721721        // to actually render, so we should intersect the dirty rect with the border box of the background.
    722722        maskRect = pixelSnappedIntRect(rect);
    723         maskRect.intersect(paintInfo.rect);
     723        maskRect.intersect(pixelSnappedIntRect(paintInfo.rect));
    724724
    725725        // Now create the mask.
     
    774774        if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY()) {
    775775            if (!boxShadowShouldBeAppliedToBackground)
    776                 backgroundRect.intersect(paintInfo.rect);
     776                backgroundRect.intersect(pixelSnappedIntRect(paintInfo.rect));
    777777
    778778            // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
     
    806806        BackgroundImageGeometry geometry;
    807807        calculateBackgroundImageGeometry(paintInfo.paintContainer, bgLayer, scrolledPaintRect, geometry, backgroundObject);
    808         geometry.clip(paintInfo.rect);
     808        geometry.clip(pixelSnappedIntRect(paintInfo.rect));
    809809        if (!geometry.destRect().isEmpty()) {
    810810            CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r162663 r162732  
    27272727}
    27282728
    2729 static IntRect cornerRect(const RenderLayer* layer, const IntRect& bounds)
     2729static LayoutRect cornerRect(const RenderLayer* layer, const LayoutRect& bounds)
    27302730{
    27312731    int horizontalThickness;
     
    27462746        verticalThickness = layer->horizontalScrollbar()->height();
    27472747    }
    2748     return IntRect(cornerStart(layer, bounds.x(), bounds.maxX(), horizontalThickness),
     2748    return LayoutRect(cornerStart(layer, bounds.x(), bounds.maxX(), horizontalThickness),
    27492749        bounds.maxY() - verticalThickness - layer->renderer().style().borderBottomWidth(),
    27502750        horizontalThickness, verticalThickness);
     
    27612761    bool hasResizer = renderer().style().resize() != RESIZE_NONE;
    27622762    if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
    2763         return cornerRect(this, renderBox()->pixelSnappedBorderBoxRect());
     2763        return pixelSnappedIntRect(cornerRect(this, renderBox()->borderBoxRect()));
    27642764    return IntRect();
    27652765}
    27662766
    2767 static IntRect resizerCornerRect(const RenderLayer* layer, const IntRect& bounds)
     2767static LayoutRect resizerCornerRect(const RenderLayer* layer, const LayoutRect& bounds)
    27682768{
    27692769    ASSERT(layer->renderer().isBox());
    27702770    if (layer->renderer().style().resize() == RESIZE_NONE)
    2771         return IntRect();
     2771        return LayoutRect();
    27722772    return cornerRect(layer, bounds);
    27732773}
    27742774
    2775 IntRect RenderLayer::scrollCornerAndResizerRect() const
     2775LayoutRect RenderLayer::scrollCornerAndResizerRect() const
    27762776{
    27772777    RenderBox* box = renderBox();
    27782778    if (!box)
    27792779        return IntRect();
    2780     IntRect scrollCornerAndResizer = scrollCornerRect();
     2780    LayoutRect scrollCornerAndResizer = scrollCornerRect();
    27812781    if (scrollCornerAndResizer.isEmpty())
    2782         scrollCornerAndResizer = resizerCornerRect(this, box->pixelSnappedBorderBoxRect());
     2782        scrollCornerAndResizer = resizerCornerRect(this, box->borderBoxRect());
    27832783    return scrollCornerAndResizer;
    27842784}
     
    29012901    int x = minX + box->borderLeft();
    29022902    if (renderer().style().shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
    2903         x += m_vBar ? m_vBar->width() : resizerCornerRect(this, box->pixelSnappedBorderBoxRect()).width();
     2903        x += m_vBar ? m_vBar->width() : roundToInt(resizerCornerRect(this, box->borderBoxRect()).width());
    29042904    return x;
    29052905}
     
    34843484}
    34853485
    3486 void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, IntRect resizerCornerRect)
     3486void RenderLayer::drawPlatformResizerImage(GraphicsContext* context, const LayoutRect& resizerCornerRect)
    34873487{
    34883488    float deviceScaleFactor = WebCore::deviceScaleFactor(&renderer().frame());
     
    35093509        return;
    35103510    }
    3511     IntRect imageRect(resizerCornerRect.maxXMaxYCorner() - cornerResizerSize, cornerResizerSize);
    3512     context->drawImage(resizeCornerImage.get(), renderer().style().colorSpace(), imageRect);
    3513 }
    3514 
    3515 void RenderLayer::paintResizer(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect)
     3511    LayoutRect imageRect(resizerCornerRect.maxXMaxYCorner() - cornerResizerSize, cornerResizerSize);
     3512    context->drawImage(resizeCornerImage.get(), renderer().style().colorSpace(), pixelSnappedIntRect(imageRect));
     3513}
     3514
     3515void RenderLayer::paintResizer(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& damageRect)
    35163516{
    35173517    if (renderer().style().resize() == RESIZE_NONE)
     
    35213521    ASSERT(box);
    35223522
    3523     IntRect absRect = resizerCornerRect(this, box->pixelSnappedBorderBoxRect());
     3523    LayoutRect absRect = resizerCornerRect(this, box->borderBoxRect());
    35243524    absRect.moveBy(paintOffset);
    35253525    if (!absRect.intersects(damageRect))
     
    35433543        GraphicsContextStateSaver stateSaver(*context);
    35443544        context->clip(absRect);
    3545         IntRect largerCorner = absRect;
    3546         largerCorner.setSize(IntSize(largerCorner.width() + 1, largerCorner.height() + 1));
     3545        LayoutRect largerCorner = absRect;
     3546        largerCorner.setSize(LayoutSize(largerCorner.width() + LayoutUnit::fromPixel(1), largerCorner.height() + LayoutUnit::fromPixel(1)));
    35473547        context->setStrokeColor(Color(makeRGB(217, 217, 217)), ColorSpaceDeviceRGB);
    35483548        context->setStrokeThickness(1.0f);
    35493549        context->setFillColor(Color::transparent, ColorSpaceDeviceRGB);
    3550         context->drawRect(largerCorner);
     3550        context->drawRect(pixelSnappedIntRect(largerCorner));
    35513551    }
    35523552}
     
    35763576    IntRect resizeControlRect;
    35773577    if (renderer().style().resize() != RESIZE_NONE) {
    3578         resizeControlRect = resizerCornerRect(this, box->pixelSnappedBorderBoxRect());
     3578        resizeControlRect = pixelSnappedIntRect(resizerCornerRect(this, box->borderBoxRect()));
    35793579        if (resizeControlRect.contains(localPoint))
    35803580            return true;
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r162663 r162732  
    460460    void paintOverflowControls(GraphicsContext*, const IntPoint&, const IntRect& damageRect, bool paintingOverlayControls = false);
    461461    void paintScrollCorner(GraphicsContext*, const IntPoint&, const IntRect& damageRect);
    462     void paintResizer(GraphicsContext*, const IntPoint&, const IntRect& damageRect);
     462    void paintResizer(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect);
    463463
    464464    void updateScrollInfoAfterLayout();
     
    10791079
    10801080    // Rectangle encompassing the scroll corner and resizer rect.
    1081     IntRect scrollCornerAndResizerRect() const;
     1081    LayoutRect scrollCornerAndResizerRect() const;
    10821082
    10831083    // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
     
    11311131    void updateResizerStyle();
    11321132
    1133     void drawPlatformResizerImage(GraphicsContext*, IntRect resizerCornerRect);
     1133    void drawPlatformResizerImage(GraphicsContext*, const LayoutRect& resizerCornerRect);
    11341134
    11351135    void updatePagination();
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r162679 r162732  
    22542254        paintScrollbar(m_owningLayer.verticalScrollbar(), context, clip);
    22552255    } else if (graphicsLayer == layerForScrollCorner()) {
    2256         const IntRect& scrollCornerAndResizer = m_owningLayer.scrollCornerAndResizerRect();
     2256        const LayoutRect& scrollCornerAndResizer = m_owningLayer.scrollCornerAndResizerRect();
    22572257        context.save();
    22582258        context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y());
    2259         IntRect transformedClip = clip;
     2259        LayoutRect transformedClip = clip;
    22602260        transformedClip.moveBy(scrollCornerAndResizer.location());
    2261         m_owningLayer.paintScrollCorner(&context, IntPoint(), transformedClip);
     2261        m_owningLayer.paintScrollCorner(&context, IntPoint(), pixelSnappedIntRect(transformedClip));
    22622262        m_owningLayer.paintResizer(&context, IntPoint(), transformedClip);
    22632263        context.restore();
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r162663 r162732  
    351351            height() - (borderTop() + borderBottom()));
    352352        m_vBar->setFrameRect(scrollRect);
    353         m_vBar->paint(paintInfo.context, paintInfo.rect);
     353        m_vBar->paint(paintInfo.context, pixelSnappedIntRect(paintInfo.rect));
    354354    }
    355355}
  • trunk/Source/WebCore/rendering/RenderWidget.cpp

    r160236 r162732  
    228228    IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + paddingLeft()),
    229229        roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop()));
    230     IntRect paintRect = paintInfo.rect;
    231 
    232     IntSize widgetPaintOffset = paintLocation - widgetLocation;
     230    LayoutRect paintRect = paintInfo.rect;
     231
     232    LayoutSize widgetPaintOffset = paintLocation - widgetLocation;
    233233    // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
    234234    // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
     
    237237        paintRect.move(-widgetPaintOffset);
    238238    }
    239     m_widget->paint(paintInfo.context, paintRect);
     239    m_widget->paint(paintInfo.context, pixelSnappedIntRect(paintRect));
    240240
    241241    if (!widgetPaintOffset.isZero())
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r161501 r162732  
    330330    // Clipping the extender region here allows us to draw the bottom extender glyph into the
    331331    // regions of the bottom glyph without worrying about overdraw (hairy pixels) and simplifies later clipping.
    332     IntRect clipBounds = info.rect;
     332    LayoutRect clipBounds = info.rect;
    333333    clipBounds.shiftYEdgeTo(from.y());
    334334    clipBounds.shiftMaxYEdgeTo(to.y());
  • trunk/Source/WebCore/rendering/svg/SVGRenderingContext.h

    r159791 r162732  
    116116    PaintInfo* m_paintInfo;
    117117    GraphicsContext* m_savedContext;
    118     IntRect m_savedPaintRect;
     118    LayoutRect m_savedPaintRect;
    119119#if ENABLE(FILTERS)
    120120    RenderSVGResourceFilter* m_filter;
Note: See TracChangeset for help on using the changeset viewer.