Reland "Add support for unpremul image sources in the GPU backend"
This reverts commit cbf64e3634ee7adfddf221e7ba525672ee226580.
Reason for revert: Ancestral CLs have re-landed.
Original change's description:
> Revert "Add support for unpremul image sources in the GPU backend"
>
> This reverts commit f06240de2c4583c8d8ef2e798dd4636e6cfe8f47.
>
> Reason for revert: I think this requires the skcms codec change to re-land,
>
> Original change's description:
> > Add support for unpremul image sources in the GPU backend
> >
> > Change-Id: Ib940fa0d658fff0b2dd923abfcc5ca4a49b2b38b
> > Reviewed-on: https://skia-review.googlesource.com/148397
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Reviewed-by: Mike Klein <mtklein@google.com>
>
> TBR=mtklein@google.com,bsalomon@google.com,brianosman@google.com
>
> Change-Id: Ib9358cf858c3c0887322503a4b021e08a0ac4cd5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/148861
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
TBR=mtklein@google.com,bsalomon@google.com,brianosman@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I20d8d17f5cc6ed1a359c0f7af1c96bf5304f6885
Reviewed-on: https://skia-review.googlesource.com/149804
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index cc5803f..b6ed9b3 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -316,7 +316,7 @@
// object. If that produces something, then both are tagged, and the source is in a different
// gamut than the dest. There is some overhead to making the xform, but those are cached, and
// if we get one back, that means we're about to use it during the conversion anyway.
- auto colorSpaceXform = GrColorSpaceXform::Make(src->getColorSpace(), kPremul_SkAlphaType,
+ auto colorSpaceXform = GrColorSpaceXform::Make(src->getColorSpace(), src->alphaType(),
outProps.colorSpace(), kPremul_SkAlphaType);
if (!colorSpaceXform) {
diff --git a/src/effects/SkToSRGBColorFilter.cpp b/src/effects/SkToSRGBColorFilter.cpp
index d5fdec0..4b5558d 100644
--- a/src/effects/SkToSRGBColorFilter.cpp
+++ b/src/effects/SkToSRGBColorFilter.cpp
@@ -52,6 +52,7 @@
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkToSRGBColorFilter::asFragmentProcessor(
GrContext*, const GrColorSpaceInfo&) const {
- return GrColorSpaceXformEffect::Make(fSrcColorSpace.get(), sk_srgb_singleton());
+ return GrColorSpaceXformEffect::Make(fSrcColorSpace.get(), kPremul_SkAlphaType,
+ sk_srgb_singleton());
}
#endif
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index 9dc8ae4..4e2b0f4 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -176,7 +176,7 @@
const OutputProperties& outProps = ctx.outputProperties();
auto textureFP = GrSimpleTextureEffect::Make(std::move(inputProxy), SkMatrix::I());
textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(),
- outProps.colorSpace());
+ input->alphaType(), outProps.colorSpace());
if (!textureFP) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index e392d55..644494e 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -316,6 +316,7 @@
GrTextureDomain::MakeTexelDomain(background->subset()),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
+ background->alphaType(),
outputProperties.colorSpace());
} else {
bgFP = GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
@@ -331,6 +332,7 @@
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),
foreground->getColorSpace(),
+ foreground->alphaType(),
outputProperties.colorSpace());
paint.addColorFragmentProcessor(std::move(foregroundFP));
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index 92ac807..9a2d054 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -306,7 +306,8 @@
offsetMatrix,
std::move(colorProxy),
SkISize::Make(color->width(), color->height()));
- fp = GrColorSpaceXformEffect::Make(std::move(fp), color->getColorSpace(), colorSpace);
+ fp = GrColorSpaceXformEffect::Make(std::move(fp), color->getColorSpace(),
+ color->alphaType(), colorSpace);
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
diff --git a/src/effects/imagefilters/SkMagnifierImageFilter.cpp b/src/effects/imagefilters/SkMagnifierImageFilter.cpp
index 88d7862..c17e8fa 100644
--- a/src/effects/imagefilters/SkMagnifierImageFilter.cpp
+++ b/src/effects/imagefilters/SkMagnifierImageFilter.cpp
@@ -115,7 +115,7 @@
bounds.width() * invInset,
bounds.height() * invInset);
fp = GrColorSpaceXformEffect::Make(std::move(fp), input->getColorSpace(),
- ctx.outputProperties().colorSpace());
+ input->alphaType(), ctx.outputProperties().colorSpace());
if (!fp) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index cc5cacb..9dc577d 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -286,6 +286,7 @@
GrTextureDomain::kDecal_Mode,
GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
+ background->alphaType(),
outputProperties.colorSpace());
} else {
bgFP = GrConstColorProcessor::Make(GrColor4f::TransparentBlack(),
@@ -301,6 +302,7 @@
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),
foreground->getColorSpace(),
+ foreground->alphaType(),
outputProperties.colorSpace());
paint.addColorFragmentProcessor(std::move(foregroundFP));
diff --git a/src/gpu/GrColorSpaceXform.cpp b/src/gpu/GrColorSpaceXform.cpp
index 484654f..b0b23ea 100644
--- a/src/gpu/GrColorSpaceXform.cpp
+++ b/src/gpu/GrColorSpaceXform.cpp
@@ -146,8 +146,9 @@
}
std::unique_ptr<GrFragmentProcessor> GrColorSpaceXformEffect::Make(SkColorSpace* src,
+ SkAlphaType srcAT,
SkColorSpace* dst) {
- auto xform = GrColorSpaceXform::Make(src, kPremul_SkAlphaType,
+ auto xform = GrColorSpaceXform::Make(src, srcAT,
dst, kPremul_SkAlphaType);
if (!xform) {
return nullptr;
@@ -159,12 +160,12 @@
std::unique_ptr<GrFragmentProcessor> GrColorSpaceXformEffect::Make(
std::unique_ptr<GrFragmentProcessor> child,
- SkColorSpace* src, SkColorSpace* dst) {
+ SkColorSpace* src, SkAlphaType srcAT, SkColorSpace* dst) {
if (!child) {
return nullptr;
}
- auto xform = GrColorSpaceXform::Make(src, kPremul_SkAlphaType,
+ auto xform = GrColorSpaceXform::Make(src, srcAT,
dst, kPremul_SkAlphaType);
if (!xform) {
return child;
diff --git a/src/gpu/GrColorSpaceXform.h b/src/gpu/GrColorSpaceXform.h
index b55c9dd..d824dcd 100644
--- a/src/gpu/GrColorSpaceXform.h
+++ b/src/gpu/GrColorSpaceXform.h
@@ -51,14 +51,16 @@
/**
* Returns a fragment processor that converts the input's color space from src to dst.
*/
- static std::unique_ptr<GrFragmentProcessor> Make(SkColorSpace* src, SkColorSpace* dst);
+ static std::unique_ptr<GrFragmentProcessor> Make(SkColorSpace* src, SkAlphaType srcAT,
+ SkColorSpace* dst);
/**
* Returns a fragment processor that calls the passed in fragment processor, and then converts
* the color space of the output from src to dst.
*/
static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child,
- SkColorSpace* src, SkColorSpace* dst);
+ SkColorSpace* src, SkAlphaType srcAT,
+ SkColorSpace* dst);
const char* name() const override { return "ColorSpaceXform"; }
std::unique_ptr<GrFragmentProcessor> clone() const override;
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index b2fc058..0f65b5b 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -162,5 +162,5 @@
(domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
auto fp = CreateFragmentProcessorForDomainAndFilter(std::move(proxy), textureMatrix,
domainMode, domain, filterOrNullForBicubic);
- return GrColorSpaceXformEffect::Make(std::move(fp), fColorSpace, dstColorSpace);
+ return GrColorSpaceXformEffect::Make(std::move(fp), fColorSpace, fAlphaType, dstColorSpace);
}
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index 820e47a..16bcefa 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -152,5 +152,6 @@
SkASSERT(kTightCopy_DomainMode != domainMode);
auto fp = CreateFragmentProcessorForDomainAndFilter(std::move(proxy), adjustedMatrix,
domainMode, domain, filterOrNullForBicubic);
- return GrColorSpaceXformEffect::Make(std::move(fp), texColorSpace.get(), dstColorSpace);
+ return GrColorSpaceXformEffect::Make(std::move(fp), texColorSpace.get(), this->alphaType(),
+ dstColorSpace);
}
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 3c6c7f7..9ffd8a7 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -130,7 +130,7 @@
// If the caller expects the pixels in a different color space than the one from the image,
// apply a color conversion to do this.
std::unique_ptr<GrFragmentProcessor> colorConversionProcessor =
- GrColorSpaceXformEffect::Make(srcColorSpace, dstColorSpace);
+ GrColorSpaceXformEffect::Make(srcColorSpace, kPremul_SkAlphaType, dstColorSpace);
if (colorConversionProcessor) {
paint.addColorFragmentProcessor(std::move(colorConversionProcessor));
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 4b71068..6bc4c2d 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1010,7 +1010,7 @@
fp = GrSimpleTextureEffect::Make(std::move(proxy), texMatrix, samplerState);
}
- fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(),
+ fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
fRenderTargetContext->colorSpaceInfo().colorSpace());
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
@@ -1083,7 +1083,7 @@
tmpUnfiltered.setImageFilter(nullptr);
auto fp = GrSimpleTextureEffect::Make(std::move(proxy), SkMatrix::I());
- fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(),
+ fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorSpaceInfo().colorSpace());
if (GrPixelConfigIsAlphaOnly(config)) {
fp = GrFragmentProcessor::MakeInputPremulAndMulByOutput(std::move(fp));
@@ -1406,7 +1406,7 @@
if (!proxy) {
return;
}
- auto csxf = GrColorSpaceXform::Make(proxyColorSpace.get(), kPremul_SkAlphaType,
+ auto csxf = GrColorSpaceXform::Make(proxyColorSpace.get(), producer->alphaType(),
dstColorSpace, kPremul_SkAlphaType);
fRenderTargetContext->drawImageLattice(this->clip(), std::move(grPaint), this->ctm(),
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 5b61e7f..47ee36a 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -99,7 +99,7 @@
static void draw_texture(const SkPaint& paint, const SkMatrix& ctm, const SkRect* src,
const SkRect* dst, GrAA aa, SkCanvas::SrcRectConstraint constraint,
- sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrTextureProxy> proxy, SkAlphaType alphaType,
SkColorSpace* colorSpace, const GrClip& clip, GrRenderTargetContext* rtc) {
SkASSERT(!(SkToBool(src) && !SkToBool(dst)));
SkRect srcRect = src ? *src : SkRect::MakeWH(proxy->width(), proxy->height());
@@ -112,7 +112,7 @@
srcToDst.mapRect(&dstRect, srcRect);
}
auto textureXform =
- GrColorSpaceXform::Make(colorSpace , kPremul_SkAlphaType,
+ GrColorSpaceXform::Make(colorSpace , alphaType,
rtc->colorSpaceInfo().colorSpace(), kPremul_SkAlphaType);
GrSamplerState::Filter filter;
switch (paint.getFilterQuality()) {
@@ -150,7 +150,7 @@
GrAA aa = GrAA(paint.isAntiAlias());
if (can_use_draw_texture(paint)) {
draw_texture(paint, viewMatrix, srcRect, dstRect, aa, constraint, std::move(proxy),
- colorSpace, this->clip(), fRenderTargetContext.get());
+ alphaType, colorSpace, this->clip(), fRenderTargetContext.get());
return;
}
GrTextureAdjuster adjuster(this->context(), std::move(proxy), alphaType, pinnedUniqueID,
@@ -174,7 +174,7 @@
return;
}
draw_texture(paint, viewMatrix, srcRect, dstRect, aa, constraint, std::move(proxy),
- cs.get(), this->clip(), fRenderTargetContext.get());
+ maker->alphaType(), cs.get(), this->clip(), fRenderTargetContext.get());
return;
}
this->drawTextureProducer(maker, srcRect, dstRect, constraint, viewMatrix, paint);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 556373d..e4836e9 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -944,7 +944,7 @@
srcSpace = SkColorSpace::MakeSRGB();
}
- auto xform = GrColorSpaceXformEffect::Make(srcSpace.get(), target.get());
+ auto xform = GrColorSpaceXformEffect::Make(srcSpace.get(), this->alphaType(), target.get());
if (!xform) {
return sk_ref_sp(const_cast<SkImage_Gpu*>(this));
}
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 9619a45..28c569f 100644
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -242,6 +242,7 @@
inner = GrSimpleTextureEffect::Make(std::move(proxy), lmInverse, samplerState);
}
inner = GrColorSpaceXformEffect::Make(std::move(inner), texColorSpace.get(),
+ fImage->alphaType(),
args.fDstColorSpaceInfo->colorSpace());
if (isAlphaOnly) {
return inner;