[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:09:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 52ee2c57d89ba5c553b9daab738e81594252b05f
Author: ariya at webkit.org <ariya at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Aug 16 12:58:48 2010 +0000

    2010-08-16  Ariya Hidayat  <ariya at sencha.com>
    
            Reviewed by Antonio Gomes.
    
            [Qt] Save and restore shadow state in GraphicsContextQt
            https://bugs.webkit.org/show_bug.cgi?id=44031
    
            This is needed after r65362.
            Use a new class ContextShadowParameter to track and keep the shadow
            state. We use this rather than using GraphicsContextState to allow
            possible optimizations (right now only to determine the shadow type,
            but in future it might cover things like cached scratch image,
            persistent shader, etc).
    
            * platform/graphics/qt/GraphicsContextQt.cpp:
            (WebCore::ContextShadowParameter::):
            (WebCore::ContextShadowParameter::ContextShadowParameter):
            (WebCore::ContextShadowParameter::clear):
            (WebCore::GraphicsContextPlatformPrivate::hasShadow):
            (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
            (WebCore::GraphicsContext::savePlatformState):
            (WebCore::GraphicsContext::restorePlatformState):
            (WebCore::GraphicsContext::drawRect):
            (WebCore::GraphicsContext::drawLine):
            (WebCore::GraphicsContext::strokeArc):
            (WebCore::GraphicsContext::drawConvexPolygon):
            (WebCore::GraphicsContext::fillPath):
            (WebCore::GraphicsContext::strokePath):
            (WebCore::GraphicsContext::fillRect):
            (WebCore::GraphicsContext::fillRoundedRect):
            (WebCore::GraphicsContext::setPlatformShadow):
            (WebCore::GraphicsContext::clearPlatformShadow):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 970fb36..847045a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2010-08-16  Ariya Hidayat  <ariya at sencha.com>
+
+        Reviewed by Antonio Gomes.
+
+        [Qt] Save and restore shadow state in GraphicsContextQt
+        https://bugs.webkit.org/show_bug.cgi?id=44031
+
+        This is needed after r65362.
+        Use a new class ContextShadowParameter to track and keep the shadow
+        state. We use this rather than using GraphicsContextState to allow
+        possible optimizations (right now only to determine the shadow type,
+        but in future it might cover things like cached scratch image,
+        persistent shader, etc).
+
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::ContextShadowParameter::):
+        (WebCore::ContextShadowParameter::ContextShadowParameter):
+        (WebCore::ContextShadowParameter::clear):
+        (WebCore::GraphicsContextPlatformPrivate::hasShadow):
+        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
+        (WebCore::GraphicsContext::savePlatformState):
+        (WebCore::GraphicsContext::restorePlatformState):
+        (WebCore::GraphicsContext::drawRect):
+        (WebCore::GraphicsContext::drawLine):
+        (WebCore::GraphicsContext::strokeArc):
+        (WebCore::GraphicsContext::drawConvexPolygon):
+        (WebCore::GraphicsContext::fillPath):
+        (WebCore::GraphicsContext::strokePath):
+        (WebCore::GraphicsContext::fillRect):
+        (WebCore::GraphicsContext::fillRoundedRect):
+        (WebCore::GraphicsContext::setPlatformShadow):
+        (WebCore::GraphicsContext::clearPlatformShadow):
+
 2010-07-28  Marcus Bulach  <bulach at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index d22131f..d30ea66 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -167,6 +167,63 @@ static inline Qt::FillRule toQtFillRule(WindRule rule)
     return Qt::OddEvenFill;
 }
 
