RESOLVED FIXED 212231
Extended Color Cleanup: Remove trivial uses of Color::rgb()
https://bugs.webkit.org/show_bug.cgi?id=212231
Summary Extended Color Cleanup: Remove trivial uses of Color::rgb()
Sam Weinig
Reported 2020-05-21 14:17:19 PDT
Extended Color Cleanup: Remove trivial uses of Color::rgb()
Attachments
Patch (25.72 KB, patch)
2020-05-21 14:29 PDT, Sam Weinig
no flags
Patch (25.44 KB, patch)
2020-05-21 15:26 PDT, Sam Weinig
no flags
Sam Weinig
Comment 1 2020-05-21 14:29:13 PDT
Darin Adler
Comment 2 2020-05-21 15:12:47 PDT
Comment on attachment 399980 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=399980&action=review > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:381 > + if (style.hasOverrideAlpha()) > + style = CanvasStyle(currentColor(canvasBase()).colorWithAlphaUsingAlternativeRounding(style.overrideAlpha())); > + else > style = CanvasStyle(currentColor(canvasBase())); If colorWithAlphaUsingAlternativeRounding took an Optional then we could write this code in a more straightforward way. The style could give us an optional overriding value for the alpha. > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:407 > + if (style.hasOverrideAlpha()) > + style = CanvasStyle(currentColor(canvasBase()).colorWithAlphaUsingAlternativeRounding(style.overrideAlpha())); > + else > style = CanvasStyle(currentColor(canvasBase())); Would be nice here. > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:1313 > + if (alpha) > + color = color.colorWithAlphaUsingAlternativeRounding(*alpha); > + setShadow(FloatSize(width, height), blur, color); And here the code is getting less simple because we don’t have that. I wish we were keeping it. > Source/WebCore/platform/graphics/cg/ColorCG.cpp:126 > + if (equalIgnoringSemanticColor(color, Color::transparent)) { I hope performance is still great. The old version was pleasantly bit-twiddly and inlined in a way that gave me confidence it was efficient. > Source/WebCore/platform/graphics/cg/ColorCG.cpp:130 > + if (Color::isBlackColor(color)) { I find this Color::isBlackColor function vexing. Should it return true when an extended color is black? For the use here, I think we’d want the super-fast one even if it gets false negatives. > Source/WebCore/platform/graphics/cg/ColorCG.cpp:134 > + if (Color::isWhiteColor(color)) { Ditto.
Sam Weinig
Comment 3 2020-05-21 15:26:41 PDT
Sam Weinig
Comment 4 2020-05-21 15:28:46 PDT
(In reply to Darin Adler from comment #2) > Comment on attachment 399980 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=399980&action=review > > > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:381 > > + if (style.hasOverrideAlpha()) > > + style = CanvasStyle(currentColor(canvasBase()).colorWithAlphaUsingAlternativeRounding(style.overrideAlpha())); > > + else > > style = CanvasStyle(currentColor(canvasBase())); > > If colorWithAlphaUsingAlternativeRounding took an Optional then we could > write this code in a more straightforward way. The style could give us an > optional overriding value for the alpha. > > > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:407 > > + if (style.hasOverrideAlpha()) > > + style = CanvasStyle(currentColor(canvasBase()).colorWithAlphaUsingAlternativeRounding(style.overrideAlpha())); > > + else > > style = CanvasStyle(currentColor(canvasBase())); > > Would be nice here. > > > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:1313 > > + if (alpha) > > + color = color.colorWithAlphaUsingAlternativeRounding(*alpha); > > + setShadow(FloatSize(width, height), blur, color); > > And here the code is getting less simple because we don’t have that. Added. Made the code simplifications. > > I wish we were keeping it. > > > Source/WebCore/platform/graphics/cg/ColorCG.cpp:126 > > + if (equalIgnoringSemanticColor(color, Color::transparent)) { > > I hope performance is still great. The old version was pleasantly > bit-twiddly and inlined in a way that gave me confidence it was efficient. > > > Source/WebCore/platform/graphics/cg/ColorCG.cpp:130 > > + if (Color::isBlackColor(color)) { > > I find this Color::isBlackColor function vexing. Should it return true when > an extended color is black? For the use here, I think we’d want the > super-fast one even if it gets false negatives. > > > Source/WebCore/platform/graphics/cg/ColorCG.cpp:134 > > + if (Color::isWhiteColor(color)) { > > Ditto. Removed this change. It's a use of rgb() that is local to Color family of files so we can make it a friend / member of Color when needed.
EWS
Comment 5 2020-05-21 16:33:21 PDT
Committed r262035: <https://trac.webkit.org/changeset/262035> All reviewed patches have been landed. Closing bug and clearing flags on attachment 399986 [details].
Radar WebKit Bug Importer
Comment 6 2020-05-21 16:34:14 PDT
Note You need to log in before you can comment on or make changes to this bug.