| 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 | 8 |
| 9 #include "SkGr.h" | 9 #include "SkGr.h" |
| 10 #include "SkGrPriv.h" | 10 #include "SkGrPriv.h" |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 534 |
| 535 // Setup the initial color considering the shader, the SkPaint color, and th
e presence or not | 535 // Setup the initial color considering the shader, the SkPaint color, and th
e presence or not |
| 536 // of per-vertex colors. | 536 // of per-vertex colors. |
| 537 sk_sp<GrFragmentProcessor> shaderFP; | 537 sk_sp<GrFragmentProcessor> shaderFP; |
| 538 if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc))
{ | 538 if (!primColorMode || blend_requires_shader(*primColorMode, primitiveIsSrc))
{ |
| 539 if (shaderProcessor) { | 539 if (shaderProcessor) { |
| 540 shaderFP = *shaderProcessor; | 540 shaderFP = *shaderProcessor; |
| 541 } else if (const SkShader* shader = skPaint.getShader()) { | 541 } else if (const SkShader* shader = skPaint.getShader()) { |
| 542 SkSourceGammaTreatment gammaTreatment = allowSRGBInputs | 542 SkSourceGammaTreatment gammaTreatment = allowSRGBInputs |
| 543 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIg
nore; | 543 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIg
nore; |
| 544 shaderFP = shader->asFragmentProcessor(context, viewM, nullptr, | 544 shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &
viewM, nullptr, |
| 545 skPaint.getFilterQuality(), g
ammaTreatment); | 545 skPaint.ge
tFilterQuality(), |
| 546 gammaTreat
ment)); |
| 546 if (!shaderFP) { | 547 if (!shaderFP) { |
| 547 return false; | 548 return false; |
| 548 } | 549 } |
| 549 } | 550 } |
| 550 } | 551 } |
| 551 | 552 |
| 552 // Set this in below cases if the output of the shader/paint-color/paint-alp
ha/primXfermode is | 553 // Set this in below cases if the output of the shader/paint-color/paint-alp
ha/primXfermode is |
| 553 // a known constant value. In that case we can simply apply a color filter d
uring this | 554 // a known constant value. In that case we can simply apply a color filter d
uring this |
| 554 // conversion without converting the color filter to a GrFragmentProcessor. | 555 // conversion without converting the color filter to a GrFragmentProcessor. |
| 555 bool applyColorFilterToPaintColor = false; | 556 bool applyColorFilterToPaintColor = false; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 const SkMatrix& viewM, | 704 const SkMatrix& viewM, |
| 704 sk_sp<GrFragmentProcessor> fp, | 705 sk_sp<GrFragmentProcessor> fp, |
| 705 bool textureIsAlphaOnly, | 706 bool textureIsAlphaOnly, |
| 706 bool allowSRGBInputs, | 707 bool allowSRGBInputs, |
| 707 GrPaint* grPaint) { | 708 GrPaint* grPaint) { |
| 708 sk_sp<GrFragmentProcessor> shaderFP; | 709 sk_sp<GrFragmentProcessor> shaderFP; |
| 709 if (textureIsAlphaOnly) { | 710 if (textureIsAlphaOnly) { |
| 710 if (const SkShader* shader = paint.getShader()) { | 711 if (const SkShader* shader = paint.getShader()) { |
| 711 SkSourceGammaTreatment gammaTreatment = allowSRGBInputs | 712 SkSourceGammaTreatment gammaTreatment = allowSRGBInputs |
| 712 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIg
nore; | 713 ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIg
nore; |
| 713 shaderFP = shader->asFragmentProcessor(context, | 714 shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, |
| 714 viewM, | 715 &viewM, |
| 715 nullptr, | 716 nullptr, |
| 716 paint.getFilterQuality(), | 717 paint.getF
ilterQuality(), |
| 717 gammaTreatment); | 718 gammaTreat
ment)); |
| 718 if (!shaderFP) { | 719 if (!shaderFP) { |
| 719 return false; | 720 return false; |
| 720 } | 721 } |
| 721 sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(shaderFP), std::
move(fp) }; | 722 sk_sp<GrFragmentProcessor> fpSeries[] = { std::move(shaderFP), std::
move(fp) }; |
| 722 shaderFP = GrFragmentProcessor::RunInSeries(fpSeries, 2); | 723 shaderFP = GrFragmentProcessor::RunInSeries(fpSeries, 2); |
| 723 } else { | 724 } else { |
| 724 shaderFP = GrFragmentProcessor::MulOutputByInputUnpremulColor(fp); | 725 shaderFP = GrFragmentProcessor::MulOutputByInputUnpremulColor(fp); |
| 725 } | 726 } |
| 726 } else { | 727 } else { |
| 727 shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp); | 728 shaderFP = GrFragmentProcessor::MulOutputByInputAlpha(fp); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 SkErrorInternals::SetError( kInvalidPaint_SkError, | 769 SkErrorInternals::SetError( kInvalidPaint_SkError, |
| 769 "Sorry, I don't understand the filtering
" | 770 "Sorry, I don't understand the filtering
" |
| 770 "mode you asked for. Falling back to " | 771 "mode you asked for. Falling back to " |
| 771 "MIPMaps."); | 772 "MIPMaps."); |
| 772 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 773 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 773 break; | 774 break; |
| 774 | 775 |
| 775 } | 776 } |
| 776 return textureFilterMode; | 777 return textureFilterMode; |
| 777 } | 778 } |
| OLD | NEW |