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

Side by Side Diff: src/codec/SkSwizzler.cpp

Issue 1571923002: Might as well inline these premultiplies. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkSwizzler.h" 10 #include "SkSwizzler.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_premul( 388 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_premul(
389 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, 389 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
390 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { 390 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
391 391
392 src += offset; 392 src += offset;
393 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 393 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
394 INIT_RESULT_ALPHA; 394 INIT_RESULT_ALPHA;
395 for (int x = 0; x < dstWidth; x++) { 395 for (int x = 0; x < dstWidth; x++) {
396 uint8_t alpha = src[3]; 396 uint8_t alpha = src[3];
397 UPDATE_RESULT_ALPHA(alpha); 397 UPDATE_RESULT_ALPHA(alpha);
398 dst[x] = SkPreMultiplyARGB(alpha, src[2], src[1], src[0]); 398 dst[x] = SkPremultiplyARGBInline(alpha, src[2], src[1], src[0]);
399 src += deltaSrc; 399 src += deltaSrc;
400 } 400 }
401 return COMPUTE_RESULT_ALPHA; 401 return COMPUTE_RESULT_ALPHA;
402 } 402 }
403 403
404 // kRGBX 404 // kRGBX
405 static SkSwizzler::ResultAlpha swizzle_rgbx_to_n32( 405 static SkSwizzler::ResultAlpha swizzle_rgbx_to_n32(
406 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, 406 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
407 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { 407 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
408 408
(...skipping 24 matching lines...) Expand all
433 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul( 433 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul(
434 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, 434 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
435 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { 435 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
436 436
437 src += offset; 437 src += offset;
438 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 438 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
439 INIT_RESULT_ALPHA; 439 INIT_RESULT_ALPHA;
440 for (int x = 0; x < dstWidth; x++) { 440 for (int x = 0; x < dstWidth; x++) {
441 unsigned alpha = src[3]; 441 unsigned alpha = src[3];
442 UPDATE_RESULT_ALPHA(alpha); 442 UPDATE_RESULT_ALPHA(alpha);
443 dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]); 443 dst[x] = SkPremultiplyARGBInline(alpha, src[0], src[1], src[2]);
444 src += deltaSrc; 444 src += deltaSrc;
445 } 445 }
446 return COMPUTE_RESULT_ALPHA; 446 return COMPUTE_RESULT_ALPHA;
447 } 447 }
448 448
449 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_unpremul( 449 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_unpremul(
450 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, 450 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
451 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { 451 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
452 452
453 src += offset; 453 src += offset;
(...skipping 12 matching lines...) Expand all
466 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, 466 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth,
467 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) { 467 int bpp, int deltaSrc, int offset, const SkPMColor ctable[]) {
468 468
469 src += offset; 469 src += offset;
470 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 470 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
471 INIT_RESULT_ALPHA; 471 INIT_RESULT_ALPHA;
472 for (int x = 0; x < dstWidth; x++) { 472 for (int x = 0; x < dstWidth; x++) {
473 unsigned alpha = src[3]; 473 unsigned alpha = src[3];
474 UPDATE_RESULT_ALPHA(alpha); 474 UPDATE_RESULT_ALPHA(alpha);
475 if (0 != alpha) { 475 if (0 != alpha) {
476 dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]); 476 dst[x] = SkPremultiplyARGBInline(alpha, src[0], src[1], src[2]);
477 } 477 }
478 src += deltaSrc; 478 src += deltaSrc;
479 } 479 }
480 return COMPUTE_RESULT_ALPHA; 480 return COMPUTE_RESULT_ALPHA;
481 } 481 }
482 482
483 // kCMYK 483 // kCMYK
484 // 484 //
485 // CMYK is stored as four bytes per pixel. 485 // CMYK is stored as four bytes per pixel.
486 // 486 //
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 default: 772 default:
773 break; 773 break;
774 } 774 }
775 if (nullptr == proc) { 775 if (nullptr == proc) {
776 return nullptr; 776 return nullptr;
777 } 777 }
778 778
779 // Store bpp in bytes if it is an even multiple, otherwise use bits 779 // Store bpp in bytes if it is an even multiple, otherwise use bits
780 int srcBPP = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPixel (sc); 780 int srcBPP = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPixel (sc);
781 int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType()); 781 int dstBPP = SkColorTypeBytesPerPixel(dstInfo.colorType());
782 782
783 int srcOffset = 0; 783 int srcOffset = 0;
784 int srcWidth = dstInfo.width(); 784 int srcWidth = dstInfo.width();
785 int dstOffset = 0; 785 int dstOffset = 0;
786 int dstWidth = srcWidth; 786 int dstWidth = srcWidth;
787 if (options.fSubset) { 787 if (options.fSubset) {
788 // We do not currently support subset decodes for image types that may h ave 788 // We do not currently support subset decodes for image types that may h ave
789 // frames (gif). 789 // frames (gif).
790 SkASSERT(!frame); 790 SkASSERT(!frame);
791 srcOffset = options.fSubset->left(); 791 srcOffset = options.fSubset->left();
792 srcWidth = options.fSubset->width(); 792 srcWidth = options.fSubset->width();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX); 826 fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX);
827 827
828 return fAllocatedWidth; 828 return fAllocatedWidth;
829 } 829 }
830 830
831 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRIC T src) { 831 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRIC T src) {
832 SkASSERT(nullptr != dst && nullptr != src); 832 SkASSERT(nullptr != dst && nullptr != src);
833 return fRowProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth , fSrcBPP, 833 return fRowProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth , fSrcBPP,
834 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable); 834 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable);
835 } 835 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698