| OLD | NEW |
| 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 631 |
| 632 #else | 632 #else |
| 633 #error "Must choose R11 EAC algorithm" | 633 #error "Must choose R11 EAC algorithm" |
| 634 #endif | 634 #endif |
| 635 } | 635 } |
| 636 | 636 |
| 637 SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer, | 637 SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer, |
| 638 SkTBlitterAllocator* allocator) { | 638 SkTBlitterAllocator* allocator) { |
| 639 | 639 |
| 640 if ((width % 4) != 0 || (height % 4) != 0) { | 640 if ((width % 4) != 0 || (height % 4) != 0) { |
| 641 return NULL; | 641 return nullptr; |
| 642 } | 642 } |
| 643 | 643 |
| 644 // Memset the output buffer to an encoding that decodes to zero. We must do
this | 644 // Memset the output buffer to an encoding that decodes to zero. We must do
this |
| 645 // in order to avoid having uninitialized values in the buffer if the blitte
r | 645 // in order to avoid having uninitialized values in the buffer if the blitte
r |
| 646 // decides not to write certain scanlines (and skip entire rows of blocks). | 646 // decides not to write certain scanlines (and skip entire rows of blocks). |
| 647 // In the case of R11, we use the encoding from recognizing all zero pixels
from above. | 647 // In the case of R11, we use the encoding from recognizing all zero pixels
from above. |
| 648 const int nBlocks = (width * height / 16); // 4x4 pixel blocks. | 648 const int nBlocks = (width * height / 16); // 4x4 pixel blocks. |
| 649 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer); | 649 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer); |
| 650 for (int i = 0; i < nBlocks; ++i) { | 650 for (int i = 0; i < nBlocks; ++i) { |
| 651 *dst = 0x0020000000002000ULL; | 651 *dst = 0x0020000000002000ULL; |
| 652 ++dst; | 652 ++dst; |
| 653 } | 653 } |
| 654 | 654 |
| 655 return allocator->createT< | 655 return allocator->createT< |
| 656 SkTCompressedAlphaBlitter<4, 8, CompressorR11EAC>, int, int, void*> | 656 SkTCompressedAlphaBlitter<4, 8, CompressorR11EAC>, int, int, void*> |
| 657 (width, height, outputBuffer); | 657 (width, height, outputBuffer); |
| 658 } | 658 } |
| 659 | 659 |
| 660 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid
th, int height) { | 660 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid
th, int height) { |
| 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 |
| OLD | NEW |