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

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

Issue 443303006: Pass a struct of functions instead of a function to the compressed blitter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
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 10
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } else if (val > 2047) { 583 } else if (val > 2047) {
584 dst[i] = 0xFF; 584 dst[i] = 0xFF;
585 } else { 585 } else {
586 dst[i] = (val >> 3) & 0xFF; 586 dst[i] = (val >> 3) & 0xFF;
587 } 587 }
588 } 588 }
589 dst += dstRowBytes; 589 dst += dstRowBytes;
590 } 590 }
591 } 591 }
592 592
593 struct CompressorR11EAC {
594 static inline void CompressA8Vertical(uint8_t* dst, const uint8_t* src) {
595 compress_block_vertical(dst, src);
596 }
597
598 static inline void CompressA8Horizontal(uint8_t* dst, const uint8_t* src,
599 int srcRowBytes) {
600 *(reinterpret_cast<uint64_t*>(dst)) = compress_r11eac_block_fast(src, sr cRowBytes);
601 }
602
603 static inline void UpdateBlock(uint8_t* dst, const uint8_t* src) {
604 }
605 };
606
593 //////////////////////////////////////////////////////////////////////////////// 607 ////////////////////////////////////////////////////////////////////////////////
594 608
595 namespace SkTextureCompressor { 609 namespace SkTextureCompressor {
596 610
597 bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height, int rowBytes) { 611 bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height, int rowBytes) {
598 612
599 #if (COMPRESS_R11_EAC_SLOW) || (COMPRESS_R11_EAC_FAST) 613 #if (COMPRESS_R11_EAC_SLOW) || (COMPRESS_R11_EAC_FAST)
600 614
601 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ r11eac_block); 615 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ r11eac_block);
602 616
(...skipping 18 matching lines...) Expand all
621 // decides not to write certain scanlines (and skip entire rows of blocks). 635 // decides not to write certain scanlines (and skip entire rows of blocks).
622 // In the case of R11, we use the encoding from recognizing all zero pixels from above. 636 // In the case of R11, we use the encoding from recognizing all zero pixels from above.
623 const int nBlocks = (width * height / 16); // 4x4 pixel blocks. 637 const int nBlocks = (width * height / 16); // 4x4 pixel blocks.
624 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer); 638 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer);
625 for (int i = 0; i < nBlocks; ++i) { 639 for (int i = 0; i < nBlocks; ++i) {
626 *dst = 0x0020000000002000ULL; 640 *dst = 0x0020000000002000ULL;
627 ++dst; 641 ++dst;
628 } 642 }
629 643
630 return allocator->createT< 644 return allocator->createT<
631 SkTCompressedAlphaBlitter<4, 8, compress_block_vertical>, int, int, void *> 645 SkTCompressedAlphaBlitter<4, 8, CompressorR11EAC>, int, int, void*>
632 (width, height, outputBuffer); 646 (width, height, outputBuffer);
633 } 647 }
634 648
635 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid th, int height) { 649 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid th, int height) {
636 for (int j = 0; j < height; j += 4) { 650 for (int j = 0; j < height; j += 4) {
637 for (int i = 0; i < width; i += 4) { 651 for (int i = 0; i < width; i += 4) {
638 decompress_r11_eac_block(dst + i, dstRowBytes, src); 652 decompress_r11_eac_block(dst + i, dstRowBytes, src);
639 src += 8; 653 src += 8;
640 } 654 }
641 dst += 4 * dstRowBytes; 655 dst += 4 * dstRowBytes;
642 } 656 }
643 } 657 }
644 658
645 } // namespace SkTextureCompressor 659 } // namespace SkTextureCompressor
OLDNEW
« src/utils/SkTextureCompressor_ASTC.cpp ('K') | « src/utils/SkTextureCompressor_LATC.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698