Bug 183774 - [Cairo] Draw Cairo patterns with cairo_paint_with_alpha()
Summary: [Cairo] Draw Cairo patterns with cairo_paint_with_alpha()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-03-20 05:26 PDT by Zan Dobersek
Modified: 2018-03-29 09:25 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.04 KB, patch)
2018-03-20 05:33 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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)).