+
+// This is to track and keep the shadow state. We use this rather than
+// using GraphicsContextState to allow possible optimizations (right now
+// only to determine the shadow type, but in future it might cover things
+// like cached scratch image, persistent shader, etc).
+
+class ContextShadowParameter {
+public:
+    enum {
+        NoShadow,
+        OpaqueSolidShadow,
+        AlphaSolidShadow,
+        BlurShadow
+    } type;
+
+    QColor color;
+    int blurRadius;
+    QPointF offset;
+
+    ContextShadowParameter()
+        : type(NoShadow)
+        , blurRadius(0)
+    {
+    }
+
+    ContextShadowParameter(const QColor& c, float r, qreal dx, qreal dy)
+        : color(c)
+        , blurRadius(qRound(r))
+        , offset(dx, dy)
+    {
+        // The type of shadow is decided by the blur radius, shadow offset, and shadow color.
+        if (!color.isValid() || !color.alpha()) {
+            // Can't paint the shadow with invalid or invisible color.
+            type = NoShadow;
+        } else if (r > 0) {
+            // Shadow is always blurred, even the offset is zero.
+            type = BlurShadow;
+        } else if (offset.isNull()) {
+            // Without blur and zero offset means the shadow is fully hidden.
+            type = NoShadow;
+        } else {
+            if (color.alpha() > 0)
+                type = AlphaSolidShadow;
+            else
+                type = OpaqueSolidShadow;
+        }
+    }
+
+    void clear()
+    {
+        type = NoShadow;
+        color = QColor();
+        blurRadius = 0;
+        offset = QPointF();
+    }
+};
+
 class GraphicsContextPlatformPrivate : public Noncopyable {
 public:
     GraphicsContextPlatformPrivate(QPainter* painter);
@@ -199,19 +256,12 @@ public:
     // Only used by SVG for now.
     QPainterPath currentPath;
 
-    enum {
-        NoShadow,
-        OpaqueSolidShadow,
-        AlphaSolidShadow,
-        BlurShadow
-    } shadowType;
-    QColor shadowColor;
-    int shadowBlurRadius;
-    QPointF shadowOffset;
+    ContextShadowParameter shadow;
+    QStack<ContextShadowParameter> shadowStack;
 
     bool hasShadow() const
     {
-        return shadowType != NoShadow;
+        return shadow.type != ContextShadowParameter::NoShadow;
     }
 
 private:
@@ -237,9 +287,6 @@ GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p)
         painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
     } else
         antiAliasingForRectsAndLines = false;
-
-    shadowType = NoShadow;
-    shadowBlurRadius = 0;
 }
 
 GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
@@ -284,6 +331,7 @@ void GraphicsContext::savePlatformState()
     if (!m_data->layers.isEmpty() && !m_data->layers.top()->alphaMask.isNull())
         ++m_data->layers.top()->saveCounter;
     m_data->p()->save();
+    m_data->shadowStack.push(m_data->shadow);
 }
 
 void GraphicsContext::restorePlatformState()
@@ -298,6 +346,11 @@ void GraphicsContext::restorePlatformState()
         QTransform matrix = m_common->state.pathTransform;
         m_data->currentPath = m_data->currentPath * matrix;
     }
+
+    if (m_data->shadowStack.isEmpty())
+        m_data->shadow = ContextShadowParameter();
+    else
+        m_data->shadow = m_data->shadowStack.pop();
 }
 
 // Draws a filled rectangle with a stroked border.
