Extended Color Cleanup: Remove red()/green()/blue() accessors from ExtendedColor...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 May 2020 17:56:34 +0000 (17:56 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 May 2020 17:56:34 +0000 (17:56 +0000)
commit2a1d4005a16b76ee7002da6383c9cde91e36fec3
treea0f2e05527a876fb1123d01bce61d009b72e95d1
parent0540f8c215adcaccc4f4c12253b40fc2608beaa5
Extended Color Cleanup: Remove red()/green()/blue() accessors from ExtendedColor in preperation for supporting non-RGB based ColorSpaces
https://bugs.webkit.org/show_bug.cgi?id=212366

Reviewed by Simon Fraser.

Source/WebCore:

* platform/graphics/Color.cpp:
(WebCore::differenceSquared):
Switch to using toSRGBASimpleColorLossy() rather than poking at the ExtendedColor
components directly. The old code was already incorrect if the two colors had
differing color spaces so this at least now gives reasonable results.

(WebCore::Color::colorWithAlpha const):
(WebCore::Color::colorWithAlphaUsingAlternativeRounding const):
Delegate to ExtendedColor completely for colorWithAlpha() to allow for more
control over how the components might be stored in the future.

* platform/graphics/Color.h:
(WebCore::Color::isBlackColor):
(WebCore::Color::isWhiteColor):
Delegate to ExtendedColor for isBlack()/isWhite() to allow per-color space
interpretations of the predicate.

(WebCore::Color::encode const):
(WebCore::Color::decode):
Use c1, c2, c3 rather than red/green/blue. This should be acceptable for the
forseeable future, as all expected colorspaces only have 3 channels, but at
some point, it may make sense to delegate coding to ExtendedColor completely.

* platform/graphics/ExtendedColor.cpp:
* platform/graphics/ExtendedColor.h:
(WebCore::ExtendedColor::channels const):
(WebCore::ExtendedColor::red const): Deleted.
(WebCore::ExtendedColor::green const): Deleted.
(WebCore::ExtendedColor::blue const): Deleted.
(WebCore::ExtendedColor::colorWithAlpha const): Added.
(WebCore::ExtendedColor::isWhite const): Added.
(WebCore::ExtendedColor::isBlack const): Added.
Use channels() with structured bindings rather than the red()/green()/blue() accessors
everywhere.

Tools:

* TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp:
(TestWebKitAPI::TEST):
Update tests to pull values from the channels rather than from the red()/green()/blue() accessors.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/Color.h
Source/WebCore/platform/graphics/ExtendedColor.cpp
Source/WebCore/platform/graphics/ExtendedColor.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp