Diff
Modified: trunk/Source/WebCore/ChangeLog (147749 => 147750)
--- trunk/Source/WebCore/ChangeLog 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/ChangeLog 2013-04-05 15:52:08 UTC (rev 147750)
@@ -1,3 +1,50 @@
+2013-03-28 Allan Sandfeld Jensen <[email protected]>
+
+ [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):
+
2013-04-05 Ryosuke Niwa <[email protected]>
Remove Chromium code from WebCore/page
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -184,6 +184,29 @@
return hasShadow();
}
+bool GraphicsContext::hasBlurredShadow() const
+{
+ return m_state.shadowColor.isValid() && m_state.shadowColor.alpha() && m_state.shadowBlur;
+}
+
+#if PLATFORM(QT) || USE(CAIRO)
+bool GraphicsContext::mustUseShadowBlur() const
+{
+ // We can't avoid ShadowBlur if the shadow has blur.
+ if (hasBlurredShadow())
+ return true;
+ // We can avoid ShadowBlur and optimize, since we're not drawing on a
+ // canvas and box shadows are affected by the transformation matrix.
+ if (!m_state.shadowsIgnoreTransforms)
+ return false;
+ // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
+ if (getCTM().isIdentity())
+ return false;
+ // Otherwise, no chance avoiding ShadowBlur.
+ return true;
+}
+#endif
+
float GraphicsContext::strokeThickness() const
{
return m_state.strokeThickness;
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h 2013-04-05 15:52:08 UTC (rev 147750)
@@ -53,9 +53,6 @@
typedef class WebCore::SurfaceOpenVG PlatformGraphicsContext;
#elif PLATFORM(QT)
#include <QPainter>
-namespace WebCore {
-class ShadowBlur;
-}
typedef QPainter PlatformGraphicsContext;
#elif PLATFORM(WX)
class wxGCDC;
@@ -394,6 +391,11 @@
bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
void clearShadow();
+ bool hasBlurredShadow() const;
+#if PLATFORM(QT) || USE(CAIRO)
+ bool mustUseShadowBlur() const;
+#endif
+
void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
void drawFocusRing(const Path&, int width, int offset, const Color&);
@@ -517,10 +519,6 @@
void takeOwnershipOfPlatformContext();
#endif
-#if PLATFORM(QT)
- ShadowBlur* shadowBlur();
-#endif
-
#if USE(CAIRO)
GraphicsContext(cairo_t*);
#endif
Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -3,6 +3,7 @@
* Copyright (C) 2010 Sencha, Inc. All rights reserved.
* Copyright (C) 2010 Igalia S.L. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ * Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -168,6 +169,13 @@
static const int templateSideLength = 1;
+#if USE(CG)
+static float radiusToLegacyRadius(float radius)
+{
+ return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
+}
+#endif
+
ShadowBlur::ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color& color, ColorSpace colorSpace)
: m_color(color)
, m_colorSpace(colorSpace)
@@ -179,6 +187,23 @@
updateShadowBlurValues();
}
+ShadowBlur::ShadowBlur(const GraphicsContextState& state)
+ : m_color(state.shadowColor)
+ , m_colorSpace(state.shadowColorSpace)
+ , m_blurRadius(state.shadowBlur, state.shadowBlur)
+ , m_offset(state.shadowOffset)
+ , m_layerImage(0)
+ , m_shadowsIgnoreTransforms(state.shadowsIgnoreTransforms)
+{
+#if USE(CG)
+ if (state.shadowsUseLegacyRadius) {
+ float shadowBlur = radiusToLegacyRadius(state.shadowBlur);
+ m_blurRadius = FloatSize(shadowBlur, shadowBlur);
+ }
+#endif
+ updateShadowBlurValues();
+}
+
ShadowBlur::ShadowBlur()
: m_type(NoShadow)
, m_blurRadius(0, 0)
@@ -897,22 +922,4 @@
ScratchBuffer::shared().scheduleScratchBufferPurge();
}
-#if PLATFORM(QT) || USE(CAIRO)
-bool ShadowBlur::mustUseShadowBlur(GraphicsContext* context) const
-{
- // We can't avoid ShadowBlur, since the shadow has blur.
- if (type() == BlurShadow)
- return true;
- // We can avoid ShadowBlur and optimize, since we're not drawing on a
- // canvas and box shadows are affected by the transformation matrix.
- if (!shadowsIgnoreTransforms())
- return false;
- // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
- if (context->getCTM().isIdentity())
- return false;
- // Otherwise, no chance avoiding ShadowBlur.
- return true;
-}
-#endif
-
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ShadowBlur.h (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/ShadowBlur.h 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/ShadowBlur.h 2013-04-05 15:52:08 UTC (rev 147750)
@@ -39,6 +39,7 @@
class AffineTransform;
class GraphicsContext;
+struct GraphicsContextState;
class ImageBuffer;
class ShadowBlur {
@@ -51,6 +52,7 @@
};
ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color&, ColorSpace);
+ ShadowBlur(const GraphicsContextState&);
ShadowBlur();
void setShadowValues(const FloatSize&, const FloatSize& , const Color&, ColorSpace, bool ignoreTransforms = false);
@@ -70,10 +72,6 @@
ShadowType type() const { return m_type; }
-#if PLATFORM(QT) || USE(CAIRO)
- bool mustUseShadowBlur(GraphicsContext*) const;
-#endif
-
private:
void updateShadowBlurValues();
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -69,7 +69,7 @@
if (!(graphicsContext->textDrawingMode() & TextModeFill) || shadow.type() == ShadowBlur::NoShadow)
return;
- if (!shadow.mustUseShadowBlur(graphicsContext)) {
+ if (!graphicsContext->mustUseShadowBlur()) {
// Optimize non-blurry shadows, by just drawing text without the ShadowBlur.
cairo_t* context = graphicsContext->platformContext()->cr();
cairo_save(context);
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -762,16 +762,6 @@
CGContextStrokePath(context);
}
-static float radiusToLegacyRadius(float radius)
-{
- return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
-}
-
-static bool hasBlurredShadow(const GraphicsContextState& state)
-{
- return state.shadowColor.isValid() && state.shadowColor.alpha() && state.shadowBlur;
-}
-
void GraphicsContext::fillRect(const FloatRect& rect)
{
if (paintingDisabled())
@@ -808,14 +798,13 @@
if (m_state.fillPattern)
applyFillPattern();
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
}
@@ -837,14 +826,13 @@
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
}
@@ -869,15 +857,13 @@
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
-
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
}
@@ -922,15 +908,13 @@
setFillColor(color, colorSpace);
// fillRectWithRoundedHole() assumes that the edges of rect are clipped out, so we only care about shadows cast around inside the hole.
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms;
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms;
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
-
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
}
Modified: trunk/Source/WebCore/platform/graphics/qt/FontQt.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/qt/FontQt.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/qt/FontQt.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -125,44 +125,36 @@
if (context->textDrawingMode() & TextModeStroke)
textStrokePath = pathForGlyphs(qtGlyphRun, point);
- ShadowBlur* shadow = context->shadowBlur();
- if (context->hasShadow() && shadow->type() != ShadowBlur::NoShadow) {
- switch (shadow->type()) {
- case ShadowBlur::SolidShadow: {
- QPen previousPen = painter->pen();
- painter->setPen(context->state().shadowColor);
- const QPointF shadowOffset(context->state().shadowOffset.width(), context->state().shadowOffset.height());
- painter->translate(shadowOffset);
- if (context->textDrawingMode() & TextModeFill)
- painter->drawGlyphRun(point, qtGlyphRun);
- else if (context->textDrawingMode() & TextModeStroke)
- painter->strokePath(textStrokePath, painter->pen());
- painter->translate(-shadowOffset);
- painter->setPen(previousPen);
- break;
- }
- case ShadowBlur::BlurShadow: {
+ if (context->hasShadow()) {
+ const GraphicsContextState& state = context->state();
+ if (context->mustUseShadowBlur()) {
+ ShadowBlur shadow(state);
const int width = qtGlyphRun.boundingRect().width();
const QRawFont& font = qtGlyphRun.rawFont();
const int height = font.ascent() + font.descent();
const QRectF boundingRect(point.x(), point.y() - font.ascent() + baseLineOffset, width, height);
- GraphicsContext* shadowContext = shadow->beginShadowLayer(context, boundingRect);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(context, boundingRect);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->setPen(shadowContext->state().shadowColor);
+ shadowPainter->setPen(state.shadowColor);
if (shadowContext->textDrawingMode() & TextModeFill)
shadowPainter->drawGlyphRun(point, qtGlyphRun);
else if (shadowContext->textDrawingMode() & TextModeStroke)
shadowPainter->strokePath(textStrokePath, shadowPainter->pen());
- shadow->endShadowLayer(context);
+ shadow.endShadowLayer(context);
}
- break;
+ } else {
+ QPen previousPen = painter->pen();
+ painter->setPen(state.shadowColor);
+ const QPointF shadowOffset(state.shadowOffset.width(), state.shadowOffset.height());
+ painter->translate(shadowOffset);
+ if (context->textDrawingMode() & TextModeFill)
+ painter->drawGlyphRun(point, qtGlyphRun);
+ else if (context->textDrawingMode() & TextModeStroke)
+ painter->strokePath(textStrokePath, painter->pen());
+ painter->translate(-shadowOffset);
+ painter->setPen(previousPen);
}
- case ShadowBlur::NoShadow:
- default:
- ASSERT_NOT_REACHED();
- break;
- }
}
if (context->textDrawingMode() & TextModeStroke)
Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -10,6 +10,7 @@
* Copyright (C) 2008 Dirk Schulze <[email protected]>
* Copyright (C) 2010, 2011 Sencha, Inc.
* Copyright (C) 2011 Andreas Kling <[email protected]>
+ * Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies).
*
* All rights reserved.
*
@@ -250,8 +251,6 @@
InterpolationQuality imageInterpolationQuality;
bool initialSmoothPixmapTransformHint;
- ShadowBlur* shadow;
-
QRectF clipBoundingRect() const
{
return p()->clipBoundingRect();
@@ -270,7 +269,6 @@
, solidColor(initialSolidColor)
, imageInterpolationQuality(InterpolationDefault)
, initialSmoothPixmapTransformHint(false)
- , shadow(new ShadowBlur())
, painter(p)
, platformContextIsOwned(false)
{
@@ -289,8 +287,6 @@
GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
{
- delete shadow;
-
if (!platformContextIsOwned)
return;
@@ -355,8 +351,6 @@
endPlatformTransparencyLayer();
m_data->p()->restore();
-
- m_data->shadow->setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace, m_state.shadowsIgnoreTransforms);
}
// Draws a filled rectangle with a stroked border.
@@ -628,10 +622,10 @@
platformPath.setFillRule(toQtFillRule(fillRule()));
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this) || m_state.fillPattern || m_state.fillGradient)
+ if (mustUseShadowBlur() || m_state.fillPattern || m_state.fillGradient)
{
- GraphicsContext* shadowContext = shadow->beginShadowLayer(this, platformPath.controlPointRect());
+ ShadowBlur shadow(m_state);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, platformPath.controlPointRect());
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
if (m_state.fillPattern) {
@@ -643,7 +637,7 @@
} else {
shadowPainter->fillPath(platformPath, p->brush());
}
- shadow->endShadowLayer(this);
+ shadow.endShadowLayer(this);
}
} else {
QPointF offset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
@@ -687,12 +681,12 @@
pathStroker.setWidth(pen.widthF());
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this) || m_state.strokePattern || m_state.strokeGradient)
+ if (mustUseShadowBlur() || m_state.strokePattern || m_state.strokeGradient)
{
+ ShadowBlur shadow(m_state);
FloatRect boundingRect = platformPath.controlPointRect();
boundingRect.inflate(pen.miterLimit() + pen.widthF());
- GraphicsContext* shadowContext = shadow->beginShadowLayer(this, boundingRect);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, boundingRect);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
if (m_state.strokeGradient) {
@@ -701,7 +695,7 @@
fillPathStroke(shadowPainter, pathStroker, platformPath, brush);
} else
fillPathStroke(shadowPainter, pathStroker, platformPath, pen.brush());
- shadow->endShadowLayer(this);
+ shadow.endShadowLayer(this);
}
} else {
QPointF offset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
@@ -779,40 +773,46 @@
QPainter* p = m_data->p();
QRectF normalizedRect = rect.normalized();
- ShadowBlur* shadow = shadowBlur();
if (m_state.fillPattern) {
- GraphicsContext* shadowContext = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0;
- if (shadowContext) {
- QPainter* shadowPainter = shadowContext->platformContext();
- drawRepeatPattern(shadowPainter, m_state.fillPattern, normalizedRect);
- shadow->endShadowLayer(this);
+ if (hasShadow()) {
+ ShadowBlur shadow(m_state);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
+ if (shadowContext) {
+ QPainter* shadowPainter = shadowContext->platformContext();
+ drawRepeatPattern(shadowPainter, m_state.fillPattern, normalizedRect);
+ shadow.endShadowLayer(this);
+ }
}
drawRepeatPattern(p, m_state.fillPattern, normalizedRect);
} else if (m_state.fillGradient) {
QBrush brush(*m_state.fillGradient->platformGradient());
brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
- GraphicsContext* shadowContext = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0;
- if (shadowContext) {
- QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->fillRect(normalizedRect, brush);
- shadow->endShadowLayer(this);
+ if (hasShadow()) {
+ ShadowBlur shadow(m_state);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
+ if (shadowContext) {
+ QPainter* shadowPainter = shadowContext->platformContext();
+ shadowPainter->fillRect(normalizedRect, brush);
+ shadow.endShadowLayer(this);
+ }
}
p->fillRect(normalizedRect, brush);
} else {
if (hasShadow()) {
- if (shadow->mustUseShadowBlur(this)) {
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
// drawRectShadowWithTiling does not work with rotations, and the fallback of
// drawing though clipToImageBuffer() produces scaling artifacts for us.
if (!getCTM().preservesAxisAlignment()) {
- GraphicsContext* shadowContext = shadow->beginShadowLayer(this, normalizedRect);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
shadowPainter->fillRect(normalizedRect, p->brush());
- shadow->endShadowLayer(this);
+ shadow.endShadowLayer(this);
}
} else
- shadow->drawRectShadow(this, rect, RoundedRect::Radii());
+ shadow.drawRectShadow(this, rect, RoundedRect::Radii());
} else {
// Solid rectangle fill with no blur shadow or transformations applied can be done
// faster without using the shadow layer at all.
@@ -835,9 +835,9 @@
QRectF platformRect(rect);
QPainter* p = m_data->p();
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this)) {
- shadow->drawRectShadow(this, platformRect, RoundedRect::Radii());
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ shadow.drawRectShadow(this, platformRect, RoundedRect::Radii());
} else {
QColor shadowColor = m_state.shadowColor;
shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF());
@@ -856,9 +856,9 @@
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
QPainter* p = m_data->p();
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this)) {
- shadow->drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ shadow.drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
} else {
const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
p->translate(shadowOffset);
@@ -886,10 +886,10 @@
QPainter* p = m_data->p();
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this))
- shadow->drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
- else {
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ 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));
@@ -905,11 +905,6 @@
return m_data->layerCount;
}
-ShadowBlur* GraphicsContext::shadowBlur()
-{
- return m_data->shadow;
-}
-
void GraphicsContext::clip(const IntRect& rect)
{
if (paintingDisabled())
@@ -1170,19 +1165,15 @@
{
// Qt doesn't support shadows natively, they are drawn manually in the draw*
// functions
-
if (m_state.shadowsIgnoreTransforms) {
// Meaning that this graphics context is associated with a CanvasRenderingContext
// We flip the height since CG and HTML5 Canvas have opposite Y axis
m_state.shadowOffset = FloatSize(size.width(), -size.height());
}
-
- m_data->shadow->setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur), m_state.shadowOffset, color, colorSpace, m_state.shadowsIgnoreTransforms);
}
void GraphicsContext::clearPlatformShadow()
{
- m_data->shadow->clear();
}
void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask)
Modified: trunk/Source/WebCore/platform/graphics/qt/ImageQt.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/qt/ImageQt.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/qt/ImageQt.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -259,12 +259,12 @@
ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
if (ctxt->hasShadow()) {
- ShadowBlur* shadow = ctxt->shadowBlur();
- GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
+ ShadowBlur shadow(ctxt->state());
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
- shadow->endShadowLayer(ctxt);
+ shadow.endShadowLayer(ctxt);
}
}
Modified: trunk/Source/WebCore/platform/graphics/qt/StillImageQt.cpp (147749 => 147750)
--- trunk/Source/WebCore/platform/graphics/qt/StillImageQt.cpp 2013-04-05 15:49:35 UTC (rev 147749)
+++ trunk/Source/WebCore/platform/graphics/qt/StillImageQt.cpp 2013-04-05 15:52:08 UTC (rev 147750)
@@ -80,12 +80,12 @@
ctxt->setCompositeOperation(op);
if (ctxt->hasShadow()) {
- ShadowBlur* shadow = ctxt->shadowBlur();
- GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
+ ShadowBlur shadow(ctxt->state());
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
- shadow->endShadowLayer(ctxt);
+ shadow.endShadowLayer(ctxt);
}
}