gfx/thebes/genTables.py
author Chris Karlof <ckarlof@mozilla.com>
Wed, 12 Mar 2014 14:31:18 -0700
changeset 191544 58252ac4f28d9f7c816191ee95ffb5473bd28810
parent 186604 dff8f9be1a46085b2dbcdaf663e5cdebb0c383f8
child 324880 1be1bac73a4fda04c8720571d856debad65b030f
permissions -rw-r--r--
Bug 982848: Don't clear syncKeyBundle in BrowserID Identity manager during failures to fetch token. r=markh

#!/usr/bin/python

def table_generator(f):
    return ",\n".join([", ".join(["0x%2.2x" % h for h in [f(i) for i in range(r,r+16)]]) for r in range(0, 65536, 16)])

with open("DeprecatedPremultiplyTables.h", "w") as f:
  f.write("const uint8_t gfxUtils::sPremultiplyTable[256*256] = {\n");
  f.write(table_generator(lambda i: ((i / 256) * (i % 256) + 254) / 255) + "\n")
  f.write("};\n");
  f.write("const uint8_t gfxUtils::sUnpremultiplyTable[256*256] = {\n");
  f.write(table_generator(lambda i: (i % 256) * 255 / ((i / 256) if (i / 256) > 0 else 255) % 256) + "\n")
  f.write("};\n");