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

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: Added comments 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
« no previous file with comments | « src/utils/SkTextureCompressor_Blitter.h ('k') | src/utils/SkTextureCompressor_R11EAC.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This is the type passed as the CompressorType argument of the compressed
418 // blitter for the LATC format. The static functions required to be in this
419 // struct are documented in SkTextureCompressor_Blitter.h
420 struct CompressorLATC {
421 static inline void CompressA8Vertical(uint8_t* dst, const uint8_t block[]) {
422 compress_a8_latc_block<PackColumnMajor>(&dst, block, 4);
423 }
424
425 static inline void CompressA8Horizontal(uint8_t* dst, const uint8_t* src,
426 int srcRowBytes) {
427 compress_a8_latc_block<PackRowMajor>(&dst, src, srcRowBytes);
428 }
429
430 static inline void UpdateBlock(uint8_t* dst, const uint8_t* src) {
431 }
432 };
433
417 //////////////////////////////////////////////////////////////////////////////// 434 ////////////////////////////////////////////////////////////////////////////////
418 435
419 namespace SkTextureCompressor { 436 namespace SkTextureCompressor {
420 437
421 bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i nt rowBytes) { 438 bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i nt rowBytes) {
422 #if COMPRESS_LATC_FAST 439 #if COMPRESS_LATC_FAST
423 return compress_4x4_a8_latc(dst, src, width, height, rowBytes); 440 return compress_4x4_a8_latc(dst, src, width, height, rowBytes);
424 #elif COMPRESS_LATC_SLOW 441 #elif COMPRESS_LATC_SLOW
425 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block); 442 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block);
426 #else 443 #else
(...skipping 10 matching lines...) Expand all
437 #if COMPRESS_LATC_FAST 454 #if COMPRESS_LATC_FAST
438 // Memset the output buffer to an encoding that decodes to zero. We must do this 455 // 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 456 // 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). 457 // 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, 458 // 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. 459 // 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 460 // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2
444 sk_bzero(outputBuffer, width * height / 2); 461 sk_bzero(outputBuffer, width * height / 2);
445 462
446 return allocator->createT< 463 return allocator->createT<
447 SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical>, int, int, void* > 464 SkTCompressedAlphaBlitter<4, 8, CompressorLATC>, int, int, void* >
448 (width, height, outputBuffer); 465 (width, height, outputBuffer);
449 #elif COMPRESS_LATC_SLOW 466 #elif COMPRESS_LATC_SLOW
450 // TODO (krajcevski) 467 // TODO (krajcevski)
451 return NULL; 468 return NULL;
452 #endif 469 #endif
453 } 470 }
454 471
455 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) { 472 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) {
456 for (int j = 0; j < height; j += 4) { 473 for (int j = 0; j < height; j += 4) {
457 for (int i = 0; i < width; i += 4) { 474 for (int i = 0; i < width; i += 4) {
458 decompress_latc_block(dst + i, dstRowBytes, src); 475 decompress_latc_block(dst + i, dstRowBytes, src);
459 src += 8; 476 src += 8;
460 } 477 }
461 dst += 4 * dstRowBytes; 478 dst += 4 * dstRowBytes;
462 } 479 }
463 } 480 }
464 481
465 } // SkTextureCompressor 482 } // SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor_Blitter.h ('k') | src/utils/SkTextureCompressor_R11EAC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698