Changeset 74187 in webkit
- Timestamp:
- Dec 16, 2010 6:44:16 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r74186 r74187 242 242 * compositing/reflections/remove-add-reflection-expected.txt: Added. 243 243 * compositing/reflections/remove-add-reflection.html: Added. 244 245 2010-12-15 Helder Correia <helder@sencha.com>246 247 Reviewed by Ariya Hidayat.248 249 [Qt] Canvas shadow offset should not be affected by any transformation250 https://bugs.webkit.org/show_bug.cgi?id=50422251 252 On a canvas context, shadows are currently affected by all253 transformations except scaling. According to the spec:254 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#shadows255 256 "The shadowOffsetX and shadowOffsetY attributes specify the distance257 that the shadow will be offset in the positive horizontal and positive258 vertical distance respectively. Their values are in coordinate space259 units. They are not affected by the current transformation matrix."260 261 NOTE: this applies only to canvas, not to box shadows.262 263 Add new test to ensure that shadows are correctly transformed keeping264 the relative offset to the shape.265 266 * fast/canvas/canvas-scale-strokePath-shadow-expected.txt:267 * fast/canvas/canvas-transforms-fillRect-shadow-expected.txt: Added.268 * fast/canvas/canvas-transforms-fillRect-shadow.html: Added.269 * fast/canvas/script-tests/canvas-scale-fillPath-shadow.js:270 * fast/canvas/script-tests/canvas-scale-fillRect-shadow.js:271 * fast/canvas/script-tests/canvas-scale-strokePath-shadow.js: Now using272 a lineWidth > 1 to make it easier to test and more fair among all273 ports, since there can be different transformation smoothness or274 aliasing settings.275 * fast/canvas/script-tests/canvas-transforms-fillRect-shadow.js: Added.276 244 277 245 2010-12-15 Kenji Imasaki <imasaki@chromium.org> -
trunk/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
r74154 r74187 31 31 PASS d[1] is 0 32 32 PASS d[2] is 0 33 PASS d[3] is around 14933 PASS d[3] is around 20 34 34 PASS d[0] is 255 35 35 PASS d[1] is 0 36 36 PASS d[2] is 0 37 PASS d[3] is around 11637 PASS d[3] is around 22 38 38 PASS d[0] is 255 39 39 PASS d[1] is 0 40 40 PASS d[2] is 0 41 PASS d[3] is around 11541 PASS d[3] is around 28 42 42 PASS d[0] is 255 43 43 PASS d[1] is 0 44 44 PASS d[2] is 0 45 PASS d[3] is around 7045 PASS d[3] is around 22 46 46 PASS d[0] is 255 47 47 PASS d[1] is 0 48 48 PASS d[2] is 0 49 PASS d[3] is around 7049 PASS d[3] is around 15 50 50 PASS d[0] is 255 51 51 PASS d[1] is 0 52 52 PASS d[2] is 0 53 PASS d[3] is around 6953 PASS d[3] is around 17 54 54 PASS successfullyParsed is true 55 55 -
trunk/LayoutTests/fast/canvas/script-tests/canvas-scale-fillPath-shadow.js
r74154 r74187 80 80 shouldBe('d[3]', '255'); 81 81 82 d = ctx.getImageData(29 8, 295, 1, 1).data;82 d = ctx.getImageData(299, 295, 1, 1).data; 83 83 shouldBe('d[0]', '255'); 84 84 shouldBe('d[1]', '0'); … … 86 86 shouldBe('d[3]', '255'); 87 87 88 d = ctx.getImageData(200, 29 8, 1, 1).data;88 d = ctx.getImageData(200, 299, 1, 1).data; 89 89 shouldBe('d[0]', '255'); 90 90 shouldBe('d[1]', '0'); … … 99 99 shouldBeAround('d[3]', '76'); 100 100 101 d = ctx.getImageData(29 8, 405, 1, 1).data;101 d = ctx.getImageData(299, 405, 1, 1).data; 102 102 shouldBe('d[0]', '255'); 103 103 shouldBe('d[1]', '0'); … … 105 105 shouldBeAround('d[3]', '76'); 106 106 107 d = ctx.getImageData(205, 49 8, 1, 1).data;107 d = ctx.getImageData(205, 499, 1, 1).data; 108 108 shouldBe('d[0]', '255'); 109 109 shouldBe('d[1]', '0'); -
trunk/LayoutTests/fast/canvas/script-tests/canvas-scale-fillRect-shadow.js
r74154 r74187 59 59 shouldBe('d[3]', '255'); 60 60 61 d = ctx.getImageData(29 8, 298, 1, 1).data;61 d = ctx.getImageData(299, 295, 1, 1).data; 62 62 shouldBe('d[0]', '255'); 63 63 shouldBe('d[1]', '0'); … … 65 65 shouldBe('d[3]', '255'); 66 66 67 d = ctx.getImageData(20 1, 298, 1, 1).data;67 d = ctx.getImageData(200, 299, 1, 1).data; 68 68 shouldBe('d[0]', '255'); 69 69 shouldBe('d[1]', '0'); … … 78 78 shouldBeAround('d[3]', '76'); 79 79 80 d = ctx.getImageData(29 8, 405, 1, 1).data;80 d = ctx.getImageData(299, 405, 1, 1).data; 81 81 shouldBe('d[0]', '255'); 82 82 shouldBe('d[1]', '0'); … … 84 84 shouldBeAround('d[3]', '76'); 85 85 86 d = ctx.getImageData(205, 49 8, 1, 1).data;86 d = ctx.getImageData(205, 499, 1, 1).data; 87 87 shouldBe('d[0]', '255'); 88 88 shouldBe('d[1]', '0'); -
trunk/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
r74154 r74187 36 36 ctx.shadowOffsetY = 100; 37 37 ctx.strokeStyle = 'rgba(0, 0, 255, 1)'; 38 ctx.lineWidth = 5;39 38 40 39 ctx.shadowColor = 'rgba(255, 0, 0, 1.0)'; … … 78 77 79 78 // Verify solid shadow. 80 d = ctx.getImageData(2 50, 200, 1, 1).data;79 d = ctx.getImageData(200, 205, 1, 1).data; 81 80 shouldBe('d[0]', '255'); 82 81 shouldBe('d[1]', '0'); … … 84 83 shouldBe('d[3]', '255'); 85 84 86 d = ctx.getImageData( 300, 290, 1, 1).data;85 d = ctx.getImageData(299, 295, 1, 1).data; 87 86 shouldBe('d[0]', '255'); 88 87 shouldBe('d[1]', '0'); … … 90 89 shouldBe('d[3]', '255'); 91 90 92 d = ctx.getImageData(20 0, 250, 1, 1).data;91 d = ctx.getImageData(201, 299, 1, 1).data; 93 92 shouldBe('d[0]', '255'); 94 93 shouldBe('d[1]', '0'); … … 97 96 98 97 // Verify solid alpha shadow. 99 d = ctx.getImageData(20 1, 405, 1, 1).data;98 d = ctx.getImageData(200, 405, 1, 1).data; 100 99 shouldBe('d[0]', '255'); 101 100 shouldBe('d[1]', '0'); … … 103 102 shouldBeAround('d[3]', '76'); 104 103 105 d = ctx.getImageData(2 01, 500, 1, 1).data;104 d = ctx.getImageData(299, 405, 1, 1).data; 106 105 shouldBe('d[0]', '255'); 107 106 shouldBe('d[1]', '0'); … … 109 108 shouldBeAround('d[3]', '76'); 110 109 111 d = ctx.getImageData( 300, 499, 1, 1).data;110 d = ctx.getImageData(205, 499, 1, 1).data; 112 111 shouldBe('d[0]', '255'); 113 112 shouldBe('d[1]', '0'); … … 116 115 117 116 // Verify blurry shadow. 118 d = ctx.getImageData( 404, 210, 1, 1).data;117 d = ctx.getImageData(394, 208, 1, 1).data; 119 118 shouldBe('d[0]', '255'); 120 119 shouldBe('d[1]', '0'); 121 120 shouldBe('d[2]', '0'); 122 shouldBeAround('d[3]', ' 149');121 shouldBeAround('d[3]', '20'); 123 122 124 d = ctx.getImageData(50 5, 250, 1, 1).data;123 d = ctx.getImageData(503, 301, 1, 1).data; 125 124 shouldBe('d[0]', '255'); 126 125 shouldBe('d[1]', '0'); 127 126 shouldBe('d[2]', '0'); 128 shouldBeAround('d[3]', ' 116');127 shouldBeAround('d[3]', '22'); 129 128 130 d = ctx.getImageData( 450, 205, 1, 1).data;129 d = ctx.getImageData(504, 250, 1, 1).data; 131 130 shouldBe('d[0]', '255'); 132 131 shouldBe('d[1]', '0'); 133 132 shouldBe('d[2]', '0'); 134 shouldBeAround('d[3]', ' 115');133 shouldBeAround('d[3]', '28'); 135 134 136 135 // Verify blurry alpha shadow. 137 d = ctx.getImageData( 505, 450, 1, 1).data;136 d = ctx.getImageData(405, 405, 1, 1).data; 138 137 shouldBe('d[0]', '255'); 139 138 shouldBe('d[1]', '0'); 140 139 shouldBe('d[2]', '0'); 141 shouldBeAround('d[3]', ' 70');140 shouldBeAround('d[3]', '22'); 142 141 143 d = ctx.getImageData( 505, 450, 1, 1).data;142 d = ctx.getImageData(415, 495, 1, 1).data; 144 143 shouldBe('d[0]', '255'); 145 144 shouldBe('d[1]', '0'); 146 145 shouldBe('d[2]', '0'); 147 shouldBeAround('d[3]', ' 70');146 shouldBeAround('d[3]', '15'); 148 147 149 d = ctx.getImageData(450, 405, 1, 1).data;148 d = ctx.getImageData(450, 504, 1, 1).data; 150 149 shouldBe('d[0]', '255'); 151 150 shouldBe('d[1]', '0'); 152 151 shouldBe('d[2]', '0'); 153 shouldBeAround('d[3]', ' 69');152 shouldBeAround('d[3]', '17'); 154 153 155 154 var successfullyParsed = true; -
trunk/WebCore/ChangeLog
r74186 r74187 349 349 * platform/graphics/ca/GraphicsLayerCA.cpp: 350 350 (WebCore::GraphicsLayerCA::ensureStructuralLayer): 351 352 2010-12-15 Helder Correia <helder@sencha.com>353 354 Reviewed by Ariya Hidayat.355 356 [Qt] Canvas shadow offset should not be affected by any transformation357 https://bugs.webkit.org/show_bug.cgi?id=50422358 359 On a canvas context, shadows are currently affected by all360 transformations except scaling. According to the spec:361 http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#shadows362 363 "The shadowOffsetX and shadowOffsetY attributes specify the distance364 that the shadow will be offset in the positive horizontal and positive365 vertical distance respectively. Their values are in coordinate space366 units. They are not affected by the current transformation matrix."367 368 NOTE: this applies only to canvas, not to box shadows.369 370 Test: fast/canvas/canvas-transforms-fillRect-shadow.html371 372 * platform/graphics/ContextShadow.cpp:373 (WebCore::ContextShadow::ContextShadow):374 (WebCore::ContextShadow::calculateLayerBoundingRect):375 * platform/graphics/ContextShadow.h:376 (WebCore::ContextShadow::setShadowsIgnoreTransforms):377 (WebCore::ContextShadow::shadowsIgnoreTransforms):378 (WebCore::ContextShadow::offset):379 * platform/graphics/qt/ContextShadowQt.cpp:380 (WebCore::ContextShadow::beginShadowLayer):381 (WebCore::ContextShadow::endShadowLayer):382 * platform/graphics/qt/GraphicsContextQt.cpp:383 (WebCore::mustUseContextShadow):384 (WebCore::GraphicsContext::fillPath):385 (WebCore::GraphicsContext::strokePath):386 (WebCore::GraphicsContext::fillRect):387 (WebCore::GraphicsContext::fillRoundedRect):388 (WebCore::GraphicsContext::setPlatformShadow):389 351 390 352 2010-12-15 Timothy Hatcher <timothy@apple.com> -
trunk/WebCore/platform/graphics/ContextShadow.cpp
r74154 r74187 42 42 , m_blurDistance(0) 43 43 , m_layerContext(0) 44 , m_shadowsIgnoreTransforms(false)45 44 { 46 45 } … … 51 50 , m_offset(offset) 52 51 , m_layerContext(0) 53 , m_shadowsIgnoreTransforms(false)54 52 { 55 53 // See comments in http://webkit.org/b/40793, it seems sensible … … 152 150 } 153 151 154 #if PLATFORM(QT)155 IntRect ContextShadow::calculateLayerBoundingRect(const PlatformContext p, const FloatRect& layerArea, const IntRect& clipRect)156 {157 // Calculate the destination of the blurred and/or transformed layer.158 FloatRect layerFloatRect;159 float inflation = 0;160 161 const QTransform transform = p->transform();162 if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {163 QPolygonF transformedPolygon = transform.map(QPolygonF(layerArea));164 transformedPolygon.translate(offset());165 layerFloatRect = transform.inverted().map(transformedPolygon).boundingRect();166 } else {167 layerFloatRect = layerArea;168 layerFloatRect.move(m_offset);169 }170 171 // We expand the area by the blur radius to give extra space for the blur transition.172 if (m_type == BlurShadow) {173 layerFloatRect.inflate(m_blurDistance);174 inflation += m_blurDistance;175 }176 177 FloatRect unclippedLayerRect = layerFloatRect;178 179 if (!clipRect.contains(enclosingIntRect(layerFloatRect))) {180 // No need to have the buffer larger than the clip.181 layerFloatRect.intersect(clipRect);182 183 // If we are totally outside the clip region, we aren't painting at all.184 if (layerFloatRect.isEmpty())185 return IntRect(0, 0, 0, 0);186 187 // We adjust again because the pixels at the borders are still188 // potentially affected by the pixels outside the buffer.189 if (m_type == BlurShadow) {190 layerFloatRect.inflate(m_blurDistance);191 unclippedLayerRect.inflate(m_blurDistance);192 inflation += m_blurDistance;193 }194 }195 196 const int frameSize = inflation * 2;197 m_sourceRect = IntRect(0, 0, layerArea.width() + frameSize, layerArea.height() + frameSize);198 199 m_layerOrigin = FloatPoint(layerFloatRect.x(), layerFloatRect.y());200 201 const FloatPoint m_unclippedLayerOrigin = FloatPoint(unclippedLayerRect.x(), unclippedLayerRect.y());202 const FloatSize clippedOut = m_unclippedLayerOrigin - m_layerOrigin;203 204 // Set the origin as the top left corner of the scratch image, or, in case there's a clipped205 // out region, set the origin accordingly to the full bounding rect's top-left corner.206 const float translationX = -layerArea.x() + inflation - fabsf(clippedOut.width());207 const float translationY = -layerArea.y() + inflation - fabsf(clippedOut.height());208 m_layerContextTranslation = FloatPoint(translationX, translationY);209 210 return enclosingIntRect(layerFloatRect);211 }212 #endif213 214 #if PLATFORM(CAIRO)215 152 void ContextShadow::calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect) 216 153 { … … 237 174 } 238 175 } 239 #endif240 176 241 177 } // namespace WebCore -
trunk/WebCore/platform/graphics/ContextShadow.h
r74154 r74187 107 107 void endShadowLayer(PlatformContext); 108 108 static void purgeScratchBuffer(); 109 void setShadowsIgnoreTransforms(bool enable) { m_shadowsIgnoreTransforms = enable; }110 bool shadowsIgnoreTransforms() const { return m_shadowsIgnoreTransforms; }111 109 #if PLATFORM(CAIRO) 112 110 void drawRectShadow(GraphicsContext* context, const IntRect& rect, const IntSize& topLeftRadius = IntSize(), const IntSize& topRightRadius = IntSize(), const IntSize& bottomLeftRadius = IntSize(), const IntSize& bottomRightRadius = IntSize()); 113 111 #endif 112 114 113 #if PLATFORM(QT) 115 QPointF offset() const{ return QPointF(m_offset.width(), m_offset.height()); }114 QPointF offset() { return QPointF(m_offset.width(), m_offset.height()); } 116 115 #endif 117 116 118 117 119 118 private: 120 // Buffer to where the temporary shadow will be drawn to.119 IntRect m_layerRect; 121 120 PlatformImage m_layerImage; 122 // Context used to paint the shadow to the layer image.123 121 PlatformContext m_layerContext; 124 #if PLATFORM(QT) 125 // Sub-rect of m_layerImage that contains the shadow pixels. 126 FloatRect m_sourceRect; 127 // Top-left corner of the (possibly clipped) bounding rect to draw the shadow to. 128 FloatPoint m_layerOrigin; 129 // Translation to apply to m_layerContext for the shadow to be correctly clipped. 130 FloatPoint m_layerContextTranslation; 131 #endif 132 #if PLATFORM(CAIRO) 133 // Enclosing int rect where shadow needs to be drawn to using the layer context. 134 IntRect m_layerRect; 122 135 123 // Used for reference when canvas scale(x,y) was called. 136 124 FloatRect m_unscaledLayerRect; 137 #endif138 bool m_shadowsIgnoreTransforms;139 125 140 126 void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride); 127 void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect); 141 128 #if PLATFORM(CAIRO) 142 void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect);143 129 void drawRectShadowWithoutTiling(PlatformContext context, const IntRect& shadowRect, const IntSize& topLeftRadius, const IntSize& topRightRadius, const IntSize& bottomLeftRadius, const IntSize& bottomRightRadius, float alpha); 144 #else145 IntRect calculateLayerBoundingRect(const PlatformContext, const FloatRect& layerArea, const IntRect& clipRect);146 130 #endif 147 131 }; -
trunk/WebCore/platform/graphics/qt/ContextShadowQt.cpp
r74154 r74187 115 115 clipRect = p->transform().inverted().mapRect(p->window()); 116 116 117 // Set m_layerOrigin, m_layerContextTranslation, m_sourceRect. 118 IntRect clip(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height()); 119 IntRect layerRect = calculateLayerBoundingRect(p, layerArea, clip); 117 m_unscaledLayerRect = layerArea; 118 calculateLayerBoundingRect(layerArea, IntRect(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height())); 120 119 121 120 // Don't paint if we are totally outside the clip region. 122 if ( layerRect.isEmpty())121 if (m_layerRect.isEmpty()) 123 122 return 0; 124 123 125 124 ShadowBuffer* shadowBuffer = scratchShadowBuffer(); 126 QImage* shadowImage = shadowBuffer->scratchImage( layerRect.size());125 QImage* shadowImage = shadowBuffer->scratchImage(m_layerRect.size()); 127 126 m_layerImage = QImage(*shadowImage); 128 127 … … 130 129 m_layerContext->begin(&m_layerImage); 131 130 m_layerContext->setFont(p->font()); 132 m_layerContext->translate(m_layerContextTranslation); 131 m_layerContext->translate(m_offset.width(), m_offset.height()); 132 133 // The origin is now the top left corner of the scratch image. 134 m_layerContext->translate(-m_layerRect.x(), -m_layerRect.y()); 135 133 136 return m_layerContext; 134 137 } … … 153 156 } 154 157 155 p->drawImage(m_layerOrigin, m_layerImage, m_sourceRect); 158 const QTransform transform = p->transform(); 159 if (transform.isScaling()) { 160 qreal x = m_unscaledLayerRect.x() + m_offset.width() / transform.m11() - m_blurDistance; 161 qreal y = m_unscaledLayerRect.y() + m_offset.height() / transform.m22() - m_blurDistance; 162 p->drawImage(QPointF(x, y), m_layerImage); 163 } else 164 p->drawImage(m_layerRect.topLeft(), m_layerImage); 156 165 157 166 scratchShadowBuffer()->schedulePurge(); -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r74154 r74187 54 54 55 55 #include <QBrush> 56 #include <QDebug> 56 57 #include <QGradient> 57 58 #include <QPaintDevice> … … 175 176 } 176 177 177 static inline bool mustUseContextShadow(QPainter* painter, ContextShadow* shadow)178 {179 if (shadow->m_type == ContextShadow::BlurShadow)180 // We can't avoid ContextShadow, since the shadow has blur.181 return true;182 if (!shadow->shadowsIgnoreTransforms())183 // We can avoid ContextShadow and optimize, since we're not drawing on a canvas and box184 // shadows are affected by the transformation matrix.185 return false;186 if (painter->transform().isIdentity())187 // We can avoid ContextShadow, since there are no transformations to apply to the canvas.188 return false;189 // Otherwise, no chance avoiding ContextShadow.190 return true;191 }192 193 178 class GraphicsContextPlatformPrivate : public Noncopyable { 194 179 public: … … 522 507 if (m_data->hasShadow()) { 523 508 ContextShadow* shadow = contextShadow(); 524 if (mustUseContextShadow(p, shadow) || m_state.fillPattern || m_state.fillGradient) 509 if (shadow->m_type != ContextShadow::BlurShadow 510 && !m_state.fillPattern && !m_state.fillGradient) 525 511 { 512 QPointF offset = shadow->offset(); 513 const QTransform& transform = p->transform(); 514 if (transform.isScaling()) { 515 // If scaling is required, find the new coord for shadow origin, 516 // so that the relative offset to its shape is kept. 517 QPointF translatedOffset(offset.x() / transform.m11(), 518 offset.y() / transform.m22()); 519 platformPath.translate(translatedOffset); 520 p->fillPath(platformPath, QColor(shadow->m_color)); 521 platformPath.translate(-translatedOffset); 522 } else { 523 p->translate(offset); 524 p->fillPath(platformPath, QColor(shadow->m_color)); 525 p->translate(-offset); 526 } 527 } else { 526 528 QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect()); 527 529 if (shadowPainter) { … … 530 532 shadow->endShadowLayer(p); 531 533 } 532 } else {533 QPointF offset = shadow->offset();534 p->translate(offset);535 p->fillPath(platformPath, QColor(shadow->m_color));536 p->translate(-offset);537 534 } 535 538 536 } 539 537 if (m_state.fillPattern) { … … 560 558 if (m_data->hasShadow()) { 561 559 ContextShadow* shadow = contextShadow(); 562 if (mustUseContextShadow(p, shadow) || m_state.strokePattern || m_state.strokeGradient) 560 561 if (shadow->m_type != ContextShadow::BlurShadow 562 && !m_state.strokePattern && !m_state.strokeGradient) 563 563 { 564 QPen shadowPen(pen); 565 shadowPen.setColor(m_data->shadow.m_color); 566 QPointF offset = shadow->offset(); 567 const QTransform& transform = p->transform(); 568 if (transform.isScaling()) { 569 // If scaling is required, find the new coord for shadow origin, 570 // so that the relative offset to its shape is kept. 571 QPointF translatedOffset(offset.x() / transform.m11(), 572 offset.y() / transform.m22()); 573 platformPath.translate(translatedOffset); 574 p->strokePath(platformPath, shadowPen); 575 platformPath.translate(-translatedOffset); 576 } else { 577 p->translate(offset); 578 p->strokePath(platformPath, shadowPen); 579 p->translate(-offset); 580 } 581 } else { 564 582 FloatRect boundingRect = platformPath.controlPointRect(); 565 583 boundingRect.inflate(pen.miterLimit() + pen.widthF()); … … 570 588 shadow->endShadowLayer(p); 571 589 } 572 } else {573 QPen shadowPen(pen);574 shadowPen.setColor(m_data->shadow.m_color);575 QPointF offset = shadow->offset();576 p->translate(offset);577 p->strokePath(platformPath, shadowPen);578 p->translate(-offset);579 590 } 580 591 } … … 696 707 } else { 697 708 if (m_data->hasShadow()) { 698 if ( mustUseContextShadow(p, shadow)) {709 if (shadow->m_type == ContextShadow::BlurShadow) { 699 710 QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect); 700 711 if (shadowPainter) { … … 704 715 } 705 716 } else { 706 // Solid rectangle fill with no blur shadow or transformations applied can be done707 // fasterwithout using the shadow layer at all.717 // Solid rectangle fill with no blur shadow can be done faster 718 // without using the shadow layer at all. 708 719 QColor shadowColor = shadow->m_color; 709 720 shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); 710 p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); 721 const QTransform& transform = p->transform(); 722 if (transform.isScaling()) { 723 p->fillRect(normalizedRect.translated(static_cast<qreal>(shadow->offset().x()) / transform.m11(), 724 static_cast<qreal>(shadow->offset().y() / transform.m22())), 725 shadowColor); 726 } else 727 p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); 711 728 } 712 729 } … … 728 745 if (m_data->hasShadow()) { 729 746 ContextShadow* shadow = contextShadow(); 730 if (mustUseContextShadow(p, shadow)) { 747 748 if (shadow->m_type != ContextShadow::BlurShadow) { 749 // We do not need any layer for simple shadow. 750 p->fillRect(normalizedRect.translated(shadow->offset()), shadow->m_color); 751 } else { 731 752 QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect); 732 753 if (shadowPainter) { … … 735 756 shadow->endShadowLayer(p); 736 757 } 737 } else 738 p->fillRect(normalizedRect.translated(shadow->offset()), shadow->m_color); 758 } 739 759 } 740 760 … … 752 772 if (m_data->hasShadow()) { 753 773 ContextShadow* shadow = contextShadow(); 754 if (mustUseContextShadow(p, shadow)) { 774 775 if (shadow->m_type != ContextShadow::BlurShadow) { 776 // We do not need any layer for simple shadow. 777 p->translate(m_data->shadow.offset()); 778 p->fillPath(path.platformPath(), QColor(m_data->shadow.m_color)); 779 p->translate(-m_data->shadow.offset()); 780 } else { 755 781 QPainter* shadowPainter = shadow->beginShadowLayer(p, rect); 756 782 if (shadowPainter) { … … 759 785 shadow->endShadowLayer(p); 760 786 } 761 } else {762 p->translate(m_data->shadow.offset());763 p->fillPath(path.platformPath(), QColor(m_data->shadow.m_color));764 p->translate(-m_data->shadow.offset());765 787 } 766 788 } … … 932 954 m_state.shadowOffset = FloatSize(size.width(), -size.height()); 933 955 m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), -size.height())); 934 } else 956 } else { 935 957 m_data->shadow = ContextShadow(color, blur, FloatSize(size.width(), size.height())); 936 937 m_data->shadow.setShadowsIgnoreTransforms(m_state.shadowsIgnoreTransforms); 958 } 938 959 } 939 960
Note: See TracChangeset
for help on using the changeset viewer.