OLD | NEW |
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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 507 |
508 /////////////////////////////////////////////////////////////////////////////// | 508 /////////////////////////////////////////////////////////////////////////////// |
509 | 509 |
510 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
paintColor, | 510 void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
paintColor, |
511 bool constantColor, GrPaint* grPaint) { | 511 bool constantColor, GrPaint* grPaint) { |
512 | 512 |
513 grPaint->setDither(skPaint.isDither()); | 513 grPaint->setDither(skPaint.isDither()); |
514 grPaint->setAntiAlias(skPaint.isAntiAlias()); | 514 grPaint->setAntiAlias(skPaint.isAntiAlias()); |
515 | 515 |
516 SkXfermode* mode = skPaint.getXfermode(); | 516 SkXfermode* mode = skPaint.getXfermode(); |
517 GrFragmentProcessor* fragmentProcessor = NULL; | |
518 GrXPFactory* xpFactory = NULL; | 517 GrXPFactory* xpFactory = NULL; |
519 if (SkXfermode::AsFragmentProcessorOrXPFactory(mode, &fragmentProcessor, &xp
Factory)) { | 518 if (!SkXfermode::AsXPFactory(mode, &xpFactory)) { |
520 if (fragmentProcessor) { | |
521 SkASSERT(NULL == xpFactory); | |
522 grPaint->addColorProcessor(fragmentProcessor)->unref(); | |
523 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode); | |
524 } | |
525 } else { | |
526 // Fall back to src-over | 519 // Fall back to src-over |
527 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode); | 520 xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode); |
528 } | 521 } |
529 SkASSERT(xpFactory); | 522 SkASSERT(xpFactory); |
530 grPaint->setXPFactory(xpFactory)->unref(); | 523 grPaint->setXPFactory(xpFactory)->unref(); |
531 | 524 |
532 //set the color of the paint to the one of the parameter | 525 //set the color of the paint to the one of the parameter |
533 grPaint->setColor(paintColor); | 526 grPaint->setColor(paintColor); |
534 | 527 |
535 SkColorFilter* colorFilter = skPaint.getColorFilter(); | 528 SkColorFilter* colorFilter = skPaint.getColorFilter(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { | 590 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol
or, &fp) && fp) { |
598 grPaint->addColorProcessor(fp)->unref(); | 591 grPaint->addColorProcessor(fp)->unref(); |
599 constantColor = false; | 592 constantColor = false; |
600 } | 593 } |
601 } | 594 } |
602 | 595 |
603 // The grcolor is automatically set when calling asFragmentProcessor. | 596 // The grcolor is automatically set when calling asFragmentProcessor. |
604 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. | 597 // If the shader can be seen as an effect it returns true and adds its effec
t to the grpaint. |
605 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
); | 598 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
); |
606 } | 599 } |
OLD | NEW |