@@ -436,9 +489,9 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp
 
     if (m_data->hasShadow()) {
         p->save();
-        p->translate(m_data->shadowOffset);
+        p->translate(m_data->shadow.offset);
         QPen pen(p->pen());
-        pen.setColor(m_data->shadowColor);
+        pen.setColor(m_data->shadow.color);
         p->setPen(pen);
         p->drawArc(rect, startAngle, angleSpan);
         p->restore();
@@ -466,12 +519,12 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
     p->setRenderHint(QPainter::Antialiasing, shouldAntialias);
     if (m_data->hasShadow()) {
         p->save();
-        p->translate(m_data->shadowOffset);
+        p->translate(m_data->shadow.offset);
         if (p->brush().style() != Qt::NoBrush)
-            p->setBrush(QBrush(m_data->shadowColor));
+            p->setBrush(QBrush(m_data->shadow.color));
         QPen pen(p->pen());
         if (pen.style() != Qt::NoPen) {
-            pen.setColor(m_data->shadowColor);
+            pen.setColor(m_data->shadow.color);
             p->setPen(pen);
         }
         p->drawConvexPolygon(polygon);
@@ -515,9 +568,9 @@ void GraphicsContext::fillPath()
     path.setFillRule(toQtFillRule(fillRule()));
 
     if (m_data->hasShadow()) {
-        p->translate(m_data->shadowOffset);
-        p->fillPath(path, m_data->shadowColor);
-        p->translate(-m_data->shadowOffset);
+        p->translate(m_data->shadow.offset);
+        p->fillPath(path, m_data->shadow.color);
+        p->translate(-m_data->shadow.offset);
     }
     if (m_common->state.fillPattern) {
         AffineTransform affine;
@@ -543,11 +596,11 @@ void GraphicsContext::strokePath()
     path.setFillRule(toQtFillRule(fillRule()));
 
     if (m_data->hasShadow()) {
-        p->translate(m_data->shadowOffset);
+        p->translate(m_data->shadow.offset);
         QPen shadowPen(pen);
-        shadowPen.setColor(m_data->shadowColor);
+        shadowPen.setColor(m_data->shadow.color);
         p->strokePath(path, shadowPen);
-        p->translate(-m_data->shadowOffset);
+        p->translate(-m_data->shadow.offset);
     }
     if (m_common->state.strokePattern) {
         AffineTransform affine;
@@ -648,10 +701,10 @@ void GraphicsContext::fillRect(const FloatRect& rect)
         shadowImage = new QImage(roundedIntSize(normalizedRect.size()), QImage::Format_ARGB32_Premultiplied);
         pShadow = new QPainter(shadowImage);
         shadowDestRect = normalizedRect;
-        shadowDestRect.translate(m_data->shadowOffset);
+        shadowDestRect.translate(m_data->shadow.offset);
 
         pShadow->setCompositionMode(QPainter::CompositionMode_Source);
-        pShadow->fillRect(shadowImage->rect(), m_data->shadowColor);
+        pShadow->fillRect(shadowImage->rect(), m_data->shadow.color);
         pShadow->setCompositionMode(QPainter::CompositionMode_DestinationIn);
     }
 
@@ -700,7 +753,7 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
     QPainter* p = m_data->p();
 
     if (m_data->hasShadow())
-        p->fillRect(QRectF(rect).translated(m_data->shadowOffset), m_data->shadowColor);
+        p->fillRect(QRectF(rect).translated(m_data->shadow.offset), m_data->shadow.color);
 
     p->fillRect(rect, m_data->solidColor);
 }
@@ -713,9 +766,9 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
     Path path = Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight);
     QPainter* p = m_data->p();
     if (m_data->hasShadow()) {
-        p->translate(m_data->shadowOffset);
-        p->fillPath(path.platformPath(), m_data->shadowColor);
-        p->translate(-m_data->shadowOffset);
+        p->translate(m_data->shadow.offset);
+        p->fillPath(path.platformPath(), m_data->shadow.color);
+        p->translate(-m_data->shadow.offset);
     }
     p->fillPath(path.platformPath(), QColor(color));
 }
@@ -867,40 +920,15 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size, float blur, const
         // Meaning that this graphics context is associated with a CanvasRenderingContext
         // We flip the height since CG and HTML5 Canvas have opposite Y axis
         m_common->state.shadowSize = FloatSize(size.width(), -size.height());
-    }
-
-    // Here we just store important shadow states.
-
-    m_data->shadowBlurRadius = qRound(blur);
-    m_data->shadowOffset = QPointF(m_common->state.shadowSize.width(), m_common->state.shadowSize.height());
-    m_data->shadowColor = color;
-
-    // The type of shadow is decided by the blur radius, shadow offset, and shadow color.
-
-    if (!color.isValid() || !color.alpha()) {
-        // Can't paint the shadow with invalid or invisible color.
-        m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow;
+        m_data->shadow = ContextShadowParameter(color, blur, size.width(), -size.height());
     } else {
-        if (blur > 0) {
-            // Shadow is always blurred, even the offset is zero.
-            m_data->shadowType = GraphicsContextPlatformPrivate::BlurShadow;
-        } else {
-            if (m_data->shadowOffset.isNull()) {
-                // Without blur and zero offset means the shadow is fully hidden.
-                m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow;
-            } else {
-                if (color.hasAlpha())
-                    m_data->shadowType = GraphicsContextPlatformPrivate::AlphaSolidShadow;
-                else
-                    m_data->shadowType = GraphicsContextPlatformPrivate::OpaqueSolidShadow;
-            }
-        }
+        m_data->shadow = ContextShadowParameter(color, blur, size.width(), size.height());
     }
 }
 
 void GraphicsContext::clearPlatformShadow()
 {
-    m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow;
+    m_data->shadow.clear();
 }
 
 void GraphicsContext::beginTransparencyLayer(float opacity)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list