Bug 827934 - Only build gfxUtils.cpp when needed; r=jrmuizel,ted

This commit is contained in:
Ehsan Akhgari 2013-01-08 14:09:32 -05:00
parent 89b19dbab6
commit 4ac0cf0d93
3 changed files with 10 additions and 17 deletions

View File

@ -394,8 +394,7 @@ gfxAlphaRecoverySSE2.$(OBJ_SUFFIX): OS_CXXFLAGS += -xarch=sse2 -xO4
endif
endif
.PHONY: CONSTANT_TABLES
CONSTANT_TABLES:
PremultiplyTables.h: $(srcdir)/genTables.py
$(PYTHON) $(srcdir)/genTables.py
gfxUtils.$(OBJ_SUFFIX): CONSTANT_TABLES
gfxUtils.$(OBJ_SUFFIX): PremultiplyTables.h

View File

@ -3,10 +3,10 @@
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)])
f = open("sPremultiplyTable.h", "w")
f.write(table_generator(lambda i: ((i / 256) * (i % 256) + 254) / 255) + "\n")
f.close()
f = open("sUnpremultiplyTable.h", "w")
f.write(table_generator(lambda i: (i % 256) * 255 / ((i / 256) if (i / 256) > 0 else 255) % 256) + "\n")
f.close()
with open("PremultiplyTables.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");

View File

@ -20,13 +20,7 @@ using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::gfx;
const uint8_t gfxUtils::sPremultiplyTable[256*256] = {
#include "sPremultiplyTable.h"
};
const uint8_t gfxUtils::sUnpremultiplyTable[256*256] = {
#include "sUnpremultiplyTable.h"
};
#include "PremultiplyTables.h"
static const uint8_t PremultiplyValue(uint8_t a, uint8_t v) {
return gfxUtils::sPremultiplyTable[a*256+v];