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

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

Issue 207683004: Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up Created 6 years, 9 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 /* 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // a nearby mipmap level. If it does, it will adjust the working 391 // a nearby mipmap level. If it does, it will adjust the working
392 // matrix as well as the working bitmap. It may also adjust the filter 392 // matrix as well as the working bitmap. It may also adjust the filter
393 // quality to avoid re-filtering an already perfectly scaled image. 393 // quality to avoid re-filtering an already perfectly scaled image.
394 if (!this->possiblyScaleImage()) { 394 if (!this->possiblyScaleImage()) {
395 if (!this->lockBaseBitmap()) { 395 if (!this->lockBaseBitmap()) {
396 return false; 396 return false;
397 } 397 }
398 } 398 }
399 // The above logic should have always assigned fBitmap, but in case it 399 // The above logic should have always assigned fBitmap, but in case it
400 // didn't, we check for that now... 400 // didn't, we check for that now...
401 // TODO(dominikg): Can we just use an SkASSERT(fBitmap)?
scroggo 2014/03/24 21:24:46 I think humper@ is the right person to ask that qu
Dominik Grewe 2014/03/27 14:27:20 Works fine on the tests.
401 if (NULL == fBitmap) { 402 if (NULL == fBitmap) {
402 return false; 403 return false;
403 } 404 }
404 405
405 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; 406 bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
406 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX && 407 bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
407 SkShader::kClamp_TileMode == fTileModeY; 408 SkShader::kClamp_TileMode == fTileModeY;
408 409
409 if (!(clampClamp || trivialMatrix)) { 410 if (!(clampClamp || trivialMatrix)) {
410 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height()); 411 fInvMatrix.postIDiv(fOrigBitmap.width(), fOrigBitmap.height());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (fInvType <= SkMatrix::kTranslate_Mask || 474 if (fInvType <= SkMatrix::kTranslate_Mask ||
474 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { 475 !valid_for_filtering(fBitmap->width() | fBitmap->height())) {
475 fFilterLevel = SkPaint::kNone_FilterLevel; 476 fFilterLevel = SkPaint::kNone_FilterLevel;
476 } 477 }
477 } 478 }
478 479
479 // At this point, we know exactly what kind of sampling the per-scanline 480 // At this point, we know exactly what kind of sampling the per-scanline
480 // shader will perform. 481 // shader will perform.
481 482
482 fMatrixProc = this->chooseMatrixProc(trivialMatrix); 483 fMatrixProc = this->chooseMatrixProc(trivialMatrix);
484 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns NULL.
scroggo 2014/03/24 21:24:46 If chooseMatrixProc never returns NULL, then I thi
Dominik Grewe 2014/03/26 17:22:22 I was trying to reduce the cases where this functi
483 if (NULL == fMatrixProc) { 485 if (NULL == fMatrixProc) {
484 return false; 486 return false;
485 } 487 }
486 488
487 /////////////////////////////////////////////////////////////////////// 489 ///////////////////////////////////////////////////////////////////////
488 490
489 // No need to do this if we're doing HQ sampling; if filter quality is 491 // No need to do this if we're doing HQ sampling; if filter quality is
490 // still set to HQ by the time we get here, then we must have installed 492 // still set to HQ by the time we get here, then we must have installed
491 // the shader procs above and can skip all this. 493 // the shader procs above and can skip all this.
492 494
(...skipping 21 matching lines...) Expand all
514 index |= 16; 516 index |= 16;
515 break; 517 break;
516 case SkBitmap::kARGB_4444_Config: 518 case SkBitmap::kARGB_4444_Config:
517 index |= 24; 519 index |= 24;
518 break; 520 break;
519 case SkBitmap::kA8_Config: 521 case SkBitmap::kA8_Config:
520 index |= 32; 522 index |= 32;
521 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); 523 fPaintPMColor = SkPreMultiplyColor(paint.getColor());
522 break; 524 break;
523 default: 525 default:
526 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead?
524 return false; 527 return false;
525 } 528 }
526 529
527 #if !SK_ARM_NEON_IS_ALWAYS 530 #if !SK_ARM_NEON_IS_ALWAYS
528 static const SampleProc32 gSkBitmapProcStateSample32[] = { 531 static const SampleProc32 gSkBitmapProcStateSample32[] = {
529 S32_opaque_D32_nofilter_DXDY, 532 S32_opaque_D32_nofilter_DXDY,
530 S32_alpha_D32_nofilter_DXDY, 533 S32_alpha_D32_nofilter_DXDY,
531 S32_opaque_D32_nofilter_DX, 534 S32_opaque_D32_nofilter_DX,
532 S32_alpha_D32_nofilter_DX, 535 S32_alpha_D32_nofilter_DX,
533 S32_opaque_D32_filter_DXDY, 536 S32_opaque_D32_filter_DXDY,
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } else { 1036 } else {
1034 size >>= 2; 1037 size >>= 2;
1035 } 1038 }
1036 1039
1037 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 1040 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
1038 size >>= 1; 1041 size >>= 1;
1039 } 1042 }
1040 1043
1041 return size; 1044 return size;
1042 } 1045 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698