Supply random dst color space to asFP in unit tests
TBR=bsalomon@google.com (Testing-only API change) BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2876 Change-Id: I0ca26da0307848cdfc8ffaac2d042601663ab00b Reviewed-on: https://skia-review.googlesource.com/2876 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
70cdb396eb
commit
0d9dfe981e
@ -729,8 +729,9 @@ sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData*
|
||||
|
||||
GrPaint grPaint;
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto colorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
|
||||
kNone_SkFilterQuality, nullptr,
|
||||
kNone_SkFilterQuality, colorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
}
|
||||
|
||||
@ -1137,8 +1138,9 @@ sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTe
|
||||
|
||||
GrPaint grPaint;
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto colorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
|
||||
kNone_SkFilterQuality, nullptr,
|
||||
kNone_SkFilterQuality, colorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ const SkPath& TestPathConvex(SkRandom*);
|
||||
SkStrokeRec TestStrokeRec(SkRandom*);
|
||||
/** Creates styles with dash path effects and null path effects */
|
||||
void TestStyle(SkRandom*, GrStyle*);
|
||||
sk_sp<SkColorSpace> TestColorSpace(SkRandom*);
|
||||
sk_sp<GrColorSpaceXform> TestColorXform(SkRandom*);
|
||||
|
||||
// We have a simplified dash path effect here to avoid relying on SkDashPathEffect which
|
||||
|
@ -593,8 +593,9 @@ sk_sp<GrFragmentProcessor> GrPerlinNoiseEffect::TestCreate(GrProcessorTestData*
|
||||
stitchTiles ? &tileSize : nullptr));
|
||||
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto colorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
return shader->asFragmentProcessor(SkShader::AsFPArgs(d->fContext, &viewMatrix, nullptr,
|
||||
kNone_SkFilterQuality, nullptr,
|
||||
kNone_SkFilterQuality, colorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
}
|
||||
|
||||
|
@ -421,8 +421,9 @@ sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d)
|
||||
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
|
||||
auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
|
@ -315,8 +315,9 @@ sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d)
|
||||
int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
|
||||
auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
|
@ -198,8 +198,9 @@ sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
|
||||
sk_sp<SkShader> shader(SkGradientShader::MakeSweep(center.fX, center.fY, colors, stops,
|
||||
colorCount));
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
|
@ -207,8 +207,9 @@ sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
|
||||
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
|
||||
colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
@ -482,8 +483,9 @@ sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
|
||||
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
|
||||
colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
@ -686,8 +688,9 @@ sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
|
||||
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
|
||||
colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
@ -932,8 +935,9 @@ sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorT
|
||||
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
|
||||
colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
@ -1165,8 +1169,9 @@ sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessor
|
||||
auto shader = SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,
|
||||
colors, stops, colorCount, tm);
|
||||
SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
|
||||
auto dstColorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPArgs(
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, nullptr,
|
||||
d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, dstColorSpace.get(),
|
||||
SkSourceGammaTreatment::kRespect));
|
||||
GrAlwaysAssert(fp);
|
||||
return fp;
|
||||
|
@ -290,6 +290,20 @@ SkPathEffect::DashType TestDashPathEffect::asADash(DashInfo* info) const {
|
||||
return kDash_DashType;
|
||||
}
|
||||
|
||||
sk_sp<SkColorSpace> TestColorSpace(SkRandom* random) {
|
||||
static sk_sp<SkColorSpace> gColorSpaces[3];
|
||||
static bool gOnce;
|
||||
if (!gOnce) {
|
||||
gOnce = true;
|
||||
// No color space (legacy mode)
|
||||
gColorSpaces[0] = nullptr;
|
||||
// sRGB or Adobe
|
||||
gColorSpaces[1] = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
|
||||
gColorSpaces[2] = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named);
|
||||
}
|
||||
return gColorSpaces[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gColorSpaces)))];
|
||||
}
|
||||
|
||||
sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) {
|
||||
static sk_sp<GrColorSpaceXform> gXforms[3];
|
||||
static bool gOnce;
|
||||
|
Loading…
Reference in New Issue
Block a user