Changeset 65334 in webkit
- Timestamp:
- Aug 13, 2010 11:05:23 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r65333 r65334 1 2010-08-13 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r65331. 4 http://trac.webkit.org/changeset/65331 5 https://bugs.webkit.org/show_bug.cgi?id=43980 6 7 This patch breaks some shadow tests on Qt Linux release 8 (Requested by ariya on #webkit). 9 10 * platform/graphics/qt/GraphicsContextQt.cpp: 11 (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): 12 (WebCore::GraphicsContext::drawRect): 13 (WebCore::GraphicsContext::drawLine): 14 (WebCore::GraphicsContext::strokeArc): 15 (WebCore::GraphicsContext::drawConvexPolygon): 16 (WebCore::drawFilledShadowPath): 17 (WebCore::GraphicsContext::fillPath): 18 (WebCore::GraphicsContext::strokePath): 19 (WebCore::drawBorderlessRectShadow): 20 (WebCore::GraphicsContext::fillRect): 21 (WebCore::GraphicsContext::fillRoundedRect): 22 (WebCore::GraphicsContext::setPlatformShadow): 23 (WebCore::GraphicsContext::clearPlatformShadow): 24 1 25 2010-08-13 Kinuko Yasuda <kinuko@chromium.org> 2 26 -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r65331 r65334 200 200 QPainterPath currentPath; 201 201 202 enum {203 NoShadow,204 OpaqueSolidShadow,205 AlphaSolidShadow,206 BlurShadow207 } shadowType;208 QColor shadowColor;209 int shadowBlurRadius;210 QPointF shadowOffset;211 212 bool hasShadow() const213 {214 return shadowType != NoShadow;215 }216 217 202 private: 218 203 QPainter* painter; … … 238 223 } else 239 224 antiAliasingForRectsAndLines = false; 240 241 shadowType = NoShadow;242 shadowBlurRadius = 0;243 225 } 244 226 … … 311 293 p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines); 312 294 313 if (m_data->hasShadow()) { 314 IntRect shadowRect = rect; 315 shadowRect.move(m_data->shadowOffset.x(), m_data->shadowOffset.y()); 316 shadowRect.inflate(static_cast<int>(p->pen().widthF())); 317 p->fillRect(shadowRect, m_data->shadowColor); 295 if (m_common->state.shadowColor.isValid()) { 296 FloatSize shadowSize; 297 float shadowBlur; 298 Color shadowColor; 299 if (getShadow(shadowSize, shadowBlur, shadowColor)) { 300 IntRect shadowRect = rect; 301 shadowRect.move(shadowSize.width(), shadowSize.height()); 302 shadowRect.inflate(static_cast<int>(p->pen().widthF())); 303 p->fillRect(shadowRect, QColor(shadowColor)); 304 } 318 305 } 319 306 … … 345 332 adjustLineToPixelBoundaries(p1, p2, width, style); 346 333 347 if (m_data->hasShadow()) { 348 if (textDrawingMode() == cTextFill) { 349 p->save(); 350 p->translate(m_data->shadowOffset); 351 p->setPen(m_data->shadowColor); 352 p->drawLine(p1, p2); 353 p->restore(); 354 } 334 FloatSize shadowSize; 335 float shadowBlur; 336 Color shadowColor; 337 if (textDrawingMode() == cTextFill && getShadow(shadowSize, shadowBlur, shadowColor)) { 338 p->save(); 339 p->translate(shadowSize.width(), shadowSize.height()); 340 p->setPen(shadowColor); 341 p->drawLine(p1, p2); 342 p->restore(); 355 343 } 356 344 … … 446 434 p->setRenderHint(QPainter::Antialiasing, true); 447 435 436 FloatSize shadowSize; 437 float shadowBlur; 438 Color shadowColor; 448 439 startAngle *= 16; 449 440 angleSpan *= 16; 450 451 if (m_data->hasShadow()) { 441 if (getShadow(shadowSize, shadowBlur, shadowColor)) { 452 442 p->save(); 453 p->translate( m_data->shadowOffset);443 p->translate(shadowSize.width(), shadowSize.height()); 454 444 QPen pen(p->pen()); 455 pen.setColor( m_data->shadowColor);445 pen.setColor(shadowColor); 456 446 p->setPen(pen); 457 447 p->drawArc(rect, startAngle, angleSpan); … … 479 469 p->save(); 480 470 p->setRenderHint(QPainter::Antialiasing, shouldAntialias); 481 if (m_data->hasShadow()) { 471 FloatSize shadowSize; 472 float shadowBlur; 473 Color shadowColor; 474 if (getShadow(shadowSize, shadowBlur, shadowColor)) { 482 475 p->save(); 483 p->translate( m_data->shadowOffset);476 p->translate(shadowSize.width(), shadowSize.height()); 484 477 if (p->brush().style() != Qt::NoBrush) 485 p->setBrush(QBrush( m_data->shadowColor));478 p->setBrush(QBrush(shadowColor)); 486 479 QPen pen(p->pen()); 487 480 if (pen.style() != Qt::NoPen) { 488 pen.setColor( m_data->shadowColor);481 pen.setColor(shadowColor); 489 482 p->setPen(pen); 490 483 } … … 520 513 } 521 514 515 static void inline drawFilledShadowPath(GraphicsContext* context, QPainter* p, const QPainterPath& path) 516 { 517 FloatSize shadowSize; 518 float shadowBlur; 519 Color shadowColor; 520 if (context->getShadow(shadowSize, shadowBlur, shadowColor)) { 521 p->translate(shadowSize.width(), shadowSize.height()); 522 p->fillPath(path, QBrush(shadowColor)); 523 p->translate(-shadowSize.width(), -shadowSize.height()); 524 } 525 } 526 522 527 void GraphicsContext::fillPath() 523 528 { … … 529 534 path.setFillRule(toQtFillRule(fillRule())); 530 535 531 if (m_data->hasShadow()) { 532 p->translate(m_data->shadowOffset); 533 p->fillPath(path, m_data->shadowColor); 534 p->translate(-m_data->shadowOffset); 535 } 536 drawFilledShadowPath(this, p, path); 536 537 if (m_common->state.fillPattern) { 537 538 AffineTransform affine; … … 557 558 path.setFillRule(toQtFillRule(fillRule())); 558 559 559 if (m_data->hasShadow()) { 560 p->translate(m_data->shadowOffset); 560 FloatSize shadowSize; 561 float shadowBlur; 562 Color shadowColor; 563 if (getShadow(shadowSize, shadowBlur, shadowColor)) { 564 QTransform t(p->worldTransform()); 565 p->translate(shadowSize.width(), shadowSize.height()); 561 566 QPen shadowPen(pen); 562 shadowPen.setColor( m_data->shadowColor);567 shadowPen.setColor(shadowColor); 563 568 p->strokePath(path, shadowPen); 564 p-> translate(-m_data->shadowOffset);569 p->setWorldTransform(t); 565 570 } 566 571 if (m_common->state.strokePattern) { … … 578 583 p->strokePath(path, pen); 579 584 m_data->currentPath = QPainterPath(); 585 } 586 587 static inline void drawBorderlessRectShadow(GraphicsContext* context, QPainter* p, const FloatRect& rect) 588 { 589 FloatSize shadowSize; 590 float shadowBlur; 591 Color shadowColor; 592 if (context->getShadow(shadowSize, shadowBlur, shadowColor)) { 593 FloatRect shadowRect(rect); 594 shadowRect.move(shadowSize.width(), shadowSize.height()); 595 p->fillRect(shadowRect, QColor(shadowColor)); 596 } 580 597 } 581 598 … … 655 672 FloatRect normalizedRect = rect.normalized(); 656 673 657 QRectF shadowDestRect; 674 FloatSize shadowSize; 675 float shadowBlur; 676 Color shadowColor; 677 bool hasShadow = getShadow(shadowSize, shadowBlur, shadowColor); 678 FloatRect shadowDestRect; 658 679 QImage* shadowImage = 0; 659 680 QPainter* pShadow = 0; 660 681 661 if ( m_data->hasShadow()) {682 if (hasShadow) { 662 683 shadowImage = new QImage(roundedIntSize(normalizedRect.size()), QImage::Format_ARGB32_Premultiplied); 663 684 pShadow = new QPainter(shadowImage); 664 685 shadowDestRect = normalizedRect; 665 shadowDestRect. translate(m_data->shadowOffset);686 shadowDestRect.move(shadowSize.width(), shadowSize.height()); 666 687 667 688 pShadow->setCompositionMode(QPainter::CompositionMode_Source); 668 pShadow->fillRect(shadow DestRect, m_data->shadowColor);689 pShadow->fillRect(shadowImage->rect(), shadowColor); 669 690 pShadow->setCompositionMode(QPainter::CompositionMode_DestinationIn); 670 691 } … … 676 697 QPixmap* image = m_common->state.fillPattern->tileImage()->nativeImageForCurrentFrame(); 677 698 678 if ( m_data->hasShadow()) {699 if (hasShadow) { 679 700 drawRepeatPattern(pShadow, image, FloatRect(static_cast<QRectF>(shadowImage->rect())), m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY()); 680 701 pShadow->end(); … … 686 707 brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform()); 687 708 688 if ( m_data->hasShadow()) {709 if (hasShadow) { 689 710 pShadow->fillRect(shadowImage->rect(), brush); 690 711 pShadow->end(); … … 693 714 p->fillRect(normalizedRect, brush); 694 715 } else { 695 if ( m_data->hasShadow()) {716 if (hasShadow) { 696 717 pShadow->fillRect(shadowImage->rect(), p->brush()); 697 718 pShadow->end(); … … 713 734 m_data->solidColor.setColor(color); 714 735 QPainter* p = m_data->p(); 715 716 if (m_data->hasShadow()) 717 p->fillRect(QRectF(rect).translated(m_data->shadowOffset), m_data->shadowColor); 718 736 if (m_common->state.shadowColor.isValid()) 737 drawBorderlessRectShadow(this, p, rect); 719 738 p->fillRect(rect, m_data->solidColor); 720 739 } … … 727 746 Path path = Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight); 728 747 QPainter* p = m_data->p(); 729 if (m_data->hasShadow()) { 730 p->translate(m_data->shadowOffset); 731 p->fillPath(path.platformPath(), m_data->shadowColor); 732 p->translate(-m_data->shadowOffset); 733 } 748 drawFilledShadowPath(this, p, path.platformPath()); 734 749 p->fillPath(path.platformPath(), QColor(color)); 735 750 } … … 873 888 } 874 889 875 void GraphicsContext::setPlatformShadow(const FloatSize& size, float blur, const Color& color, ColorSpace)890 void GraphicsContext::setPlatformShadow(const FloatSize& size, float, const Color&, ColorSpace) 876 891 { 877 892 // Qt doesn't support shadows natively, they are drawn manually in the draw* … … 883 898 m_common->state.shadowSize = FloatSize(size.width(), -size.height()); 884 899 } 885 886 // Here we just store important shadow states.887 888 m_data->shadowBlurRadius = qRound(blur);889 m_data->shadowOffset = QPointF(m_common->state.shadowSize.width(), m_common->state.shadowSize.height());890 m_data->shadowColor = color;891 892 // The type of shadow is decided by the blur radius, shadow offset, and shadow color.893 894 if (!color.isValid() || !color.alpha()) {895 // Can't paint the shadow with invalid or invisible color.896 m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow;897 } else {898 if (blur >= 1) {899 // Shadow is always blurred, even the offset is zero.900 m_data->shadowType = GraphicsContextPlatformPrivate::BlurShadow;901 } else {902 if (m_data->shadowOffset.isNull()) {903 // Without blur and zero offset means the shadow is fully hidden.904 m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow;905 } else {906 if (color.hasAlpha())907 m_data->shadowType = GraphicsContextPlatformPrivate::AlphaSolidShadow;908 else909 m_data->shadowType = GraphicsContextPlatformPrivate::OpaqueSolidShadow;910 }911 }912 }913 900 } 914 901 915 902 void GraphicsContext::clearPlatformShadow() 916 903 { 917 m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow; 904 // Qt doesn't support shadows natively, they are drawn manually in the draw* 905 // functions 918 906 } 919 907
Note: See TracChangeset
for help on using the changeset viewer.