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

Side by Side Diff: src/core/SkBitmapProcState.cpp

Issue 386203002: don't draw unpremul alpha (yet) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 | src/core/SkSpriteBlitter_RGB16.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBitmapProcState.h" 8 #include "SkBitmapProcState.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkFilterProc.h" 10 #include "SkFilterProc.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // shader will perform. 474 // shader will perform.
475 475
476 fMatrixProc = this->chooseMatrixProc(trivialMatrix); 476 fMatrixProc = this->chooseMatrixProc(trivialMatrix);
477 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns NULL. 477 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns NULL.
478 if (NULL == fMatrixProc) { 478 if (NULL == fMatrixProc) {
479 return false; 479 return false;
480 } 480 }
481 481
482 /////////////////////////////////////////////////////////////////////// 482 ///////////////////////////////////////////////////////////////////////
483 483
484 const SkAlphaType at = fBitmap->alphaType();
485
484 // No need to do this if we're doing HQ sampling; if filter quality is 486 // No need to do this if we're doing HQ sampling; if filter quality is
485 // still set to HQ by the time we get here, then we must have installed 487 // still set to HQ by the time we get here, then we must have installed
486 // the shader procs above and can skip all this. 488 // the shader procs above and can skip all this.
487 489
488 if (fFilterLevel < SkPaint::kHigh_FilterLevel) { 490 if (fFilterLevel < SkPaint::kHigh_FilterLevel) {
489 491
490 int index = 0; 492 int index = 0;
491 if (fAlphaScale < 256) { // note: this distinction is not used for D16 493 if (fAlphaScale < 256) { // note: this distinction is not used for D16
492 index |= 1; 494 index |= 1;
493 } 495 }
494 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 496 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
495 index |= 2; 497 index |= 2;
496 } 498 }
497 if (fFilterLevel > SkPaint::kNone_FilterLevel) { 499 if (fFilterLevel > SkPaint::kNone_FilterLevel) {
498 index |= 4; 500 index |= 4;
499 } 501 }
500 // bits 3,4,5 encoding the source bitmap format 502 // bits 3,4,5 encoding the source bitmap format
501 switch (fBitmap->colorType()) { 503 switch (fBitmap->colorType()) {
502 case kN32_SkColorType: 504 case kN32_SkColorType:
505 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
506 return false;
507 }
503 index |= 0; 508 index |= 0;
504 break; 509 break;
505 case kRGB_565_SkColorType: 510 case kRGB_565_SkColorType:
506 index |= 8; 511 index |= 8;
507 break; 512 break;
508 case kIndex_8_SkColorType: 513 case kIndex_8_SkColorType:
514 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
515 return false;
516 }
509 index |= 16; 517 index |= 16;
510 break; 518 break;
511 case kARGB_4444_SkColorType: 519 case kARGB_4444_SkColorType:
520 if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
521 return false;
522 }
512 index |= 24; 523 index |= 24;
513 break; 524 break;
514 case kAlpha_8_SkColorType: 525 case kAlpha_8_SkColorType:
515 index |= 32; 526 index |= 32;
516 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); 527 fPaintPMColor = SkPreMultiplyColor(paint.getColor());
517 break; 528 break;
518 default: 529 default:
519 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead? 530 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead?
520 return false; 531 return false;
521 } 532 }
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 } else { 1040 } else {
1030 size >>= 2; 1041 size >>= 2;
1031 } 1042 }
1032 1043
1033 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 1044 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
1034 size >>= 1; 1045 size >>= 1;
1035 } 1046 }
1036 1047
1037 return size; 1048 return size;
1038 } 1049 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkSpriteBlitter_RGB16.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698