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

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

Issue 249643002: Revert of 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: Created 6 years, 8 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/core/SkBitmapProcState.h ('k') | src/core/SkBlitter.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 /* 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 fScaledBitmap.reset(); 353 fScaledBitmap.reset();
354 return false; 354 return false;
355 } 355 }
356 } 356 }
357 } 357 }
358 fBitmap = &fScaledBitmap; 358 fBitmap = &fScaledBitmap;
359 unlocker.release(); 359 unlocker.release();
360 return true; 360 return true;
361 } 361 }
362 362
363 void SkBitmapProcState::endContext() {
364 SkDELETE(fBitmapFilter);
365 fBitmapFilter = NULL;
366 fScaledBitmap.reset();
367
368 if (fScaledCacheID) {
369 SkScaledImageCache::Unlock(fScaledCacheID);
370 fScaledCacheID = NULL;
371 }
372 }
373
363 SkBitmapProcState::~SkBitmapProcState() { 374 SkBitmapProcState::~SkBitmapProcState() {
364 if (fScaledCacheID) { 375 if (fScaledCacheID) {
365 SkScaledImageCache::Unlock(fScaledCacheID); 376 SkScaledImageCache::Unlock(fScaledCacheID);
366 } 377 }
367 SkDELETE(fBitmapFilter); 378 SkDELETE(fBitmapFilter);
368 } 379 }
369 380
370 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { 381 bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
371 SkASSERT(fOrigBitmap.width() && fOrigBitmap.height()); 382 SkASSERT(fOrigBitmap.width() && fOrigBitmap.height());
372 383
373 fBitmap = NULL; 384 fBitmap = NULL;
374 fInvMatrix = inv; 385 fInvMatrix = inv;
375 fFilterLevel = paint.getFilterLevel(); 386 fFilterLevel = paint.getFilterLevel();
376 387
377 SkASSERT(NULL == fScaledCacheID); 388 SkASSERT(NULL == fScaledCacheID);
378 389
379 // possiblyScaleImage will look to see if it can rescale the image as a 390 // possiblyScaleImage will look to see if it can rescale the image as a
380 // preprocess; either by scaling up to the target size, or by selecting 391 // preprocess; either by scaling up to the target size, or by selecting
381 // a nearby mipmap level. If it does, it will adjust the working 392 // a nearby mipmap level. If it does, it will adjust the working
382 // matrix as well as the working bitmap. It may also adjust the filter 393 // matrix as well as the working bitmap. It may also adjust the filter
383 // quality to avoid re-filtering an already perfectly scaled image. 394 // quality to avoid re-filtering an already perfectly scaled image.
384 if (!this->possiblyScaleImage()) { 395 if (!this->possiblyScaleImage()) {
385 if (!this->lockBaseBitmap()) { 396 if (!this->lockBaseBitmap()) {
386 return false; 397 return false;
387 } 398 }
388 } 399 }
389 // The above logic should have always assigned fBitmap, but in case it 400 // The above logic should have always assigned fBitmap, but in case it
390 // didn't, we check for that now... 401 // didn't, we check for that now...
391 // TODO(dominikg): Ask humper@ if we can just use an SkASSERT(fBitmap)?
392 if (NULL == fBitmap) { 402 if (NULL == fBitmap) {
393 return false; 403 return false;
394 } 404 }
395 405
396 // If we are "still" kMedium_FilterLevel, then the request was not fulfilled by possiblyScale, 406 // If we are "still" kMedium_FilterLevel, then the request was not fulfilled by possiblyScale,
397 // so we downgrade to kLow (so the rest of the sniffing code can assume that ) 407 // so we downgrade to kLow (so the rest of the sniffing code can assume that )
398 if (SkPaint::kMedium_FilterLevel == fFilterLevel) { 408 if (SkPaint::kMedium_FilterLevel == fFilterLevel) {
399 fFilterLevel = SkPaint::kLow_FilterLevel; 409 fFilterLevel = SkPaint::kLow_FilterLevel;
400 } 410 }
401 411
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (fInvType <= SkMatrix::kTranslate_Mask || 480 if (fInvType <= SkMatrix::kTranslate_Mask ||
471 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { 481 !valid_for_filtering(fBitmap->width() | fBitmap->height())) {
472 fFilterLevel = SkPaint::kNone_FilterLevel; 482 fFilterLevel = SkPaint::kNone_FilterLevel;
473 } 483 }
474 } 484 }
475 485
476 // At this point, we know exactly what kind of sampling the per-scanline 486 // At this point, we know exactly what kind of sampling the per-scanline
477 // shader will perform. 487 // shader will perform.
478 488
479 fMatrixProc = this->chooseMatrixProc(trivialMatrix); 489 fMatrixProc = this->chooseMatrixProc(trivialMatrix);
480 // TODO(dominikg): SkASSERT(fMatrixProc) instead? chooseMatrixProc never ret urns NULL.
481 if (NULL == fMatrixProc) { 490 if (NULL == fMatrixProc) {
482 return false; 491 return false;
483 } 492 }
484 493
485 /////////////////////////////////////////////////////////////////////// 494 ///////////////////////////////////////////////////////////////////////
486 495
487 // No need to do this if we're doing HQ sampling; if filter quality is 496 // No need to do this if we're doing HQ sampling; if filter quality is
488 // still set to HQ by the time we get here, then we must have installed 497 // still set to HQ by the time we get here, then we must have installed
489 // the shader procs above and can skip all this. 498 // the shader procs above and can skip all this.
490 499
(...skipping 21 matching lines...) Expand all
512 index |= 16; 521 index |= 16;
513 break; 522 break;
514 case SkBitmap::kARGB_4444_Config: 523 case SkBitmap::kARGB_4444_Config:
515 index |= 24; 524 index |= 24;
516 break; 525 break;
517 case SkBitmap::kA8_Config: 526 case SkBitmap::kA8_Config:
518 index |= 32; 527 index |= 32;
519 fPaintPMColor = SkPreMultiplyColor(paint.getColor()); 528 fPaintPMColor = SkPreMultiplyColor(paint.getColor());
520 break; 529 break;
521 default: 530 default:
522 // TODO(dominikg): Should we ever get here? SkASSERT(false) inst ead?
523 return false; 531 return false;
524 } 532 }
525 533
526 #if !SK_ARM_NEON_IS_ALWAYS 534 #if !SK_ARM_NEON_IS_ALWAYS
527 static const SampleProc32 gSkBitmapProcStateSample32[] = { 535 static const SampleProc32 gSkBitmapProcStateSample32[] = {
528 S32_opaque_D32_nofilter_DXDY, 536 S32_opaque_D32_nofilter_DXDY,
529 S32_alpha_D32_nofilter_DXDY, 537 S32_alpha_D32_nofilter_DXDY,
530 S32_opaque_D32_nofilter_DX, 538 S32_opaque_D32_nofilter_DX,
531 S32_alpha_D32_nofilter_DX, 539 S32_alpha_D32_nofilter_DX,
532 S32_opaque_D32_filter_DXDY, 540 S32_opaque_D32_filter_DXDY,
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 } else { 1040 } else {
1033 size >>= 2; 1041 size >>= 2;
1034 } 1042 }
1035 1043
1036 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 1044 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
1037 size >>= 1; 1045 size >>= 1;
1038 } 1046 }
1039 1047
1040 return size; 1048 return size;
1041 } 1049 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBlitter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698