Changeset 147750 in webkit


Ignore:
Timestamp:
Apr 5, 2013 8:52:08 AM (11 years ago)
Author:
allan.jensen@digia.com
Message:

[Qt] Create ShadowBlur on demand.
https://bugs.webkit.org/show_bug.cgi?id=113506

Reviewed by Noam Rosenthal.

This patch creates ShadowBlur objects on demand instead of keeping a single one alive for
each GraphicsContext. This matches what other platforms does and fixes the problem with
an active shadowblur being affected by changing shadow settings on the GraphicsContext.

The method mustUseShadowBlur is moved from ShadowBlur to GraphcisContext, so that it can
be used to determine if a ShadowBlur object should even be generated.

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::hasBlurredShadow):
(WebCore::GraphicsContext::mustUseShadowBlur):

  • platform/graphics/GraphicsContext.h:

(GraphicsContext):

  • platform/graphics/ShadowBlur.cpp:

(WebCore::ShadowBlur::ShadowBlur):

  • platform/graphics/ShadowBlur.h:
  • platform/graphics/cairo/FontCairo.cpp:

(WebCore::drawGlyphsShadow):

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::fillRectWithRoundedHole):

  • platform/graphics/qt/FontQt.cpp:

(WebCore::drawQtGlyphRun):

  • platform/graphics/qt/GraphicsContextQt.cpp:

(GraphicsContextPlatformPrivate):
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
(WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
(WebCore::GraphicsContext::restorePlatformState):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::fillRoundedRect):
(WebCore::GraphicsContext::fillRectWithRoundedHole):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::clearPlatformShadow):

  • platform/graphics/qt/ImageQt.cpp:

(WebCore::BitmapImage::draw):

  • platform/graphics/qt/StillImageQt.cpp:

