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

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: Fix compiler error 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_ASTC.h ('k') | src/utils/SkTextureCompressor_LATC.h » ('j') | 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_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
2020 // Memset the output buffer to an encoding that decodes to zero. We must do this
2021 // in order to avoid having uninitialized values in the buffer if the blitte r
2022 // decides not to write certain scanlines (and skip entire rows of blocks).
2023 // In the case of ASTC, if everything index is zero, then the interpolated v alue
2024 // will decode to zero provided we have the right header. We use the encodin g
2025 // from recognizing all zero blocks from above.
2026 const int nBlocks = (width * height / 144);
2027 uint8_t *dst = reinterpret_cast<uint8_t *>(outputBuffer);
2028 for (int i = 0; i < nBlocks; ++i) {
2029 send_packing(&dst, SkTEndian_SwapLE64(0x0000000001FE000173ULL), 0);
2030 }
2031
2032 return allocator->createT<
2033 SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical>, int, int , void* >
2017 (width, height, outputBuffer); 2034 (width, height, outputBuffer);
2018 } 2035 }
2019 2036
2020 void DecompressASTC(uint8_t* dst, int dstRowBytes, const uint8_t* src, 2037 void DecompressASTC(uint8_t* dst, int dstRowBytes, const uint8_t* src,
2021 int width, int height, int blockDimX, int blockDimY) { 2038 int width, int height, int blockDimX, int blockDimY) {
2022 // ASTC is encoded in what they call "raster order", so that the first 2039 // 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 2040 // block is the bottom-left block in the image, and the first pixel
2024 // is the bottom-left pixel of the image 2041 // is the bottom-left pixel of the image
2025 dst += height * dstRowBytes; 2042 dst += height * dstRowBytes;
2026 2043
2027 ASTCDecompressionData data(blockDimX, blockDimY); 2044 ASTCDecompressionData data(blockDimX, blockDimY);
2028 for (int y = 0; y < height; y += blockDimY) { 2045 for (int y = 0; y < height; y += blockDimY) {
2029 dst -= blockDimY * dstRowBytes; 2046 dst -= blockDimY * dstRowBytes;
2030 SkColor *colorPtr = reinterpret_cast<SkColor*>(dst); 2047 SkColor *colorPtr = reinterpret_cast<SkColor*>(dst);
2031 for (int x = 0; x < width; x += blockDimX) { 2048 for (int x = 0; x < width; x += blockDimX) {
2032 read_astc_block(&data, src); 2049 read_astc_block(&data, src);
2033 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR owBytes, data); 2050 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR owBytes, data);
2034 2051
2035 // ASTC encoded blocks are 16 bytes (128 bits) large. 2052 // ASTC encoded blocks are 16 bytes (128 bits) large.
2036 src += 16; 2053 src += 16;
2037 } 2054 }
2038 } 2055 }
2039 } 2056 }
2040 2057
2041 } // SkTextureCompressor 2058 } // SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor_ASTC.h ('k') | src/utils/SkTextureCompressor_LATC.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698