Connect dst color space in a few places (removing TODOs)
There is one more XFORMTODO left, but it requires more plumbing.
With this change, certain drawing paths do gamut conversion with
no special hacking required.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2174843002
Review-Url: https://codereview.chromium.org/2174843002
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index e077fee..c2f220c 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -373,6 +373,7 @@
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
+ SkColorSpace* dstColorSpace,
SkSourceGammaTreatment gammaTreatment) {
SkMatrix textureMatrix = origTextureMatrix;
@@ -425,7 +426,6 @@
SkASSERT(kNoDomain_DomainMode == domainMode ||
(domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
textureMatrix.postIDiv(texture->width(), texture->height());
- SkColorSpace* dstColorSpace = nullptr; // XFORMTODO
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(this->getColorSpace(),
dstColorSpace);
return create_fp_for_domain_and_filter(texture, std::move(colorSpaceXform), textureMatrix,
@@ -474,6 +474,7 @@
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
+ SkColorSpace* dstColorSpace,
SkSourceGammaTreatment gammaTreatment) {
const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBicubic;
@@ -507,7 +508,6 @@
SkASSERT(kTightCopy_DomainMode != domainMode);
SkMatrix normalizedTextureMatrix = textureMatrix;
normalizedTextureMatrix.postIDiv(texture->width(), texture->height());
- SkColorSpace* dstColorSpace = nullptr; // XFORMTODO
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(this->getColorSpace(),
dstColorSpace);
return create_fp_for_domain_and_filter(texture, std::move(colorSpaceXform),
diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h
index eee761f..4377ae5 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -65,6 +65,7 @@
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
+ SkColorSpace* dstColorSpace,
SkSourceGammaTreatment) = 0;
virtual ~GrTextureProducer() {}
@@ -138,6 +139,7 @@
FilterConstraint,
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
+ SkColorSpace* dstColorSpace,
SkSourceGammaTreatment) override;
protected:
@@ -179,6 +181,7 @@
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
+ SkColorSpace* dstColorSpace,
SkSourceGammaTreatment) override;
protected:
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 20e5afe..873256d 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1104,9 +1104,8 @@
return;
}
- SkColorSpace* dstColorSpace = nullptr; // XFORMTODO
- sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(bitmap.colorSpace(),
- dstColorSpace);
+ sk_sp<GrColorSpaceXform> colorSpaceXform =
+ GrColorSpaceXform::Make(bitmap.colorSpace(), fDrawContext->getColorSpace());
SkRect dstRect = {0, 0, srcRect.width(), srcRect.height() };
SkRect paintRect;
SkScalar wInv = SkScalarInvert(SkIntToScalar(texture->width()));
@@ -1545,7 +1544,7 @@
producer->createFragmentProcessor(SkMatrix::I(),
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
- &kMode, gammaTreatment));
+ &kMode, fDrawContext->getColorSpace(), gammaTreatment));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std::move(fp),
producer->isAlphaOnly(), gammaCorrect, &grPaint)) {
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 8dc4926..e402985 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -206,7 +206,7 @@
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
sk_sp<GrFragmentProcessor> fp(producer->createFragmentProcessor(
*textureMatrix, clippedSrcRect, constraintMode, coordsAllInsideSrcRect, filterMode,
- gammaTreatment));
+ fDrawContext->getColorSpace(), gammaTreatment));
if (!fp) {
return;
}