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 #include "SkTextureCompressor_Utils.h" | 10 #include "SkTextureCompressor_Utils.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 #elif COMPRESS_LATC_SLOW | 478 #elif COMPRESS_LATC_SLOW |
479 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_
latc_block); | 479 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_
latc_block); |
480 #else | 480 #else |
481 #error "Must choose either fast or slow LATC compression" | 481 #error "Must choose either fast or slow LATC compression" |
482 #endif | 482 #endif |
483 } | 483 } |
484 | 484 |
485 SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer, | 485 SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer, |
486 SkTBlitterAllocator* allocator) { | 486 SkTBlitterAllocator* allocator) { |
487 if ((width % 4) != 0 || (height % 4) != 0) { | 487 if ((width % 4) != 0 || (height % 4) != 0) { |
488 return NULL; | 488 return nullptr; |
489 } | 489 } |
490 | 490 |
491 #if COMPRESS_LATC_FAST | 491 #if COMPRESS_LATC_FAST |
492 // Memset the output buffer to an encoding that decodes to zero. We must do
this | 492 // Memset the output buffer to an encoding that decodes to zero. We must do
this |
493 // in order to avoid having uninitialized values in the buffer if the blitte
r | 493 // in order to avoid having uninitialized values in the buffer if the blitte
r |
494 // decides not to write certain scanlines (and skip entire rows of blocks). | 494 // decides not to write certain scanlines (and skip entire rows of blocks). |
495 // In the case of LATC, if everything is zero, then LUM0 and LUM1 are also z
ero, | 495 // In the case of LATC, if everything is zero, then LUM0 and LUM1 are also z
ero, |
496 // and they will only be non-zero (0xFF) if the index is 7. So bzero will do
just fine. | 496 // and they will only be non-zero (0xFF) if the index is 7. So bzero will do
just fine. |
497 // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2 | 497 // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2 |
498 sk_bzero(outputBuffer, width * height / 2); | 498 sk_bzero(outputBuffer, width * height / 2); |
499 | 499 |
500 return allocator->createT< | 500 return allocator->createT< |
501 SkTCompressedAlphaBlitter<4, 8, CompressorLATC>, int, int, void* > | 501 SkTCompressedAlphaBlitter<4, 8, CompressorLATC>, int, int, void* > |
502 (width, height, outputBuffer); | 502 (width, height, outputBuffer); |
503 #elif COMPRESS_LATC_SLOW | 503 #elif COMPRESS_LATC_SLOW |
504 // TODO (krajcevski) | 504 // TODO (krajcevski) |
505 return NULL; | 505 return nullptr; |
506 #endif | 506 #endif |
507 } | 507 } |
508 | 508 |
509 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width
, int height) { | 509 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width
, int height) { |
510 for (int j = 0; j < height; j += 4) { | 510 for (int j = 0; j < height; j += 4) { |
511 for (int i = 0; i < width; i += 4) { | 511 for (int i = 0; i < width; i += 4) { |
512 decompress_latc_block(dst + i, dstRowBytes, src); | 512 decompress_latc_block(dst + i, dstRowBytes, src); |
513 src += 8; | 513 src += 8; |
514 } | 514 } |
515 dst += 4 * dstRowBytes; | 515 dst += 4 * dstRowBytes; |
516 } | 516 } |
517 } | 517 } |
518 | 518 |
519 } // SkTextureCompressor | 519 } // SkTextureCompressor |
OLD | NEW |