Changeset 145366 in webkit


Ignore:
Timestamp:
Mar 11, 2013 8:43:06 AM (11 years ago)
Author:
allan.jensen@digia.com
Message:

[Qt] Enable tiled shadow blur for inset box shadows
https://bugs.webkit.org/show_bug.cgi?id=111736

Reviewed by Noam Rosenthal.

Paint inset box-shadows using the optimized tiled shadow blur, instead of
applying shadow blur to the entire painted rect.

This optimizes the default CSS on common pastebin sites.

Tested by existing tests.

  • platform/graphics/GraphicsContext.cpp:
  • platform/graphics/ShadowBlur.cpp:

(WebCore::ShadowBlur::drawInsetShadowWithTiling):

Must set fill color before calling clearShadow, as that might clear m_color.

(WebCore::ShadowBlur::drawLayerPieces):

Ditto.

  • platform/graphics/qt/GraphicsContextQt.cpp:

(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::fillRectWithRoundedHole):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r145363 r145366  
     12013-03-11  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] Enable tiled shadow blur for inset box shadows
     4        https://bugs.webkit.org/show_bug.cgi?id=111736
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Paint inset box-shadows using the optimized tiled shadow blur, instead of
     9        applying shadow blur to the entire painted rect.
     10
     11        This optimizes the default CSS on common pastebin sites.
     12
     13        Tested by existing tests.
     14
     15        * platform/graphics/GraphicsContext.cpp:
     16        * platform/graphics/ShadowBlur.cpp:
     17        (WebCore::ShadowBlur::drawInsetShadowWithTiling):
     18            Must set fill color before calling clearShadow, as that might clear m_color.
     19        (WebCore::ShadowBlur::drawLayerPieces):
     20            Ditto.
     21        * platform/graphics/qt/GraphicsContextQt.cpp:
     22        (WebCore::GraphicsContext::fillPath):
     23        (WebCore::GraphicsContext::fillRectWithRoundedHole):
     24
    1252013-03-11  Alberto Garcia  <agarcia@igalia.com>
    226
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r143646 r145366  
    678678}
    679679
    680 #if !USE(CG)
     680#if !USE(CG) && !PLATFORM(QT)
    681681void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedRect& roundedHoleRect, const Color& color, ColorSpace colorSpace)
    682682{
  • trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp

    r133836 r145366  
    697697    {
    698698        GraphicsContextStateSaver fillStateSaver(*graphicsContext);
    699         graphicsContext->clearShadow();
    700699        graphicsContext->setFillRule(RULE_EVENODD);
    701700        graphicsContext->setFillColor(m_color, m_colorSpace);
     701        graphicsContext->clearShadow();
    702702        graphicsContext->fillPath(exteriorPath);
    703703    }
     
    773773
    774774    GraphicsContextStateSaver stateSaver(*graphicsContext);
     775    graphicsContext->setFillColor(m_color, m_colorSpace);
    775776    graphicsContext->clearShadow();
    776     graphicsContext->setFillColor(m_color, m_colorSpace);
    777777
    778778    // Note that drawing the ImageBuffer is faster than creating a Image and drawing that,
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r141542 r145366  
    865865}
    866866
     867void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedRect& roundedHoleRect, const Color& color, ColorSpace colorSpace)
     868{
     869    if (paintingDisabled() || !color.isValid())
     870        return;
     871
     872    Path path;
     873    path.addRect(rect);
     874    if (!roundedHoleRect.radii().isZero())
     875        path.addRoundedRect(roundedHoleRect);
     876    else
     877        path.addRect(roundedHoleRect.rect());
     878
     879    QPainterPath platformPath = path.platformPath();
     880    platformPath.setFillRule(Qt::OddEvenFill);
     881
     882    QPainter* p = m_data->p();
     883    if (hasShadow()) {
     884        ShadowBlur* shadow = shadowBlur();
     885        if (shadow->mustUseShadowBlur(this))
     886            shadow->drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
     887        else {
     888            const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
     889            p->translate(shadowOffset);
     890            p->fillPath(platformPath, QColor(m_state.shadowColor));
     891            p->translate(-shadowOffset);
     892        }
     893    }
     894
     895    p->fillPath(platformPath, QColor(color));
     896}
     897
    867898bool GraphicsContext::isInTransparencyLayer() const
    868899{
Note: See TracChangeset for help on using the changeset viewer.