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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 for (int y = 0; y < height; y += 12) { | 273 for (int y = 0; y < height; y += 12) { |
274 for (int x = 0; x < width; x += 12) { | 274 for (int x = 0; x < width; x += 12) { |
275 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy
tes); | 275 compress_a8_astc_block<GetAlpha>(dstPtr, src + y*rowBytes + x, rowBy
tes); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 return true; | 279 return true; |
280 } | 280 } |
281 | 281 |
282 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer) { | 282 SkBlitter* CreateASTCBlitter(int width, int height, void* outputBuffer) { |
| 283 if ((width % 12) != 0 || (height % 12) != 0) { |
| 284 return NULL; |
| 285 } |
| 286 |
| 287 // Memset the output buffer to an encoding that decodes to zero... |
| 288 // In the case of ASTC, if everything index is zero, then the interpolated v
alue |
| 289 // will decode to zero provided we have the right header. We use the encodin
g |
| 290 // from recognizing all zero blocks from above. |
| 291 const int nBlocks = (width * height / 144); |
| 292 uint8_t *dst = reinterpret_cast<uint8_t *>(outputBuffer); |
| 293 for (int i = 0; i < nBlocks; ++i) { |
| 294 send_packing(&dst, SkTEndian_SwapLE64(0x0000000001FE000173ULL), 0); |
| 295 } |
| 296 |
283 return new | 297 return new |
284 SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical> | 298 SkTCompressedAlphaBlitter<12, 16, CompressA8ASTCBlockVertical> |
285 (width, height, outputBuffer); | 299 (width, height, outputBuffer); |
286 } | 300 } |
287 | 301 |
288 } // SkTextureCompressor | 302 } // SkTextureCompressor |
OLD | NEW |