Title: [207028] trunk/Source/WebCore
Revision
207028
Author
bfulg...@apple.com
Date
2016-10-10 15:10:55 -0700 (Mon, 10 Oct 2016)

Log Message

[Win][Direct2D] Correct Radial Graident Bug
https://bugs.webkit.org/show_bug.cgi?id=163241

Reviewed by Darin Adler.

Radial gradients were not working correctly under Direct2D because the
points and radius values used were incorrect. D2D wants a center point and
an offset, not a start and end point. It wants an X and Y radius (for an
ellipse), not a radius at the start point, and a radius at the end point.

Covered by existing fast/gradients/css-radial-gradients.html (and others).

* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled): Remove 'notImplemented' code path.
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::generateGradient): Use correct input values to
the Radial Gradient constructor.
(WebCore::Gradient::fill): Generate a gradient if we have no active
one to use.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207027 => 207028)


--- trunk/Source/WebCore/ChangeLog	2016-10-10 22:07:19 UTC (rev 207027)
+++ trunk/Source/WebCore/ChangeLog	2016-10-10 22:10:55 UTC (rev 207028)
@@ -1,3 +1,25 @@
+2016-10-10  Brent Fulgham  <bfulg...@apple.com>
+
+        [Win][Direct2D] Correct Radial Graident Bug
+        https://bugs.webkit.org/show_bug.cgi?id=163241
+
+        Reviewed by Darin Adler.
+
+        Radial gradients were not working correctly under Direct2D because the
+        points and radius values used were incorrect. D2D wants a center point and
+        an offset, not a start and end point. It wants an X and Y radius (for an
+        ellipse), not a radius at the start point, and a radius at the end point.
+
+        Covered by existing fast/gradients/css-radial-gradients.html (and others).
+
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::drawTiled): Remove 'notImplemented' code path.
+        * platform/graphics/win/GradientDirect2D.cpp:
+        (WebCore::Gradient::generateGradient): Use correct input values to
+        the Radial Gradient constructor.
+        (WebCore::Gradient::fill): Generate a gradient if we have no active
+        one to use.
+
 2016-10-10  Jiewen Tan  <jiewen_...@apple.com>
 
         Rename CryptoAlgorithmParameters to CryptoAlgorithmParametersDeprecated

Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (207027 => 207028)


--- trunk/Source/WebCore/platform/graphics/Image.cpp	2016-10-10 22:07:19 UTC (rev 207027)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp	2016-10-10 22:10:55 UTC (rev 207028)
@@ -93,9 +93,6 @@
 
 void Image::drawTiled(GraphicsContext& ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, const FloatSize& spacing, CompositeOperator op, BlendMode blendMode)
 {
-#if USE(DIRECT2D)
-    notImplemented();
-#else
     Color color = singlePixelSolidColor();
     if (color.isValid()) {
         fillWithSolidColor(ctxt, destRect, color, op);
@@ -203,7 +200,6 @@
 #else
     startAnimation();
 #endif
-#endif
 }
 
 // FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.

Modified: trunk/Source/WebCore/platform/graphics/win/GradientDirect2D.cpp (207027 => 207028)


--- trunk/Source/WebCore/platform/graphics/win/GradientDirect2D.cpp	2016-10-10 22:07:19 UTC (rev 207027)
+++ trunk/Source/WebCore/platform/graphics/win/GradientDirect2D.cpp	2016-10-10 22:10:55 UTC (rev 207028)
@@ -67,9 +67,12 @@
     RELEASE_ASSERT(SUCCEEDED(hr));
 
     if (m_radial) {
+        FloatSize offset = p1() - p0();
         ID2D1RadialGradientBrush* radialGradient = nullptr;
+        float radiusX = endRadius() + offset.width();
+        float radiusY = radiusX / m_aspectRatio;
         hr = renderTarget->CreateRadialGradientBrush(
-            D2D1::RadialGradientBrushProperties(p0(), p1(), startRadius(), endRadius()),
+            D2D1::RadialGradientBrushProperties(p0(), D2D1::Point2F(offset.width(), offset.height()), radiusX, radiusY),
             D2D1::BrushProperties(), gradientStopCollection.get(),
             &radialGradient);
         RELEASE_ASSERT(SUCCEEDED(hr));
@@ -109,7 +112,7 @@
         d2dContext->SetTransform(ctm);
     }
 
-    if (!m_cachedHash)
+    if (!m_cachedHash || !m_gradient)
         generateGradient(d2dContext);
 
     if (!context->didBeginDraw())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to