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

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

Issue 22801016: Implement highQualityFilter16 so GM doesn't crash when you give it resources. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // downgrade to bilerp. 369 // downgrade to bilerp.
370 370
371 // NOTE: Might need to be careful here in the future when we want 371 // NOTE: Might need to be careful here in the future when we want
372 // to have the platform proc have a shot at this; it's possible that 372 // to have the platform proc have a shot at this; it's possible that
373 // the chooseBitmapFilterProc will fail to install a shader but a 373 // the chooseBitmapFilterProc will fail to install a shader but a
374 // platform-specific one might succeed, so it might be premature here 374 // platform-specific one might succeed, so it might be premature here
375 // to fall back to bilerp. This needs thought. 375 // to fall back to bilerp. This needs thought.
376 376
377 SkASSERT(fInvType > SkMatrix::kTranslate_Mask); 377 SkASSERT(fInvType > SkMatrix::kTranslate_Mask);
378 378
379 fShaderProc32 = this->chooseBitmapFilterProc(); 379 if (!this->setBitmapFilterProcs()) {
380 if (!fShaderProc32) {
381 fFilterLevel = SkPaint::kLow_FilterLevel; 380 fFilterLevel = SkPaint::kLow_FilterLevel;
382 } 381 }
383 } 382 }
384 383
385 if (SkPaint::kLow_FilterLevel == fFilterLevel) { 384 if (SkPaint::kLow_FilterLevel == fFilterLevel) {
386 // Only try bilerp if the matrix is "interesting" and 385 // Only try bilerp if the matrix is "interesting" and
387 // the image has a suitable size. 386 // the image has a suitable size.
388 387
389 if (fInvType <= SkMatrix::kTranslate_Mask || 388 if (fInvType <= SkMatrix::kTranslate_Mask ||
390 !valid_for_filtering(fBitmap->width() | fBitmap->height())) { 389 !valid_for_filtering(fBitmap->width() | fBitmap->height())) {
391 fFilterLevel = SkPaint::kNone_FilterLevel; 390 fFilterLevel = SkPaint::kNone_FilterLevel;
392 } 391 }
393 } 392 }
394 393
395 // At this point, we know exactly what kind of sampling the per-scanline 394 // At this point, we know exactly what kind of sampling the per-scanline
396 // shader will perform. 395 // shader will perform.
397 396
398 fMatrixProc = this->chooseMatrixProc(trivialMatrix); 397 fMatrixProc = this->chooseMatrixProc(trivialMatrix);
399 if (NULL == fMatrixProc) { 398 if (NULL == fMatrixProc) {
400 return false; 399 return false;
401 } 400 }
402 401
403 /////////////////////////////////////////////////////////////////////// 402 ///////////////////////////////////////////////////////////////////////
404 403
405 // No need to do this if we're doing HQ sampling; if filter quality is 404 // No need to do this if we're doing HQ sampling; if filter quality is
406 // still set to HQ by the time we get here, then we must have installed 405 // still set to HQ by the time we get here, then we must have installed
407 // the shader proc above and can skip all this. 406 // the shader procs above and can skip all this.
408 407
409 if (fFilterLevel < SkPaint::kHigh_FilterLevel) { 408 if (fFilterLevel < SkPaint::kHigh_FilterLevel) {
410 409
411 int index = 0; 410 int index = 0;
412 if (fAlphaScale < 256) { // note: this distinction is not used for D16 411 if (fAlphaScale < 256) { // note: this distinction is not used for D16
413 index |= 1; 412 index |= 1;
414 } 413 }
415 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { 414 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
416 index |= 2; 415 index |= 2;
417 } 416 }
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 } else { 948 } else {
950 size >>= 2; 949 size >>= 2;
951 } 950 }
952 951
953 if (fFilterLevel != SkPaint::kNone_FilterLevel) { 952 if (fFilterLevel != SkPaint::kNone_FilterLevel) {
954 size >>= 1; 953 size >>= 1;
955 } 954 }
956 955
957 return size; 956 return size;
958 } 957 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698