Diff
Modified: trunk/Source/WebCore/ChangeLog (264135 => 264136)
--- trunk/Source/WebCore/ChangeLog 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/ChangeLog 2020-07-08 21:46:56 UTC (rev 264136)
@@ -1,3 +1,107 @@
+2020-07-08 Sam Weinig <[email protected]>
+
+ Part 3 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them
+ https://bugs.webkit.org/show_bug.cgi?id=214082
+
+ Reviewed by Darin Adler.
+
+ - Replaces all uses of SimpleColor that are not implementation details of Color, with SRGBA<uint8_t>.
+ - Adds ColorBuilder<T> to allow maintaining the syntax SimpleColor for constant colors. e.g:
+
+ Color color = Color::yellow.colorWithAlpha(128);
+
+ * Headers.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add ColorBuilder.h
+
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::lightened const):
+ (WebCore::Color::darkened const):
+ (WebCore::Color::semanticColor const):
+ * platform/graphics/Color.h:
+ (WebCore::Color::Color):
+ (WebCore::Color::asSimple const):
+ (WebCore::Color::setSimpleColor):
+ (WebCore::Color::isBlackColor):
+ (WebCore::Color::isWhiteColor):
+ (WebCore::Color::encode const):
+ (WebCore::Color::decode):
+ - Make constructor taking a SimpleColor private.
+ - Add / modifiy constructors to take SRGBA<uint8_t>.
+ - Make setSimpleColor() take a SRGBA<uint8_t> (this will be renamed along with
+ other aspects of Color's internals in a subsequent change).
+ - Update calls that still need SimpleColor to use an explicit construction from
+ SRGBA<uint8_t>.
+
+ * platform/graphics/ColorBuilder.h: Added.
+ (WebCore::ColorBuilder::ColorBuilder):
+ (WebCore::ColorBuilder::color const):
+ (WebCore::ColorBuilder::colorWithAlpha const):
+ Added to help maintain current syntax why constructing colors. Currently it only
+ supports color type with uint8_t components, but can be expanded to support more.
+
+ * platform/graphics/ColorUtilities.h:
+ (WebCore::clampToComponentByte):
+ Remove unnecessary cast.
+
+ * platform/graphics/SimpleColor.h:
+ (WebCore::SimpleColor::SimpleColor):
+ Restrict to explicit construction via a SRGBA<uint8_t>.
+
+ (WebCore::makeSimpleColor):
+ Update to return ColorBuilder<SRGBA<uint8_t>>. A future change will update
+ the function name, but kept the same here to limit the size of the change.
+
+ * platform/graphics/mac/ColorMac.mm:
+ (WebCore::makeSimpleColorFromNSColor):
+ (WebCore::nsColor):
+ * platform/graphics/cg/ColorCG.cpp:
+ (WebCore::makeSimpleColorFromCGColor):
+ (WebCore::cachedCGColor):
+ Replace direct SimpleColor usage with SRGBA<uint8_t> and simplify Packed
+ construction now that .asSRGBA<uint8_t>() is not needed for color constants.
+
+ * css/DeprecatedCSSOMRGBColor.h:
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParser::parseNamedColor):
+ (WebCore::CSSParser::parseHexColor):
+ * css/parser/CSSParser.h:
+ * css/parser/CSSParserFastPaths.cpp:
+ (WebCore::finishParsingHexColor):
+ (WebCore::parseHexColorInternal):
+ (WebCore::parseNumericColor):
+ (WebCore::finishParsingNamedColor):
+ (WebCore::parseNamedColorInternal):
+ (WebCore::parseSimpleColorInternal):
+ (WebCore::CSSParserFastPaths::parseSimpleColor):
+ (WebCore::CSSParserFastPaths::parseHexColor):
+ (WebCore::CSSParserFastPaths::parseNamedColor):
+ * css/parser/CSSParserFastPaths.h:
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::parseHexColor):
+ * html/ColorInputType.cpp:
+ (WebCore::parseSimpleColorValue):
+ * html/HTMLElement.cpp:
+ (WebCore::parseLegacyColorValue):
+ * page/DebugPageOverlays.cpp:
+ (WebCore::touchEventRegionColors):
+ * page/cocoa/ResourceUsageOverlayCocoa.mm:
+ (WebCore::HistoricMemoryCategoryInfo::HistoricMemoryCategoryInfo):
+ * platform/graphics/ColorBlending.cpp:
+ (WebCore::blendWithWhite):
+ (WebCore::blend):
+ (WebCore::blendWithoutPremultiply):
+ * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+ (WebCore::makeSimpleColorFromARGBCFArray):
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::cloneLayerDebugBorderColor):
+ * platform/mock/MockRealtimeVideoSource.cpp:
+ (WebCore::MockRealtimeVideoSource::drawBoxes):
+ * rendering/RenderLayerBacking.cpp:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::menuBackgroundColor):
+ Replace direct SimpleColor usage with SRGBA<uint8_t>.
+
2020-07-08 Simon Fraser <[email protected]>
Make a logging channel for ScrollSnap and improve its logging
Modified: trunk/Source/WebCore/Headers.cmake (264135 => 264136)
--- trunk/Source/WebCore/Headers.cmake 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/Headers.cmake 2020-07-08 21:46:56 UTC (rev 264136)
@@ -1082,6 +1082,7 @@
platform/graphics/AudioTrackPrivate.h
platform/graphics/BitmapImage.h
platform/graphics/Color.h
+ platform/graphics/ColorBuilder.h
platform/graphics/ColorComponents.h
platform/graphics/ColorConversion.h
platform/graphics/ColorHash.h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (264135 => 264136)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-07-08 21:46:56 UTC (rev 264136)
@@ -2208,6 +2208,7 @@
7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; };
7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
7C029C6E2493C8F800268204 /* ColorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C029C6D2493C8F800268204 /* ColorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7C14A00724B5FE21001A6C6C /* ColorBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C14A00624B5FE21001A6C6C /* ColorBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1843FC1C8B7283002EB973 /* Autofill.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C193BBB1F5E0EED0088F3E6 /* CanvasDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C193BB61F5E0EB90088F3E6 /* CanvasDirection.h */; };
7C193BBC1F5E0EED0088F3E6 /* CanvasFillRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C193BA11F5E0EAB0088F3E6 /* CanvasFillRule.h */; };
@@ -9925,6 +9926,7 @@
7C0CEF2E1E4A5832008DEB80 /* JSDOMBuiltinConstructorBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMBuiltinConstructorBase.cpp; sourceTree = "<group>"; };
7C0CEF2F1E4A58AD008DEB80 /* JSDOMConstructorBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMConstructorBase.cpp; sourceTree = "<group>"; };
7C0CEF301E4A58F1008DEB80 /* JSDOMConstructorWithDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMConstructorWithDocument.cpp; sourceTree = "<group>"; };
+ 7C14A00624B5FE21001A6C6C /* ColorBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorBuilder.h; sourceTree = "<group>"; };
7C1843FB1C8B7283002EB973 /* Autofill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Autofill.cpp; sourceTree = "<group>"; };
7C1843FC1C8B7283002EB973 /* Autofill.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autofill.h; sourceTree = "<group>"; };
7C193B9A1F5E0EA70088F3E6 /* CanvasDrawImage.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CanvasDrawImage.idl; sourceTree = "<group>"; };
@@ -25524,6 +25526,7 @@
B27535390B053814002CE64F /* Color.h */,
7C1B4A6524A997590033727F /* ColorBlending.cpp */,
7C1B4A6724A997660033727F /* ColorBlending.h */,
+ 7C14A00624B5FE21001A6C6C /* ColorBuilder.h */,
7CAC6AEC247F1C5100E61D59 /* ColorComponents.h */,
7C514E0224AF80580050710F /* ColorConversion.cpp */,
7C514E0024AF80580050710F /* ColorConversion.h */,
@@ -30105,6 +30108,7 @@
46EBEA021B7D4D6500BE4941 /* CollectionTraversal.h in Headers */,
93C442000F813AE100C1A634 /* CollectionType.h in Headers */,
B27535670B053814002CE64F /* Color.h in Headers */,
+ 7C14A00724B5FE21001A6C6C /* ColorBuilder.h in Headers */,
C330A22313EC196B0000B45B /* ColorChooser.h in Headers */,
C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */,
F48D2AA52159740D00C6752B /* ColorCocoa.h in Headers */,
Modified: trunk/Source/WebCore/css/DeprecatedCSSOMRGBColor.h (264135 => 264136)
--- trunk/Source/WebCore/css/DeprecatedCSSOMRGBColor.h 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMRGBColor.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -37,7 +37,7 @@
DeprecatedCSSOMPrimitiveValue& blue() { return m_blue; }
DeprecatedCSSOMPrimitiveValue& alpha() { return m_alpha; }
- SimpleColor color() const { return makeSimpleColor(m_color); }
+ SRGBA<uint8_t> color() const { return m_color; }
private:
template<typename NumberType> static Ref<DeprecatedCSSOMPrimitiveValue> createWrapper(CSSStyleDeclaration& owner, NumberType number)
Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (264135 => 264136)
--- trunk/Source/WebCore/css/parser/CSSParser.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -124,12 +124,12 @@
return RenderTheme::singleton().systemColor(keyword, { });
}
-Optional<SimpleColor> CSSParser::parseNamedColor(StringView string)
+Optional<SRGBA<uint8_t>> CSSParser::parseNamedColor(StringView string)
{
return CSSParserFastPaths::parseNamedColor(string);
}
-Optional<SimpleColor> CSSParser::parseHexColor(StringView string)
+Optional<SRGBA<uint8_t>> CSSParser::parseHexColor(StringView string)
{
return CSSParserFastPaths::parseHexColor(string);
}
Modified: trunk/Source/WebCore/css/parser/CSSParser.h (264135 => 264136)
--- trunk/Source/WebCore/css/parser/CSSParser.h 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/css/parser/CSSParser.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -37,11 +37,11 @@
class Element;
class ImmutableStyleProperties;
class MutableStyleProperties;
-class SimpleColor;
class StyleRuleBase;
class StyleRuleKeyframe;
class StyleSheetContents;
class RenderStyle;
+template<typename> struct SRGBA;
namespace Style {
class BuilderState;
@@ -88,8 +88,8 @@
WEBCORE_EXPORT static Color parseColor(const String&, bool strict = false);
static Color parseColorWorkerSafe(StringView);
static Color parseSystemColor(StringView);
- static Optional<SimpleColor> parseNamedColor(StringView);
- static Optional<SimpleColor> parseHexColor(StringView);
+ static Optional<SRGBA<uint8_t>> parseNamedColor(StringView);
+ static Optional<SRGBA<uint8_t>> parseHexColor(StringView);
private:
ParseResult parseValue(MutableStyleProperties&, CSSPropertyID, const String&, bool important);
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (264135 => 264136)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -409,7 +409,7 @@
&& isASCIIAlphaCaselessEqual(characters[2], 'b');
}
-static Optional<SimpleColor> finishParsingHexColor(uint32_t value, unsigned length)
+static Optional<SRGBA<uint8_t>> finishParsingHexColor(uint32_t value, unsigned length)
{
switch (length) {
case 3:
@@ -416,31 +416,31 @@
// #abc converts to #aabbcc
// FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
// the SRGBA<uint8_t> directly.
- return makeSimpleColor(asSRGBA(Packed::ARGB {
+ return asSRGBA(Packed::ARGB {
0xFF000000
| (value & 0xF00) << 12 | (value & 0xF00) << 8
| (value & 0xF0) << 8 | (value & 0xF0) << 4
- | (value & 0xF) << 4 | (value & 0xF) }));
+ | (value & 0xF) << 4 | (value & 0xF) });
case 4:
// #abcd converts to ddaabbcc since alpha bytes are the high bytes.
// FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
// the SRGBA<uint8_t> directly.
- return makeSimpleColor(asSRGBA(Packed::ARGB {
+ return asSRGBA(Packed::ARGB {
(value & 0xF) << 28 | (value & 0xF) << 24
| (value & 0xF000) << 8 | (value & 0xF000) << 4
| (value & 0xF00) << 4 | (value & 0xF00)
- | (value & 0xF0) | (value & 0xF0) >> 4 }));
+ | (value & 0xF0) | (value & 0xF0) >> 4 });
case 6:
// FIXME: Replace conversion to Packed::ARGB with simpler bit math to construct
// the SRGBA<uint8_t> directly.
- return makeSimpleColor(asSRGBA(Packed::ARGB { 0xFF000000 | value }));
+ return asSRGBA(Packed::ARGB { 0xFF000000 | value });
case 8:
- return makeSimpleColor(asSRGBA(Packed::RGBA { value }));
+ return asSRGBA(Packed::RGBA { value });
}
return WTF::nullopt;
}
-template<typename CharacterType> static Optional<SimpleColor> parseHexColorInternal(const CharacterType* characters, unsigned length)
+template<typename CharacterType> static Optional<SRGBA<uint8_t>> parseHexColorInternal(const CharacterType* characters, unsigned length)
{
if (length != 3 && length != 4 && length != 6 && length != 8)
return WTF::nullopt;
@@ -455,7 +455,7 @@
return finishParsingHexColor(value, length);
}
-template<typename CharacterType> static Optional<SimpleColor> parseNumericColor(const CharacterType* characters, unsigned length, bool strict)
+template<typename CharacterType> static Optional<SRGBA<uint8_t>> parseNumericColor(const CharacterType* characters, unsigned length, bool strict)
{
if (length >= 4 && characters[0] == '#') {
if (auto hexColor = parseHexColorInternal(characters + 1, length - 1))
@@ -511,7 +511,7 @@
return WTF::nullopt;
}
-static Optional<SimpleColor> parseNumericColor(StringView string, const CSSParserContext& context)
+static Optional<SRGBA<uint8_t>> parseNumericColor(StringView string, const CSSParserContext& context)
{
bool strict = !isQuirksModeBehavior(context.mode);
if (string.is8Bit())
@@ -533,16 +533,16 @@
return nullptr;
}
-static Optional<SimpleColor> finishParsingNamedColor(char* buffer, unsigned length)
+static Optional<SRGBA<uint8_t>> finishParsingNamedColor(char* buffer, unsigned length)
{
buffer[length] = '\0';
auto namedColor = findColor(buffer, length);
if (!namedColor)
return WTF::nullopt;
- return makeSimpleColor(asSRGBA(Packed::ARGB { namedColor->ARGBValue }));
+ return asSRGBA(Packed::ARGB { namedColor->ARGBValue });
}
-template<typename CharacterType> static Optional<SimpleColor> parseNamedColorInternal(const CharacterType* characters, unsigned length)
+template<typename CharacterType> static Optional<SRGBA<uint8_t>> parseNamedColorInternal(const CharacterType* characters, unsigned length)
{
char buffer[64]; // Easily big enough for the longest color name.
if (length > sizeof(buffer) - 1)
@@ -556,7 +556,7 @@
return finishParsingNamedColor(buffer, length);
}
-template<typename CharacterType> static Optional<SimpleColor> parseSimpleColorInternal(const CharacterType* characters, unsigned length, bool strict)
+template<typename CharacterType> static Optional<SRGBA<uint8_t>> parseSimpleColorInternal(const CharacterType* characters, unsigned length, bool strict)
{
if (auto color = parseNumericColor(characters, length, strict))
return color;
@@ -563,7 +563,7 @@
return parseNamedColorInternal(characters, length);
}
-Optional<SimpleColor> CSSParserFastPaths::parseSimpleColor(StringView string, bool strict)
+Optional<SRGBA<uint8_t>> CSSParserFastPaths::parseSimpleColor(StringView string, bool strict)
{
if (string.is8Bit())
return parseSimpleColorInternal(string.characters8(), string.length(), strict);
@@ -570,7 +570,7 @@
return parseSimpleColorInternal(string.characters16(), string.length(), strict);
}
-Optional<SimpleColor> CSSParserFastPaths::parseHexColor(StringView string)
+Optional<SRGBA<uint8_t>> CSSParserFastPaths::parseHexColor(StringView string)
{
if (string.is8Bit())
return parseHexColorInternal(string.characters8(), string.length());
@@ -577,7 +577,7 @@
return parseHexColorInternal(string.characters16(), string.length());
}
-Optional<SimpleColor> CSSParserFastPaths::parseNamedColor(StringView string)
+Optional<SRGBA<uint8_t>> CSSParserFastPaths::parseNamedColor(StringView string)
{
if (string.is8Bit())
return parseNamedColorInternal(string.characters8(), string.length());
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.h (264135 => 264136)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.h 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -36,8 +36,9 @@
namespace WebCore {
class CSSValue;
-class SimpleColor;
+template<typename> struct SRGBA;
+
struct CSSParserContext;
class CSSParserFastPaths {
@@ -50,9 +51,9 @@
static bool isValidKeywordPropertyAndValue(CSSPropertyID, CSSValueID, const CSSParserContext&);
// Parses numeric and named colors.
- static Optional<SimpleColor> parseSimpleColor(StringView, bool strict = false);
- static Optional<SimpleColor> parseHexColor(StringView); // Hex colors of length 3, 4, 6, or 8, without leading "#".
- static Optional<SimpleColor> parseNamedColor(StringView);
+ static Optional<SRGBA<uint8_t>> parseSimpleColor(StringView, bool strict = false);
+ static Optional<SRGBA<uint8_t>> parseHexColor(StringView); // Hex colors of length 3, 4, 6, or 8, without leading "#".
+ static Optional<SRGBA<uint8_t>> parseNamedColor(StringView);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (264135 => 264136)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -689,7 +689,7 @@
return makeExtendedColor(colorChannels[0], colorChannels[1], colorChannels[2], colorChannels[3], colorSpace);
}
-static Optional<SimpleColor> parseHexColor(CSSParserTokenRange& range, bool acceptQuirkyColors)
+static Optional<SRGBA<uint8_t>> parseHexColor(CSSParserTokenRange& range, bool acceptQuirkyColors)
{
String string;
StringView view;
Modified: trunk/Source/WebCore/html/ColorInputType.cpp (264135 => 264136)
--- trunk/Source/WebCore/html/ColorInputType.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/html/ColorInputType.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -69,7 +69,7 @@
}
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-simple-colour-values
-static Optional<SimpleColor> parseSimpleColorValue(StringView string)
+static Optional<SRGBA<uint8_t>> parseSimpleColorValue(StringView string)
{
if (!isValidSimpleColor(string))
return WTF::nullopt;
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (264135 => 264136)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -1006,7 +1006,7 @@
// Color parsing that matches HTML's "rules for parsing a legacy color value"
// https://html.spec.whatwg.org/#rules-for-parsing-a-legacy-colour-value
-static Optional<SimpleColor> parseLegacyColorValue(StringView string)
+static Optional<SRGBA<uint8_t>> parseLegacyColorValue(StringView string)
{
// An empty string doesn't apply a color.
if (string.isEmpty())
Modified: trunk/Source/WebCore/page/DebugPageOverlays.cpp (264135 => 264136)
--- trunk/Source/WebCore/page/DebugPageOverlays.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/page/DebugPageOverlays.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -144,14 +144,14 @@
return regionChanged;
}
-static const HashMap<String, SimpleColor>& touchEventRegionColors()
+static const HashMap<String, SRGBA<uint8_t>>& touchEventRegionColors()
{
static const auto regionColors = makeNeverDestroyed([] {
struct MapEntry {
ASCIILiteral name;
- int r;
- int g;
- int b;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
};
static const MapEntry entries[] = {
{ "touchstart"_s, 191, 191, 63 },
@@ -163,7 +163,7 @@
{ "mousemove"_s, 245, 245, 80 },
{ "mouseup"_s, 80, 245, 176 },
};
- HashMap<String, SimpleColor> map;
+ HashMap<String, SRGBA<uint8_t>> map;
for (auto& entry : entries)
map.add(entry.name, makeSimpleColor(entry.r, entry.g, entry.b, 50));
return map;
Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (264135 => 264136)
--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm 2020-07-08 21:46:56 UTC (rev 264136)
@@ -128,7 +128,7 @@
struct HistoricMemoryCategoryInfo {
HistoricMemoryCategoryInfo() { } // Needed for std::array.
- HistoricMemoryCategoryInfo(unsigned category, SimpleColor color, String name, bool subcategory = false)
+ HistoricMemoryCategoryInfo(unsigned category, SRGBA<uint8_t> color, String name, bool subcategory = false)
: name(WTFMove(name))
, color(cachedCGColor(color))
, isSubcategory(subcategory)
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -83,7 +83,7 @@
Color Color::lightened() const
{
// Hardcode this common case for speed.
- if (isSimple() && asSimple() == black)
+ if (isSimple() && asSimple() == SimpleColor { black })
return lightenedBlack;
auto [r, g, b, a] = toSRGBALossy<float>();
@@ -100,7 +100,7 @@
Color Color::darkened() const
{
// Hardcode this common case for speed.
- if (isSimple() && asSimple() == white)
+ if (isSimple() && asSimple() == SimpleColor { white })
return darkenedWhite;
auto [r, g, b, a] = toSRGBALossy<float>();
@@ -149,7 +149,7 @@
if (isSemantic())
return *this;
- return { makeSimpleColor(toSRGBALossy<uint8_t>()), Semantic };
+ return { toSRGBALossy<uint8_t>(), Semantic };
}
std::pair<ColorSpace, ColorComponents<float>> Color::colorSpaceAndComponents() const
Modified: trunk/Source/WebCore/platform/graphics/Color.h (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/Color.h 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/Color.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -54,15 +54,15 @@
class Color {
WTF_MAKE_FAST_ALLOCATED;
public:
- Color() { }
+ Color() = default;
- Color(SimpleColor color)
+ Color(SRGBA<uint8_t> color)
{
setSimpleColor(color);
}
enum SemanticTag { Semantic };
- Color(SimpleColor color, SemanticTag)
+ Color(SRGBA<uint8_t> color, SemanticTag)
: Color(color)
{
tagAsSemantic();
@@ -193,8 +193,13 @@
template<class Decoder> static Optional<Color> decode(Decoder&);
private:
- void setSimpleColor(SimpleColor);
+ Color(SimpleColor color)
+ : Color(color.asSRGBA<uint8_t>())
+ {
+ }
+ void setSimpleColor(SRGBA<uint8_t>);
+
void tagAsSemantic() { m_colorData.simpleColorAndFlags |= isSemanticSimpleColorBit; }
void tagAsValid() { m_colorData.simpleColorAndFlags |= validSimpleColor; }
@@ -301,12 +306,12 @@
inline const SimpleColor Color::asSimple() const
{
ASSERT(isSimple());
- return makeSimpleColor(asSRGBA(Packed::RGBA { static_cast<uint32_t>(m_colorData.simpleColorAndFlags >> 32) }));
+ return SimpleColor { asSRGBA(Packed::RGBA { static_cast<uint32_t>(m_colorData.simpleColorAndFlags >> 32) }) };
}
-inline void Color::setSimpleColor(SimpleColor simpleColor)
+inline void Color::setSimpleColor(SRGBA<uint8_t> color)
{
- m_colorData.simpleColorAndFlags = static_cast<uint64_t>(Packed::RGBA { simpleColor.asSRGBA<uint8_t>() }.value) << 32;
+ m_colorData.simpleColorAndFlags = static_cast<uint64_t>(Packed::RGBA { color }.value) << 32;
tagAsValid();
}
@@ -314,7 +319,7 @@
{
if (color.isExtended())
return color.asExtended().isBlack();
- return color.asSimple() == Color::black;
+ return color.asSimple() == SimpleColor { Color::black };
}
inline bool Color::isWhiteColor(const Color& color)
@@ -321,7 +326,7 @@
{
if (color.isExtended())
return color.asExtended().isWhite();
- return color.asSimple() == Color::white;
+ return color.asSimple() == SimpleColor { Color::white };
}
template<class Encoder>
@@ -390,7 +395,7 @@
if (!decoder.decode(value))
return WTF::nullopt;
- return Color { makeSimpleColor(asSRGBA(Packed::RGBA { value })) };
+ return Color { asSRGBA(Packed::RGBA { value }) };
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/ColorBlending.cpp (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/ColorBlending.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/ColorBlending.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -70,7 +70,7 @@
auto [existingR, existingG, existingB, existingAlpha] = color.toSRGBALossy<uint8_t>();
- SimpleColor result;
+ SRGBA<uint8_t> result;
for (int alpha = startAlpha; alpha <= endAlpha; alpha += alphaIncrement) {
// We have a solid color. Convert to an equivalent color that looks the same when blended with white
// at the current alpha. Try using less transparency if the numbers end up being negative.
@@ -107,7 +107,7 @@
WebCore::blend(premultipliedFrom.alpha, premultipliedTo.alpha, progress)
);
- return makeSimpleColor(unpremultiplied(premultipliedBlended));
+ return unpremultiplied(premultipliedBlended);
}
Color blendWithoutPremultiply(const Color& from, const Color& to, double progress)
@@ -120,7 +120,7 @@
auto fromSRGB = from.toSRGBALossy<uint8_t>();
auto toSRGB = from.toSRGBALossy<uint8_t>();
- return makeSimpleColor(
+ return clampToComponentBytes<SRGBA>(
WebCore::blend(fromSRGB.red, toSRGB.red, progress),
WebCore::blend(fromSRGB.green, toSRGB.green, progress),
WebCore::blend(fromSRGB.blue, toSRGB.blue, progress),
Added: trunk/Source/WebCore/platform/graphics/ColorBuilder.h (0 => 264136)
--- trunk/Source/WebCore/platform/graphics/ColorBuilder.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ColorBuilder.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+// Helper to allow convenient syntax for working with color types.
+// e.g. auto yellowWith50PercentAlpha = Color::yellow.colorWithAlpha(128);
+template<typename ColorType> struct ColorBuilder : public ColorType {
+ constexpr ColorBuilder(const ColorType& color)
+ : ColorType { color }
+ {
+ }
+
+ constexpr ColorType color() const
+ {
+ return *this;
+ }
+
+ constexpr ColorBuilder colorWithAlpha(uint8_t overrideAlpha) const
+ {
+ static_assert(std::is_same_v<decltype(ColorType().alpha), uint8_t>, "Only uint8_t based color types are supported.");
+
+ ColorBuilder copy = *this;
+ copy.alpha = overrideAlpha;
+ return copy;
+ }
+};
+
+}
Modified: trunk/Source/WebCore/platform/graphics/ColorUtilities.h (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/ColorUtilities.h 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/ColorUtilities.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -56,7 +56,7 @@
constexpr uint8_t clampToComponentByte(int c)
{
- return static_cast<uint8_t>(std::clamp(c, 0, 0xFF));
+ return std::clamp(c, 0, 255);
}
constexpr uint8_t clampToComponentFloat(float f)
Modified: trunk/Source/WebCore/platform/graphics/SimpleColor.h (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/SimpleColor.h 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/SimpleColor.h 2020-07-08 21:46:56 UTC (rev 264136)
@@ -25,17 +25,16 @@
#pragma once
+#include "ColorBuilder.h"
#include "ColorComponents.h"
#include "ColorTypes.h"
#include "ColorUtilities.h"
-#include <wtf/text/WTFString.h>
namespace WebCore {
class SimpleColor {
public:
- constexpr SimpleColor() : m_value { } { }
- constexpr SimpleColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : m_value { r, g, b, a } { }
+ constexpr explicit SimpleColor(SRGBA<uint8_t> value) : m_value { value } { }
constexpr uint8_t alphaComponent() const { return m_value.alpha; }
constexpr float alphaComponentAsFloat() const { return convertToComponentFloat(m_value.alpha); }
@@ -76,6 +75,8 @@
}
private:
+ constexpr SimpleColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : m_value { r, g, b, a } { }
+
SRGBA<uint8_t> m_value { 0, 0, 0, 0 };
};
@@ -82,11 +83,6 @@
bool operator==(SimpleColor, SimpleColor);
bool operator!=(SimpleColor, SimpleColor);
-constexpr SimpleColor makeSimpleColor(int r, int g, int b);
-constexpr SimpleColor makeSimpleColor(int r, int g, int b, int a);
-constexpr SimpleColor makeSimpleColor(const SRGBA<uint8_t>&);
-SimpleColor makeSimpleColor(const SRGBA<float>&);
-
inline bool operator==(SimpleColor a, SimpleColor b)
{
return a.asSRGBA<uint8_t>() == b.asSRGBA<uint8_t>();
@@ -97,24 +93,29 @@
return !(a == b);
}
-constexpr SimpleColor makeSimpleColor(const SRGBA<uint8_t>& sRGBA)
+constexpr ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(int r, int g, int b);
+constexpr ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(int r, int g, int b, int a);
+constexpr ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(SRGBA<uint8_t>);
+ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(const SRGBA<float>&);
+
+constexpr ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(int r, int g, int b)
{
- return { sRGBA.red, sRGBA.green, sRGBA.blue, sRGBA.alpha };
+ return clampToComponentBytes<SRGBA>(r, g, b, 0xFF);
}
-inline SimpleColor makeSimpleColor(const SRGBA<float>& sRGBA)
+constexpr ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(int r, int g, int b, int a)
{
- return makeSimpleColor(convertToComponentBytes(sRGBA));
+ return clampToComponentBytes<SRGBA>(r, g, b, a);
}
-constexpr SimpleColor makeSimpleColor(int r, int g, int b)
+constexpr ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(SRGBA<uint8_t> sRGBA)
{
- return makeSimpleColor(clampToComponentBytes<SRGBA>(r, g, b, 0xFF));
+ return sRGBA;
}
-constexpr SimpleColor makeSimpleColor(int r, int g, int b, int a)
+inline ColorBuilder<SRGBA<uint8_t>> makeSimpleColor(const SRGBA<float>& sRGBA)
{
- return makeSimpleColor(clampToComponentBytes<SRGBA>(r, g, b, a));
+ return convertToComponentBytes(sRGBA);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -64,7 +64,7 @@
disconnect();
}
-static Optional<SimpleColor> makeSimpleColorFromARGBCFArray(CFArrayRef colorArray)
+static Optional<SRGBA<uint8_t>> makeSimpleColorFromARGBCFArray(CFArrayRef colorArray)
{
if (CFArrayGetCount(colorArray) < 4)
return WTF::nullopt;
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -2554,7 +2554,7 @@
static const float cloneLayerBorderWidth = 2;
static Color cloneLayerDebugBorderColor(bool showingBorders)
{
- return showingBorders ? makeSimpleColor(255, 122, 251) : Color();
+ return showingBorders ? makeSimpleColor(255, 122, 251) : Color { };
}
void GraphicsLayerCA::updateDebugIndicators()
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -51,7 +51,7 @@
namespace WebCore {
-static SimpleColor makeSimpleColorFromCGColor(CGColorRef color)
+static SRGBA<uint8_t> makeSimpleColorFromCGColor(CGColorRef color)
{
// FIXME: ExtendedColor - needs to handle color spaces.
@@ -130,15 +130,15 @@
{
if (color.isSimple()) {
switch (Packed::RGBA { color.asSimple().asSRGBA<uint8_t>() }.value) {
- case Packed::RGBA { Color::transparent.asSRGBA<uint8_t>() }.value: {
+ case Packed::RGBA { Color::transparent }.value: {
static CGColorRef transparentCGColor = leakCGColor(color);
return transparentCGColor;
}
- case Packed::RGBA { Color::black.asSRGBA<uint8_t>() }.value: {
+ case Packed::RGBA { Color::black }.value: {
static CGColorRef blackCGColor = leakCGColor(color);
return blackCGColor;
}
- case Packed::RGBA { Color::white.asSRGBA<uint8_t>() }.value: {
+ case Packed::RGBA { Color::white }.value: {
static CGColorRef whiteCGColor = leakCGColor(color);
return whiteCGColor;
}
Modified: trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm (264135 => 264136)
--- trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/graphics/mac/ColorMac.mm 2020-07-08 21:46:56 UTC (rev 264136)
@@ -62,7 +62,7 @@
return useOldAquaFocusRingColor;
}
-static SimpleColor makeSimpleColorFromNSColor(NSColor *color)
+static SRGBA<uint8_t> makeSimpleColorFromNSColor(NSColor *color)
{
// FIXME: ExtendedColor - needs to handle color spaces.
@@ -124,15 +124,15 @@
{
if (color.isSimple()) {
switch (Packed::RGBA { color.asSimple().asSRGBA<uint8_t>() }.value) {
- case Packed::RGBA { Color::transparent.asSRGBA<uint8_t>() }.value: {
+ case Packed::RGBA { Color::transparent }.value: {
static NSColor *clearColor = [[NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:0] retain];
return clearColor;
}
- case Packed::RGBA { Color::black.asSRGBA<uint8_t>() }.value: {
+ case Packed::RGBA { Color::black }.value: {
static NSColor *blackColor = [[NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:1] retain];
return blackColor;
}
- case Packed::RGBA { Color::white.asSRGBA<uint8_t>() }.value: {
+ case Packed::RGBA { Color::white }.value: {
static NSColor *whiteColor = [[NSColor colorWithSRGBRed:1 green:1 blue:1 alpha:1] retain];
return whiteColor;
}
Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (264135 => 264136)
--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -318,7 +318,7 @@
boxTop += boxSize + 2;
boxLeft = boxSize;
- constexpr SimpleColor boxColors[] = { Color::white, Color::yellow, Color::cyan, darkGreen, magenta, red, blue };
+ constexpr SRGBA<uint8_t> boxColors[] = { Color::white, Color::yellow, Color::cyan, darkGreen, magenta, red, blue };
for (auto& boxColor : boxColors) {
context.fillRect(FloatRect(boxLeft, boxTop, boxSize + 1, boxSize + 1), boxColor);
boxLeft += boxSize + 1;
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (264135 => 264136)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -3099,7 +3099,7 @@
struct PatternDescription {
ASCIILiteral name;
FloatSize phase;
- SimpleColor fillColor;
+ SRGBA<uint8_t> fillColor;
};
static RefPtr<Pattern> patternForDescription(PatternDescription description, FloatSize contentOffset, GraphicsContext& destContext)
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (264135 => 264136)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-07-08 21:46:56 UTC (rev 264136)
@@ -484,7 +484,7 @@
return colorFromNSColor([NSColor findHighlightColor]);
}
-static SimpleColor menuBackgroundColor()
+static SRGBA<uint8_t> menuBackgroundColor()
{
RetainPtr<NSBitmapImageRep> offscreenRep = adoptNS([[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:1 pixelsHigh:1
bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:4 bitsPerPixel:32]);
Modified: trunk/Tools/ChangeLog (264135 => 264136)
--- trunk/Tools/ChangeLog 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Tools/ChangeLog 2020-07-08 21:46:56 UTC (rev 264136)
@@ -1,3 +1,15 @@
+2020-07-08 Sam Weinig <[email protected]>
+
+ Part 3 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them
+ https://bugs.webkit.org/show_bug.cgi?id=214082
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/Tests/WebCore/ColorTests.cpp:
+ (TestWebKitAPI::TEST):
+ Update to account for makeSimpleColor no longer returning an object that has a
+ asSRGBA<uint8_t>() function (it is already a SRGBA<uint8_t>).
+
2020-07-08 Per Arne Vollan <[email protected]>
[Cocoa] Make it possible to establish direct XPC connections between WebKit processes
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp (264135 => 264136)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp 2020-07-08 21:43:53 UTC (rev 264135)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp 2020-07-08 21:46:56 UTC (rev 264136)
@@ -213,22 +213,21 @@
EXPECT_FLOAT_EQ(Color(Color::black).luminance(), 0);
EXPECT_FLOAT_EQ(Color(Color::white).luminance(), 1);
- auto c = makeSimpleColor(85, 90, 160);
- EXPECT_FLOAT_EQ(Color(c).luminance(), 0.11781692);
+ auto cComponents = makeSimpleColor(85, 90, 160);
+ EXPECT_FLOAT_EQ(Color(cComponents).luminance(), 0.11781692);
- auto cComponents = c.asSRGBA<uint8_t>();
EXPECT_EQ(cComponents.red, 85);
EXPECT_EQ(cComponents.green, 90);
EXPECT_EQ(cComponents.blue, 160);
- auto cLigtened = Color(c).lightened().toSRGBALossy<uint8_t>();
- EXPECT_FLOAT_EQ(Color(makeSimpleColor(cLigtened)).luminance(), 0.29168808);
+ auto cLigtened = Color(cComponents).lightened().toSRGBALossy<uint8_t>();
+ EXPECT_FLOAT_EQ(Color(cLigtened).luminance(), 0.29168808);
EXPECT_EQ(cLigtened.red, 130);
EXPECT_EQ(cLigtened.green, 137);
EXPECT_EQ(cLigtened.blue, 244);
- auto cDarkened = Color(c).darkened().toSRGBALossy<uint8_t>();
- EXPECT_FLOAT_EQ(Color(makeSimpleColor(cDarkened)).luminance(), 0.027006727);
+ auto cDarkened = Color(cComponents).darkened().toSRGBALossy<uint8_t>();
+ EXPECT_FLOAT_EQ(Color(cDarkened).luminance(), 0.027006727);
EXPECT_EQ(cDarkened.red, 40);
EXPECT_EQ(cDarkened.green, 43);
EXPECT_EQ(cDarkened.blue, 76);