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

Side by Side Diff: src/utils/SkTextureCompressor_LATC.cpp

Issue 443303006: Pass a struct of functions instead of a function to the compressed blitter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
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_LATC.h" 8 #include "SkTextureCompressor_LATC.h"
9 #include "SkTextureCompressor_Blitter.h" 9 #include "SkTextureCompressor_Blitter.h"
10 10
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 block >>= 16; 407 block >>= 16;
408 for (int j = 0; j < 4; ++j) { 408 for (int j = 0; j < 4; ++j) {
409 for (int i = 0; i < 4; ++i) { 409 for (int i = 0; i < 4; ++i) {
410 dst[i] = palette[block & 0x7]; 410 dst[i] = palette[block & 0x7];
411 block >>= 3; 411 block >>= 3;
412 } 412 }
413 dst += dstRowBytes; 413 dst += dstRowBytes;
414 } 414 }
415 } 415 }
416 416
417 struct CompressorLATC {
418 static inline void CompressA8Vertical(uint8_t* dst, const uint8_t block[]) {
419 compress_a8_latc_block<PackColumnMajor>(&dst, block, 4);
420 }
421
422 static inline void CompressA8Horizontal(uint8_t* dst, const uint8_t* src,
423 int srcRowBytes) {
424 compress_a8_latc_block<PackRowMajor>(&dst, src, srcRowBytes);
425 }
426
427 static inline void UpdateBlock(uint8_t* dst, const uint8_t* src) {
428 }
429 };
430
417 //////////////////////////////////////////////////////////////////////////////// 431 ////////////////////////////////////////////////////////////////////////////////
418 432
419 namespace SkTextureCompressor { 433 namespace SkTextureCompressor {
420 434
421 bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i nt rowBytes) { 435 bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i nt rowBytes) {
422 #if COMPRESS_LATC_FAST 436 #if COMPRESS_LATC_FAST
423 return compress_4x4_a8_latc(dst, src, width, height, rowBytes); 437 return compress_4x4_a8_latc(dst, src, width, height, rowBytes);
424 #elif COMPRESS_LATC_SLOW 438 #elif COMPRESS_LATC_SLOW
425 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block); 439 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block);
426 #else 440 #else
(...skipping 10 matching lines...) Expand all
437 #if COMPRESS_LATC_FAST 451 #if COMPRESS_LATC_FAST
438 // Memset the output buffer to an encoding that decodes to zero. We must do this 452 // Memset the output buffer to an encoding that decodes to zero. We must do this
439 // in order to avoid having uninitialized values in the buffer if the blitte r 453 // in order to avoid having uninitialized values in the buffer if the blitte r
440 // decides not to write certain scanlines (and skip entire rows of blocks). 454 // decides not to write certain scanlines (and skip entire rows of blocks).
441 // In the case of LATC, if everything is zero, then LUM0 and LUM1 are also z ero, 455 // In the case of LATC, if everything is zero, then LUM0 and LUM1 are also z ero,
442 // and they will only be non-zero (0xFF) if the index is 7. So bzero will do just fine. 456 // and they will only be non-zero (0xFF) if the index is 7. So bzero will do just fine.
443 // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2 457 // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2
444 sk_bzero(outputBuffer, width * height / 2); 458 sk_bzero(outputBuffer, width * height / 2);
445 459
446 return allocator->createT< 460 return allocator->createT<
447 SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical>, int, int, void* > 461 SkTCompressedAlphaBlitter<4, 8, CompressorLATC>, int, int, void* >
448 (width, height, outputBuffer); 462 (width, height, outputBuffer);
449 #elif COMPRESS_LATC_SLOW 463 #elif COMPRESS_LATC_SLOW
450 // TODO (krajcevski) 464 // TODO (krajcevski)
451 return NULL; 465 return NULL;
452 #endif 466 #endif
453 } 467 }
454 468
455 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) { 469 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) {
456 for (int j = 0; j < height; j += 4) { 470 for (int j = 0; j < height; j += 4) {
457 for (int i = 0; i < width; i += 4) { 471 for (int i = 0; i < width; i += 4) {
458 decompress_latc_block(dst + i, dstRowBytes, src); 472 decompress_latc_block(dst + i, dstRowBytes, src);
459 src += 8; 473 src += 8;
460 } 474 }
461 dst += 4 * dstRowBytes; 475 dst += 4 * dstRowBytes;
462 } 476 }
463 } 477 }
464 478
465 } // SkTextureCompressor 479 } // SkTextureCompressor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698