Changeset 68145 in webkit
- Timestamp:
- Sep 23, 2010 8:51:41 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r68144 r68145 1 2010-09-23 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Ariya Hidayat. 4 5 [Cairo] Generalize ContextShadow from the Qt port and use it for shadow code 6 https://bugs.webkit.org/show_bug.cgi?id=45599 7 8 Make ContextShadow platform-independent and add a Cairo implementation. This is currently 9 disabled for Cairo, but will be enabled in a followup patch with new baselines. 10 11 No new tests as this does not change functionality. 12 13 * GNUmakefile.am: Update source lists. 14 * WebCore.pro: Update source lists. 15 * platform/graphics/ContextShadow.cpp: Added. A generalized version of Qt's ContextShadow. 16 (WebCore::ContextShadow::ContextShadow): 17 (WebCore::ContextShadow::clear): 18 (WebCore::ContextShadow::blurLayerImage): 19 (WebCore::ContextShadow::calculateMinimalLayerRect): 20 * platform/graphics/ContextShadow.h: Added. 21 (WebCore::ContextShadow::offset): 22 * platform/graphics/cairo/CairoUtilities.cpp: Added. 23 (WebCore::setSourceRGBAFromColor): A utility to set the source RGBA on a Cairo surface from a WebCore color. 24 * platform/graphics/cairo/CairoUtilities.h: Added. 25 * platform/graphics/cairo/ContextShadowCairo.cpp: Added. 26 (WebCore::purgeScratchBuffer): Static function to purge the shadow buffer. 27 (WebCore::PurgeScratchBufferTimer::fired): Timer callback. 28 (WebCore::scheduleScratchBufferPurge): Schedule's a WebCore timer to purge the shadow buffer. 29 (WebCore::getScratchBuffer): Create or reuse the scratch buffer. 30 (WebCore::ContextShadow::beginShadowLayer): Added. 31 (WebCore::ContextShadow::endShadowLayer): Added. 32 * platform/graphics/gtk/CairoUtilities.cpp: Removed. 33 * platform/graphics/gtk/CairoUtilities.h: Removed. 34 * platform/graphics/gtk/GdkCairoUtilities.cpp: Renamed from CairoUtilities.cpp. 35 (getCairoSurfacePixel): 36 (getGdkPixbufPixel): 37 (cairoImageSurfaceToGdkPixbuf): 38 * platform/graphics/gtk/GdkCairoUtilities.h: Added. 39 * platform/graphics/gtk/ImageBufferGtk.cpp: 40 * platform/graphics/gtk/ImageGtk.cpp: 41 * platform/graphics/qt/ContextShadow.cpp: Removed. 42 * platform/graphics/qt/ContextShadow.h: Removed. 43 * platform/graphics/qt/ContextShadowQt.cpp: Added. Adapted from code originally in ContextShadow.cpp. 44 (WebCore::ShadowBuffer::ShadowBuffer): 45 (WebCore::ShadowBuffer::scratchImage): 46 (WebCore::ShadowBuffer::schedulePurge): 47 (WebCore::ShadowBuffer::timerEvent): 48 (WebCore::ContextShadow::beginShadowLayer): 49 (WebCore::ContextShadow::endShadowLayer): 50 * platform/graphics/qt/FontQt.cpp: 51 (WebCore::drawTextCommon): Updated to reflect new ContextShadow members. 52 * platform/graphics/qt/GraphicsContextQt.cpp: 53 (WebCore::GraphicsContextPlatformPrivate::hasShadow): Updated to reflect new ContextShadow members. 54 (WebCore::GraphicsContext::strokeArc): Ditto. 55 (WebCore::GraphicsContext::drawConvexPolygon): Ditto. 56 (WebCore::GraphicsContext::fillPath): Ditto. 57 (WebCore::GraphicsContext::strokePath): Ditto. 58 (WebCore::GraphicsContext::fillRect): Ditto. 59 (WebCore::GraphicsContext::fillRoundedRect): Ditto. 60 (WebCore::GraphicsContext::setPlatformShadow): Ditto. 61 1 62 2010-09-23 Patrick Gansterer <paroga@webkit.org> 2 63 -
trunk/WebCore/GNUmakefile.am
r68022 r68145 2087 2087 WebCore/platform/graphics/Color.h \ 2088 2088 WebCore/platform/graphics/ColorSpace.h \ 2089 WebCore/platform/graphics/ContextShadow.cpp \ 2090 WebCore/platform/graphics/ContextShadow.h \ 2089 2091 WebCore/platform/graphics/DashArray.h \ 2090 2092 WebCore/platform/graphics/filters/DistantLightSource.h \ … … 3357 3359 WebCore/platform/graphics/cairo/CairoUtilities.cpp \ 3358 3360 WebCore/platform/graphics/cairo/CairoUtilities.h \ 3361 WebCore/platform/graphics/cairo/ContextShadowCairo.cpp \ 3359 3362 WebCore/platform/graphics/cairo/FontCairo.cpp \ 3360 3363 WebCore/platform/graphics/cairo/FontCustomPlatformData.h \ -
trunk/WebCore/WebCore.pro
r68056 r68145 1096 1096 platform/graphics/BitmapImage.cpp \ 1097 1097 platform/graphics/Color.cpp \ 1098 platform/graphics/ContextShadow.cpp \ 1098 1099 platform/graphics/FloatPoint3D.cpp \ 1099 1100 platform/graphics/FloatPoint.cpp \ … … 1978 1979 platform/graphics/BitmapImage.h \ 1979 1980 platform/graphics/Color.h \ 1981 platform/graphics/ContextShadow.h \ 1980 1982 platform/graphics/filters/FEBlend.h \ 1981 1983 platform/graphics/filters/FEColorMatrix.h \ … … 2023 2025 platform/graphics/Pattern.h \ 2024 2026 platform/graphics/Pen.h \ 2025 platform/graphics/qt/ContextShadow.h \2026 2027 platform/graphics/qt/FontCustomPlatformData.h \ 2027 2028 platform/graphics/qt/GraphicsLayerQt.h \ … … 2537 2538 platform/graphics/qt/TransformationMatrixQt.cpp \ 2538 2539 platform/graphics/qt/ColorQt.cpp \ 2539 platform/graphics/qt/ContextShadow .cpp \2540 platform/graphics/qt/ContextShadowQt.cpp \ 2540 2541 platform/graphics/qt/FontQt.cpp \ 2541 2542 platform/graphics/qt/FontPlatformDataQt.cpp \ -
trunk/WebCore/platform/graphics/ContextShadow.cpp
r68144 r68145 1 1 /* 2 2 * Copyright (C) 2010 Sencha, Inc. 3 * Copyright (C) 2010 Igalia S.L. 3 4 * 4 5 * All rights reserved. … … 29 30 #include "ContextShadow.h" 30 31 31 #include < QTimerEvent>32 #include <wtf/MathExtras.h> 32 33 #include <wtf/Noncopyable.h> 34 35 using WTF::min; 36 using WTF::max; 33 37 34 38 namespace WebCore { 35 39 36 // ContextShadow needs a scratch image as the buffer for the blur filter. 37 // Instead of creating and destroying the buffer for every operation, 38 // we create a buffer which will be automatically purged via a timer. 39 40 class ShadowBuffer: public QObject { 41 public: 42 ShadowBuffer(QObject* parent = 0); 43 44 QImage* scratchImage(const QSize& size); 45 46 void schedulePurge(); 47 48 protected: 49 void timerEvent(QTimerEvent* event); 50 51 private: 52 QImage image; 53 int timerId; 54 }; 55 56 ShadowBuffer::ShadowBuffer(QObject* parent) 57 : QObject(parent) 58 , timerId(0) 40 ContextShadow::ContextShadow() 41 : m_type(NoShadow) 42 , m_blurRadius(0) 59 43 { 60 44 } 61 45 62 QImage* ShadowBuffer::scratchImage(const QSize& size) 46 ContextShadow::ContextShadow(const Color& color, float radius, const FloatSize& offset) 47 : m_color(color) 48 , m_blurRadius(round(radius)) 49 , m_offset(offset) 63 50 { 64 int width = size.width(); 65 int height = size.height(); 51 // See comments in http://webkit.org/b/40793, it seems sensible 52 // to follow Skia's limit of 128 pixels of blur radius 53 m_blurRadius = min(m_blurRadius, 128); 66 54 67 // We do not need to recreate the buffer if the buffer is reasonably68 // larger than the requested size. However, if the requested size is69 // much smaller than our buffer, reduce our buffer so that we will not70 // keep too many allocated pixels for too long.71 if (!image.isNull() && (image.width() > width) && (image.height() > height))72 if (((2 * width) > image.width()) && ((2 * height) > image.height())) {73 image.fill(Qt::transparent);74 return ℑ75 }76 77 // Round to the nearest 32 pixels so we do not grow the buffer everytime78 // there is larger request by 1 pixel.79 width = (1 + (width >> 5)) << 5;80 height = (1 + (height >> 5)) << 5;81 82 image = QImage(width, height, QImage::Format_ARGB32_Premultiplied);83 image.fill(Qt::transparent);84 return ℑ85 }86 87 void ShadowBuffer::schedulePurge()88 {89 static const double BufferPurgeDelay = 2; // seconds90 killTimer(timerId);91 timerId = startTimer(BufferPurgeDelay * 1000);92 }93 94 void ShadowBuffer::timerEvent(QTimerEvent* event)95 {96 if (event->timerId() == timerId) {97 killTimer(timerId);98 image = QImage();99 }100 QObject::timerEvent(event);101 }102 103 Q_GLOBAL_STATIC(ShadowBuffer, scratchShadowBuffer)104 105 ContextShadow::ContextShadow()106 : type(NoShadow)107 , blurRadius(0)108 {109 }110 111 ContextShadow::ContextShadow(const QColor& c, float r, qreal dx, qreal dy)112 : color(c)113 , blurRadius(qRound(r))114 , offset(dx, dy)115 {116 55 // The type of shadow is decided by the blur radius, shadow offset, and shadow color. 117 if (! color.isValid() || !color.alpha()) {56 if (!m_color.isValid() || !color.alpha()) { 118 57 // Can't paint the shadow with invalid or invisible color. 119 type = NoShadow;120 } else if (r > 0) {58 m_type = NoShadow; 59 } else if (radius > 0) { 121 60 // Shadow is always blurred, even the offset is zero. 122 type = BlurShadow;123 } else if ( offset.isNull()) {61 m_type = BlurShadow; 62 } else if (!m_offset.width() && !m_offset.height()) { 124 63 // Without blur and zero offset means the shadow is fully hidden. 125 type = NoShadow;64 m_type = NoShadow; 126 65 } else { 127 if (color.alpha() > 0) 128 type = AlphaSolidShadow; 129 else 130 type = OpaqueSolidShadow; 66 m_type = SolidShadow; 131 67 } 132 68 } … … 134 70 void ContextShadow::clear() 135 71 { 136 type = NoShadow;137 color = QColor();138 blurRadius = 0;139 offset = QPointF(0, 0);72 m_type = NoShadow; 73 m_color = Color(); 74 m_blurRadius = 0; 75 m_offset = FloatSize(); 140 76 } 141 77 … … 147 83 // approximates a real gaussian blur nicely. 148 84 149 void shadowBlur(QImage& image, int radius, const QColor& shadowColor)85 void ContextShadow::blurLayerImage(unsigned char* imageData, const IntSize& size, int rowStride) 150 86 { 151 // See comments in http://webkit.org/b/40793, it seems sensible152 // to follow Skia's limit of 128 pixels for the blur radius.153 if (radius > 128)154 radius = 128;155 156 87 int channels[4] = { 3, 0, 1, 3 }; 157 int dmax = radius >> 1;158 int dmin = dmax - 1 + ( radius & 1);88 int dmax = m_blurRadius >> 1; 89 int dmin = dmax - 1 + (m_blurRadius & 1); 159 90 if (dmin < 0) 160 91 dmin = 0; … … 163 94 for (int k = 0; k < 2; ++k) { 164 95 165 unsigned char* pixels = image .bits();166 int stride = (!k) ? 4 : image.bytesPerLine();167 int delta = (!k) ? image.bytesPerLine(): 4;168 int jfinal = (!k) ? image.height() : image.width();169 int dim = (!k) ? image.width() : image.height();96 unsigned char* pixels = imageData; 97 int stride = (!k) ? 4 : rowStride; 98 int delta = (!k) ? rowStride : 4; 99 int jfinal = (!k) ? size.height() : size.width(); 100 int dim = (!k) ? size.width() : size.height(); 170 101 171 102 for (int j = 0; j < jfinal; ++j, pixels += delta) { … … 214 145 } 215 146 } 216 217 // "Colorize" with the right shadow color.218 QPainter p(&image);219 p.setCompositionMode(QPainter::CompositionMode_SourceIn);220 p.fillRect(image.rect(), shadowColor.rgb());221 p.end();222 147 } 223 148 224 QPainter* ContextShadow::beginShadowLayer(QPainter* p, const QRectF &rect)149 void ContextShadow::calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect) 225 150 { 226 // We expand the area by the blur radius * 2 to give extra space 227 // for the blur transition. 228 int extra = (type == BlurShadow) ? blurRadius * 2 : 0; 151 // Calculate the destination of the blurred layer. 152 FloatRect destinationRect(layerArea); 153 destinationRect.move(m_offset); 154 m_layerRect = enclosingIntRect(destinationRect); 229 155 230 QRectF shadowRect = rect.translated(offset); 231 QRectF bufferRect = shadowRect.adjusted(-extra, -extra, extra, extra); 232 m_layerRect = bufferRect.toAlignedRect(); 233 234 QRect clipRect; 235 if (p->hasClipping()) 236 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) 237 clipRect = p->clipBoundingRect().toAlignedRect(); 238 #else 239 clipRect = p->clipRegion().boundingRect(); 240 #endif 241 else 242 clipRect = p->transform().inverted().mapRect(p->window()); 156 // We expand the area by the blur radius * 2 to give extra space for the blur transition. 157 m_layerRect.inflate((m_type == BlurShadow) ? ceil(m_blurRadius * 2) : 0); 243 158 244 159 if (!clipRect.contains(m_layerRect)) { 160 // No need to have the buffer larger than the clip. 161 m_layerRect.intersect(clipRect); 245 162 246 // No need to have the buffer larger than the clip. 247 m_layerRect = m_layerRect.intersected(clipRect); 163 // If we are totally outside the clip region, we aren't painting at all. 248 164 if (m_layerRect.isEmpty()) 249 return 0;165 return; 250 166 251 167 // We adjust again because the pixels at the borders are still 252 168 // potentially affected by the pixels outside the buffer. 253 if ( type == BlurShadow)254 m_layerRect. adjust(-extra, -extra, extra, extra);169 if (m_type == BlurShadow) 170 m_layerRect.inflate((m_type == BlurShadow) ? ceil(m_blurRadius * 2) : 0); 255 171 } 256 257 ShadowBuffer* shadowBuffer = scratchShadowBuffer();258 QImage* shadowImage = shadowBuffer->scratchImage(m_layerRect.size());259 m_layerImage = QImage(*shadowImage);260 261 m_layerPainter = new QPainter;262 m_layerPainter->begin(&m_layerImage);263 m_layerPainter->setFont(p->font());264 m_layerPainter->translate(offset);265 266 // The origin is now the top left corner of the scratch image.267 m_layerPainter->translate(-m_layerRect.topLeft());268 269 return m_layerPainter;270 172 } 271 173 272 void ContextShadow::endShadowLayer(QPainter* p) 273 { 274 m_layerPainter->end(); 275 delete m_layerPainter; 276 m_layerPainter = 0; 277 278 if (type == BlurShadow) 279 shadowBlur(m_layerImage, blurRadius, color); 280 281 p->drawImage(m_layerRect.topLeft(), m_layerImage); 282 283 scratchShadowBuffer()->schedulePurge(); 284 } 285 286 } 174 } // namespace WebCore -
trunk/WebCore/platform/graphics/ContextShadow.h
r68144 r68145 1 1 /* 2 2 * Copyright (C) 2010 Sencha, Inc. 3 * Copyright (C) 2010 Igalia S.L. 3 4 * 4 5 * All rights reserved. … … 29 30 #define ContextShadow_h 30 31 31 #include <QPainter> 32 #include "Color.h" 33 #include "FloatRect.h" 34 #include "IntRect.h" 35 #include "RefCounted.h" 36 37 #if PLATFORM(CAIRO) 38 typedef struct _cairo cairo_t; 39 typedef struct _cairo_surface cairo_surface_t; 40 typedef cairo_surface_t* PlatformImage; 41 typedef cairo_t* PlatformContext; 42 #elif PLATFORM(QT) 43 #include <QImage> 44 class QPainter; 45 typedef QImage PlatformImage; 46 typedef QPainter* PlatformContext; 47 #endif 32 48 33 49 namespace WebCore { … … 45 61 enum { 46 62 NoShadow, 47 OpaqueSolidShadow, 48 AlphaSolidShadow, 63 SolidShadow, 49 64 BlurShadow 50 } type;65 } m_type; 51 66 52 QColorcolor;53 int blurRadius;54 QPointFoffset;67 Color m_color; 68 int m_blurRadius; 69 FloatSize m_offset; 55 70 56 71 ContextShadow(); 57 ContextShadow(const QColor& c, float r, qreal dx, qreal dy);72 ContextShadow(const Color&, float radius, const FloatSize& offset); 58 73 59 74 void clear(); 60 75 61 76 // The pair beginShadowLayer and endShadowLayer creates a temporary image 62 // where the caller can draw onto, using the returned QPainter. This63 // QPainter instance must be used only to draw between the call to64 // beginShadowLayer andendShadowLayer.77 // where the caller can draw onto, using the returned context. This context 78 // must be used only to draw between the call to beginShadowLayer and 79 // endShadowLayer. 65 80 // 66 // Note: multiple/nested shadow layer isNOT allowed.81 // Note: multiple/nested shadow layers are NOT allowed. 67 82 // 68 83 // The current clip region will be used to optimize the size of the 69 // temporary image. Thus, the original painter should not change any 70 // clipping until endShadowLayer. 71 // If the shadow will be completely outside the clipping region, 72 // beginShadowLayer will return 0. 84 // temporary image. Thus, the original context should not change any 85 // clipping until endShadowLayer. If the shadow will be completely outside 86 // the clipping region, beginShadowLayer will return 0. 73 87 // 74 // The returned QPainterwill have the transformation matrix and clipping75 // properly initialized to start doing the painting (no need to account 76 // for the shadow offset), however it will not have the same render hints,77 // pen, brush, etc as the passed QPainter. This is intentional, usually78 // shadow has different properties than the shape which casts the shadow.88 // The returned context will have the transformation matrix and clipping 89 // properly initialized to start doing the painting (no need to account for 90 // the shadow offset), however it will not have the same render hints, pen, 91 // brush, etc as the passed context. This is intentional, usually shadows 92 // have different properties than the shapes which cast them. 79 93 // 80 // Once endShadowLayer is called, the temporary image will be drawn 81 // with the original painter. If blur radius is specified, the shadow 82 // will be filtered first. 83 QPainter* beginShadowLayer(QPainter* p, const QRectF& rect); 84 void endShadowLayer(QPainter* p); 94 // Once endShadowLayer is called, the temporary image will be drawn with the 95 // original context. If blur radius is specified, the shadow will be 96 // filtered first. 97 98 PlatformContext beginShadowLayer(PlatformContext, const FloatRect& layerArea); 99 void endShadowLayer(PlatformContext); 100 static void purgeScratchBuffer(); 101 102 #if PLATFORM(QT) 103 QPointF offset() { return QPointF(m_offset.width(), m_offset.height()); } 104 #endif 105 85 106 86 107 private: 87 QRect m_layerRect; 88 QImage m_layerImage; 89 QPainter* m_layerPainter; 108 IntRect m_layerRect; 109 PlatformImage m_layerImage; 110 PlatformContext m_layerContext; 111 112 void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride); 113 void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect); 90 114 }; 91 115 -
trunk/WebCore/platform/graphics/cairo/CairoUtilities.cpp
r67981 r68145 27 27 #include "CairoUtilities.h" 28 28 29 #include "Color.h" 29 30 #include <cairo.h> 30 31 #include <wtf/Vector.h> … … 49 50 } 50 51 52 void setSourceRGBAFromColor(cairo_t* context, const Color& color) 53 { 54 float red, green, blue, alpha; 55 color.getRGBA(red, green, blue, alpha); 56 cairo_set_source_rgba(context, red, green, blue, alpha); 57 } 58 51 59 } // namespace WebCore 52 -
trunk/WebCore/platform/graphics/cairo/CairoUtilities.h
r67981 r68145 30 30 31 31 namespace WebCore { 32 class Color; 32 33 33 34 void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr); 35 void setSourceRGBAFromColor(cairo_t*, const Color&); 36 34 37 } // namespace WebCore 35 38 -
trunk/WebCore/platform/graphics/qt/FontQt.cpp
r65876 r68145 126 126 ContextShadow* ctxShadow = ctx->contextShadow(); 127 127 128 if (ctxShadow-> type != ContextShadow::NoShadow) {128 if (ctxShadow->m_type != ContextShadow::NoShadow) { 129 129 qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; 130 if (ctxShadow->offset .x() > 0)131 dx2 = ctxShadow->offset .x();130 if (ctxShadow->offset().x() > 0) 131 dx2 = ctxShadow->offset().x(); 132 132 else 133 dx1 = -ctxShadow->offset .x();134 if (ctxShadow->offset .y() > 0)135 dy2 = ctxShadow->offset .y();133 dx1 = -ctxShadow->offset().x(); 134 if (ctxShadow->offset().y() > 0) 135 dy2 = ctxShadow->offset().y(); 136 136 else 137 dy1 = -ctxShadow->offset .y();137 dy1 = -ctxShadow->offset().y(); 138 138 // expand the clip rect to include the text shadow as well 139 139 clip.adjust(dx1, dx2, dy1, dy2); 140 clip.adjust(-ctxShadow-> blurRadius, -ctxShadow->blurRadius, ctxShadow->blurRadius, ctxShadow->blurRadius);140 clip.adjust(-ctxShadow->m_blurRadius, -ctxShadow->m_blurRadius, ctxShadow->m_blurRadius, ctxShadow->m_blurRadius); 141 141 } 142 142 p->save(); … … 144 144 pt.setY(pt.y() - ascent); 145 145 146 if (ctxShadow-> type != ContextShadow::NoShadow) {146 if (ctxShadow->m_type != ContextShadow::NoShadow) { 147 147 ContextShadow* ctxShadow = ctx->contextShadow(); 148 if (ctxShadow-> type != ContextShadow::BlurShadow) {148 if (ctxShadow->m_type != ContextShadow::BlurShadow) { 149 149 p->save(); 150 p->setPen(ctxShadow-> color);151 p->translate(ctxShadow->offset );150 p->setPen(ctxShadow->m_color); 151 p->translate(ctxShadow->offset()); 152 152 line.draw(p, pt); 153 153 p->restore(); … … 156 156 if (shadowPainter) { 157 157 // Since it will be blurred anyway, we don't care about render hints. 158 shadowPainter->setPen(ctxShadow->color); 158 shadowPainter->setFont(p->font()); 159 shadowPainter->setPen(ctxShadow->m_color); 159 160 line.draw(shadowPainter, pt); 160 161 ctxShadow->endShadowLayer(p); … … 182 183 flags |= Qt::TextBypassShaping; 183 184 #endif 184 if (ctx->contextShadow()-> type != ContextShadow::NoShadow) {185 if (ctx->contextShadow()->m_type != ContextShadow::NoShadow) { 185 186 ContextShadow* ctxShadow = ctx->contextShadow(); 186 if (ctxShadow-> type != ContextShadow::BlurShadow) {187 if (ctxShadow->m_type != ContextShadow::BlurShadow) { 187 188 p->save(); 188 p->setPen(ctxShadow-> color);189 p->translate(ctxShadow->offset );189 p->setPen(ctxShadow->m_color); 190 p->translate(ctxShadow->offset()); 190 191 p->drawText(pt, string, flags, run.padding()); 191 192 p->restore(); … … 197 198 // Since it will be blurred anyway, we don't care about render hints. 198 199 shadowPainter->setFont(p->font()); 199 shadowPainter->setPen(ctxShadow-> color);200 shadowPainter->setPen(ctxShadow->m_color); 200 201 shadowPainter->drawText(pt, string, flags, run.padding()); 201 202 ctxShadow->endShadowLayer(p); -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r67819 r68145 202 202 bool hasShadow() const 203 203 { 204 return shadow. type != ContextShadow::NoShadow;204 return shadow.m_type != ContextShadow::NoShadow; 205 205 } 206 206 … … 441 441 if (m_data->hasShadow()) { 442 442 p->save(); 443 p->translate(m_data->shadow.offset );443 p->translate(m_data->shadow.offset()); 444 444 QPen pen(p->pen()); 445 pen.setColor(m_data->shadow. color);445 pen.setColor(m_data->shadow.m_color); 446 446 p->setPen(pen); 447 447 p->drawArc(rect, startAngle, angleSpan); … … 471 471 if (m_data->hasShadow()) { 472 472 p->save(); 473 p->translate(m_data->shadow.offset );473 p->translate(m_data->shadow.offset()); 474 474 if (p->brush().style() != Qt::NoBrush) 475 p->setBrush(QBrush(m_data->shadow. color));475 p->setBrush(QBrush(m_data->shadow.m_color)); 476 476 QPen pen(p->pen()); 477 477 if (pen.style() != Qt::NoPen) { 478 pen.setColor(m_data->shadow. color);478 pen.setColor(m_data->shadow.m_color); 479 479 p->setPen(pen); 480 480 } … … 520 520 521 521 if (m_data->hasShadow()) { 522 p->translate(m_data->shadow.offset );523 p->fillPath(path, m_data->shadow.color);524 p->translate(-m_data->shadow.offset );522 p->translate(m_data->shadow.offset()); 523 p->fillPath(path, QColor(m_data->shadow.m_color)); 524 p->translate(-m_data->shadow.offset()); 525 525 } 526 526 if (m_common->state.fillPattern) { … … 548 548 549 549 if (m_data->hasShadow()) { 550 p->translate(m_data->shadow.offset );550 p->translate(m_data->shadow.offset()); 551 551 QPen shadowPen(pen); 552 shadowPen.setColor(m_data->shadow. color);552 shadowPen.setColor(m_data->shadow.m_color); 553 553 p->strokePath(path, shadowPen); 554 p->translate(-m_data->shadow.offset );554 p->translate(-m_data->shadow.offset()); 555 555 } 556 556 if (m_common->state.strokePattern) { … … 654 654 drawRepeatPattern(shadowPainter, image, normalizedRect, m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY()); 655 655 shadowPainter->setCompositionMode(QPainter::CompositionMode_SourceIn); 656 shadowPainter->fillRect(normalizedRect, shadow-> color);656 shadowPainter->fillRect(normalizedRect, shadow->m_color); 657 657 shadow->endShadowLayer(p); 658 658 } … … 665 665 shadowPainter->fillRect(normalizedRect, brush); 666 666 shadowPainter->setCompositionMode(QPainter::CompositionMode_SourceIn); 667 shadowPainter->fillRect(normalizedRect, shadow-> color);667 shadowPainter->fillRect(normalizedRect, shadow->m_color); 668 668 shadow->endShadowLayer(p); 669 669 } … … 671 671 } else { 672 672 if (m_data->hasShadow()) { 673 if (shadow-> type == ContextShadow::BlurShadow) {673 if (shadow->m_type == ContextShadow::BlurShadow) { 674 674 QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect); 675 675 if (shadowPainter) { … … 680 680 // Solid rectangle fill with no blur shadow can be done faster 681 681 // without using the shadow layer at all. 682 QColor shadowColor = shadow-> color;682 QColor shadowColor = shadow->m_color; 683 683 shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); 684 p->fillRect(normalizedRect.translated(shadow->offset ), shadowColor);684 p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); 685 685 } 686 686 } … … 702 702 ContextShadow* shadow = contextShadow(); 703 703 704 if (shadow-> type != ContextShadow::BlurShadow) {704 if (shadow->m_type != ContextShadow::BlurShadow) { 705 705 // We do not need any layer for simple shadow. 706 p->fillRect(normalizedRect.translated(shadow->offset ), shadow->color);706 p->fillRect(normalizedRect.translated(shadow->offset()), shadow->m_color); 707 707 } else { 708 708 QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect); 709 709 if (shadowPainter) { 710 710 shadowPainter->setCompositionMode(QPainter::CompositionMode_Source); 711 shadowPainter->fillRect(normalizedRect, shadow-> color);711 shadowPainter->fillRect(normalizedRect, shadow->m_color); 712 712 shadow->endShadowLayer(p); 713 713 } … … 726 726 QPainter* p = m_data->p(); 727 727 if (m_data->hasShadow()) { 728 p->translate(m_data->shadow.offset );729 p->fillPath(path.platformPath(), m_data->shadow.color);730 p->translate(-m_data->shadow.offset );728 p->translate(m_data->shadow.offset()); 729 p->fillPath(path.platformPath(), QColor(m_data->shadow.m_color)); 730 p->translate(-m_data->shadow.offset()); 731 731 } 732 732 p->fillPath(path.platformPath(), QColor(color)); … … 885 885 // We flip the height since CG and HTML5 Canvas have opposite Y axis 886 886 m_common->state.shadowOffset = FloatSize(size.width(), -size.height()); 887 m_data->shadow = ContextShadow(color, blur, size.width(), -size.height());887 m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), -size.height())); 888 888 } else { 889 m_data->shadow = ContextShadow(color, blur, size.width(), size.height());889 m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), size.height())); 890 890 } 891 891 }
Note: See TracChangeset
for help on using the changeset viewer.