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

Side by Side Diff: src/utils/SkTextureCompressor_LATC.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, 1 month 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 | « gyp/utils.gypi ('k') | src/utils/SkTextureCompressor_R11EAC.cpp » ('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_LATC.h" 8 #include "SkTextureCompressor_LATC.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 // Compression options. In general, the slow version is much more accurate, but 15 // Compression options. In general, the slow version is much more accurate, but
15 // much slower. The fast option is much faster, but much less accurate. YMMV. 16 // much slower. The fast option is much faster, but much less accurate. YMMV.
16 #define COMPRESS_LATC_SLOW 0 17 #define COMPRESS_LATC_SLOW 0
17 #define COMPRESS_LATC_FAST 1 18 #define COMPRESS_LATC_FAST 1
18 19
19 //////////////////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////////////////
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // Since the palette is 323 // Since the palette is
323 // 255, 0, 219, 182, 146, 109, 73, 36 324 // 255, 0, 219, 182, 146, 109, 73, 36
324 // we need to map the high three bits of each byte in the integer 325 // we need to map the high three bits of each byte in the integer
325 // from 326 // from
326 // 0 1 2 3 4 5 6 7 327 // 0 1 2 3 4 5 6 7
327 // to 328 // to
328 // 1 7 6 5 4 3 2 0 329 // 1 7 6 5 4 3 2 0
329 // 330 //
330 // This first operation takes the mapping from 331 // This first operation takes the mapping from
331 // 0 1 2 3 4 5 6 7 --> 7 6 5 4 3 2 1 0 332 // 0 1 2 3 4 5 6 7 --> 7 6 5 4 3 2 1 0
332 x = 0x07070707 - ((x >> 5) & 0x07070707); 333 x = 0x07070707 - SkTextureCompressor::ConvertToThreeBitIndex(x);
333 334
334 // mask is 1 if index is non-zero 335 // mask is 1 if index is non-zero
335 const uint32_t mask = (x | (x >> 1) | (x >> 2)) & 0x01010101; 336 const uint32_t mask = (x | (x >> 1) | (x >> 2)) & 0x01010101;
336 337
337 // add mask: 338 // add mask:
338 // 7 6 5 4 3 2 1 0 --> 8 7 6 5 4 3 2 0 339 // 7 6 5 4 3 2 1 0 --> 8 7 6 5 4 3 2 0
339 x = (x + mask); 340 x = (x + mask);
340 341
341 // Handle overflow: 342 // Handle overflow:
342 // 8 7 6 5 4 3 2 0 --> 9 7 6 5 4 3 2 0 343 // 8 7 6 5 4 3 2 0 --> 9 7 6 5 4 3 2 0
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 for (int j = 0; j < height; j += 4) { 510 for (int j = 0; j < height; j += 4) {
510 for (int i = 0; i < width; i += 4) { 511 for (int i = 0; i < width; i += 4) {
511 decompress_latc_block(dst + i, dstRowBytes, src); 512 decompress_latc_block(dst + i, dstRowBytes, src);
512 src += 8; 513 src += 8;
513 } 514 }
514 dst += 4 * dstRowBytes; 515 dst += 4 * dstRowBytes;
515 } 516 }
516 } 517 }
517 518
518 } // SkTextureCompressor 519 } // SkTextureCompressor
OLDNEW
« no previous file with comments | « gyp/utils.gypi ('k') | src/utils/SkTextureCompressor_R11EAC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698