GrPaint grPaint;
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
- kNone_SkFilterQuality,
+ kNone_SkFilterQuality, nullptr,
SkSourceGammaTreatment::kRespect));
}
GrPaint grPaint;
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
- kNone_SkFilterQuality,
+ kNone_SkFilterQuality, nullptr,
SkSourceGammaTreatment::kRespect));
}
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];
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;
};
"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);
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
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
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
- kNone_SkFilterQuality,
+ kNone_SkFilterQuality, nullptr,
SkSourceGammaTreatment::kRespect));
}
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;
}
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;
}
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;
}
#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(
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;
}
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;
}
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;
}
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;
}
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;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(context, paint, viewMatrix, drawContext->isGammaCorrect(),
- &grPaint)) {
+ drawContext->getColorSpace(), &grPaint)) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
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;
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
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;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), newPaint, m,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
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;
}
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;
}
&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;
}
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;
}
}
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;
}
}
// 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;
}
}
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;
}
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(fContext, paint, viewMatrix, fp, producer->isAlphaOnly(),
- gammaCorrect, &grPaint)) {
+ gammaCorrect, fDrawContext->getColorSpace(), &grPaint)) {
return;
}
SkXfermode::Mode* primColorMode,
bool primitiveIsSrc,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
grPaint->setAntiAlias(skPaint.isAntiAlias());
grPaint->setAllowSRGBInputs(allowSRGBInputs);
? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &viewM, nullptr,
skPaint.getFilterQuality(),
+ dstColorSpace,
gammaTreatment));
if (!shaderFP) {
return false;
}
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. */
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
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,
sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint) {
sk_sp<GrFragmentProcessor> shaderFP;
if (textureIsAlphaOnly) {
&viewM,
nullptr,
paint.getFilterQuality(),
+ dstColorSpace,
gammaTreatment));
if (!shaderFP) {
return false;
}
return SkPaintToGrPaintReplaceShader(context, paint, std::move(shaderFP), allowSRGBInputs,
- grPaint);
+ dstColorSpace, grPaint);
}
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
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
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,
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
sk_sp<GrFragmentProcessor> fp,
bool textureIsAlphaOnly,
bool allowSRGBInputs,
+ SkColorSpace* dstColorSpace,
GrPaint* grPaint);
//////////////////////////////////////////////////////////////////////////////
// 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;
}
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");
}
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;
}
}
GrPaint paint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &paint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), dc->getColorSpace(),
+ &paint)) {
return;
}
SkMatrix mat;
mat.reset();
if (!SkPaintToGrPaint(this->context(), paint, mat,
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), fDrawContext->getColorSpace(),
+ &grPaint)) {
return;
}
SkMatrix textureMat;