RESOLVED FIXED 206862
Replace RGBA32 typedef with a class to improve type safety
https://bugs.webkit.org/show_bug.cgi?id=206862
Summary Replace RGBA32 typedef with a class to improve type safety
Darin Adler
Reported 2020-01-27 21:24:42 PST
Replace RGBA32 typedef with a class to improve type safety
Attachments
Patch (69.64 KB, patch)
2020-01-27 21:48 PST, Darin Adler
no flags
Patch (74.43 KB, patch)
2020-01-27 22:03 PST, Darin Adler
no flags
Patch (74.51 KB, patch)
2020-01-28 08:57 PST, Darin Adler
no flags
Patch (77.11 KB, patch)
2020-01-28 20:28 PST, Darin Adler
no flags
Patch (83.70 KB, patch)
2020-01-30 07:24 PST, Darin Adler
no flags
Patch (78.04 KB, patch)
2020-02-01 08:54 PST, Darin Adler
sam: review+
Darin Adler
Comment 1 2020-01-27 21:48:15 PST Comment hidden (obsolete)
Darin Adler
Comment 2 2020-01-27 21:51:52 PST
First of multiple steps to improve Color and ExtendedColor. Next step will be putting SimpleColor in its own source file. Then use Optional<SimpleColor> for cases where we don’t always have a color, but don't need to specify a color space, support extended color, or support the notion of a semantic color. Then change Color operations so they all do something sensible when called on an ExtendedColor. Then change the Color constructor to make a SimpleColor, not an ExtendedColor, when that can be done losslessly.
Darin Adler
Comment 3 2020-01-27 22:03:52 PST Comment hidden (obsolete)
Darin Adler
Comment 4 2020-01-28 08:57:43 PST Comment hidden (obsolete)
Darin Adler
Comment 5 2020-01-28 20:28:06 PST Comment hidden (obsolete)
Darin Adler
Comment 6 2020-01-30 07:24:16 PST Comment hidden (obsolete)
Darin Adler
Comment 7 2020-02-01 08:54:01 PST
Darin Adler
Comment 8 2020-02-01 15:35:36 PST Comment hidden (obsolete)
Sam Weinig
Comment 9 2020-02-03 07:11:43 PST
Comment on attachment 389460 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=389460&action=review > Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm:131 > + HistoricMemoryCategoryInfo(unsigned category, unsigned rgba, String name, bool subcategory = false) I think uint32_t would be slightly better here.
Darin Adler
Comment 10 2020-02-04 19:47:21 PST
Radar WebKit Bug Importer
Comment 11 2020-02-04 19:48:14 PST
Ryan Haddad
Comment 12 2020-02-05 10:50:38 PST
Follow up build fix for internal bots https://trac.webkit.org/changeset/255817/webkit
Philippe Normand
Comment 13 2020-07-03 06:58:59 PDT
I suspect this patch triggered these warnings (in GTK at least): In file included from DerivedSources/WebCore/unified-sources/UnifiedSource-3c72abbe-17.cpp:3: ../../Source/WebCore/platform/graphics/BitmapImage.cpp:240:84: warning: implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes value from 0.5 to 0 [-Wliteral-conversion] fillWithSolidColor(context, destRect, Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); ~~~~~~~~~~~~~~ ^~~ ../../Source/WebCore/platform/graphics/BitmapImage.cpp:251:80: warning: implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes value from 0.5 to 0 [-Wliteral-conversion] fillWithSolidColor(context, destRect, Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); ~~~~~~~~~~~~~~ ^~~ ../../Source/WebCore/platform/graphics/BitmapImage.cpp:269:84: warning: implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes value from 0.5 to 0 [-Wliteral-conversion] fillWithSolidColor(context, destRect, Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); ~~~~~~~~~~~~~~ ^~~ 3 warnings generated. Because SimpleColor doesn't have a colorWithAlpha(Optional<float>) method. Should it be added?
Sam Weinig
Comment 14 2020-07-03 10:50:31 PDT
(In reply to Philippe Normand from comment #13) > I suspect this patch triggered these warnings (in GTK at least): > > In file included from > DerivedSources/WebCore/unified-sources/UnifiedSource-3c72abbe-17.cpp:3: > ../../Source/WebCore/platform/graphics/BitmapImage.cpp:240:84: warning: > implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes > value from 0.5 to 0 [-Wliteral-conversion] > fillWithSolidColor(context, destRect, > Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); > > ~~~~~~~~~~~~~~ ^~~ > ../../Source/WebCore/platform/graphics/BitmapImage.cpp:251:80: warning: > implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes > value from 0.5 to 0 [-Wliteral-conversion] > fillWithSolidColor(context, destRect, > Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); > > ~~~~~~~~~~~~~~ ^~~ > ../../Source/WebCore/platform/graphics/BitmapImage.cpp:269:84: warning: > implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes > value from 0.5 to 0 [-Wliteral-conversion] > fillWithSolidColor(context, destRect, > Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); > > ~~~~~~~~~~~~~~ ^~~ > 3 warnings generated. > > > Because SimpleColor doesn't have a colorWithAlpha(Optional<float>) method. > Should it be added? Oh, yeah. I will fix this right away. Wonder why we don't have that warning on for other platforms. Will look into that too. Thanks for bringing it to my attention.
Sam Weinig
Comment 15 2020-07-03 11:26:04 PDT
(In reply to Sam Weinig from comment #14) > (In reply to Philippe Normand from comment #13) > > I suspect this patch triggered these warnings (in GTK at least): > > > > In file included from > > DerivedSources/WebCore/unified-sources/UnifiedSource-3c72abbe-17.cpp:3: > > ../../Source/WebCore/platform/graphics/BitmapImage.cpp:240:84: warning: > > implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes > > value from 0.5 to 0 [-Wliteral-conversion] > > fillWithSolidColor(context, destRect, > > Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); > > > > ~~~~~~~~~~~~~~ ^~~ > > ../../Source/WebCore/platform/graphics/BitmapImage.cpp:251:80: warning: > > implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes > > value from 0.5 to 0 [-Wliteral-conversion] > > fillWithSolidColor(context, destRect, > > Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); > > > > ~~~~~~~~~~~~~~ ^~~ > > ../../Source/WebCore/platform/graphics/BitmapImage.cpp:269:84: warning: > > implicit conversion from 'double' to 'uint8_t' (aka 'unsigned char') changes > > value from 0.5 to 0 [-Wliteral-conversion] > > fillWithSolidColor(context, destRect, > > Color::yellow.colorWithAlpha(0.5), options.compositeOperator()); > > > > ~~~~~~~~~~~~~~ ^~~ > > 3 warnings generated. > > > > > > Because SimpleColor doesn't have a colorWithAlpha(Optional<float>) method. > > Should it be added? > > Oh, yeah. I will fix this right away. Wonder why we don't have that warning > on for other platforms. Will look into that too. Thanks for bringing it to > my attention. Filed https://bugs.webkit.org/show_bug.cgi?id=213931 to fix this.
Note You need to log in before you can comment on or make changes to this bug.