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

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

Issue 446103002: Pass compressed blitters to our mask drawing algorithm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update 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
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
11 #include "SkBlitter.h"
11 #include "SkEndian.h" 12 #include "SkEndian.h"
12 13
13 // #define COMPRESS_R11_EAC_SLOW 1 14 // #define COMPRESS_R11_EAC_SLOW 1
14 // #define COMPRESS_R11_EAC_FAST 1 15 // #define COMPRESS_R11_EAC_FAST 1
15 #define COMPRESS_R11_EAC_FASTEST 1 16 #define COMPRESS_R11_EAC_FASTEST 1
16 17
17 // Blocks compressed into R11 EAC are represented as follows: 18 // Blocks compressed into R11 EAC are represented as follows:
18 // 0000000000000000000000000000000000000000000000000000000000000000 19 // 0000000000000000000000000000000000000000000000000000000000000000
19 // |base_cw|mod|mul| ----------------- indices ------------------- 20 // |base_cw|mod|mul| ----------------- indices -------------------
20 // 21 //
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 602
602 #elif COMPRESS_R11_EAC_FASTEST 603 #elif COMPRESS_R11_EAC_FASTEST
603 604
604 return compress_a8_to_r11eac_fast(dst, src, width, height, rowBytes); 605 return compress_a8_to_r11eac_fast(dst, src, width, height, rowBytes);
605 606
606 #else 607 #else
607 #error "Must choose R11 EAC algorithm" 608 #error "Must choose R11 EAC algorithm"
608 #endif 609 #endif
609 } 610 }
610 611
611 SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer) { 612 SkBlitter* CreateR11EACBlitter(int width, int height, void* outputBuffer,
612 return new 613 SkTBlitterAllocator* allocator) {
613 SkTCompressedAlphaBlitter<4, 8, compress_block_vertical> 614
615 if ((width % 4) != 0 || (height % 4) != 0) {
616 return NULL;
617 }
618
619 // Memset the output buffer to an encoding that decodes to zero...
620 // In the case of R11, we use the encoding from recognizing all zero pixels from above.
621 const int nBlocks = (width * height / 16); // 4x4 pixel blocks.
622 uint64_t *dst = reinterpret_cast<uint64_t *>(outputBuffer);
623 for (int i = 0; i < nBlocks; ++i) {
624 *dst = 0x0020000000002000ULL;
625 ++dst;
626 }
627
628 return allocator->createT<
629 SkTCompressedAlphaBlitter<4, 8, compress_block_vertical>, int, int, void *>
614 (width, height, outputBuffer); 630 (width, height, outputBuffer);
615 } 631 }
616 632
617 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid th, int height) { 633 void DecompressR11EAC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int wid th, int height) {
618 for (int j = 0; j < height; j += 4) { 634 for (int j = 0; j < height; j += 4) {
619 for (int i = 0; i < width; i += 4) { 635 for (int i = 0; i < width; i += 4) {
620 decompress_r11_eac_block(dst + i, dstRowBytes, src); 636 decompress_r11_eac_block(dst + i, dstRowBytes, src);
621 src += 8; 637 src += 8;
622 } 638 }
623 dst += 4 * dstRowBytes; 639 dst += 4 * dstRowBytes;
624 } 640 }
625 } 641 }
626 642
627 } // namespace SkTextureCompressor 643 } // namespace SkTextureCompressor
OLDNEW
« src/utils/SkTextureCompressor_ASTC.cpp ('K') | « src/utils/SkTextureCompressor_R11EAC.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698