diff options
author | 2014-10-23 13:18:50 -0700 | |
---|---|---|
committer | 2014-10-23 13:18:50 -0700 | |
commit | 47eedcc848e7712aea9607fd489abdc70bc8bcfd (patch) | |
tree | a3eedb1801e401fac76f852e3e9b4ed7d926c251 /tests/TextureCompressionTest.cpp | |
parent | 08fa28cd31c96b4ebd9cb532539c3a8c88803d90 (diff) |
Add utils to better quantize grayscale values to three bit indices while
compressing coverage masks.
Signed-off-by: Pavel Krajcevski <pavel@cs.unc.edu>
BUG=skia:
Review URL: https://codereview.chromium.org/669243003
Diffstat (limited to 'tests/TextureCompressionTest.cpp')
-rw-r--r-- | tests/TextureCompressionTest.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/TextureCompressionTest.cpp b/tests/TextureCompressionTest.cpp index 7dd285d4f3..568d4d14b6 100644 --- a/tests/TextureCompressionTest.cpp +++ b/tests/TextureCompressionTest.cpp @@ -255,7 +255,39 @@ DEF_TEST(CompressLATC, reporter) { // and that the three bits saved per pixel are computed from the top three // bits of the luminance value. const uint64_t kIndexEncodingMap[8] = { 1, 7, 6, 5, 4, 3, 2, 0 }; - const uint64_t kIndex = kIndexEncodingMap[lum >> 5]; + + // Quantize to three bits in the same way that we do our LATC compression: + // 1. Divide by two + // 2. Add 9 + // 3. Divide by two + // 4. Approximate division by three twice + uint32_t quant = static_cast<uint32_t>(lum); + quant >>= 1; // 1 + quant += 9; // 2 + quant >>= 1; // 3 + + uint32_t a, b, c, ar, br, cr; + + // First division by three + a = quant >> 2; + ar = (quant & 0x3) << 4; + b = quant >> 4; + br = (quant & 0xF) << 2; + c = quant >> 6; + cr = (quant & 0x3F); + quant = (a + b + c) + ((ar + br + cr) >> 6); + + // Second division by three + a = quant >> 2; + ar = (quant & 0x3) << 4; + b = quant >> 4; + br = (quant & 0xF) << 2; + c = quant >> 6; + cr = (quant & 0x3F); + quant = (a + b + c) + ((ar + br + cr) >> 6); + + const uint64_t kIndex = kIndexEncodingMap[quant]; + const uint64_t kConstColorEncoding = SkEndian_SwapLE64( 255 | |