#include "include/core/SkUnPreMultiply.h"
#include "include/core/SkColorPriv.h"
SkColor SkUnPreMultiply::PMColorToColor(SkPMColor c) { … }
const uint32_t SkUnPreMultiply::gTable[] = …;
#ifdef BUILD_DIVIDE_TABLE
void SkUnPreMultiply_BuildTable() {
for (unsigned i = 0; i <= 255; i++) {
uint32_t scale;
if (0 == i) {
scale = 0;
} else {
scale = ((255 << 24) + (i >> 1)) / i;
}
SkDebugf(" 0x%08X,", scale);
if ((i & 7) == 7) {
SkDebugf("\n");
}
for (int j = 1; j <= i; j++) {
uint32_t test = (j * scale + (1 << 23)) >> 24;
uint32_t div = roundf(j * 255.0f / i);
int diff = SkAbs32(test - div);
SkASSERT(diff <= 1 && test <= 255);
}
}
}
#endif