Plumb GrColorType through all ops/processors that sample textures.
This change also allows for the remove of GrPixelConfigIsOpaque function.
Bug: skia:6718
Change-Id: I7e7b70f02d911eda67640d648fb6348091e0f55d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248698
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index eb198cb..4b5e0a8 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -146,7 +146,7 @@
if (canvas2DFastPath) {
fp = direct->priv().createPMToUPMEffect(
GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
- SkMatrix::I()));
+ this->colorInfo().colorType(), SkMatrix::I()));
if (dstInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
dstInfo = dstInfo.makeColorType(GrColorType::kRGBA_8888);
@@ -156,7 +156,8 @@
// double unpremul.
dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType);
} else {
- fp = GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()), SkMatrix::I());
+ fp = GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
+ this->colorInfo().colorType(), SkMatrix::I());
}
if (!fp) {
return false;
@@ -340,13 +341,14 @@
std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) {
fp = direct->priv().createUPMToPMEffect(
- GrSimpleTextureEffect::Make(std::move(tempProxy), SkMatrix::I()));
+ GrSimpleTextureEffect::Make(std::move(tempProxy), colorType,
+ SkMatrix::I()));
// Important: check the original src color type here!
if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
}
} else {
- fp = GrSimpleTextureEffect::Make(std::move(tempProxy), SkMatrix::I());
+ fp = GrSimpleTextureEffect::Make(std::move(tempProxy), colorType, SkMatrix::I());
}
if (!fp) {
return false;
@@ -452,9 +454,11 @@
int srcY = srcRect.fTop;
sk_sp<GrTextureProxy> texProxy = sk_ref_sp(this->asTextureProxy());
SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
+ GrColorType srcColorType = this->colorInfo().colorType();
if (!texProxy) {
- texProxy = GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), GrMipMapped::kNo, srcRect,
- SkBackingFit::kApprox, SkBudgeted::kNo);
+ texProxy = GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), srcColorType,
+ GrMipMapped::kNo, srcRect, SkBackingFit::kApprox,
+ SkBudgeted::kNo);
if (!texProxy) {
return nullptr;
}
@@ -477,6 +481,7 @@
stepsY = sy != 1.f;
}
SkASSERT(stepsX || stepsY);
+
// Within a rescaling pass A is the input (if not null) and B is the output. At the end of the
// pass B is moved to A. If 'this' is the input on the first pass then tempA is null.
std::unique_ptr<GrRenderTargetContext> tempA;
@@ -497,7 +502,7 @@
if (!linearRTC) {
return nullptr;
}
- linearRTC->drawTexture(GrNoClip(), texProxy, GrSamplerState::Filter::kNearest,
+ linearRTC->drawTexture(GrNoClip(), texProxy, srcColorType, GrSamplerState::Filter::kNearest,
SkBlendMode::kSrc, SK_PMColor4fWHITE, SkRect::Make(srcRect),
SkRect::MakeWH(srcW, srcH), GrAA::kNo, GrQuadAAFlags::kNone,
constraint, SkMatrix::I(), std::move(xform));
@@ -561,9 +566,10 @@
if (srcW != texProxy->width() || srcH != texProxy->height()) {
auto domain = GrTextureDomain::MakeTexelDomain(
SkIRect::MakeXYWH(srcX, srcY, srcW, srcH), GrTextureDomain::kClamp_Mode);
- fp = GrBicubicEffect::Make(texProxy, matrix, domain, dir, prevAlphaType);
+ fp = GrBicubicEffect::Make(texProxy, srcColorType, matrix, domain, dir,
+ prevAlphaType);
} else {
- fp = GrBicubicEffect::Make(texProxy, matrix, dir, prevAlphaType);
+ fp = GrBicubicEffect::Make(texProxy, srcColorType, matrix, dir, prevAlphaType);
}
if (xform) {
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(xform));
@@ -577,9 +583,9 @@
auto filter = rescaleQuality == kNone_SkFilterQuality ? GrSamplerState::Filter::kNearest
: GrSamplerState::Filter::kBilerp;
auto srcSubset = SkRect::MakeXYWH(srcX, srcY, srcW, srcH);
- tempB->drawTexture(GrNoClip(), texProxy, filter, SkBlendMode::kSrc, SK_PMColor4fWHITE,
- srcSubset, dstRect, GrAA::kNo, GrQuadAAFlags::kNone, constraint,
- SkMatrix::I(), std::move(xform));
+ tempB->drawTexture(GrNoClip(), texProxy, srcColorType, filter, SkBlendMode::kSrc,
+ SK_PMColor4fWHITE, srcSubset, dstRect, GrAA::kNo,
+ GrQuadAAFlags::kNone, constraint, SkMatrix::I(), std::move(xform));
}
texProxy = tempB->asTextureProxyRef();
tempA = std::move(tempB);