Add destination color space to AsFPArgs. Eliminates last XFORMTODO.
This is going to be needed in many more places as I finish connecting the
dots. Even better - I'd like to switch to a world where SkColorSpace !=
nullptr is the only signal we use for gamma-correct rendering, so I can
eliminate SkSourceGammaTreatment and SkSurfaceProps::isGammaCorrect.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2180503002
Review-Url: https://codereview.chromium.org/2180503002
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index ac34492..cfea408 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -730,7 +730,7 @@
GrPaint grPaint;
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
- kNone_SkFilterQuality,
+ kNone_SkFilterQuality, nullptr,
SkSourceGammaTreatment::kRespect));
}
@@ -1138,7 +1138,7 @@
GrPaint grPaint;
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
- kNone_SkFilterQuality,
+ kNone_SkFilterQuality, nullptr,
SkSourceGammaTreatment::kRespect));
}
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 32d03a0..3a5d73a 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -100,7 +100,8 @@
skPaint.setColor(kPaintColors[paintType]);
}
// SRGBTODO: No sRGB inputs allowed here?
- SkAssertResult(SkPaintToGrPaint(context, skPaint, viewMatrix, false, &grPaint));
+ SkAssertResult(SkPaintToGrPaint(context, skPaint, viewMatrix, false, nullptr,
+ &grPaint));
GrConstColorProcessor::InputMode mode = (GrConstColorProcessor::InputMode) m;
GrColor color = kColors[procColor];
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 5301f46..69037d9 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -316,17 +316,20 @@
const SkMatrix* viewMatrix,
const SkMatrix* localMatrix,
SkFilterQuality filterQuality,
+ SkColorSpace* dstColorSpace,
SkSourceGammaTreatment gammaTreatment)
: fContext(context)
, fViewMatrix(viewMatrix)
, fLocalMatrix(localMatrix)
, fFilterQuality(filterQuality)
+ , fDstColorSpace(dstColorSpace)
, fGammaTreatment(gammaTreatment) {}
GrContext* fContext;
const SkMatrix* fViewMatrix;
const SkMatrix* fLocalMatrix;
SkFilterQuality fFilterQuality;
+ SkColorSpace* fDstColorSpace;
SkSourceGammaTreatment fGammaTreatment;
};
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 406cc6f..006fedf 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -457,9 +457,8 @@
"Couldn't convert bitmap to texture.");
return nullptr;
}
- SkColorSpace* dstColorSpace = nullptr; // XFORMTODO
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fRawBitmap.colorSpace(),
- dstColorSpace);
+ args.fDstColorSpace);
sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
inner = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), matrix, tm);
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index 4f74138..cdd7533 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -18,7 +18,8 @@
tmp.preConcat(*args.fLocalMatrix);
}
return fProxyShader->asFragmentProcessor(AsFPArgs(
- args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fGammaTreatment));
+ args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fDstColorSpace,
+ args.fGammaTreatment));
}
#endif
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 1b1189c..3349558 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -329,6 +329,7 @@
return nullptr;
}
return bitmapShader->asFragmentProcessor(SkShader::AsFPArgs(
- args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fGammaTreatment));
+ args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fDstColorSpace,
+ args.fGammaTreatment));
}
#endif
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index e7b7fa3..7e49117 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -594,7 +594,7 @@
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
- kNone_SkFilterQuality,
+ kNone_SkFilterQuality, nullptr,
SkSourceGammaTreatment::kRespect));
}
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index f1a9eaf..cdac5c8 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -420,7 +420,8 @@
auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index bcedb7f..a3afe5a 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -314,7 +314,8 @@
auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 31f4816..8732534 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -193,7 +193,8 @@
colorCount));
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 359ff9e..9c09701 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -357,7 +357,7 @@
#include "SkGr.h"
sk_sp<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProcessor(
- const AsFPArgs& args) const {
+ const AsFPArgs& args) const {
SkASSERT(args.fContext);
SkASSERT(fPtsToUnit.isIdentity());
sk_sp<GrFragmentProcessor> inner(
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index 438b1b5..f1fe012 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -210,7 +210,8 @@
colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
@@ -487,7 +488,8 @@
colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
@@ -695,7 +697,8 @@
colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
@@ -943,7 +946,8 @@
colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
@@ -1176,7 +1180,8 @@
colors, stops, colorCount, tm);
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
- d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTreatment::kRespect));
+ d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
+ SkSourceGammaTreatment::kRespect));
GrAlwaysAssert(fp);
return fp;
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index f6d6fc2..27d7dff 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -288,7 +288,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(context, paint, viewMatrix, drawContext->isGammaCorrect(),
- &grPaint)) {
+ drawContext->getColorSpace(), &grPaint)) {
return;
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 873256d..88f5847 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -365,7 +365,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -416,7 +417,8 @@
GrStyle style(paint, SkPaint::kStroke_Style);
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
SkPath path;
@@ -437,7 +439,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -475,7 +478,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -493,7 +497,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -569,7 +574,8 @@
if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -614,7 +620,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -671,7 +678,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), newPaint, m,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -1168,7 +1176,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, std::move(fp),
kAlpha_8_SkColorType == bitmap.colorType(),
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
@@ -1259,7 +1268,8 @@
fp = GrFragmentProcessor::MulOutputByInputAlpha(std::move(fp));
}
if (!SkPaintToGrPaintReplaceShader(this->context(), tmpUnfiltered, std::move(fp),
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
@@ -1547,7 +1557,8 @@
&kMode, fDrawContext->getColorSpace(), gammaTreatment));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, std::move(fp),
- producer->isAlphaOnly(), gammaCorrect, &grPaint)) {
+ producer->isAlphaOnly(), gammaCorrect,
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
@@ -1615,7 +1626,8 @@
GrPaint grPaint;
// we ignore the shader if texs is null.
if (!SkPaintToGrPaintNoShader(this->context(), copy,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
@@ -1688,13 +1700,14 @@
}
if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMatrix, colorMode,
false, this->surfaceProps().isGammaCorrect(),
- &grPaint)) {
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
} else {
// We have a shader, but no colors to blend it against.
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
}
@@ -1704,13 +1717,14 @@
// we should ignore the shader).
if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint,
this->surfaceProps().isGammaCorrect(),
- &grPaint)) {
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
} else {
// No colors and no shaders. Just draw with the paint color.
if (!SkPaintToGrPaintNoShader(this->context(), paint,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
}
@@ -1748,12 +1762,14 @@
GrPaint grPaint;
if (colors) {
if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mode, true,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
} else {
if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(),
+ fDrawContext->getColorSpace(), &grPaint)) {
return;
}
}
@@ -1773,7 +1789,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -1792,7 +1809,8 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index e402985..6014e95 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -213,7 +213,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(fContext, paint, viewMatrix, fp, producer->isAlphaOnly(),
- gammaCorrect, &grPaint)) {
+ gammaCorrect, fDrawContext->getColorSpace(), &grPaint)) {
return;
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 15c3892..cc05f7a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -518,6 +518,7 @@
SkXfermode::Mode* primColorMode,
bool primitiveIsSrc,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
grPaint->setAntiAlias(skPaint.isAntiAlias());
grPaint->setAllowSRGBInputs(allowSRGBInputs);
@@ -543,6 +544,7 @@
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &viewM, nullptr,
skPaint.getFilterQuality(),
+ dstColorSpace,
gammaTreatment));
if (!shaderFP) {
return false;
@@ -656,9 +658,9 @@
}
bool SkPaintToGrPaint(GrContext* context, const SkPaint& skPaint, const SkMatrix& viewM,
- bool allowSRGBInputs, GrPaint* grPaint) {
+ bool allowSRGBInputs, SkColorSpace* dstColorSpace, GrPaint* grPaint) {
return skpaint_to_grpaint_impl(context, skPaint, viewM, nullptr, nullptr, false,
- allowSRGBInputs, grPaint);
+ allowSRGBInputs, dstColorSpace, grPaint);
}
/** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProcessor. */
@@ -666,24 +668,26 @@
const SkPaint& skPaint,
sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
if (!shaderFP) {
return false;
}
return skpaint_to_grpaint_impl(context, skPaint, SkMatrix::I(), &shaderFP, nullptr, false,
- allowSRGBInputs, grPaint);
+ allowSRGBInputs, dstColorSpace, grPaint);
}
/** Ignores the SkShader (if any) on skPaint. */
bool SkPaintToGrPaintNoShader(GrContext* context,
const SkPaint& skPaint,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
// Use a ptr to a nullptr to to indicate that the SkShader is ignored and not replaced.
static sk_sp<GrFragmentProcessor> kNullShaderFP(nullptr);
static sk_sp<GrFragmentProcessor>* kIgnoreShader = &kNullShaderFP;
return skpaint_to_grpaint_impl(context, skPaint, SkMatrix::I(), kIgnoreShader, nullptr, false,
- allowSRGBInputs, grPaint);
+ allowSRGBInputs, dstColorSpace, grPaint);
}
/** Blends the SkPaint's shader (or color if no shader) with a per-primitive color which must
@@ -694,9 +698,10 @@
SkXfermode::Mode primColorMode,
bool primitiveIsSrc,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
return skpaint_to_grpaint_impl(context, skPaint, viewM, nullptr, &primColorMode, primitiveIsSrc,
- allowSRGBInputs, grPaint);
+ allowSRGBInputs, dstColorSpace, grPaint);
}
bool SkPaintToGrPaintWithTexture(GrContext* context,
@@ -705,6 +710,7 @@
sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
sk_sp<GrFragmentProcessor> shaderFP;
if (textureIsAlphaOnly) {
@@ -715,6 +721,7 @@
&viewM,
nullptr,
paint.getFilterQuality(),
+ dstColorSpace,
gammaTreatment));
if (!shaderFP) {
return false;
@@ -729,7 +736,7 @@
}
return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), allowSRGBInputs,
- grPaint);
+ dstColorSpace, grPaint);
}
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 7188856..ad1e88a 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -49,12 +49,14 @@
const SkPaint& skPaint,
const SkMatrix& viewM,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint);
/** Same as above but ignores the SkShader (if any) on skPaint. */
bool SkPaintToGrPaintNoShader(GrContext* context,
const SkPaint& skPaint,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint);
/** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProcessor. The processor
@@ -64,6 +66,7 @@
const SkPaint& skPaint,
sk_sp<GrFragmentProcessor> shaderFP,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint);
/** Blends the SkPaint's shader (or color if no shader) with the color which specified via a
@@ -76,6 +79,7 @@
SkXfermode::Mode primColorMode,
bool primitiveIsSrc,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint);
/** This is used when there is a primitive color, but the shader should be ignored. Currently,
@@ -83,9 +87,10 @@
unpremultiplied so that interpolation is done in unpremul space. The paint's alpha will be
applied to the primitive color after interpolation. */
inline bool SkPaintToGrPaintWithPrimitiveColor(GrContext* context, const SkPaint& skPaint,
- bool allowSRGBInputs, GrPaint* grPaint) {
+ bool allowSRGBInputs, SkColorSpace* dstColorSpace,
+ GrPaint* grPaint) {
return SkPaintToGrPaintWithXfermode(context, skPaint, SkMatrix::I(), SkXfermode::kDst_Mode,
- false, allowSRGBInputs, grPaint);
+ false, allowSRGBInputs, dstColorSpace, grPaint);
}
/** This is used when there may or may not be a shader, and the caller wants to plugin a texture
@@ -96,6 +101,7 @@
sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint);
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index ff62b1f..9b66d2f 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -124,7 +124,8 @@
// Though for the time being runs in the textblob can override the paint, they only touch font
// info.
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.isGammaCorrect(), &grPaint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.isGammaCorrect(), dc->getColorSpace(),
+ &grPaint)) {
return;
}
@@ -398,7 +399,7 @@
skPaint.setSubpixelText(random->nextBool());
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCorrect(),
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCorrect(), nullptr,
&grPaint)) {
SkFAIL("couldn't convert paint\n");
}
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index ebf735a..9c75da4 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -165,7 +165,8 @@
runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, runPaint, viewMatrix, dc->isGammaCorrect(), &grPaint)) {
+ if (!SkPaintToGrPaint(context, runPaint, viewMatrix, dc->isGammaCorrect(),
+ dc->getColorSpace(), &grPaint)) {
return;
}
@@ -220,7 +221,8 @@
}
GrPaint paint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &paint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), dc->getColorSpace(),
+ &paint)) {
return;
}
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 21761c2..f7c1f0c 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -140,7 +140,8 @@
SkMatrix mat;
mat.reset();
if (!SkPaintToGrPaint(this->context(), paint, mat,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
SkMatrix textureMat;