[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

ariya at webkit.org ariya at webkit.org
Wed Dec 22 12:28:00 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a493d26b724202dfb6c2ac492750314e067f679b
Author: ariya at webkit.org <ariya at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 24 08:38:35 2010 +0000

    [Qt] Support text-shadow blur
    https://bugs.webkit.org/show_bug.cgi?id=19728
    
    Patch by Ariya Hidayat <ariya at sencha.com> on 2010-08-24
    Reviewed by Kenneth Rohde Christiansen.
    
    Implement blur for text shadow using the shadow layer in r65782.
    
    * platform/graphics/qt/ContextShadow.cpp:
    (WebCore::ContextShadow::beginShadowLayer):
    * platform/graphics/qt/FontQt.cpp:
    (WebCore::drawTextCommon):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65876 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 415a015..cc176f0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-24  Ariya Hidayat  <ariya at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Support text-shadow blur
+        https://bugs.webkit.org/show_bug.cgi?id=19728
+
+        Implement blur for text shadow using the shadow layer in r65782.
+
+        * platform/graphics/qt/ContextShadow.cpp:
+        (WebCore::ContextShadow::beginShadowLayer):
+        * platform/graphics/qt/FontQt.cpp:
+        (WebCore::drawTextCommon):
+
 2010-08-23  Andreas Kling  <andreas.kling at nokia.com>
 
         Reviewed by Tor Arne Vestbø.
diff --git a/WebCore/platform/graphics/qt/ContextShadow.cpp b/WebCore/platform/graphics/qt/ContextShadow.cpp
index 96d13fc..829ca82 100644
--- a/WebCore/platform/graphics/qt/ContextShadow.cpp
+++ b/WebCore/platform/graphics/qt/ContextShadow.cpp
@@ -314,6 +314,7 @@ QPainter* ContextShadow::beginShadowLayer(QPainter* p, const QRectF &rect)
 
     m_layerPainter = new QPainter;
     m_layerPainter->begin(&m_layerImage);
+    m_layerPainter->setFont(p->font());
     m_layerPainter->translate(offset);
 
     // The origin is now the top left corner of the scratch image.
diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp
index 8edd356..2b246de 100644
--- a/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/WebCore/platform/graphics/qt/FontQt.cpp
@@ -23,6 +23,7 @@
 #include "Font.h"
 
 #include "AffineTransform.h"
+#include "ContextShadow.h"
 #include "FontDescription.h"
 #include "FontFallbackList.h"
 #include "FontSelector.h"
@@ -108,12 +109,6 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
     QString string = fromRawDataWithoutRef(sanitized);
     QPointF pt(point.x(), point.y());
 
-    // text shadow
-    FloatSize shadowSize;
-    float shadowBlur;
-    Color shadowColor;
-    bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor);
-
     if (from > 0 || to < run.length()) {
         if (isComplexText) {
             QTextLayout layout(string, font);
@@ -125,32 +120,46 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
 
             QFontMetrics fm(font);
             int ascent = fm.ascent();
-            QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
+            QRectF boundingRect(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
+            QRectF clip = boundingRect;
+
+            ContextShadow* ctxShadow = ctx->contextShadow();
 
-            if (hasShadow) {
-                // TODO: when blur support is added, the clip will need to account
-                // for the blur radius
+            if (ctxShadow->type != ContextShadow::NoShadow) {
                 qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
-                if (shadowSize.width() > 0)
-                    dx2 = shadowSize.width();
+                if (ctxShadow->offset.x() > 0)
+                    dx2 = ctxShadow->offset.x();
                 else
-                    dx1 = -shadowSize.width();
-                if (shadowSize.height() > 0)
-                    dy2 = shadowSize.height();
+                    dx1 = -ctxShadow->offset.x();
+                if (ctxShadow->offset.y() > 0)
+                    dy2 = ctxShadow->offset.y();
                 else
-                    dy1 = -shadowSize.height();
+                    dy1 = -ctxShadow->offset.y();
                 // expand the clip rect to include the text shadow as well
                 clip.adjust(dx1, dx2, dy1, dy2);
+                clip.adjust(-ctxShadow->blurRadius, -ctxShadow->blurRadius, ctxShadow->blurRadius, ctxShadow->blurRadius);
             }
             p->save();
             p->setClipRect(clip.toRect(), Qt::IntersectClip);
             pt.setY(pt.y() - ascent);
-            if (hasShadow) {
-                p->save();
-                p->setPen(QColor(shadowColor));
-                p->translate(shadowSize.width(), shadowSize.height());
-                line.draw(p, pt);
-                p->restore();
+
+            if (ctxShadow->type != ContextShadow::NoShadow) {
+                ContextShadow* ctxShadow = ctx->contextShadow();
+                if (ctxShadow->type != ContextShadow::BlurShadow) {
+                    p->save();
+                    p->setPen(ctxShadow->color);
+                    p->translate(ctxShadow->offset);
+                    line.draw(p, pt);
+                    p->restore();
+                } else {
+                    QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect);
+                    if (shadowPainter) {
+                        // Since it will be blurred anyway, we don't care about render hints.
+                        shadowPainter->setPen(ctxShadow->color);
+                        line.draw(shadowPainter, pt);
+                        ctxShadow->endShadowLayer(p);
+                    }
+                }
             }
             p->setPen(textFillPen);
             line.draw(p, pt);
@@ -172,13 +181,26 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
     if (!isComplexText && !(ctx->textDrawingMode() & cTextStroke))
         flags |= Qt::TextBypassShaping;
 #endif
-    if (hasShadow) {
-        // TODO: text shadow blur support
-        p->save();
-        p->setPen(QColor(shadowColor));
-        p->translate(shadowSize.width(), shadowSize.height());
-        p->drawText(pt, string, flags, run.padding());
-        p->restore();
+    if (ctx->contextShadow()->type != ContextShadow::NoShadow) {
+        ContextShadow* ctxShadow = ctx->contextShadow();
+        if (ctxShadow->type != ContextShadow::BlurShadow) {
+            p->save();
+            p->setPen(ctxShadow->color);
+            p->translate(ctxShadow->offset);
+            p->drawText(pt, string, flags, run.padding());
+            p->restore();
+        } else {
+            QFontMetrics fm(font);
+            QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height());
+            QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect);
+            if (shadowPainter) {
+                // Since it will be blurred anyway, we don't care about render hints.
+                shadowPainter->setFont(p->font());
+                shadowPainter->setPen(ctxShadow->color);
+                shadowPainter->drawText(pt, string, flags, run.padding());
+                ctxShadow->endShadowLayer(p);
+            }
+        }
     }
     if (ctx->textDrawingMode() & cTextStroke) {
         QPainterPath path;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list