Changeset 65334 in webkit


Ignore:
Timestamp:
Aug 13, 2010 11:05:23 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-08-13 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r65331.
http://trac.webkit.org/changeset/65331
https://bugs.webkit.org/show_bug.cgi?id=43980

This patch breaks some shadow tests on Qt Linux release
(Requested by ariya on #webkit).

  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): (WebCore::GraphicsContext::drawRect): (WebCore::GraphicsContext::drawLine): (WebCore::GraphicsContext::strokeArc): (WebCore::GraphicsContext::drawConvexPolygon): (WebCore::drawFilledShadowPath): (WebCore::GraphicsContext::fillPath): (WebCore::GraphicsContext::strokePath): (WebCore::drawBorderlessRectShadow): (WebCore::GraphicsContext::fillRect): (WebCore::GraphicsContext::fillRoundedRect): (WebCore::GraphicsContext::setPlatformShadow): (WebCore::GraphicsContext::clearPlatformShadow):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65333 r65334  
     12010-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
    1252010-08-13  Kinuko Yasuda  <kinuko@chromium.org>
    226
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r65331 r65334  
    200200    QPainterPath currentPath;
    201201
    202     enum {
    203         NoShadow,
    204         OpaqueSolidShadow,
    205         AlphaSolidShadow,
    206         BlurShadow
    207     } shadowType;
    208     QColor shadowColor;
    209     int shadowBlurRadius;
    210     QPointF shadowOffset;
    211 
    212     bool hasShadow() const
    213     {
    214         return shadowType != NoShadow;
    215     }
    216 
    217202private:
    218203    QPainter* painter;
     
    238223    } else
    239224        antiAliasingForRectsAndLines = false;
    240 
    241     shadowType = NoShadow;
    242     shadowBlurRadius = 0;
    243225}
    244226
     
    311293    p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
    312294
    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        }
    318305    }
    319306
     
    345332    adjustLineToPixelBoundaries(p1, p2, width, style);
    346333
    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();
    355343    }
    356344
     
    446434    p->setRenderHint(QPainter::Antialiasing, true);
    447435
     436    FloatSize shadowSize;
     437    float shadowBlur;
     438    Color shadowColor;
    448439    startAngle *= 16;
    449440    angleSpan *= 16;
    450 
    451     if (m_data->hasShadow()) {
     441    if (getShadow(shadowSize, shadowBlur, shadowColor)) {
    452442        p->save();
    453         p->translate(m_data->shadowOffset);
     443        p->translate(shadowSize.width(), shadowSize.height());
    454444        QPen pen(p->pen());
    455         pen.setColor(m_data->shadowColor);
     445        pen.setColor(shadowColor);
    456446        p->setPen(pen);
    457447        p->drawArc(rect, startAngle, angleSpan);
     
    479469    p->save();
    480470    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)) {
    482475        p->save();
    483         p->translate(m_data->shadowOffset);
     476        p->translate(shadowSize.width(), shadowSize.height());
    484477        if (p->brush().style() != Qt::NoBrush)
    485             p->setBrush(QBrush(m_data->shadowColor));
     478            p->setBrush(QBrush(shadowColor));
    486479        QPen pen(p->pen());
    487480        if (pen.style() != Qt::NoPen) {
    488             pen.setColor(m_data->shadowColor);
     481            pen.setColor(shadowColor);
    489482            p->setPen(pen);
    490483        }
     
    520513}
    521514
     515static 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
    522527void GraphicsContext::fillPath()
    523528{
     
    529534    path.setFillRule(toQtFillRule(fillRule()));
    530535
    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);
    536537    if (m_common->state.fillPattern) {
    537538        AffineTransform affine;
     
    557558    path.setFillRule(toQtFillRule(fillRule()));
    558559
    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());
    561566        QPen shadowPen(pen);
    562         shadowPen.setColor(m_data->shadowColor);
     567        shadowPen.setColor(shadowColor);
    563568        p->strokePath(path, shadowPen);
    564         p->translate(-m_data->shadowOffset);
     569        p->setWorldTransform(t);
    565570    }
    566571    if (m_common->state.strokePattern) {
     
    578583        p->strokePath(path, pen);
    579584    m_data->currentPath = QPainterPath();
     585}
     586
     587static 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    }
    580597}
    581598
     
    655672    FloatRect normalizedRect = rect.normalized();
    656673
    657     QRectF shadowDestRect;
     674    FloatSize shadowSize;
     675    float shadowBlur;
     676    Color shadowColor;
     677    bool hasShadow = getShadow(shadowSize, shadowBlur, shadowColor);
     678    FloatRect shadowDestRect;
    658679    QImage* shadowImage = 0;
    659680    QPainter* pShadow = 0;
    660681
    661     if (m_data->hasShadow()) {
     682    if (hasShadow) {
    662683        shadowImage = new QImage(roundedIntSize(normalizedRect.size()), QImage::Format_ARGB32_Premultiplied);
    663684        pShadow = new QPainter(shadowImage);
    664685        shadowDestRect = normalizedRect;
    665         shadowDestRect.translate(m_data->shadowOffset);
     686        shadowDestRect.move(shadowSize.width(), shadowSize.height());
    666687
    667688        pShadow->setCompositionMode(QPainter::CompositionMode_Source);
    668         pShadow->fillRect(shadowDestRect, m_data->shadowColor);
     689        pShadow->fillRect(shadowImage->rect(), shadowColor);
    669690        pShadow->setCompositionMode(QPainter::CompositionMode_DestinationIn);
    670691    }
     
    676697        QPixmap* image = m_common->state.fillPattern->tileImage()->nativeImageForCurrentFrame();
    677698
    678         if (m_data->hasShadow()) {
     699        if (hasShadow) {
    679700            drawRepeatPattern(pShadow, image, FloatRect(static_cast<QRectF>(shadowImage->rect())), m_common->state.fillPattern->repeatX(), m_common->state.fillPattern->repeatY());
    680701            pShadow->end();
     
    686707        brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform());
    687708
    688         if (m_data->hasShadow()) {
     709        if (hasShadow) {
    689710            pShadow->fillRect(shadowImage->rect(), brush);
    690711            pShadow->end();
     
    693714        p->fillRect(normalizedRect, brush);
    694715    } else {
    695         if (m_data->hasShadow()) {
     716        if (hasShadow) {
    696717            pShadow->fillRect(shadowImage->rect(), p->brush());
    697718            pShadow->end();
     
    713734    m_data->solidColor.setColor(color);
    714735    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);
    719738    p->fillRect(rect, m_data->solidColor);
    720739}
     
    727746    Path path = Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight);
    728747    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());
    734749    p->fillPath(path.platformPath(), QColor(color));
    735750}
     
    873888}
    874889
    875 void GraphicsContext::setPlatformShadow(const FloatSize& size, float blur, const Color& color, ColorSpace)
     890void GraphicsContext::setPlatformShadow(const FloatSize& size, float, const Color&, ColorSpace)
    876891{
    877892    // Qt doesn't support shadows natively, they are drawn manually in the draw*
     
    883898        m_common->state.shadowSize = FloatSize(size.width(), -size.height());
    884899    }
    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                 else
    909                     m_data->shadowType = GraphicsContextPlatformPrivate::OpaqueSolidShadow;
    910             }
    911         }
    912     }
    913900}
    914901
    915902void GraphicsContext::clearPlatformShadow()
    916903{
    917     m_data->shadowType = GraphicsContextPlatformPrivate::NoShadow;
     904    // Qt doesn't support shadows natively, they are drawn manually in the draw*
     905    // functions
    918906}
    919907
Note: See TracChangeset for help on using the changeset viewer.