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_LATC.h" | 8 #include "SkTextureCompressor_LATC.h" |
9 #include "SkTextureCompressor_Blitter.h" | 9 #include "SkTextureCompressor_Blitter.h" |
10 | 10 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 #if COMPRESS_LATC_FAST | 421 #if COMPRESS_LATC_FAST |
422 return compress_4x4_a8_latc(dst, src, width, height, rowBytes); | 422 return compress_4x4_a8_latc(dst, src, width, height, rowBytes); |
423 #elif COMPRESS_LATC_SLOW | 423 #elif COMPRESS_LATC_SLOW |
424 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block); | 424 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block); |
425 #else | 425 #else |
426 #error "Must choose either fast or slow LATC compression" | 426 #error "Must choose either fast or slow LATC compression" |
427 #endif | 427 #endif |
428 } | 428 } |
429 | 429 |
430 SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer) { | 430 SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer) { |
431 if ((width % 4) != 0 || (height % 4) != 0) { | |
432 return NULL; | |
433 } | |
434 | |
431 #if COMPRESS_LATC_FAST | 435 #if COMPRESS_LATC_FAST |
436 // Memset the output buffer to an encoding that decodes to zero... | |
437 // In the case of LATC, if everything is zero, then LUM0 and LUM1 are also z ero, | |
438 // and they will only be non-zero (0xFF) if the index is 7. So bzero will do just fine. | |
robertphillips
2014/08/06 20:54:49
// (8 bytes/block) * (w * h / 4*4) blocks = w * h
krajcevski
2014/08/06 22:42:00
Done.
| |
439 sk_bzero(outputBuffer, width * height / 2); | |
440 | |
432 return new | 441 return new |
433 SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical> | 442 SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical> |
434 (width, height, outputBuffer); | 443 (width, height, outputBuffer); |
435 #elif COMPRESS_LATC_SLOW | 444 #elif COMPRESS_LATC_SLOW |
436 // TODO (krajcevski) | 445 // TODO (krajcevski) |
437 return NULL; | 446 return NULL; |
438 #endif | 447 #endif |
439 } | 448 } |
440 | 449 |
441 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) { | 450 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) { |
442 for (int j = 0; j < height; j += 4) { | 451 for (int j = 0; j < height; j += 4) { |
443 for (int i = 0; i < width; i += 4) { | 452 for (int i = 0; i < width; i += 4) { |
444 decompress_latc_block(dst + i, dstRowBytes, src); | 453 decompress_latc_block(dst + i, dstRowBytes, src); |
445 src += 8; | 454 src += 8; |
446 } | 455 } |
447 dst += 4 * dstRowBytes; | 456 dst += 4 * dstRowBytes; |
448 } | 457 } |
449 } | 458 } |
450 | 459 |
451 } // SkTextureCompressor | 460 } // SkTextureCompressor |
OLD | NEW |