[Color] Make gradients work with ExtendedColors
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 17:34:50 +0000 (17:34 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Apr 2017 17:34:50 +0000 (17:34 +0000)
commitb73837561ae24616213dfbdab2004a83a906e8da
tree11abe675d982107c51a4392f232bd40957321407
parent2afb08f91939080728c120c858189f24d5bad321
[Color] Make gradients work with ExtendedColors
https://bugs.webkit.org/show_bug.cgi?id=171315
<rdar://problems/31830177>

Reviewed by Antoine Quint.

Source/WebCore:

Allow gradients to hold Color objects, and thus
handle ExtendedColor. Implement the backend for
CoreGraphics.

Test: css3/color/gradients.html

* platform/graphics/Gradient.cpp:
(WebCore::Gradient::addColorStop): Just copy the Color now.
(WebCore::compareStops): Handle rename of stop to offset.
(WebCore::Gradient::hasAlpha): Use Color's helper.
* platform/graphics/Gradient.h:
(WebCore::Gradient::ColorStop::ColorStop): Rename stop
to offset, and store a Color rather than four floating
point values.
* platform/graphics/cairo/GradientCairo.cpp:
(WebCore::Gradient::platformGradient):
* platform/graphics/cg/GradientCG.cpp:
(WebCore::Gradient::platformGradient): Use the CG method
that can handle CGColorRefs with ColorSpace values, and
pass the Extended sRGB space which should be no change for
all existing gradients but also handle ColorSpaces like
Display P3.
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::generateGradient):
* svg/SVGGradientElement.cpp:
(WebCore::SVGGradientElement::buildStops):

LayoutTests:

Test for gradients using the color() syntax. Unfortunately,
due to rounding errors, we can't use a ref test for some
transparent colors, so comment them out for the moment.
These can be re-enabled when we can specify a tolerance
value for image comparison in the testing framework.

* css3/color/gradients-expected.html: Added.
* css3/color/gradients.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/css3/color/gradients-expected.html [new file with mode: 0644]
LayoutTests/css3/color/gradients.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Gradient.cpp
Source/WebCore/platform/graphics/Gradient.h
Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
Source/WebCore/platform/graphics/cg/GradientCG.cpp
Source/WebCore/platform/graphics/win/GradientDirect2D.cpp
Source/WebCore/svg/SVGGradientElement.cpp