Title: [145366] trunk/Source/WebCore
Revision
145366
Author
[email protected]
Date
2013-03-11 08:43:06 -0700 (Mon, 11 Mar 2013)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145365 => 145366)


--- trunk/Source/WebCore/ChangeLog	2013-03-11 15:33:35 UTC (rev 145365)
+++ trunk/Source/WebCore/ChangeLog	2013-03-11 15:43:06 UTC (rev 145366)
@@ -1,3 +1,27 @@
+2013-03-11  Allan Sandfeld Jensen  <[email protected]>
+
+        [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):
+
 2013-03-11  Alberto Garcia  <[email protected]>
 
         [BlackBerry] GraphicsLayer: rename notifySyncRequired to notifyFlushRequired

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (145365 => 145366)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2013-03-11 15:33:35 UTC (rev 145365)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2013-03-11 15:43:06 UTC (rev 145366)
@@ -677,7 +677,7 @@
         fillRect(rect.rect(), 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())

Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp (145365 => 145366)


--- trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2013-03-11 15:33:35 UTC (rev 145365)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp	2013-03-11 15:43:06 UTC (rev 145366)
@@ -696,9 +696,9 @@
 
     {
         GraphicsContextStateSaver fillStateSaver(*graphicsContext);
-        graphicsContext->clearShadow();
         graphicsContext->setFillRule(RULE_EVENODD);
         graphicsContext->setFillColor(m_color, m_colorSpace);
+        graphicsContext->clearShadow();
         graphicsContext->fillPath(exteriorPath);
     }
     
@@ -772,8 +772,8 @@
     }
 
     GraphicsContextStateSaver stateSaver(*graphicsContext);
+    graphicsContext->setFillColor(m_color, m_colorSpace);
     graphicsContext->clearShadow();
-    graphicsContext->setFillColor(m_color, m_colorSpace);
 
     // 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.

Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp (145365 => 145366)


--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp	2013-03-11 15:33:35 UTC (rev 145365)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp	2013-03-11 15:43:06 UTC (rev 145366)
@@ -864,6 +864,37 @@
     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;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to