Update existing TestCreate methods to honor the inputFP in the TestData.

This can be leveraged to build chains of test FPs in a controlled way.
At present, `inputFP` it is never set to anything other than null; as
such, all calls to TestCreate continue to set a null inputFP
(exactly as they do already).

Change-Id: I0d74f37a076ca338e44ff734816299beb1667c26
Bug: skia:10384
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302668
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-07-17 14:52:12 -04:00 committed by Skia Commit-Bot
parent d0c9d0cb7f
commit 6609cb6452
24 changed files with 57 additions and 65 deletions

View File

@ -389,7 +389,7 @@ protected:
private:
sk_sp<SkColorFilterBase> fCF0;
sk_sp<SkColorFilterBase> fCF1;
const float fWeight;
const float fWeight;
friend class SkColorFilter;

View File

@ -369,7 +369,7 @@ std::unique_ptr<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTes
));
sk_sp<SkColorSpace> colorSpace = GrTest::TestColorSpace(d->fRandom);
auto [success, fp] = as_CFB(filter)->asFragmentProcessor(
/*inputFP=*/nullptr, d->context(),
d->inputFP(), d->context(),
GrColorInfo(GrColorType::kRGBA_8888, kUnknown_SkAlphaType, std::move(colorSpace)));
SkASSERT(success);
return std::move(fp);

View File

