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

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

Issue 776843004: Use static XPF for porter duff xp factories. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
Patch Set: Block case statements Created 6 years 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/gpu/GrPaint.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.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 * 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 #include "SkGr.h" 8 #include "SkGr.h"
9 9
10 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 SkXfermode::Coeff dm; 468 SkXfermode::Coeff dm;
469 469
470 SkXfermode* mode = skPaint.getXfermode(); 470 SkXfermode* mode = skPaint.getXfermode();
471 GrFragmentProcessor* fragmentProcessor = NULL; 471 GrFragmentProcessor* fragmentProcessor = NULL;
472 GrXPFactory* xpFactory = NULL; 472 GrXPFactory* xpFactory = NULL;
473 if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xp Factory, 473 if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xp Factory,
474 &sm, &dm)) { 474 &sm, &dm)) {
475 if (fragmentProcessor) { 475 if (fragmentProcessor) {
476 SkASSERT(NULL == xpFactory); 476 SkASSERT(NULL == xpFactory);
477 grPaint->addColorProcessor(fragmentProcessor)->unref(); 477 grPaint->addColorProcessor(fragmentProcessor)->unref();
478 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff, 478 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode);
479 SkXfermode::kZero_Coeff);
480 sm = SkXfermode::kOne_Coeff; 479 sm = SkXfermode::kOne_Coeff;
481 dm = SkXfermode::kZero_Coeff; 480 dm = SkXfermode::kZero_Coeff;
482 } 481 }
483 } else { 482 } else {
484 // Fall back to src-over 483 // Fall back to src-over
485 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kOne_Coeff, 484 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode);
486 SkXfermode::kISA_Coeff);
487 sm = SkXfermode::kOne_Coeff; 485 sm = SkXfermode::kOne_Coeff;
488 dm = SkXfermode::kISA_Coeff; 486 dm = SkXfermode::kISA_Coeff;
489 } 487 }
490 SkASSERT(xpFactory); 488 SkASSERT(xpFactory);
491 grPaint->setXPFactory(xpFactory)->unref(); 489 grPaint->setXPFactory(xpFactory)->unref();
492 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); 490 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));
493 491
494 //set the color of the paint to the one of the parameter 492 //set the color of the paint to the one of the parameter
495 grPaint->setColor(paintColor); 493 grPaint->setColor(paintColor);
496 494
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { 580 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
583 grPaint->addColorProcessor(fp)->unref(); 581 grPaint->addColorProcessor(fp)->unref();
584 constantColor = false; 582 constantColor = false;
585 } 583 }
586 } 584 }
587 585
588 // The grcolor is automatically set when calling asFragmentProcessor. 586 // The grcolor is automatically set when calling asFragmentProcessor.
589 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 587 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
590 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 588 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
591 } 589 }
OLDNEW
« no previous file with comments | « src/gpu/GrPaint.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698