Bug 206862

Summary: Replace RGBA32 typedef with a class to improve type safety
Product: WebKit Reporter: Darin Adler <darin>
Component: PlatformAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, eric.carlson, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, hi, jer.noble, joepeck, kondapallykalyan, macpherson, menard, mifenton, pdr, philipj, pnormand, ryuan.choi, sam, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch sam: review+

Description Darin Adler 2020-01-27 21:24:42 PST
Replace RGBA32 typedef with a class to improve type safety
Comment 1 Darin Adler 2020-01-27 21:48:15 PST Comment hidden (obsolete)
Comment 2 Darin Adler 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.
Comment 3 Darin Adler 2020-01-27 22:03:52 PST Comment hidden (obsolete)
Comment 4 Darin Adler 2020-01-28 08:57:43 PST Comment hidden (obsolete)
Comment 5 Darin Adler 2020-01-28 20:28:06 PST Comment hidden (obsolete)
Comment 6 Darin Adler 2020-01-30 07:24:16 PST Comment hidden (obsolete)
Comment 7 Darin Adler 2020-02-01 08:54:01 PST
Created attachment 389460 [details]
Patch
Comment 8 Darin Adler 2020-02-01 15:35:36 PST Comment hidden (obsolete)
Comment 9 Sam Weinig 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.
Comment 10 Darin Adler 2020-02-04 19:47:21 PST
Committed r255785: <https://trac.webkit.org/changeset/255785>
Comment 11 Radar WebKit Bug Importer 2020-02-04 19:48:14 PST
<rdar://problem/59176489>
Comment 12 Ryan Haddad 2020-02-05 10:50:38 PST
Follow up build fix for internal bots https://trac.webkit.org/changeset/255817/webkit
Comment 13 Philippe Normand 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?
Comment 14 Sam Weinig 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.
Comment 15 Sam Weinig 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.