2010-11-22 Andreas Kling <kling@webkit.org>

        Reviewed by Ariya Hidayat.

        [Qt] Canvas: strokeText() and fillText() produce same shadow
        https://bugs.webkit.org/show_bug.cgi?id=48845

        Test: fast/canvas/canvas-strokeText-strokes-shadow.html

        * platform/graphics/qt/FontQt.cpp:
        (WebCore::drawTextCommon): Stroke the shadow rather than filling it in the cTextStroke case.
2010-11-22  Andreas Kling  <kling@webkit.org>

        Reviewed by Ariya Hidayat.

        [Qt] Canvas: strokeText() and fillText() produce same shadow
        https://bugs.webkit.org/show_bug.cgi?id=48845

        Add test to verify that strokeText() doesn't produce a fillText() shadow.

        * fast/canvas/canvas-strokeText-strokes-shadow.html: Added.
        * fast/canvas/canvas-strokeText-strokes-shadow-expected.txt: Added.
        * fast/canvas/script-tests/canvas-strokeText-strokes-shadow.js: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72577 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a117f857
2010-11-22 Andreas Kling <kling@webkit.org>
Reviewed by Ariya Hidayat.
[Qt] Canvas: strokeText() and fillText() produce same shadow
https://bugs.webkit.org/show_bug.cgi?id=48845
Add test to verify that strokeText() doesn't produce a fillText() shadow.
* fast/canvas/canvas-strokeText-strokes-shadow.html: Added.
* fast/canvas/canvas-strokeText-strokes-shadow-expected.txt: Added.
* fast/canvas/script-tests/canvas-strokeText-strokes-shadow.js: Added.
2010-11-22 Adam Roben <aroben@apple.com>
Update Windows 7 results for two tests
Test that strokeText() doesn't produce a filled shadow.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS imgdata[0] is 0
PASS imgdata[1] is 128
PASS imgdata[2] is 0
PASS imgdata[3] is 255
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/canvas-strokeText-strokes-shadow.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
description("Test that strokeText() doesn't produce a filled shadow.");
var ctx = document.createElement('canvas').getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
// Stroke an 'I' with its shadow in the upper left corner.
ctx.strokeStyle = 'white';
ctx.lineWidth = 2;
ctx.shadowColor = 'red';
ctx.shadowOffsetX = -15;
ctx.shadowOffsetY = 0;
ctx.font = '128px sans-serif';
ctx.strokeText("I", 0, 50);
imageData = ctx.getImageData(0, 0, 1, 1);
imgdata = imageData.data;
shouldBe("imgdata[0]", "0");
shouldBe("imgdata[1]", "128");
shouldBe("imgdata[2]", "0");
shouldBe("imgdata[3]", "255");
var successfullyParsed = true;
2010-11-22 Andreas Kling <kling@webkit.org>
Reviewed by Ariya Hidayat.
[Qt] Canvas: strokeText() and fillText() produce same shadow
https://bugs.webkit.org/show_bug.cgi?id=48845
Test: fast/canvas/canvas-strokeText-strokes-shadow.html
* platform/graphics/qt/FontQt.cpp:
(WebCore::drawTextCommon): Stroke the shadow rather than filling it in the cTextStroke case.
2010-11-22 Patrick Gansterer <paroga@webkit.org>
Reviewed by Sam Weinig.
......@@ -182,32 +182,54 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
if (!isComplexText && !(ctx->textDrawingMode() & cTextStroke))
flags |= Qt::TextBypassShaping;
#endif
if (ctx->contextShadow()->m_type != ContextShadow::NoShadow) {
ContextShadow* ctxShadow = ctx->contextShadow();
if (ctxShadow->m_type != ContextShadow::BlurShadow) {
p->save();
p->setPen(ctxShadow->m_color);
p->translate(ctxShadow->offset());
p->drawText(pt, string, flags, run.padding());
p->restore();
} else {
QFontMetrics fm(font);
QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height());
QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect);
if (shadowPainter) {
// Since it will be blurred anyway, we don't care about render hints.
shadowPainter->setFont(p->font());
shadowPainter->setPen(ctxShadow->m_color);
shadowPainter->drawText(pt, string, flags, run.padding());
ctxShadow->endShadowLayer(p);
QPainterPath textStrokePath;
if (ctx->textDrawingMode() & cTextStroke)
textStrokePath.addText(pt, font, string);
ContextShadow* ctxShadow = ctx->contextShadow();
if (ctxShadow->m_type != ContextShadow::NoShadow) {
if (ctx->textDrawingMode() & cTextFill) {
if (ctxShadow->m_type != ContextShadow::BlurShadow) {
p->save();
p->setPen(ctxShadow->m_color);
p->translate(ctxShadow->offset());
p->drawText(pt, string, flags, run.padding());
p->restore();
} else {
QFontMetrics fm(font);
QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height());
QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect);
if (shadowPainter) {
// Since it will be blurred anyway, we don't care about render hints.
shadowPainter->setFont(p->font());
shadowPainter->setPen(ctxShadow->m_color);
shadowPainter->drawText(pt, string, flags, run.padding());
ctxShadow->endShadowLayer(p);
}
}
} else if (ctx->textDrawingMode() & cTextStroke) {
if (ctxShadow->m_type != ContextShadow::BlurShadow) {
p->translate(ctxShadow->offset());
p->strokePath(textStrokePath, QPen(ctxShadow->m_color));
p->translate(-ctxShadow->offset());
} else {
QFontMetrics fm(font);
QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height());
QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect);
if (shadowPainter) {
// Since it will be blurred anyway, we don't care about render hints.
shadowPainter->setFont(p->font());
shadowPainter->strokePath(textStrokePath, QPen(ctxShadow->m_color));
ctxShadow->endShadowLayer(p);
}
}
}
}
if (ctx->textDrawingMode() & cTextStroke) {
QPainterPath path;
path.addText(pt, font, string);
p->strokePath(path, textStrokePen);
}
if (ctx->textDrawingMode() & cTextStroke)
p->strokePath(textStrokePath, textStrokePen);
if (ctx->textDrawingMode() & cTextFill) {
QPen previousPen = p->pen();
p->setPen(textFillPen);
......
Markdown is supported
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