Title: [190758] branches/safari-601-branch

Diff

Modified: branches/safari-601-branch/LayoutTests/ChangeLog (190757 => 190758)


--- branches/safari-601-branch/LayoutTests/ChangeLog	2015-10-08 23:19:27 UTC (rev 190757)
+++ branches/safari-601-branch/LayoutTests/ChangeLog	2015-10-08 23:30:24 UTC (rev 190758)
@@ -1,3 +1,23 @@
+2015-10-08  Lucas Forschler  <[email protected]>
+
+        Merge r188148. rdar://problem/22802036
+
+    2015-08-06  Dean Jackson  <[email protected]>
+
+            Shadows don't draw on fillText when using a gradient fill
+            https://bugs.webkit.org/show_bug.cgi?id=147758
+            <rdar://problem/20860912>
+
+            Reviewed by Myles Maxfield.
+
+            New test that exercises shadows on gradient fills. This really
+            should be a ref test, but there is a very small rendering difference
+            caused by masking, so instead it uses JS to look for pixels of
+            the correct color.
+
+            * fast/canvas/gradient-text-with-shadow-expected.txt: Added.
+            * fast/canvas/gradient-text-with-shadow.html: Added.
+
 2015-10-06  Benjamin Poulain  <[email protected]>
 
         We can't use let in JS on the safari-601 branch

Copied: branches/safari-601-branch/LayoutTests/fast/canvas/gradient-text-with-shadow-expected.txt (from rev 188148, trunk/LayoutTests/fast/canvas/gradient-text-with-shadow-expected.txt) (0 => 190758)


--- branches/safari-601-branch/LayoutTests/fast/canvas/gradient-text-with-shadow-expected.txt	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/canvas/gradient-text-with-shadow-expected.txt	2015-10-08 23:30:24 UTC (rev 190758)
@@ -0,0 +1 @@
+PASSED

Copied: branches/safari-601-branch/LayoutTests/fast/canvas/gradient-text-with-shadow.html (from rev 188148, trunk/LayoutTests/fast/canvas/gradient-text-with-shadow.html) (0 => 190758)


--- branches/safari-601-branch/LayoutTests/fast/canvas/gradient-text-with-shadow.html	                        (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/canvas/gradient-text-with-shadow.html	2015-10-08 23:30:24 UTC (rev 190758)
@@ -0,0 +1,43 @@
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function runTest() {
+
+    var canvas = document.querySelector("canvas");
+    var context = canvas.getContext('2d');
+
+    context.shadowOffsetX = 0;
+    context.shadowOffsetY = 10;
+    context.shadowBlur = 0;
+    context.shadowColor = "rgb(255, 0, 0)";
+
+    context.font = "80px sans-serif";
+
+    var gradient = context.createLinearGradient(0, 0, 0, 100);
+    gradient.addColorStop(0, "blue");
+    gradient.addColorStop(1, "blue");
+
+    context.fillStyle = gradient;
+    context.fillText("hello", 10, 95);
+
+    // If we correctly drew the shadow, there will be some
+    // red pixels along the bottom line of the canvas.
+
+    var buffer = context.getImageData(0, canvas.height - 1, canvas.width, 1);
+    var passed = false;
+    for (var i = 0; i < canvas.width; ++i) {
+        if (buffer.data[i * 4] > 0) {
+            passed = true;
+            break;
+        }
+    }
+    document.querySelector("p").textContent = passed ? "PASSED" : "FAILED";
+}
+
+window.addEventListener("load", runTest, false);
+
+</script>
+<canvas width="200" height="100"></canvas>
+<p></p>
\ No newline at end of file

Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (190757 => 190758)


--- branches/safari-601-branch/Source/WebCore/ChangeLog	2015-10-08 23:19:27 UTC (rev 190757)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog	2015-10-08 23:30:24 UTC (rev 190758)
@@ -1,5 +1,30 @@
 2015-10-08  Lucas Forschler  <[email protected]>
 
+        Merge r188148. rdar://problem/22802036
+
+    2015-08-06  Dean Jackson  <[email protected]>
+
+            Shadows don't draw on fillText when using a gradient fill
+            https://bugs.webkit.org/show_bug.cgi?id=147758
+            <rdar://problem/20860912>
+
+            Reviewed by Myles Maxfield.
+
+            Since we use a mask to render a pattern or gradient
+            into text, any shadow was being clipped out. Change
+            this to draw the shadow before the mask + fill operation,
+            using a technique similar to text-shadow.
+
+            Test: fast/canvas/gradient-text-with-shadow.html
+
+            * html/canvas/CanvasRenderingContext2D.cpp:
+            (WebCore::CanvasRenderingContext2D::drawTextInternal): Get the current shadow
+            style, paint the text with a transformed shadow offset so that we only
+            see the shadow and not the text, then combine with the existing pattern/gradient
+            fill.
+
+2015-10-08  Lucas Forschler  <[email protected]>
+
         Rollout r190745
 
 2015-10-08  Lucas Forschler  <[email protected]>

Modified: branches/safari-601-branch/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (190757 => 190758)


--- branches/safari-601-branch/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2015-10-08 23:19:27 UTC (rev 190757)
+++ branches/safari-601-branch/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2015-10-08 23:30:24 UTC (rev 190758)
@@ -2357,8 +2357,40 @@
 #if USE(CG)
     const CanvasStyle& drawStyle = fill ? state().m_fillStyle : state().m_strokeStyle;
     if (drawStyle.canvasGradient() || drawStyle.canvasPattern()) {
+
         IntRect maskRect = enclosingIntRect(textRect);
 
+        // If we have a shadow, we need to draw it before the mask operation.
+        // Follow a procedure similar to paintTextWithShadows in TextPainter.
+
+        if (shouldDrawShadows()) {
+            GraphicsContextStateSaver stateSaver(*c);
+
+            FloatSize offset = FloatSize(0, 2 * maskRect.height());
+
+            FloatSize shadowOffset;
+            float shadowRadius;
+            Color shadowColor;
+            ColorSpace shadowColorSpace;
+            c->getShadow(shadowOffset, shadowRadius, shadowColor, shadowColorSpace);
+
+            FloatRect shadowRect(maskRect);
+            shadowRect.inflate(shadowRadius * 1.4);
+            shadowRect.move(shadowOffset * -1);
+            c->clip(shadowRect);
+
+            shadowOffset += offset;
+
+            c->setLegacyShadow(shadowOffset, shadowRadius, shadowColor, shadowColorSpace);
+
+            if (fill)
+                c->setFillColor(Color::black, ColorSpaceDeviceRGB);
+            else
+                c->setStrokeColor(Color::black, ColorSpaceDeviceRGB);
+
+            c->drawBidiText(font, textRun, location + offset, FontCascade::UseFallbackIfFontNotReady);
+        }
+
         std::unique_ptr<ImageBuffer> maskImage = c->createCompatibleBuffer(maskRect.size());
 
         GraphicsContext* maskImageContext = maskImage->context();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to