Commit 58630be5 authored by hausmann@webkit.org's avatar hausmann@webkit.org
Browse files

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

        Reviewed by Darin.

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

        Return bool from GraphicsContext::getShadow() so the tests aren't duplicated so
        many times in Cairo and Qt ports.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34765 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6b27f0e8
2008-06-24 Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
Reviewed by Darin.
https://bugs.webkit.org/show_bug.cgi?id=19727
Return bool from GraphicsContext::getShadow() so the tests aren't duplicated so
many times in Cairo and Qt ports.
* platform/graphics/GraphicsContext.h:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::getShadow): return a boolean from getShadow()
which indicates whether there is a visible shadow to draw or not. Ports
without a platform shadow implementation can use this flag to determine
whether a shadow needs to be drawn manually
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::Font::drawGlyphs):
* platform/graphics/qt/FontQt.cpp:
(WebCore::Font::drawText):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::drawLine): use return from getShadow() to
determine whether to draw the shadow
2008-06-24 Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
 
Reviewed by Simon.
......@@ -154,11 +154,13 @@ void GraphicsContext::clearShadow()
clearPlatformShadow();
}
void GraphicsContext::getShadow(IntSize& size, int& blur, Color& color)
bool GraphicsContext::getShadow(IntSize& size, int& blur, Color& color) const
{
size = m_common->state.shadowSize;
blur = m_common->state.shadowBlur;
color = m_common->state.shadowColor;
return color.isValid() && color.alpha() && (blur || size.width() || size.height());
}
float GraphicsContext::strokeThickness() const
......
......@@ -197,7 +197,7 @@ namespace WebCore {
void endTransparencyLayer();
void setShadow(const IntSize&, int blur, const Color&);
void getShadow(IntSize&, int&, Color&);
bool getShadow(IntSize&, int&, Color&) const;
void clearShadow();
void initFocusRing(int width, int offset);
......
......@@ -57,10 +57,10 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
IntSize shadowSize;
int shadowBlur;
Color shadowColor;
context->getShadow(shadowSize, shadowBlur, shadowColor);
bool hasShadow = context->textDrawingMode() == cTextFill &&
context->getShadow(shadowSize, shadowBlur, shadowColor);
// TODO: Blur support
bool hasShadow = context->textDrawingMode() == cTextFill && shadowColor.isValid() && (shadowSize.width() || shadowSize.height());
if (hasShadow) {
// Disable graphics context shadows (not yet implemented) and paint them manually
context->clearShadow();
......
......@@ -129,14 +129,13 @@ void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint&
Color color = ctx->fillColor();
p->setPen(QColor(color));
QString string = qstring(run);
// text shadow
IntSize shadowSize;
int shadowBlur;
Color shadowColor;
ctx->getShadow(shadowSize, shadowBlur, shadowColor);
bool hasShadow = ctx->textDrawingMode() == cTextFill && shadowColor.isValid() && (shadowSize.width() || shadowSize.height());
QString string = qstring(run);
bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor);
if (from > 0 || to < run.length()) {
QTextLayout layout(string, m_font);
......@@ -149,6 +148,7 @@ void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint&
QFontMetrics fm(m_font);
int ascent = fm.ascent();
QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
if (hasShadow) {
// TODO: when blur support is added, the clip will need to account
// for the blur radius
......
......@@ -438,9 +438,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
IntSize shadowSize;
int shadowBlur;
Color shadowColor;
getShadow(shadowSize, shadowBlur, shadowColor);
bool hasShadow = textDrawingMode() == cTextFill && shadowColor.isValid() && (shadowSize.width() || shadowSize.height());
if (hasShadow) {
if (textDrawingMode() == cTextFill && getShadow(shadowSize, shadowBlur, shadowColor)) {
p->save();
p->translate(shadowSize.width(), shadowSize.height());
p->setPen(QColor(shadowColor));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment