Bug 183774

Summary: [Cairo] Draw Cairo patterns with cairo_paint_with_alpha()
Product: WebKit Reporter: Zan Dobersek <zan>
Component: New BugsAssignee: Zan Dobersek <zan>
Status: RESOLVED FIXED    
Severity: Normal CC: cgarcia, darin, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Zan Dobersek 2018-03-20 05:26:22 PDT
[Cairo] Draw Cairo patterns with cairo_paint_with_alpha()
Comment 1 Zan Dobersek 2018-03-20 05:33:48 PDT
Created attachment 336115 [details]
Patch
Comment 2 Zan Dobersek 2018-03-21 00:17:26 PDT
Comment on attachment 336115 [details]
Patch

Clearing flags on attachment: 336115

Committed r229796: <https://trac.webkit.org/changeset/229796>
Comment 3 Zan Dobersek 2018-03-21 00:17:30 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 Radar WebKit Bug Importer 2018-03-21 00:18:18 PDT
<rdar://problem/38697417>
Comment 5 Darin Adler 2018-03-29 09:25:04 PDT
Comment on attachment 336115 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=336115&action=review

> Source/WebCore/platform/graphics/cairo/CairoOperations.cpp:155
> +    cairo_paint_with_alpha(cr, std::max<float>(0, std::min<float>(1.0, alpha)));

Another way to write this with MathExtras.h is clampTo<float>(alpha, 0, 1).
Comment 6 Darin Adler 2018-03-29 09:25:55 PDT
Comment on attachment 336115 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=336115&action=review

>> Source/WebCore/platform/graphics/cairo/CairoOperations.cpp:155
>> +    cairo_paint_with_alpha(cr, std::max<float>(0, std::min<float>(1.0, alpha)));
> 
> Another way to write this with MathExtras.h is clampTo<float>(alpha, 0, 1).

But I just realized that MathExtras does not have enough overloads for float, so maybe it’s better to write it the way you did, or write std::max(0.0f, std::min(1.0f, alpha)).