diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-03-14 14:01:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-18 15:50:55 +0100 |
commit | 3774b52275c59d74571b0e1f87950dcfc257d408 (patch) | |
tree | c87848b7f7c8206554c7a1437c3da77cabffd00f /Source/WebCore | |
parent | fa9f68ec24fee49e30d22d0d911853de15a86624 (diff) |
[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):
Change-Id: Idc563ff997f8150ef9553d8fe3d164e488f16e9f
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'Source/WebCore')
-rw-r--r-- | Source/WebCore/platform/graphics/GraphicsContext.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/ShadowBlur.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp | 31 |
3 files changed, 34 insertions, 3 deletions
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp index c21173ae2..4ede7da2e 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.cpp +++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp @@ -671,7 +671,7 @@ void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& colo fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace); } -#if !USE(CG) +#if !USE(CG) && !PLATFORM(QT) void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedRect& roundedHoleRect, const Color& color, ColorSpace colorSpace) { if (paintingDisabled()) diff --git a/Source/WebCore/platform/graphics/ShadowBlur.cpp b/Source/WebCore/platform/graphics/ShadowBlur.cpp index 335928367..5c92612d2 100644 --- a/Source/WebCore/platform/graphics/ShadowBlur.cpp +++ b/Source/WebCore/platform/graphics/ShadowBlur.cpp @@ -696,9 +696,9 @@ void ShadowBlur::drawInsetShadowWithTiling(GraphicsContext* graphicsContext, con { GraphicsContextStateSaver fillStateSaver(*graphicsContext); - graphicsContext->clearShadow(); graphicsContext->setFillRule(RULE_EVENODD); graphicsContext->setFillColor(m_color, m_colorSpace); + graphicsContext->clearShadow(); graphicsContext->fillPath(exteriorPath); } @@ -772,8 +772,8 @@ void ShadowBlur::drawLayerPieces(GraphicsContext* graphicsContext, const FloatRe } GraphicsContextStateSaver stateSaver(*graphicsContext); - graphicsContext->clearShadow(); graphicsContext->setFillColor(m_color, m_colorSpace); + graphicsContext->clearShadow(); // Note that drawing the ImageBuffer is faster than creating a Image and drawing that, // because ImageBuffer::draw() knows that it doesn't have to copy the image bits. diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index e91c2d287..ec992d648 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -791,6 +791,37 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef p->fillPath(path.platformPath(), QColor(color)); } +void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedRect& roundedHoleRect, const Color& color, ColorSpace colorSpace) +{ + if (paintingDisabled() || !color.isValid()) + return; + + Path path; + path.addRect(rect); + if (!roundedHoleRect.radii().isZero()) + path.addRoundedRect(roundedHoleRect); + else + path.addRect(roundedHoleRect.rect()); + + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(Qt::OddEvenFill); + + QPainter* p = m_data->p(); + if (hasShadow()) { + ShadowBlur* shadow = shadowBlur(); + if (shadow->mustUseShadowBlur(this)) + shadow->drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii()); + else { + const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height()); + p->translate(shadowOffset); + p->fillPath(platformPath, QColor(m_state.shadowColor)); + p->translate(-shadowOffset); + } + } + + p->fillPath(platformPath, QColor(color)); +} + bool GraphicsContext::isInTransparencyLayer() const { return m_data->layerCount; |