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

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

Issue 446103002: Pass compressed blitters to our mask drawing algorithm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix compiler error 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_LATC.h ('k') | src/utils/SkTextureCompressor_R11EAC.h » ('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
11 #include "SkBlitter.h"
11 #include "SkEndian.h" 12 #include "SkEndian.h"
12 13
13 // Compression options. In general, the slow version is much more accurate, but 14 // Compression options. In general, the slow version is much more accurate, but
14 // much slower. The fast option is much faster, but much less accurate. YMMV. 15 // much slower. The fast option is much faster, but much less accurate. YMMV.
15 #define COMPRESS_LATC_SLOW 0 16 #define COMPRESS_LATC_SLOW 0
16 #define COMPRESS_LATC_FAST 1 17 #define COMPRESS_LATC_FAST 1
17 18
18 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
19 20
20 // Generates an LATC palette. LATC constructs 21 // Generates an LATC palette. LATC constructs
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i nt rowBytes) { 421 bool CompressA8ToLATC(uint8_t* dst, const uint8_t* src, int width, int height, i nt rowBytes) {
421 #if COMPRESS_LATC_FAST 422 #if COMPRESS_LATC_FAST
422 return compress_4x4_a8_latc(dst, src, width, height, rowBytes); 423 return compress_4x4_a8_latc(dst, src, width, height, rowBytes);
423 #elif COMPRESS_LATC_SLOW 424 #elif COMPRESS_LATC_SLOW
424 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block); 425 return compress_4x4_a8_to_64bit(dst, src, width, height, rowBytes, compress_ latc_block);
425 #else 426 #else
426 #error "Must choose either fast or slow LATC compression" 427 #error "Must choose either fast or slow LATC compression"
427 #endif 428 #endif
428 } 429 }
429 430
430 SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer) { 431 SkBlitter* CreateLATCBlitter(int width, int height, void* outputBuffer,
432 SkTBlitterAllocator* allocator) {
433 if ((width % 4) != 0 || (height % 4) != 0) {
434 return NULL;
435 }
436
431 #if COMPRESS_LATC_FAST 437 #if COMPRESS_LATC_FAST
432 return new 438 // Memset the output buffer to an encoding that decodes to zero. We must do this
433 SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical> 439 // 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).
441 // 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.
443 // (8 bytes per block) * (w * h / 16 blocks) = w * h / 2
444 sk_bzero(outputBuffer, width * height / 2);
445
446 return allocator->createT<
447 SkTCompressedAlphaBlitter<4, 8, CompressA8LATCBlockVertical>, int, int, void* >
434 (width, height, outputBuffer); 448 (width, height, outputBuffer);
435 #elif COMPRESS_LATC_SLOW 449 #elif COMPRESS_LATC_SLOW
436 // TODO (krajcevski) 450 // TODO (krajcevski)
437 return NULL; 451 return NULL;
438 #endif 452 #endif
439 } 453 }
440 454
441 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) { 455 void DecompressLATC(uint8_t* dst, int dstRowBytes, const uint8_t* src, int width , int height) {
442 for (int j = 0; j < height; j += 4) { 456 for (int j = 0; j < height; j += 4) {
443 for (int i = 0; i < width; i += 4) { 457 for (int i = 0; i < width; i += 4) {
444 decompress_latc_block(dst + i, dstRowBytes, src); 458 decompress_latc_block(dst + i, dstRowBytes, src);
445 src += 8; 459 src += 8;
446 } 460 }
447 dst += 4 * dstRowBytes; 461 dst += 4 * dstRowBytes;
448 } 462 }
449 } 463 }
450 464
451 } // SkTextureCompressor 465 } // SkTextureCompressor
OLDNEW
« no previous file with comments | « src/utils/SkTextureCompressor_LATC.h ('k') | src/utils/SkTextureCompressor_R11EAC.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698