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

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: Added comments 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
« no previous file with comments | « src/utils/SkTextureCompressor_LATC.cpp ('k') | no next file » | 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 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 // This is the type passed as the CompressorType argument of the compressed
594 // blitter for the R11 EAC format. The static functions required to be in this
595 // struct are documented in SkTextureCompressor_Blitter.h
596 struct CompressorR11EAC {
597 static inline void CompressA8Vertical(uint8_t* dst, const uint8_t* src) {
598 compress_block_vertical(dst, src);
599 }
600
601 static inline void CompressA8Horizontal(uint8_t* dst, const uint8_t* src,
602 int srcRowBytes) {
603 *(reinterpret_cast<uint64_t*>(dst)) = compress_r11eac_block_fast(src, sr cRowBytes);
604 }
605
606 static inline void UpdateBlock(uint8_t* dst, const uint8_t* src) {
607 }
608 };
609
593 //////////////////////////////////////////////////////////////////////////////// 610 ////////////////////////////////////////////////////////////////////////////////
594 611
595 namespace SkTextureCompressor { 612 namespace SkTextureCompressor {
596 613
597 bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height, int rowBytes) { 614 bool CompressA8ToR11EAC(uint8_t* dst, const uint8_t* src, int width, int height, int rowBytes) {
598 615
599 #if (COMPRESS_R11_EAC_SLOW) || (COMPRESS_R11_EAC_FAST) 616 #if (COMPRESS_R11_EAC_SLOW) || (COMPRESS_R11_EAC_FAST)
600 617
601 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ r11eac_block); 618 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ r11eac_block);
602 619
(...skipping 18 matching lines...) Expand all
621 // decides not to write certain scanlines (and skip entire rows of blocks). 638 // 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. 639 // 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. 640 const int nBlocks = (width * height / 16); // 4x4 pixel blocks.
624 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer); 641 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer);
625 for (int i = 0; i < nBlocks; ++i) { 642 for (int i = 0; i < nBlocks; ++i) {
626 *dst = 0x0020000000002000ULL; 643 *dst = 0x0020000000002000ULL;
627 ++dst; 644 ++dst;
628 } 645 }
629 646
630 return allocator->createT< 647 return allocator->createT<
631 SkTCompressedAlphaBlitter<4, 8, compress_block_vertical>, int, int, void *> 648 SkTCompressedAlphaBlitter<4, 8, CompressorR11EAC>, int, int, void*>
632 (width, height, outputBuffer); 649 (width, height, outputBuffer);
633 } 650 }
634 651
635 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid th, int height) { 652 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) { 653 for (int j = 0; j < height; j += 4) {
637 for (int i = 0; i < width; i += 4) { 654 for (int i = 0; i < width; i += 4) {
638 decompress_r11_eac_block(dst + i, dstRowBytes, src); 655 decompress_r11_eac_block(dst + i, dstRowBytes, src);
639 src += 8; 656 src += 8;
640 } 657 }
641 dst += 4 * dstRowBytes; 658 dst += 4 * dstRowBytes;
642 } 659 }
643 } 660 }
644 661
645 } // namespace SkTextureCompressor 662 } // namespace SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor_LATC.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698