From 8c3171f5317524ef3ace170dc4610717d9700818 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Wed, 8 Jul 2020 16:53:13 -0400 Subject: [PATCH] Update onMakeColorTypeAndColorSpace to consolidate color processors. Rather than adding multiple color processors to the GrPaint, we now use child FPs to compose the desired operation. Change-Id: Ie4397c2ca75cb1d8a65920756355efd4e274e636 Bug: skia:10217 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301220 Reviewed-by: Brian Osman Commit-Queue: John Stiles --- src/image/SkImage_Gpu.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 34383f92ad..79b3fc08c3 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -87,11 +87,6 @@ sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con return nullptr; } - auto xform = GrColorSpaceXformEffect::Make(/*childFP=*/nullptr, - this->colorSpace(), this->alphaType(), - targetCS.get(), this->alphaType()); - SkASSERT(xform || targetCT != this->colorType()); - auto renderTargetContext = GrRenderTargetContext::MakeWithFallback( context, SkColorTypeToGrColorType(targetCT), nullptr, SkBackingFit::kExact, this->dimensions()); @@ -99,12 +94,15 @@ sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con return nullptr; } + auto texFP = GrTextureEffect::Make(*this->view(context), this->alphaType()); + auto colorFP = GrColorSpaceXformEffect::Make(std::move(texFP), + this->colorSpace(), this->alphaType(), + targetCS.get(), this->alphaType()); + SkASSERT(colorFP); + GrPaint paint; paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.addColorFragmentProcessor(GrTextureEffect::Make(*this->view(context), this->alphaType())); - if (xform) { - paint.addColorFragmentProcessor(std::move(xform)); - } + paint.addColorFragmentProcessor(std::move(colorFP)); renderTargetContext->drawRect(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(), SkRect::MakeIWH(this->width(), this->height()));