@ -13,11 +13,10 @@
#if GR_TEST_UTILS
GrProcessorTestData::GrProcessorTestData(SkRandom* random,
GrRecordingContext* context,
int numViews,
const ViewInfo views[])
: fRandom(random), fContext(context) {
GrProcessorTestData::GrProcessorTestData(SkRandom* random, GrRecordingContext* context,
int numViews, const ViewInfo views[],
std::unique_ptr<GrFragmentProcessor> inputFP)
: fRandom(random), fContext(context), fInputFP(std::move(inputFP)) {
fViews.reset(views, numViews);
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
}
@ -28,6 +27,8 @@ GrProxyProvider* GrProcessorTestData::proxyProvider() { return fContext->priv().
const GrCaps* GrProcessorTestData::caps() { return fContext->priv().caps(); }
std::unique_ptr<GrFragmentProcessor> GrProcessorTestData::inputFP() { return std::move(fInputFP); }
GrProcessorTestData::ViewInfo GrProcessorTestData::randomView() {
SkASSERT(!fViews.empty());
return fViews[fRandom->nextULessThan(fViews.count())];

View File

@ -53,7 +53,9 @@ class GrProcessorTestData {
public:
using ViewInfo = std::tuple<GrSurfaceProxyView, GrColorType, SkAlphaType>;
GrProcessorTestData(SkRandom*, GrRecordingContext*, int numViews, const ViewInfo views[]);
GrProcessorTestData(SkRandom* random, GrRecordingContext* context,
int numViews, const ViewInfo views[],
std::unique_ptr<GrFragmentProcessor> inputFP = nullptr);
GrProcessorTestData(const GrProcessorTestData&) = delete;
~GrProcessorTestData();
@ -61,6 +63,7 @@ public:
GrProxyProvider* proxyProvider();
const GrCaps* caps();
SkArenaAlloc* allocator() { return fArena.get(); }
std::unique_ptr<GrFragmentProcessor> inputFP();
ViewInfo randomView();
ViewInfo randomAlphaOnlyView();

View File

@ -13,7 +13,7 @@ uniform float4 rectUniform;
@optimizationFlags {
(inputFP ? ProcessorOptimizationFlags(inputFP.get()) : kAll_OptimizationFlags) &
kCompatibleWithCoverageAsAlpha_OptimizationFlag
kCompatibleWithCoverageAsAlpha_OptimizationFlag
}
void main() {
@ -59,12 +59,8 @@ void main() {
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1());
std::unique_ptr<GrFragmentProcessor> fp;
do {
GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
fp = GrAARectEffect::Make(/*inputFP=*/nullptr, edgeType, rect);
} while (nullptr == fp);
return fp;
return GrAARectEffect::Make(d->inputFP(), edgeType, rect);
}

View File

@ -305,6 +305,6 @@ void main() {
SkScalar wh = testData->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = testData->fRandom->nextRangeF(1.f, 10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
return GrCircleBlurFragmentProcessor::Make(/*inputFP=*/nullptr, testData->context(),
return GrCircleBlurFragmentProcessor::Make(testData->inputFP(), testData->context(),
circle, sigma);
}

View File

@ -77,10 +77,10 @@ void main() {
center.fY = testData->fRandom->nextRangeScalar(0.f, 1000.f);
SkScalar radius = testData->fRandom->nextRangeF(1.f, 1000.f);
bool success;
std::unique_ptr<GrFragmentProcessor> fp;
std::unique_ptr<GrFragmentProcessor> fp = testData->inputFP();
do {
GrClipEdgeType et = (GrClipEdgeType)testData->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
std::tie(success, fp) = GrCircleEffect::Make(/*inputFP=*/nullptr, et, center, radius);
std::tie(success, fp) = GrCircleEffect::Make(std::move(fp), et, center, radius);
} while (!success);
return fp;
}

View File

@ -37,5 +37,5 @@ void main() {
}
@test(d) {
return GrClampFragmentProcessor::Make(/*inputFP=*/nullptr, d->fRandom->nextBool());
return GrClampFragmentProcessor::Make(d->inputFP(), d->fRandom->nextBool());
}

View File

@ -85,5 +85,5 @@ void main() {
bool unpremul = d->fRandom->nextBool();
bool clampRGB = d->fRandom->nextBool();
bool premul = d->fRandom->nextBool();
return Make(/*inputFP=*/nullptr, m, unpremul, clampRGB, premul);
return Make(d->inputFP(), m, unpremul, clampRGB, premul);
}

View File

@ -226,16 +226,13 @@ std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::TestCreate(GrProcessorT
edges[i] = d->fRandom->nextSScalar1();
}
std::unique_ptr<GrFragmentProcessor> fp;
bool success;
std::unique_ptr<GrFragmentProcessor> fp = d->inputFP();
do {
GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(
d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
auto [success, convexPolyFP] = GrConvexPolyEffect::Make(/*inputFP=*/nullptr, edgeType,
count, edges);
if (success) {
fp = std::move(convexPolyFP);
}
} while (nullptr == fp);
GrClipEdgeType edgeType =
static_cast<GrClipEdgeType>(d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
std::tie(success, fp) = GrConvexPolyEffect::Make(std::move(fp), edgeType, count, edges);
} while (!success);
return fp;
}
#endif

View File

@ -130,10 +130,10 @@ void main() {
SkScalar rx = testData->fRandom->nextRangeF(0.f, 1000.f);
SkScalar ry = testData->fRandom->nextRangeF(0.f, 1000.f);
bool success;
std::unique_ptr<GrFragmentProcessor> fp;
std::unique_ptr<GrFragmentProcessor> fp = testData->inputFP();
do {
GrClipEdgeType et = (GrClipEdgeType)testData->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
std::tie(success, fp) = GrEllipseEffect::Make(/*inputFP=*/nullptr, et, center,
std::tie(success, fp) = GrEllipseEffect::Make(std::move(fp), et, center,
SkPoint::Make(rx, ry),
*testData->caps()->shaderCaps());
} while (!success);

View File

@ -128,6 +128,6 @@ void main() {
SkHighContrastConfig config{/*grayscale=*/d->fRandom->nextBool(),
InvertStyle(d->fRandom->nextRangeU(0, int(InvertStyle::kLast))),
/*contrast=*/d->fRandom->nextF()};
return GrHighContrastFilterEffect::Make(/*inputFP=*/nullptr, config,
return GrHighContrastFilterEffect::Make(d->inputFP(), config,
/*linearize=*/d->fRandom->nextBool());
}

View File

@ -176,7 +176,7 @@ uniform half blurRadius;
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
return GrRRectBlurEffect::Make(/*inputFP=*/nullptr, d->context(), sigma, sigma, rrect, rrect);
return GrRRectBlurEffect::Make(d->inputFP(), d->context(), sigma, sigma, rrect, rrect);
}
void main() {

View File

@ -132,12 +132,12 @@ std::unique_ptr<GrFragmentProcessor> CircularRRectEffect::TestCreate(GrProcessor
SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
std::unique_ptr<GrFragmentProcessor> fp;
std::unique_ptr<GrFragmentProcessor> fp = d->inputFP();
bool success;
do {
GrClipEdgeType et =
(GrClipEdgeType)d->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
std::tie(success, fp) = GrRRectEffect::Make(/*inputFP=*/nullptr, et, rrect,
std::tie(success, fp) = GrRRectEffect::Make(std::move(fp), et, rrect,
*d->caps()->shaderCaps());
} while (!success);
return fp;
@ -501,11 +501,11 @@ std::unique_ptr<GrFragmentProcessor> EllipticalRRectEffect::TestCreate(GrProcess
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
std::unique_ptr<GrFragmentProcessor> fp;
std::unique_ptr<GrFragmentProcessor> fp = d->inputFP();
bool success;
do {
GrClipEdgeType et = (GrClipEdgeType)d->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
std::tie(success, fp) = GrRRectEffect::Make(/*inputFP=*/nullptr, et, rrect,
std::tie(success, fp) = GrRRectEffect::Make(std::move(fp), et, rrect,
*d->caps()->shaderCaps());
} while (!success);
return fp;

View File

@ -208,6 +208,6 @@ void main() {
float sigma = data->fRandom->nextRangeF(3,8);
float width = data->fRandom->nextRangeF(200,300);
float height = data->fRandom->nextRangeF(200,300);
return GrRectBlurEffect::Make(/*inputFP=*/nullptr, data->context(), *data->caps()->shaderCaps(),
return GrRectBlurEffect::Make(data->inputFP(), data->context(), *data->caps()->shaderCaps(),
SkRect::MakeWH(width, height), sigma);
}

View File

@ -57,13 +57,13 @@ half alpha;
args.fUniformHandler->getUniformCStr(rectUniformVar),
args.fUniformHandler->getUniformCStr(rectUniformVar), (int)_outer.edgeType,
(int)_outer.edgeType);
SkString _sample1677 = this->invokeChild(0, args);
SkString _sample1678 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(
half4 inputColor = %s;
%s = inputColor * alpha;
)SkSL",
_sample1677.c_str(), args.fOutputColor);
_sample1678.c_str(), args.fOutputColor);
}
private:
@ -116,13 +116,9 @@ std::unique_ptr<GrFragmentProcessor> GrAARectEffect::TestCreate(GrProcessorTestD
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1(),
d->fRandom->nextSScalar1());
std::unique_ptr<GrFragmentProcessor> fp;
do {
GrClipEdgeType edgeType =
static_cast<GrClipEdgeType>(d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
GrClipEdgeType edgeType =
static_cast<GrClipEdgeType>(d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
fp = GrAARectEffect::Make(/*inputFP=*/nullptr, edgeType, rect);
} while (nullptr == fp);
return fp;
return GrAARectEffect::Make(d->inputFP(), edgeType, rect);
}
#endif

View File

@ -366,7 +366,7 @@ std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate(
SkScalar wh = testData->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = testData->fRandom->nextRangeF(1.f, 10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
return GrCircleBlurFragmentProcessor::Make(/*inputFP=*/nullptr, testData->context(), circle,
return GrCircleBlurFragmentProcessor::Make(testData->inputFP(), testData->context(), circle,
sigma);
}
#endif

View File

@ -128,10 +128,10 @@ std::unique_ptr<GrFragmentProcessor> GrCircleEffect::TestCreate(GrProcessorTestD
center.fY = testData->fRandom->nextRangeScalar(0.f, 1000.f);
SkScalar radius = testData->fRandom->nextRangeF(1.f, 1000.f);
bool success;
std::unique_ptr<GrFragmentProcessor> fp;
std::unique_ptr<GrFragmentProcessor> fp = testData->inputFP();
do {
GrClipEdgeType et = (GrClipEdgeType)testData->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
std::tie(success, fp) = GrCircleEffect::Make(/*inputFP=*/nullptr, et, center, radius);
std::tie(success, fp) = GrCircleEffect::Make(std::move(fp), et, center, radius);
} while (!success);
return fp;
}

View File

@ -67,6 +67,6 @@ std::unique_ptr<GrFragmentProcessor> GrClampFragmentProcessor::clone() const {
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrClampFragmentProcessor);
#if GR_TEST_UTILS
std::unique_ptr<GrFragmentProcessor> GrClampFragmentProcessor::TestCreate(GrProcessorTestData* d) {
return GrClampFragmentProcessor::Make(/*inputFP=*/nullptr, d->fRandom->nextBool());
return GrClampFragmentProcessor::Make(d->inputFP(), d->fRandom->nextBool());
}
#endif

View File

@ -133,6 +133,6 @@ std::unique_ptr<GrFragmentProcessor> GrColorMatrixFragmentProcessor::TestCreate(
bool unpremul = d->fRandom->nextBool();
bool clampRGB = d->fRandom->nextBool();
bool premul = d->fRandom->nextBool();
return Make(/*inputFP=*/nullptr, m, unpremul, clampRGB, premul);
return Make(d->inputFP(), m, unpremul, clampRGB, premul);
}
#endif

View File

@ -169,12 +169,11 @@ std::unique_ptr<GrFragmentProcessor> GrEllipseEffect::TestCreate(GrProcessorTest
SkScalar rx = testData->fRandom->nextRangeF(0.f, 1000.f);
SkScalar ry = testData->fRandom->nextRangeF(0.f, 1000.f);
bool success;
std::unique_ptr<GrFragmentProcessor> fp;
std::unique_ptr<GrFragmentProcessor> fp = testData->inputFP();
do {
GrClipEdgeType et = (GrClipEdgeType)testData->fRandom->nextULessThan(kGrClipEdgeTypeCnt);
std::tie(success, fp) =
GrEllipseEffect::Make(/*inputFP=*/nullptr, et, center, SkPoint::Make(rx, ry),
*testData->caps()->shaderCaps());
std::tie(success, fp) = GrEllipseEffect::Make(
std::move(fp), et, center, SkPoint::Make(rx, ry), *testData->caps()->shaderCaps());
} while (!success);
return fp;
}

View File

@ -170,7 +170,7 @@ std::unique_ptr<GrFragmentProcessor> GrHighContrastFilterEffect::TestCreate(
SkHighContrastConfig config{/*grayscale=*/d->fRandom->nextBool(),
InvertStyle(d->fRandom->nextRangeU(0, int(InvertStyle::kLast))),
/*contrast=*/d->fRandom->nextF()};
return GrHighContrastFilterEffect::Make(/*inputFP=*/nullptr, config,
return GrHighContrastFilterEffect::Make(d->inputFP(), config,
/*linearize=*/d->fRandom->nextBool());
}
#endif

View File

@ -94,18 +94,18 @@ half2 texCoord = translatedFragPos / proxyDims;)SkSL",
args.fUniformHandler->getUniformCStr(proxyRectVar),
args.fUniformHandler->getUniformCStr(blurRadiusVar),
args.fUniformHandler->getUniformCStr(cornerRadiusVar));
SkString _sample9561 = this->invokeChild(0, args);
SkString _sample9554 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
R"SkSL(
half4 inputColor = %s;)SkSL",
_sample9561.c_str());
SkString _coords9609("float2(texCoord)");
SkString _sample9609 = this->invokeChild(1, args, _coords9609.c_str());
_sample9554.c_str());
SkString _coords9602("float2(texCoord)");
SkString _sample9602 = this->invokeChild(1, args, _coords9602.c_str());
fragBuilder->codeAppendf(
R"SkSL(
%s = inputColor * %s;
)SkSL",
args.fOutputColor, _sample9609.c_str());
args.fOutputColor, _sample9602.c_str());
}
private:
@ -167,6 +167,6 @@ std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTe
SkScalar sigma = d->fRandom->nextRangeF(1.f, 10.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
return GrRRectBlurEffect::Make(/*inputFP=*/nullptr, d->context(), sigma, sigma, rrect, rrect);
return GrRRectBlurEffect::Make(d->inputFP(), d->context(), sigma, sigma, rrect, rrect);
}
#endif

View File

@ -157,7 +157,7 @@ std::unique_ptr<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTes
float sigma = data->fRandom->nextRangeF(3, 8);
float width = data->fRandom->nextRangeF(200, 300);
float height = data->fRandom->nextRangeF(200, 300);
return GrRectBlurEffect::Make(/*inputFP=*/nullptr, data->context(), *data->caps()->shaderCaps(),
return GrRectBlurEffect::Make(data->inputFP(), data->context(), *data->caps()->shaderCaps(),
SkRect::MakeWH(width, height), sigma);
}
#endif