diff options
author | krajcevski <krajcevski@google.com> | 2014-08-07 08:15:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-07 08:15:14 -0700 |
commit | b8ccc2f6d258a8466f79fc418e9e0a55aeaf58ce (patch) | |
tree | 1e859270a248919ef5f5562fe576958384b8abeb /src/utils/SkTextureCompressor_ASTC.cpp | |
parent | 963137b75c0a1fe91f35e9826742f36309f5e65d (diff) |
Pass compressed blitters to our mask drawing algorithm
R=robertphillips@google.com, reed@google.com
Author: krajcevski@google.com
Review URL: https://codereview.chromium.org/446103002
Diffstat (limited to 'src/utils/SkTextureCompressor_ASTC.cpp')
-rw-r--r-- | src/utils/SkTextureCompressor_ASTC.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/utils/SkTextureCompressor_ASTC.cpp b/src/utils/SkTextureCompressor_ASTC.cpp index fbae8504e5..816d2f1860 100644 --- a/src/utils/SkTextureCompressor_ASTC.cpp +++ b/src/utils/SkTextureCompressor_ASTC.cpp @@ -2011,9 +2011,26 @@ bool CompressA8To12x12ASTC(uint8_t* dst, const uint8_t* src, return true; } -SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer) { - return new - SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical> +SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer, + SkTBlitterAllocator* allocator) { + if ((width % 12) != 0 || (height % 12) != 0) { + return NULL; + } + + // Memset the output buffer to an encoding that decodes to zero. We must do this + // in order to avoid having uninitialized values in the buffer if the blitter + // decides not to write certain scanlines (and skip entire rows of blocks). + // In the case of ASTC, if everything index is zero, then the interpolated value + // will decode to zero provided we have the right header. We use the encoding + // from recognizing all zero blocks from above. + const int nBlocks = (width * height / 144); + uint8_t *dst = reinterpret_cast<uint8_t *>(outputBuffer); + for (int i = 0; i < nBlocks; ++i) { + send_packing(&dst, SkTEndian_SwapLE64(0x0000000001FE000173ULL), 0); + } + + return allocator->createT< + SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical>, int, int, void* > (width, height, outputBuffer); } |