mozilla/pdf.js — pull request #4199 by fkaelberer (2014-01-26 14:20:51+00:00)
Title: Fix and simplify composeSMask()

Fixes #4198.

The old code is equivalent to setting a0 = 255/alpha in the new code, so numerator and denomitator were accidentally swapped before (since we are blending two colors, a0 is supposed to be within 0...1).

I also skipped the range checks of the colors. Assuming that the input is proper (integers in 0...255), the output can NEVER be out of range, which can easily be checked by the skript below.

```
var e = 0;
for (var a = 1; a < 255; a++) {
var a0 = a / 255;
var a1 = 1 - a0;
for (var ldb = 0; ldb < 256; ldb++) {
for (var r0 = 0; r0 < 256; r0++) {
var c = (a0* ldb + a1 * r0) | 0;
if (c > 255 || c < 0) {
e++;
}
}
}
}
console.log("errors: " + e);
```