Simplify API of color_utils functions for blending to a minimum contrast |
||||
Issue descriptionAs discussed in crrev.com/c/1147605 it is possible that we can eliminate the alpha_error_tolerance parameter on GetBlendValueForContrastRatio (currently only used by GetColorWithMinimumContrast passing in kCloseEnoughAlphaDelta). The benefit is simpler code and slightly improved accuracy for contrast ratios, which may be worth the few extra cycles. To be sure, we should measure speed and see whether this gets called in any tight loops.
,
Aug 9
We should also simplify the API from three functions to one. Not only is this simpler to use, it guarantees consistent behavior. All callers probably want to use GetResultingPaintColor(), but FindBlendValueWithMinimumContrast() doesn't(); and the other two functions don't let you retrieve exact alpha.
I think the right API is roughly:
struct BlendResult {
SkColor color;
SkAlpha alpha;
};
// Alpha-blends |default_foreground| toward |high_contrast_foreground| until the
// result has a contrast ratio against |background| of at least
// |contrast_ratio|. Returns both the blended color and the alpha used to
// achieve that blend, since different callers want one or the other and it's
// more efficient to compute them both at once. If |default_foreground| already
// has sufficient contrast, returns {default_foreground, 0}.
BlendResult GetBlendWithMinimumContrast(
SkColor background,
SkColor default_foreground,
SkColor high_contrast_foreground =
BlendTowardOppositeLuma(base, SK_AlphaOPAQUE),
float contrast_ratio = kMinimumReadableContrastRatio);
And the implementation would use GetResultingPaintColor() first, ensure that we only run one contrast check in the case where there's sufficient contrast already, and compute exact alpha.
,
Nov 16
***UI Mass Triage*** Adding appropriate label for expert review.
,
Dec 28
|
||||
►
Sign in to add a comment |
||||
Comment 1 by orinj@chromium.org
, Aug 3