Add Support for Conic Gradients
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 01:36:36 +0000 (01:36 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 01:36:36 +0000 (01:36 +0000)
commitd752953fe4f3a824ac4f2d8dab14500d5f789523
tree138a6ea7eb990e516e6dab855af9991211e5ecc3
parenta190e710d6f31f0f80ad58c051fc07716704354e
Add Support for Conic Gradients
https://bugs.webkit.org/show_bug.cgi?id=189329
<rdar://problem/21444701>

Reviewed by Simon Fraser.

Source/WebCore:

Add support for rendering CSS conic gradients.
The parsing work was already done, this just hooks up the data we have
with the CG functionality for conic gradients. Add the needed plumbing
to allow for this additional type and fill in the creation of
a conic gradient.

Tests: fast/gradients/conic-repeating.html
       fast/gradients/conic.html

* css/CSSGradientValue.cpp:
(WebCore::createGradient):
(WebCore::LinearGradientAdapter::gradientLength const):
(WebCore::RadialGradientAdapter::gradientLength const):
(WebCore::ConicGradientAdapter::ConicGradientAdapter):
(WebCore::ConicGradientAdapter::gradientLength const):
(WebCore::ConicGradientAdapter::maxExtent const):
(WebCore::ConicGradientAdapter::normalizeStopsAndEndpointsOutsideRange):

Compute what the color stops should be if they extend past 0-1

(WebCore::CSSGradientValue::computeStops):
(WebCore::CSSConicGradientValue::createGradient):
(WebCore::LinearGradientAdapter::startPoint const): Deleted.
(WebCore::LinearGradientAdapter::endPoint const): Deleted.
(WebCore::RadialGradientAdapter::startPoint const): Deleted.
(WebCore::RadialGradientAdapter::endPoint const): Deleted.

Start and End points weren't very universal. All we really need from these
gradientAdapters is their length, so just ask for that instead.

* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::buildArrayForCanvasGradient):
* platform/graphics/Gradient.cpp:
(WebCore::Gradient::create):
(WebCore::Gradient::Gradient):
(WebCore::Gradient::type const):
(WebCore::Gradient::adjustParametersForTiledDrawing):
(WebCore::Gradient::isZeroSize const):
(WebCore::Gradient::hash const):
* platform/graphics/Gradient.h:
* platform/graphics/cg/GradientCG.cpp:
(WebCore::Gradient::paint):

Source/WebCore/PAL:

Define the CG functionality for conic gradients.

* pal/spi/cg/CoreGraphicsSPI.h:

Source/WebKit:

Connect up web preferences to allow conic gradients to be turned on in the
experimental features menu.

* Shared/WebPreferences.yaml:

LayoutTests:

Simple tests to see if conic gradients are rendered properly.

* fast/gradients/conic-expected.html: Added.
* fast/gradients/conic-repeating-expected.html: Added.
* fast/gradients/conic-repeating.html: Added.
* fast/gradients/conic.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/gradients/conic-center-outside-box-expected.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-center-outside-box.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-expected.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-extended-stops-expected.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-extended-stops.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-off-center-expected.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-off-center.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-repeating-expected.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-repeating.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic.html [new file with mode: 0644]
LayoutTests/platform/ios-12/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/inspector/InspectorCanvas.cpp
Source/WebCore/page/Settings.yaml
Source/WebCore/page/SettingsDefaultValues.h
Source/WebCore/platform/graphics/Gradient.cpp
Source/WebCore/platform/graphics/Gradient.h
Source/WebCore/platform/graphics/cg/GradientCG.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/Shared/WebPreferencesDefaultValues.h