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

Side by Side Diff: src/utils/SkTextureCompressor_R11EAC.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 unified diff | Download patch
« no previous file with comments | « src/utils/SkTextureCompressor_LATC.cpp ('k') | src/utils/SkTextureCompressor_Utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTextureCompressor.h" 8 #include "SkTextureCompressor.h"
9 #include "SkTextureCompressor_Blitter.h" 9 #include "SkTextureCompressor_Blitter.h"
10 #include "SkTextureCompressor_Utils.h"
10 11
11 #include "SkBlitter.h" 12 #include "SkBlitter.h"
12 #include "SkEndian.h" 13 #include "SkEndian.h"
13 14
14 // #define COMPRESS_R11_EAC_SLOW 1 15 // #define COMPRESS_R11_EAC_SLOW 1
15 // #define COMPRESS_R11_EAC_FAST 1 16 // #define COMPRESS_R11_EAC_FAST 1
16 #define COMPRESS_R11_EAC_FASTEST 1 17 #define COMPRESS_R11_EAC_FASTEST 1
17 18
18 // Blocks compressed into R11 EAC are represented as follows: 19 // Blocks compressed into R11 EAC are represented as follows:
19 // 0000000000000000000000000000000000000000000000000000000000000000 20 // 0000000000000000000000000000000000000000000000000000000000000000
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // To compute this, we first negate each byte, and then add three, which 314 // To compute this, we first negate each byte, and then add three, which
314 // gives the mapping 315 // gives the mapping
315 // 3 2 1 0 -1 -2 -3 -4 316 // 3 2 1 0 -1 -2 -3 -4
316 // 317 //
317 // Then we mask out the negative values, take their absolute value, and 318 // Then we mask out the negative values, take their absolute value, and
318 // add three. 319 // add three.
319 // 320 //
320 // Most of the voodoo in this function comes from Hacker's Delight, section 2-18 321 // Most of the voodoo in this function comes from Hacker's Delight, section 2-18
321 static inline uint32_t convert_indices(uint32_t x) { 322 static inline uint32_t convert_indices(uint32_t x) {
322 // Take the top three bits... 323 // Take the top three bits...
323 x = (x & 0xE0E0E0E0) >> 5; 324 x = SkTextureCompressor::ConvertToThreeBitIndex(x);
324 325
325 // Negate... 326 // Negate...
326 x = ~((0x80808080 - x) ^ 0x7F7F7F7F); 327 x = ~((0x80808080 - x) ^ 0x7F7F7F7F);
327 328
328 // Add three 329 // Add three
329 const uint32_t s = (x & 0x7F7F7F7F) + 0x03030303; 330 const uint32_t s = (x & 0x7F7F7F7F) + 0x03030303;
330 x = ((x ^ 0x03030303) & 0x80808080) ^ s; 331 x = ((x ^ 0x03030303) & 0x80808080) ^ s;
331 332
332 // Absolute value 333 // Absolute value
333 const uint32_t a = x & 0x80808080; 334 const uint32_t a = x & 0x80808080;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 for (int j = 0; j < height; j += 4) { 661 for (int j = 0; j < height; j += 4) {
661 for (int i = 0; i < width; i += 4) { 662 for (int i = 0; i < width; i += 4) {
662 decompress_r11_eac_block(dst + i, dstRowBytes, src); 663 decompress_r11_eac_block(dst + i, dstRowBytes, src);
663 src += 8; 664 src += 8;
664 } 665 }
665 dst += 4 * dstRowBytes; 666 dst += 4 * dstRowBytes;
666 } 667 }
667 } 668 }
668 669
669 } // namespace SkTextureCompressor 670 } // namespace SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor_LATC.cpp ('k') | src/utils/SkTextureCompressor_Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698