Changeset 34763 in webkit


Ignore:
Timestamp:
Jun 24, 2008 3:35:53 AM (16 years ago)
Author:
Simon Hausmann
Message:

2008-06-24 Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>

Reviewed by Simon.

https://bugs.webkit.org/show_bug.cgi?id=18459

Implemented basic text-shadow support for the Qt port.

Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r34762 r34763  
     12008-06-24  Jonathon Jongsma  <jonathon.jongsma@collabora.co.uk>
     2
     3        Reviewed by Simon.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=18459
     6
     7        Implemented basic text-shadow support for the Qt port.
     8
     9        * platform/graphics/qt/FontQt.cpp:
     10        (WebCore::Font::drawText): implement text-shadow support in the Qt port
     11        * platform/graphics/qt/GraphicsContextQt.cpp:
     12        (WebCore::GraphicsContext::drawLine): also draw shadows for text
     13        decorations such as unerlines
     14
    1152008-06-24  Simon Hausmann  <hausmann@webkit.org>
    216
  • trunk/WebCore/platform/graphics/qt/FontQt.cpp

    r32488 r34763  
    130130    p->setPen(QColor(color));
    131131
     132    // text shadow
     133    IntSize shadowSize;
     134    int shadowBlur;
     135    Color shadowColor;
     136    ctx->getShadow(shadowSize, shadowBlur, shadowColor);
     137    bool hasShadow = ctx->textDrawingMode() == cTextFill && shadowColor.isValid() && (shadowSize.width() || shadowSize.height());
     138
    132139    QString string = qstring(run);
    133140
     
    143150        int ascent = fm.ascent();
    144151        QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
    145 
     152        if (hasShadow) {
     153            // TODO: when blur support is added, the clip will need to account
     154            // for the blur radius
     155            qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
     156            if (shadowSize.width() > 0)
     157                dx2 = shadowSize.width();
     158            else
     159                dx1 = -shadowSize.width();
     160            if (shadowSize.height() > 0)
     161                dy2 = shadowSize.height();
     162            else
     163                dy1 = -shadowSize.height();
     164            // expand the clip rect to include the text shadow as well
     165            clip.adjust(dx1, dx2, dy1, dy2);
     166        }
    146167        p->save();
    147168        p->setClipRect(clip.toRect());
    148169        QPointF pt(point.x(), point.y() - ascent);
     170        if (hasShadow) {
     171            p->save();
     172            p->setPen(QColor(shadowColor));
     173            p->translate(shadowSize.width(), shadowSize.height());
     174            line.draw(p, pt);
     175            p->restore();
     176        }
    149177        line.draw(p, pt);
    150178        p->restore();
     
    156184    QPointF pt(point.x(), point.y());
    157185    int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
     186    if (hasShadow) {
     187        // TODO: text shadow blur support
     188        p->save();
     189        p->setPen(QColor(shadowColor));
     190        p->translate(shadowSize.width(), shadowSize.height());
     191        p->drawText(pt, string, flags, run.padding());
     192        p->restore();
     193    }
    158194    p->drawText(pt, string, flags, run.padding());
    159195}
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r34076 r34763  
    454454    const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
    455455    p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
    456 
    457456    adjustLineToPixelBoundaries(p1, p2, strokeThickness(), strokeStyle());
     457
     458    IntSize shadowSize;
     459    int shadowBlur;
     460    Color shadowColor;
     461    getShadow(shadowSize, shadowBlur, shadowColor);
     462    bool hasShadow = textDrawingMode() == cTextFill && shadowColor.isValid() && (shadowSize.width() || shadowSize.height());
     463    if (hasShadow) {
     464        p->save();
     465        p->translate(shadowSize.width(), shadowSize.height());
     466        p->setPen(QColor(shadowColor));
     467        p->drawLine(p1, p2);
     468        p->restore();
     469    }
     470
    458471    p->drawLine(p1, p2);
    459472
Note: See TracChangeset for help on using the changeset viewer.