Extended Color: Refactor FloatComponents and ColorComponents into a single templatize...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2020 02:30:37 +0000 (02:30 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2020 02:30:37 +0000 (02:30 +0000)
commit394ede9d9ccfeeafb221bbe3ee67844e9c642c5b
treeb23f3af4f4c7011e4d28db86ac46712262029008
parentb41998256770af535e51f681a759f59fd224cdcb
Extended Color: Refactor FloatComponents and ColorComponents into a single templatized ColorComponents class
https://bugs.webkit.org/show_bug.cgi?id=212446

Reviewed by Simon Fraser.

Merge FloatComponents and ColorComponents into ColorComponents<T> and move them to their own
header. This avoids duplicate code and paves the way for further generalization down the line.

Also moves some utility functions to ColorUtilities.h from SimpleColor.h as they make more sense
in the former.

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:
Add ColorComponents.h

* platform/graphics/ColorComponents.h: Copied from Source/WebCore/platform/graphics/ColorUtilities.h.
Moved ColorComponents to its own header and templatized it to allow it to serve the
needs of both the old ColorComponents and old FloatComponents classes.

* platform/graphics/ColorUtilities.cpp:
* platform/graphics/ColorUtilities.h:
Removed ColorComponents/FloatComponents and update existing usages to their new names.
Also moved roundAndClampColorChannel, fastMultiplyBy255, fastDivideBy255
and colorFloatToSimpleColorByte here from SimpleColor to make it clear where
general helper functions can go.

* platform/graphics/Color.h:
* platform/graphics/Color.cpp:
(WebCore::Color::colorSpaceAndComponents const):
(WebCore::Color::toSRGBAComponentsLossy const):
* platform/graphics/ExtendedColor.h:
(WebCore::ExtendedColor::channels const):
Update for rename of FloatComponents to ColorComponents<float>.

* platform/graphics/SimpleColor.cpp:
(WebCore::makeSimpleColorFromHSLA):
Use structured bindings and simplify code.

* platform/graphics/SimpleColor.h:
(WebCore::roundAndClampColorChannel): Deleted.
(WebCore::fastMultiplyBy255): Deleted.
(WebCore::fastDivideBy255): Deleted.
(WebCore::colorFloatToSimpleColorByte): Deleted.
As noted above, moved roundAndClampColorChannel, fastMultiplyBy255, fastDivideBy255
and colorFloatToSimpleColorByte to ColorUtilities.h

* platform/graphics/filters/FEColorMatrix.cpp:
Update for rename of FloatComponents to ColorComponents<float>.

* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::byteOffsetOfPixel):
Moved byteOffsetOfPixel here from ColorUtilities. This file is the only user
and it wasn't general in a way that was clear for other users.

* platform/graphics/filters/FELighting.cpp:
(WebCore::FELighting::drawLighting):
Update for rename of FloatComponents to ColorComponents<float>.

* platform/graphics/filters/FEMorphology.cpp:
(WebCore::makeColorComponentsfromPixelValue):
Added. Used to be ColorComponents::fromRGBA(), but was only used here
and didn't seem generally useful.

(WebCore::makePixelValueFromColorComponents):
Added. Used to be ColorComponents::toRGBA(), but was only used here
and didn't seem generally useful.

(WebCore::minOrMax):
(WebCore::columnExtremum):
(WebCore::kernelExtremum):
(WebCore::FEMorphology::platformApplyGeneric):
Update for rename of FloatComponents to ColorComponents<float> and ColorComponents
to ColorComponents<uint8_t>.

* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::noise2D const):
(WebCore::toIntBasedColorComponents):
(WebCore::FETurbulence::calculateTurbulenceValueForPoint const):
(WebCore::FETurbulence::fillRegion const):
* platform/graphics/filters/FETurbulence.h:
Update for rename of FloatComponents to ColorComponents<float> and ColorComponents
to ColorComponents<uint8_t>. Also renames toColorComponents to toIntBasedColorComponents
as the former was no longer specific enough. Updated to use std::clamp.

* platform/graphics/filters/FilterOperation.cpp:
(WebCore::BasicColorMatrixFilterOperation::transformColor const):
(WebCore::BasicComponentTransferFilterOperation::transformColor const):
(WebCore::InvertLightnessFilterOperation::transformColor const):
(WebCore::InvertLightnessFilterOperation::inverseTransformColor const):
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::transformColor const):
(WebCore::FilterOperation::inverseTransformColor const):
* platform/graphics/filters/FilterOperations.cpp:
(WebCore::FilterOperations::transformColor const):
(WebCore::FilterOperations::inverseTransformColor const):
Update for rename of FloatComponents to ColorComponents<float>.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262232 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Headers.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/Color.h
Source/WebCore/platform/graphics/ColorComponents.h [new file with mode: 0644]
Source/WebCore/platform/graphics/ColorMatrix.cpp
Source/WebCore/platform/graphics/ColorMatrix.h
Source/WebCore/platform/graphics/ColorUtilities.cpp
Source/WebCore/platform/graphics/ColorUtilities.h
Source/WebCore/platform/graphics/ExtendedColor.h
Source/WebCore/platform/graphics/SimpleColor.cpp
Source/WebCore/platform/graphics/SimpleColor.h
Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
Source/WebCore/platform/graphics/filters/FELighting.cpp
Source/WebCore/platform/graphics/filters/FEMorphology.cpp
Source/WebCore/platform/graphics/filters/FETurbulence.cpp
Source/WebCore/platform/graphics/filters/FETurbulence.h
Source/WebCore/platform/graphics/filters/FilterOperation.cpp
Source/WebCore/platform/graphics/filters/FilterOperation.h
Source/WebCore/platform/graphics/filters/FilterOperations.cpp