From 3774b52275c59d74571b0e1f87950dcfc257d408 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 14 Mar 2013 14:01:52 +0100 Subject: [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 --- .../platform/graphics/qt/GraphicsContextQt.cpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp') 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; -- cgit v1.2.3