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

Side by Side Diff: src/utils/SkTextureCompressor_ASTC.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_ASTC.h" 8 #include "SkTextureCompressor_ASTC.h"
9 #include "SkTextureCompressor_Blitter.h" 9 #include "SkTextureCompressor_Blitter.h"
10 10
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 uint8_t** dstPtr = &dst; 2004 uint8_t** dstPtr = &dst;
2005 for (int y = 0; y < height; y += 12) { 2005 for (int y = 0; y < height; y += 12) {
2006 for (int x = 0; x < width; x += 12) { 2006 for (int x = 0; x < width; x += 12) {
2007 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy tes); 2007 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy tes);
2008 } 2008 }
2009 } 2009 }
2010 2010
2011 return true; 2011 return true;
2012 } 2012 }
2013 2013
2014 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer) { 2014 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer,
2015 return new 2015 SkTBlitterAllocator* allocator) {
2016 SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical> 2016 if ((width % 12) != 0 || (height % 12) != 0) {
2017 return NULL;
2018 }
2019
robertphillips 2014/08/07 13:55:06 Why do we need to zero out here?
krajcevski 2014/08/07 14:48:12 The blitter isn't required to write every row, and
robertphillips 2014/08/07 14:52:23 Can we add a comment re that at each of the three
krajcevski 2014/08/07 15:00:48 Done.
2020 // Memset the output buffer to an encoding that decodes to zero...
2021 // In the case of ASTC, if everything index is zero, then the interpolated v alue
2022 // will decode to zero provided we have the right header. We use the encodin g
2023 // from recognizing all zero blocks from above.
2024 const int nBlocks = (width * height / 144);
2025 uint8_t *dst = reinterpret_cast<uint8_t *>(outputBuffer);
2026 for (int i = 0; i < nBlocks; ++i) {
2027 send_packing(&dst, SkTEndian_SwapLE64(0x0000000001FE000173ULL), 0);
2028 }
2029
2030 return allocator->createT<
2031 SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical>, int, int , void* >
2017 (width, height, outputBuffer); 2032 (width, height, outputBuffer);
2018 } 2033 }
2019 2034
2020 void DecompressASTC(uint8_t* dst, int dstRowBytes, const uint8_t* src, 2035 void DecompressASTC(uint8_t* dst, int dstRowBytes, const uint8_t* src,
2021 int width, int height, int blockDimX, int blockDimY) { 2036 int width, int height, int blockDimX, int blockDimY) {
2022 // ASTC is encoded in what they call "raster order", so that the first 2037 // ASTC is encoded in what they call "raster order", so that the first
2023 // block is the bottom-left block in the image, and the first pixel 2038 // block is the bottom-left block in the image, and the first pixel
2024 // is the bottom-left pixel of the image 2039 // is the bottom-left pixel of the image
2025 dst += height * dstRowBytes; 2040 dst += height * dstRowBytes;
2026 2041
2027 ASTCDecompressionData data(blockDimX, blockDimY); 2042 ASTCDecompressionData data(blockDimX, blockDimY);
2028 for (int y = 0; y < height; y += blockDimY) { 2043 for (int y = 0; y < height; y += blockDimY) {
2029 dst -= blockDimY * dstRowBytes; 2044 dst -= blockDimY * dstRowBytes;
2030 SkColor *colorPtr = reinterpret_cast<SkColor*>(dst); 2045 SkColor *colorPtr = reinterpret_cast<SkColor*>(dst);
2031 for (int x = 0; x < width; x += blockDimX) { 2046 for (int x = 0; x < width; x += blockDimX) {
2032 read_astc_block(&data, src); 2047 read_astc_block(&data, src);
2033 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR owBytes, data); 2048 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR owBytes, data);
2034 2049
2035 // ASTC encoded blocks are 16 bytes (128 bits) large. 2050 // ASTC encoded blocks are 16 bytes (128 bits) large.
2036 src += 16; 2051 src += 16;
2037 } 2052 }
2038 } 2053 }
2039 } 2054 }
2040 2055
2041 } // SkTextureCompressor 2056 } // SkTextureCompressor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698