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

Side by Side Diff: src/utils/SkTextureCompressor_R11EAC.cpp

Issue 800993002: Even more win64 warning fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years 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_R11EAC.h ('k') | tests/ImageCacheTest.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.h" 8 #include "SkTextureCompressor.h"
9 #include "SkTextureCompressor_Blitter.h" 9 #include "SkTextureCompressor_Blitter.h"
10 #include "SkTextureCompressor_Utils.h" 10 #include "SkTextureCompressor_Utils.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 return compress_heterogeneous_r11eac_block(block); 268 return compress_heterogeneous_r11eac_block(block);
269 } 269 }
270 270
271 // This function is used by R11 EAC to compress 4x4 blocks 271 // This function is used by R11 EAC to compress 4x4 blocks
272 // of 8-bit alpha into 64-bit values that comprise the compressed data. 272 // of 8-bit alpha into 64-bit values that comprise the compressed data.
273 // We need to make sure that the dimensions of the src pixels are divisible 273 // We need to make sure that the dimensions of the src pixels are divisible
274 // by 4, and copy 4x4 blocks one at a time for compression. 274 // by 4, and copy 4x4 blocks one at a time for compression.
275 typedef uint64_t (*A84x4To64BitProc)(const uint8_t block[]); 275 typedef uint64_t (*A84x4To64BitProc)(const uint8_t block[]);
276 276
277 static bool compress_4x4_a8_to_64bit(uint8_t* dst, const uint8_t* src, 277 static bool compress_4x4_a8_to_64bit(uint8_t* dst, const uint8_t* src,
278 int width, int height, int rowBytes, 278 int width, int height, size_t rowBytes,
279 A84x4To64BitProc proc) { 279 A84x4To64BitProc proc) {
280 // Make sure that our data is well-formed enough to be considered for compre ssion 280 // Make sure that our data is well-formed enough to be considered for compre ssion
281 if (0 == width || 0 == height || (width % 4) != 0 || (height % 4) != 0) { 281 if (0 == width || 0 == height || (width % 4) != 0 || (height % 4) != 0) {
282 return false; 282 return false;
283 } 283 }
284 284
285 int blocksX = width >> 2; 285 int blocksX = width >> 2;
286 int blocksY = height >> 2; 286 int blocksY = height >> 2;
287 287
288 uint8_t block[16]; 288 uint8_t block[16];
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 x = (x & (0xFFFULL << 36)) | ((x & 0xFFFFFFULL) << 12) | ((x >> 24) & 0xFFFU LL); 414 x = (x & (0xFFFULL << 36)) | ((x & 0xFFFFFFULL) << 12) | ((x >> 24) & 0xFFFU LL);
415 #endif 415 #endif
416 416
417 // x: 00 00 00 00 00 00 00 00 a e i m b f j n c g k o d h l p 417 // x: 00 00 00 00 00 00 00 00 a e i m b f j n c g k o d h l p
418 return x; 418 return x;
419 } 419 }
420 420
421 // This function follows the same basic procedure as compress_heterogeneous_r11e ac_block 421 // This function follows the same basic procedure as compress_heterogeneous_r11e ac_block
422 // above when COMPRESS_R11_EAC_FAST is defined, but it avoids a few loads/stores and 422 // above when COMPRESS_R11_EAC_FAST is defined, but it avoids a few loads/stores and
423 // tries to optimize where it can using SIMD. 423 // tries to optimize where it can using SIMD.
424 static uint64_t compress_r11eac_block_fast(const uint8_t* src, int rowBytes) { 424 static uint64_t compress_r11eac_block_fast(const uint8_t* src, size_t rowBytes) {
425 // Store each row of alpha values in an integer 425 // Store each row of alpha values in an integer
426 const uint32_t alphaRow1 = *(reinterpret_cast<const uint32_t*>(src)); 426 const uint32_t alphaRow1 = *(reinterpret_cast<const uint32_t*>(src));
427 const uint32_t alphaRow2 = *(reinterpret_cast<const uint32_t*>(src + rowByte s)); 427 const uint32_t alphaRow2 = *(reinterpret_cast<const uint32_t*>(src + rowByte s));
428 const uint32_t alphaRow3 = *(reinterpret_cast<const uint32_t*>(src + 2*rowBy tes)); 428 const uint32_t alphaRow3 = *(reinterpret_cast<const uint32_t*>(src + 2*rowBy tes));
429 const uint32_t alphaRow4 = *(reinterpret_cast<const uint32_t*>(src + 3*rowBy tes)); 429 const uint32_t alphaRow4 = *(reinterpret_cast<const uint32_t*>(src + 3*rowBy tes));
430 430
431 // Check for solid blocks. The explanations for these values 431 // Check for solid blocks. The explanations for these values
432 // can be found in the comments of compress_r11eac_block above 432 // can be found in the comments of compress_r11eac_block above
433 if (alphaRow1 == alphaRow2 && alphaRow1 == alphaRow3 && alphaRow1 == alphaRo w4) { 433 if (alphaRow1 == alphaRow2 && alphaRow1 == alphaRow3 && alphaRow1 == alphaRo w4) {
434 if (0 == alphaRow1) { 434 if (0 == alphaRow1) {
(...skipping 20 matching lines...) Expand all
455 // taken care of in interleave6. 455 // taken care of in interleave6.
456 const uint32_t r1r2 = (indexRow1 << 3) | indexRow2; 456 const uint32_t r1r2 = (indexRow1 << 3) | indexRow2;
457 const uint32_t r3r4 = (indexRow3 << 3) | indexRow4; 457 const uint32_t r3r4 = (indexRow3 << 3) | indexRow4;
458 const uint64_t indices = interleave6(r1r2, r3r4); 458 const uint64_t indices = interleave6(r1r2, r3r4);
459 459
460 // Return the packed incdices in the least significant bits with the magic h eader 460 // Return the packed incdices in the least significant bits with the magic h eader
461 return SkEndian_SwapBE64(0x8490000000000000ULL | indices); 461 return SkEndian_SwapBE64(0x8490000000000000ULL | indices);
462 } 462 }
463 463
464 static bool compress_a8_to_r11eac_fast(uint8_t* dst, const uint8_t* src, 464 static bool compress_a8_to_r11eac_fast(uint8_t* dst, const uint8_t* src,
465 int width, int height, int rowBytes) { 465 int width, int height, size_t rowBytes) {
466 // Make sure that our data is well-formed enough to be considered for compre ssion 466 // Make sure that our data is well-formed enough to be considered for compre ssion
467 if (0 == width || 0 == height || (width % 4) != 0 || (height % 4) != 0) { 467 if (0 == width || 0 == height || (width % 4) != 0 || (height % 4) != 0) {
468 return false; 468 return false;
469 } 469 }
470 470
471 const int blocksX = width >> 2; 471 const int blocksX = width >> 2;
472 const int blocksY = height >> 2; 472 const int blocksY = height >> 2;
473 473
474 uint64_t* encPtr = reinterpret_cast<uint64_t*>(dst); 474 uint64_t* encPtr = reinterpret_cast<uint64_t*>(dst);
475 for (int y = 0; y < blocksY; ++y) { 475 for (int y = 0; y < blocksY; ++y) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // the R11EAC indices directly correspond to pixel values. 612 // the R11EAC indices directly correspond to pixel values.
613 SkFAIL("Implement me!"); 613 SkFAIL("Implement me!");
614 } 614 }
615 #endif 615 #endif
616 }; 616 };
617 617
618 //////////////////////////////////////////////////////////////////////////////// 618 ////////////////////////////////////////////////////////////////////////////////
619 619
620 namespace SkTextureCompressor { 620 namespace SkTextureCompressor {
621 621
622 bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height, int rowBytes) { 622 bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height, size_t rowBytes) {
623 623
624 #if (COMPRESS_R11_EAC_SLOW) || (COMPRESS_R11_EAC_FAST) 624 #if (COMPRESS_R11_EAC_SLOW) || (COMPRESS_R11_EAC_FAST)
625 625
626 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ r11eac_block); 626 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ r11eac_block);
627 627
628 #elif COMPRESS_R11_EAC_FASTEST 628 #elif COMPRESS_R11_EAC_FASTEST
629 629
630 return compress_a8_to_r11eac_fast(dst, src, width, height, rowBytes); 630 return compress_a8_to_r11eac_fast(dst, src, width, height, rowBytes);
631 631
632 #else 632 #else
(...skipping 28 matching lines...) Expand all
661 for (int j = 0; j < height; j += 4) { 661 for (int j = 0; j < height; j += 4) {
662 for (int i = 0; i < width; i += 4) { 662 for (int i = 0; i < width; i += 4) {
663 decompress_r11_eac_block(dst + i, dstRowBytes, src); 663 decompress_r11_eac_block(dst + i, dstRowBytes, src);
664 src += 8; 664 src += 8;
665 } 665 }
666 dst += 4 * dstRowBytes; 666 dst += 4 * dstRowBytes;
667 } 667 }
668 } 668 }
669 669
670 } // namespace SkTextureCompressor 670 } // namespace SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor_R11EAC.h ('k') | tests/ImageCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698