Simpler version of Plus w/ AA. ~25% faster too.

BUG=skia:3852

TBR=fmalita@chromium.org

Review URL: https://codereview.chromium.org/1150693003
This commit is contained in:
mtklein 2015-05-22 12:43:41 -07:00 committed by Commit bot
parent 08bf86d1b7
commit 4e506c200b

View File

@ -89,10 +89,8 @@ static Sk4px xfer_aa(const Sk4px& s, const Sk4px& d, const Sk16b& aa) {
template <> Sk4px xfer_aa<Name>(const Sk4px& s, const Sk4px& d, const Sk16b& aa)
// Plus' clamp needs to happen after AA. skia:3852
XFERMODE_AA(Plus) { // [ clamp(D + AA*S) ]
// We implement this as D + Min(S*AA, (1-D)) to fit the arguments to Min in 16 bits.
return d +
Sk4px::Wide(Sk16h::Min(s.mulWiden(aa), d.inv().mul255Widen())).div255RoundNarrow();
XFERMODE_AA(Plus) { // [ clamp( (1-AA)D + (AA)(S+D) ) == clamp(D + AA*S) ]
return d.saturatedAdd(s.fastMulDiv255Round(aa));
}
#undef XFERMODE_AA