(WebCore::StillImage::draw):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147749 r147750  
     12013-03-28  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] Create ShadowBlur on demand.
     4        https://bugs.webkit.org/show_bug.cgi?id=113506
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        This patch creates ShadowBlur objects on demand instead of keeping a single one alive for
     9        each GraphicsContext. This matches what other platforms does and fixes the problem with
     10        an active shadowblur being affected by changing shadow settings on the GraphicsContext.
     11
     12        The method mustUseShadowBlur is moved from ShadowBlur to GraphcisContext, so that it can
     13        be used to determine if a ShadowBlur object should even be generated.
     14
     15        * platform/graphics/GraphicsContext.cpp:
     16        (WebCore::GraphicsContext::hasBlurredShadow):
     17        (WebCore::GraphicsContext::mustUseShadowBlur):
     18        * platform/graphics/GraphicsContext.h:
     19        (GraphicsContext):
     20        * platform/graphics/ShadowBlur.cpp:
     21        (WebCore::ShadowBlur::ShadowBlur):
     22        * platform/graphics/ShadowBlur.h:
     23        * platform/graphics/cairo/FontCairo.cpp:
     24        (WebCore::drawGlyphsShadow):
     25        * platform/graphics/cg/GraphicsContextCG.cpp:
     26        (WebCore::GraphicsContext::fillRect):
     27        (WebCore::GraphicsContext::fillRoundedRect):
     28        (WebCore::GraphicsContext::fillRectWithRoundedHole):
     29        * platform/graphics/qt/FontQt.cpp:
     30        (WebCore::drawQtGlyphRun):
     31        * platform/graphics/qt/GraphicsContextQt.cpp:
     32        (GraphicsContextPlatformPrivate):
     33        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
     34        (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
     35        (WebCore::GraphicsContext::restorePlatformState):
     36        (WebCore::GraphicsContext::fillPath):
     37        (WebCore::GraphicsContext::strokePath):
     38        (WebCore::GraphicsContext::fillRect):
     39        (WebCore::GraphicsContext::fillRoundedRect):
     40        (WebCore::GraphicsContext::fillRectWithRoundedHole):
     41        (WebCore::GraphicsContext::setPlatformShadow):
     42        (WebCore::GraphicsContext::clearPlatformShadow):
     43        * platform/graphics/qt/ImageQt.cpp:
     44        (WebCore::BitmapImage::draw):
     45        * platform/graphics/qt/StillImageQt.cpp:
     46        (WebCore::StillImage::draw):
     47
    1482013-04-05  Ryosuke Niwa  <rniwa@webkit.org>
    249
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r145366 r147750  
    185185}
    186186
     187bool GraphicsContext::hasBlurredShadow() const
     188{
     189    return m_state.shadowColor.isValid() && m_state.shadowColor.alpha() && m_state.shadowBlur;
     190}
     191
     192#if PLATFORM(QT) || USE(CAIRO)
     193bool GraphicsContext::mustUseShadowBlur() const
     194{
     195    // We can't avoid ShadowBlur if the shadow has blur.
     196    if (hasBlurredShadow())
     197        return true;
     198    // We can avoid ShadowBlur and optimize, since we're not drawing on a
     199    // canvas and box shadows are affected by the transformation matrix.
     200    if (!m_state.shadowsIgnoreTransforms)
     201        return false;
     202    // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
     203    if (getCTM().isIdentity())
     204        return false;
     205    // Otherwise, no chance avoiding ShadowBlur.
     206    return true;
     207}
     208#endif
     209
    187210float GraphicsContext::strokeThickness() const
    188211{
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r147622 r147750  
    5454#elif PLATFORM(QT)
    5555#include <QPainter>
    56 namespace WebCore {
    57 class ShadowBlur;
    58 }
    5956typedef QPainter PlatformGraphicsContext;
    6057#elif PLATFORM(WX)
     
    395392        void clearShadow();
    396393
     394        bool hasBlurredShadow() const;
     395#if PLATFORM(QT) || USE(CAIRO)
     396        bool mustUseShadowBlur() const;
     397#endif
     398
    397399        void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
    398400        void drawFocusRing(const Path&, int width, int offset, const Color&);
     
    516518        void pushTransparencyLayerInternal(const QRect&, qreal, QPixmap&);
    517519        void takeOwnershipOfPlatformContext();
    518 #endif
    519 
    520 #if PLATFORM(QT)
    521         ShadowBlur* shadowBlur();
    522520#endif
    523521
  • trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp

    r145810 r147750  
    44 * Copyright (C) 2010 Igalia S.L. All rights reserved.
    55 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
     6 * Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies).
    67 *
    78 * Redistribution and use in source and binary forms, with or without
     
    169170static const int templateSideLength = 1;
    170171
     172#if USE(CG)
     173static float radiusToLegacyRadius(float radius)
     174{
     175    return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
     176}
     177#endif
     178
    171179ShadowBlur::ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color& color, ColorSpace colorSpace)
    172180    : m_color(color)
     
    177185    , m_shadowsIgnoreTransforms(false)
    178186{
     187    updateShadowBlurValues();
     188}
     189
     190ShadowBlur::ShadowBlur(const GraphicsContextState& state)
     191    : m_color(state.shadowColor)
     192    , m_colorSpace(state.shadowColorSpace)
     193    , m_blurRadius(state.shadowBlur, state.shadowBlur)
     194    , m_offset(state.shadowOffset)
     195    , m_layerImage(0)
     196    , m_shadowsIgnoreTransforms(state.shadowsIgnoreTransforms)
     197{
     198#if USE(CG)
     199    if (state.shadowsUseLegacyRadius) {
     200        float shadowBlur = radiusToLegacyRadius(state.shadowBlur);
     201        m_blurRadius = FloatSize(shadowBlur, shadowBlur);
     202    }
     203#endif
    179204    updateShadowBlurValues();
    180205}
     
    898923}
    899924
    900 #if PLATFORM(QT) || USE(CAIRO)
    901 bool ShadowBlur::mustUseShadowBlur(GraphicsContext* context) const
    902 {
    903     // We can't avoid ShadowBlur, since the shadow has blur.
    904     if (type() == BlurShadow)
    905         return true;
    906     // We can avoid ShadowBlur and optimize, since we're not drawing on a
    907     // canvas and box shadows are affected by the transformation matrix.
    908     if (!shadowsIgnoreTransforms())
    909         return false;
    910     // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
    911     if (context->getCTM().isIdentity())
    912         return false;
    913     // Otherwise, no chance avoiding ShadowBlur.
    914     return true;
    915 }
    916 #endif
    917 
    918925} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/ShadowBlur.h

    r95901 r147750  
    4040class AffineTransform;
    4141class GraphicsContext;
     42struct GraphicsContextState;
    4243class ImageBuffer;
    4344
     
    5253
    5354    ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color&, ColorSpace);
     55    ShadowBlur(const GraphicsContextState&);
    5456    ShadowBlur();
    5557
     
    7072
    7173    ShadowType type() const { return m_type; }
    72 
    73 #if PLATFORM(QT) || USE(CAIRO)
    74     bool mustUseShadowBlur(GraphicsContext*) const;
    75 #endif
    7674
    7775private:
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp

    r129657 r147750  
    7070        return;
    7171
    72     if (!shadow.mustUseShadowBlur(graphicsContext)) {
     72    if (!graphicsContext->mustUseShadowBlur()) {
    7373        // Optimize non-blurry shadows, by just drawing text without the ShadowBlur.
    7474        cairo_t* context = graphicsContext->platformContext()->cr();
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r147710 r147750  
    763763}
    764764
    765 static float radiusToLegacyRadius(float radius)
    766 {
    767     return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
    768 }
    769 
    770 static bool hasBlurredShadow(const GraphicsContextState& state)
    771 {
    772     return state.shadowColor.isValid() && state.shadowColor.alpha() && state.shadowBlur;
    773 }
    774 
    775765void GraphicsContext::fillRect(const FloatRect& rect)
    776766{
     
    809799        applyFillPattern();
    810800
    811     bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
     801    bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
    812802    if (drawOwnShadow) {
    813         float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
    814803        // Turn off CG shadows.
    815804        CGContextSaveGState(context);
    816805        CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
    817806
    818         ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
     807        ShadowBlur contextShadow(m_state);
    819808        contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
    820809    }
     
    838827        setCGFillColor(context, color, colorSpace);
    839828
    840     bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
     829    bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
    841830    if (drawOwnShadow) {
    842         float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
    843831        // Turn off CG shadows.
    844832        CGContextSaveGState(context);
    845833        CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
    846834
    847         ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
     835        ShadowBlur contextShadow(m_state);
    848836        contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
    849837    }
     
    870858        setCGFillColor(context, color, colorSpace);
    871859
    872     bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
     860    bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
    873861    if (drawOwnShadow) {
    874         float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
    875 
    876862        // Turn off CG shadows.
    877863        CGContextSaveGState(context);
    878864        CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
    879865
    880         ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
     866        ShadowBlur contextShadow(m_state);
    881867        contextShadow.drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
    882868    }
     
    923909
    924910    // fillRectWithRoundedHole() assumes that the edges of rect are clipped out, so we only care about shadows cast around inside the hole.
    925     bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms;
     911    bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms;
    926912    if (drawOwnShadow) {
    927         float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
    928 
    929913        // Turn off CG shadows.
    930914        CGContextSaveGState(context);
    931915        CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
    932916
    933         ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
     917        ShadowBlur contextShadow(m_state);
    934918        contextShadow.drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
    935919    }
  • trunk/Source/WebCore/platform/graphics/qt/FontQt.cpp

    r146761 r147750  
    126126        textStrokePath = pathForGlyphs(qtGlyphRun, point);
    127127
    128     ShadowBlur* shadow = context->shadowBlur();
    129     if (context->hasShadow() && shadow->type() != ShadowBlur::NoShadow) {
    130         switch (shadow->type()) {
    131         case ShadowBlur::SolidShadow: {
     128    if (context->hasShadow()) {
     129        const GraphicsContextState& state = context->state();
     130        if (context->mustUseShadowBlur()) {
     131            ShadowBlur shadow(state);
     132            const int width = qtGlyphRun.boundingRect().width();
     133            const QRawFont& font = qtGlyphRun.rawFont();
     134            const int height = font.ascent() + font.descent();
     135            const QRectF boundingRect(point.x(), point.y() - font.ascent() + baseLineOffset, width, height);
     136            GraphicsContext* shadowContext = shadow.beginShadowLayer(context, boundingRect);
     137            if (shadowContext) {
     138                QPainter* shadowPainter = shadowContext->platformContext();
     139                shadowPainter->setPen(state.shadowColor);
     140                if (shadowContext->textDrawingMode() & TextModeFill)
     141                    shadowPainter->drawGlyphRun(point, qtGlyphRun);
     142                else if (shadowContext->textDrawingMode() & TextModeStroke)
     143                    shadowPainter->strokePath(textStrokePath, shadowPainter->pen());
     144                shadow.endShadowLayer(context);
     145            }
     146        } else {
    132147            QPen previousPen = painter->pen();
    133             painter->setPen(context->state().shadowColor);
    134             const QPointF shadowOffset(context->state().shadowOffset.width(), context->state().shadowOffset.height());
     148            painter->setPen(state.shadowColor);
     149            const QPointF shadowOffset(state.shadowOffset.width(), state.shadowOffset.height());
    135150            painter->translate(shadowOffset);
    136151            if (context->textDrawingMode() & TextModeFill)
     
    140155            painter->translate(-shadowOffset);
    141156            painter->setPen(previousPen);
    142             break;
    143         }
    144         case ShadowBlur::BlurShadow: {
    145             const int width = qtGlyphRun.boundingRect().width();
    146             const QRawFont& font = qtGlyphRun.rawFont();
    147             const int height = font.ascent() + font.descent();
    148             const QRectF boundingRect(point.x(), point.y() - font.ascent() + baseLineOffset, width, height);
    149             GraphicsContext* shadowContext = shadow->beginShadowLayer(context, boundingRect);
    150             if (shadowContext) {
    151                 QPainter* shadowPainter = shadowContext->platformContext();
    152                 shadowPainter->setPen(shadowContext->state().shadowColor);
    153                 if (shadowContext->textDrawingMode() & TextModeFill)
    154                     shadowPainter->drawGlyphRun(point, qtGlyphRun);
    155                 else if (shadowContext->textDrawingMode() & TextModeStroke)
    156                     shadowPainter->strokePath(textStrokePath, shadowPainter->pen());
    157                 shadow->endShadowLayer(context);
    158             }
    159             break;
    160         }
    161         case ShadowBlur::NoShadow:
    162         default:
    163             ASSERT_NOT_REACHED();
    164             break;
    165157        }
    166158    }
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r146878 r147750  
    1111 * Copyright (C) 2010, 2011 Sencha, Inc.
    1212 * Copyright (C) 2011 Andreas Kling <kling@webkit.org>
     13 * Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies).
    1314 *
    1415 * All rights reserved.
     
    251252    bool initialSmoothPixmapTransformHint;
    252253
    253     ShadowBlur* shadow;
    254 
    255254    QRectF clipBoundingRect() const
    256255    {
     
    271270    , imageInterpolationQuality(InterpolationDefault)
    272271    , initialSmoothPixmapTransformHint(false)
    273     , shadow(new ShadowBlur())
    274272    , painter(p)
    275273    , platformContextIsOwned(false)
     
    290288GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
    291289{
    292     delete shadow;
    293 
    294290    if (!platformContextIsOwned)
    295291        return;
     
    356352
    357353    m_data->p()->restore();
    358 
    359     m_data->shadow->setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace, m_state.shadowsIgnoreTransforms);
    360354}
    361355
     
    629623
    630624    if (hasShadow()) {
    631         ShadowBlur* shadow = shadowBlur();
    632         if (shadow->mustUseShadowBlur(this) || m_state.fillPattern || m_state.fillGradient)
     625        if (mustUseShadowBlur() || m_state.fillPattern || m_state.fillGradient)
    633626        {
    634             GraphicsContext* shadowContext = shadow->beginShadowLayer(this, platformPath.controlPointRect());
     627            ShadowBlur shadow(m_state);
     628            GraphicsContext* shadowContext = shadow.beginShadowLayer(this, platformPath.controlPointRect());
    635629            if (shadowContext) {
    636630                QPainter* shadowPainter = shadowContext->platformContext();
     
    644638                    shadowPainter->fillPath(platformPath, p->brush());
    645639                }
    646                 shadow->endShadowLayer(this);
     640                shadow.endShadowLayer(this);
    647641            }
    648642        } else {
     
    688682
    689683    if (hasShadow()) {
    690         ShadowBlur* shadow = shadowBlur();
    691         if (shadow->mustUseShadowBlur(this) || m_state.strokePattern || m_state.strokeGradient)
     684        if (mustUseShadowBlur() || m_state.strokePattern || m_state.strokeGradient)
    692685        {
     686            ShadowBlur shadow(m_state);
    693687            FloatRect boundingRect = platformPath.controlPointRect();
    694688            boundingRect.inflate(pen.miterLimit() + pen.widthF());
    695             GraphicsContext* shadowContext = shadow->beginShadowLayer(this, boundingRect);
     689            GraphicsContext* shadowContext = shadow.beginShadowLayer(this, boundingRect);
    696690            if (shadowContext) {
    697691                QPainter* shadowPainter = shadowContext->platformContext();
     
    702696                } else
    703697                    fillPathStroke(shadowPainter, pathStroker, platformPath, pen.brush());
    704                 shadow->endShadowLayer(this);
     698                shadow.endShadowLayer(this);
    705699            }
    706700        } else {
     
    780774    QPainter* p = m_data->p();
    781775    QRectF normalizedRect = rect.normalized();
    782     ShadowBlur* shadow = shadowBlur();
    783776
    784777    if (m_state.fillPattern) {
    785         GraphicsContext* shadowContext = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0;
    786         if (shadowContext) {
    787             QPainter* shadowPainter = shadowContext->platformContext();
    788             drawRepeatPattern(shadowPainter, m_state.fillPattern, normalizedRect);
    789             shadow->endShadowLayer(this);
     778        if (hasShadow()) {
     779            ShadowBlur shadow(m_state);
     780            GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
     781            if (shadowContext) {
     782                QPainter* shadowPainter = shadowContext->platformContext();
     783                drawRepeatPattern(shadowPainter, m_state.fillPattern, normalizedRect);
     784                shadow.endShadowLayer(this);
     785            }
    790786        }
    791787        drawRepeatPattern(p, m_state.fillPattern, normalizedRect);
     
    793789        QBrush brush(*m_state.fillGradient->platformGradient());
    794790        brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
    795         GraphicsContext* shadowContext = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0;
    796         if (shadowContext) {
    797             QPainter* shadowPainter = shadowContext->platformContext();
    798             shadowPainter->fillRect(normalizedRect, brush);
    799             shadow->endShadowLayer(this);
     791        if (hasShadow()) {
     792            ShadowBlur shadow(m_state);
     793            GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
     794            if (shadowContext) {
     795                QPainter* shadowPainter = shadowContext->platformContext();
     796                shadowPainter->fillRect(normalizedRect, brush);
     797                shadow.endShadowLayer(this);
     798            }
    800799        }
    801800        p->fillRect(normalizedRect, brush);
    802801    } else {
    803802        if (hasShadow()) {
    804             if (shadow->mustUseShadowBlur(this)) {
     803            if (mustUseShadowBlur()) {
     804                ShadowBlur shadow(m_state);
    805805                // drawRectShadowWithTiling does not work with rotations, and the fallback of
    806806                // drawing though clipToImageBuffer() produces scaling artifacts for us.
    807807                if (!getCTM().preservesAxisAlignment()) {
    808                     GraphicsContext* shadowContext = shadow->beginShadowLayer(this, normalizedRect);
     808                    GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
    809809                    if (shadowContext) {
    810810                        QPainter* shadowPainter = shadowContext->platformContext();
    811811                        shadowPainter->fillRect(normalizedRect, p->brush());
    812                         shadow->endShadowLayer(this);
     812                        shadow.endShadowLayer(this);
    813813                    }
    814814                } else
    815                     shadow->drawRectShadow(this, rect, RoundedRect::Radii());
     815                    shadow.drawRectShadow(this, rect, RoundedRect::Radii());
    816816            } else {
    817817                // Solid rectangle fill with no blur shadow or transformations applied can be done
     
    836836    QPainter* p = m_data->p();
    837837    if (hasShadow()) {
    838         ShadowBlur* shadow = shadowBlur();
    839         if (shadow->mustUseShadowBlur(this)) {
    840             shadow->drawRectShadow(this, platformRect, RoundedRect::Radii());
     838        if (mustUseShadowBlur()) {
     839            ShadowBlur shadow(m_state);
     840            shadow.drawRectShadow(this, platformRect, RoundedRect::Radii());
    841841        } else {
    842842            QColor shadowColor = m_state.shadowColor;
     
    857857    QPainter* p = m_data->p();
    858858    if (hasShadow()) {
    859         ShadowBlur* shadow = shadowBlur();
    860         if (shadow->mustUseShadowBlur(this)) {
    861             shadow->drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
     859        if (mustUseShadowBlur()) {
     860            ShadowBlur shadow(m_state);
     861            shadow.drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
    862862        } else {
    863863            const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
     
    887887    QPainter* p = m_data->p();
    888888    if (hasShadow()) {
    889         ShadowBlur* shadow = shadowBlur();
    890         if (shadow->mustUseShadowBlur(this))
    891             shadow->drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
    892         else {
     889        if (mustUseShadowBlur()) {
     890            ShadowBlur shadow(m_state);
     891            shadow.drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
     892        } else {
    893893            const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
    894894            p->translate(shadowOffset);
     
    904904{
    905905    return m_data->layerCount;
    906 }
    907 
    908 ShadowBlur* GraphicsContext::shadowBlur()
    909 {
    910     return m_data->shadow;
    911906}
    912907
     
    11711166    // Qt doesn't support shadows natively, they are drawn manually in the draw*
    11721167    // functions
    1173 
    11741168    if (m_state.shadowsIgnoreTransforms) {
    11751169        // Meaning that this graphics context is associated with a CanvasRenderingContext
     
    11771171        m_state.shadowOffset = FloatSize(size.width(), -size.height());
    11781172    }
    1179 
    1180     m_data->shadow->setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur), m_state.shadowOffset, color, colorSpace, m_state.shadowsIgnoreTransforms);
    11811173}
    11821174
    11831175void GraphicsContext::clearPlatformShadow()
    11841176{
    1185     m_data->shadow->clear();
    11861177}
    11871178
  • trunk/Source/WebCore/platform/graphics/qt/ImageQt.cpp

    r143046 r147750  
    260260
    261261    if (ctxt->hasShadow()) {
    262         ShadowBlur* shadow = ctxt->shadowBlur();
    263         GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
     262        ShadowBlur shadow(ctxt->state());
     263        GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
    264264        if (shadowContext) {
    265265            QPainter* shadowPainter = shadowContext->platformContext();
    266266            shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
    267             shadow->endShadowLayer(ctxt);
     267            shadow.endShadowLayer(ctxt);
    268268        }
    269269    }
  • trunk/Source/WebCore/platform/graphics/qt/StillImageQt.cpp

    r147622 r147750  
    8181
    8282    if (ctxt->hasShadow()) {
    83         ShadowBlur* shadow = ctxt->shadowBlur();
    84         GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
     83        ShadowBlur shadow(ctxt->state());
     84        GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
    8585        if (shadowContext) {
    8686            QPainter* shadowPainter = shadowContext->platformContext();
    8787            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
    88             shadow->endShadowLayer(ctxt);
     88            shadow.endShadowLayer(ctxt);
    8989        }
    9090    }
Note: See TracChangeset for help on using the changeset viewer.