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 <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-07-08 16:53:13 -04:00 committed by Skia Commit-Bot
parent eb7703565a
commit 8c3171f531

View File

@ -87,11 +87,6 @@ sk_sp<SkImage> 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> 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()));