Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1137)

Unified Diff: tests/TextureCompressionTest.cpp

Issue 669243003: Add utils to better quantize grayscale values to three bit indices while (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update tests to reflect new qunatization method Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/SkTextureCompressor_Utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/TextureCompressionTest.cpp
diff --git a/tests/TextureCompressionTest.cpp b/tests/TextureCompressionTest.cpp
index b93cabb4e0e0e0187ac1b9e6c7d8d9b41f5fbc91..46b14db8e235966c6ae603a64750c7638cf0c9c0 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 |
« no previous file with comments | « src/utils/SkTextureCompressor_Utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698