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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 1674673002: Alter SkXfermode's asFragmentProcessor & asXPFactory contracts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit test bug Created 4 years, 10 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/effects/SkXfermodeImageFilter.cpp ('k') | src/utils/debugger/SkOverdrawMode.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 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "SkGr.h" 9 #include "SkGr.h"
10 10
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 SkAutoTUnref<const GrFragmentProcessor> cfFP( 482 SkAutoTUnref<const GrFragmentProcessor> cfFP(
483 colorFilter->asFragmentProcessor(context)); 483 colorFilter->asFragmentProcessor(context));
484 if (cfFP) { 484 if (cfFP) {
485 grPaint->addColorFragmentProcessor(cfFP); 485 grPaint->addColorFragmentProcessor(cfFP);
486 } else { 486 } else {
487 return false; 487 return false;
488 } 488 }
489 } 489 }
490 } 490 }
491 491
492 SkXfermode* mode = skPaint.getXfermode(); 492 // When the xfermode is null on the SkPaint (meaning kSrcOver) we need the X PFactory field on
493 GrXPFactory* xpFactory = nullptr; 493 // the GrPaint to also be null (also kSrcOver).
494 SkXfermode::AsXPFactory(mode, &xpFactory); 494 SkASSERT(!grPaint->getXPFactory());
495 SkSafeUnref(grPaint->setXPFactory(xpFactory)); 495 SkXfermode* xfermode = skPaint.getXfermode();
496 if (xfermode) {
497 // SafeUnref in case a new xfermode is added that returns null.
498 // In such cases we will fall back to kSrcOver_Mode.
499 SkSafeUnref(grPaint->setXPFactory(xfermode->asXPFactory()));
500 }
496 501
497 #ifndef SK_IGNORE_GPU_DITHER 502 #ifndef SK_IGNORE_GPU_DITHER
498 if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) { 503 if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) {
499 grPaint->addColorFragmentProcessor(GrDitherEffect::Create())->unref(); 504 grPaint->addColorFragmentProcessor(GrDitherEffect::Create())->unref();
500 } 505 }
501 #endif 506 #endif
502 return true; 507 return true;
503 } 508 }
504 509
505 bool SkPaintToGrPaint(GrContext* context, const SkPaint& skPaint, const SkMatrix & viewM, 510 bool SkPaintToGrPaint(GrContext* context, const SkPaint& skPaint, const SkMatrix & viewM,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 SkErrorInternals::SetError( kInvalidPaint_SkError, 634 SkErrorInternals::SetError( kInvalidPaint_SkError,
630 "Sorry, I don't understand the filtering " 635 "Sorry, I don't understand the filtering "
631 "mode you asked for. Falling back to " 636 "mode you asked for. Falling back to "
632 "MIPMaps."); 637 "MIPMaps.");
633 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 638 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
634 break; 639 break;
635 640
636 } 641 }
637 return textureFilterMode; 642 return textureFilterMode;
638 } 643 }
OLDNEW
« no previous file with comments | « src/effects/SkXfermodeImageFilter.cpp ('k') | src/utils/debugger/SkOverdrawMode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698