| OLD | NEW |
| 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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 numValues += ((cemInt >> 2) + 1) * 2; | 1168 numValues += ((cemInt >> 2) + 1) * 2; |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 return numValues; | 1171 return numValues; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 // Figures out the number of bits available for color values, and fills | 1174 // Figures out the number of bits available for color values, and fills |
| 1175 // in the maximum encoding that will fit the number of color values that | 1175 // in the maximum encoding that will fit the number of color values that |
| 1176 // we need. Returns false on error. (See section C.2.22 of the spec) | 1176 // we need. Returns false on error. (See section C.2.22 of the spec) |
| 1177 bool getColorValueEncoding(int *nBits, int *nTrits, int *nQuints) const { | 1177 bool getColorValueEncoding(int *nBits, int *nTrits, int *nQuints) const { |
| 1178 if (NULL == nBits || NULL == nTrits || NULL == nQuints) { | 1178 if (nullptr == nBits || nullptr == nTrits || nullptr == nQuints) { |
| 1179 return false; | 1179 return false; |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 const int nColorVals = this->numColorValues(); | 1182 const int nColorVals = this->numColorValues(); |
| 1183 if (nColorVals <= 0) { | 1183 if (nColorVals <= 0) { |
| 1184 return false; | 1184 return false; |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 const int colorBits = fColorEndBit - fColorStartBit; | 1187 const int colorBits = fColorEndBit - fColorStartBit; |
| 1188 SkASSERT(colorBits > 0); | 1188 SkASSERT(colorBits > 0); |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy
tes); | 2050 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy
tes); |
| 2051 } | 2051 } |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 return true; | 2054 return true; |
| 2055 } | 2055 } |
| 2056 | 2056 |
| 2057 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer, | 2057 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer, |
| 2058 SkTBlitterAllocator* allocator) { | 2058 SkTBlitterAllocator* allocator) { |
| 2059 if ((width % 12) != 0 || (height % 12) != 0) { | 2059 if ((width % 12) != 0 || (height % 12) != 0) { |
| 2060 return NULL; | 2060 return nullptr; |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 // Memset the output buffer to an encoding that decodes to zero. We must do
this | 2063 // Memset the output buffer to an encoding that decodes to zero. We must do
this |
| 2064 // in order to avoid having uninitialized values in the buffer if the blitte
r | 2064 // in order to avoid having uninitialized values in the buffer if the blitte
r |
| 2065 // decides not to write certain scanlines (and skip entire rows of blocks). | 2065 // decides not to write certain scanlines (and skip entire rows of blocks). |
| 2066 // In the case of ASTC, if everything index is zero, then the interpolated v
alue | 2066 // In the case of ASTC, if everything index is zero, then the interpolated v
alue |
| 2067 // will decode to zero provided we have the right header. We use the encodin
g | 2067 // will decode to zero provided we have the right header. We use the encodin
g |
| 2068 // from recognizing all zero blocks from above. | 2068 // from recognizing all zero blocks from above. |
| 2069 const int nBlocks = (width * height / 144); | 2069 const int nBlocks = (width * height / 144); |
| 2070 uint8_t *dst = reinterpret_cast<uint8_t *>(outputBuffer); | 2070 uint8_t *dst = reinterpret_cast<uint8_t *>(outputBuffer); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2092 read_astc_block(&data, src); | 2092 read_astc_block(&data, src); |
| 2093 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR
owBytes, data); | 2093 decompress_astc_block(reinterpret_cast<uint8_t*>(colorPtr + x), dstR
owBytes, data); |
| 2094 | 2094 |
| 2095 // ASTC encoded blocks are 16 bytes (128 bits) large. | 2095 // ASTC encoded blocks are 16 bytes (128 bits) large. |
| 2096 src += 16; | 2096 src += 16; |
| 2097 } | 2097 } |
| 2098 } | 2098 } |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 } // SkTextureCompressor | 2101 } // SkTextureCompressor |
| OLD | NEW |