19#if defined(GR_TEST_UTILS)
24 int maxTreeDepth,
int numViews,
const ViewInfo views[])
25 : GrProcessorTestData(random, context, maxTreeDepth, numViews, views,
29 int maxTreeDepth,
int numViews,
const ViewInfo views[],
30 std::unique_ptr<GrFragmentProcessor> inputFP)
32 , fMaxTreeDepth(maxTreeDepth)
34 , fInputFP(
std::move(inputFP)) {
35 fViews.reset(views, numViews);
36 fArena = std::make_unique<SkArenaAlloc>(1000);
39GrProcessorTestData::~GrProcessorTestData() {}
43const GrCaps* GrProcessorTestData::caps() {
return fContext->priv().caps(); }
45std::unique_ptr<GrFragmentProcessor> GrProcessorTestData::inputFP() {
46 if (fCurrentTreeDepth == 0) {
48 return fInputFP ? fInputFP->clone() :
nullptr;
55GrProcessorTestData::ViewInfo GrProcessorTestData::randomView() {
57 return fViews[fRandom->nextULessThan(fViews.size())];
60GrProcessorTestData::ViewInfo GrProcessorTestData::randomAlphaOnlyView() {
62 for (
const auto& [v, ct, at] : fViews) {
68 int idx = fRandom->nextULessThan(numAlphaOnly);
69 for (
const auto& [v, ct, at] : fViews) {
77template <
class ProcessorSmartPtr>
78GrProcessorTestFactory<ProcessorSmartPtr>::GrProcessorTestFactory(MakeProc makeProc,
81 GetFactories()->push_back(
this);
84template <
class ProcessorSmartPtr>
87 if (GetFactories()->
size() == 0) {
90 uint32_t idx =
data->fRandom->nextULessThan(GetFactories()->
size());
91 return MakeIdx(idx,
data);
94template <
class ProcessorSmartPtr>
95ProcessorSmartPtr GrProcessorTestFactory<ProcessorSmartPtr>::MakeIdx(
int idx,
96 GrProcessorTestData*
data) {
98 GrProcessorTestFactory<ProcessorSmartPtr>* factory = (*GetFactories())[idx];
99 ProcessorSmartPtr processor = factory->fMakeProc(
data);
100 if (processor ==
nullptr) {
101 SK_ABORT(
"%s: TestCreate returned null", factory->fName.c_str());
106template <
class ProcessorSmartPtr>
107int GrProcessorTestFactory<ProcessorSmartPtr>::Count() {
108 return GetFactories()->size();
111GrXPFactoryTestFactory::GrXPFactoryTestFactory(GetFn* getProc) : fGetProc(getProc) {
112 GetFactories()->push_back(
this);
116 VerifyFactoryCount();
117 if (GetFactories()->
size() == 0) {
120 uint32_t idx =
data->fRandom->nextRangeU(0, GetFactories()->
size() - 1);
152static constexpr int kFPFactoryCount = 10;
153static constexpr int kGPFactoryCount = 14;
154static constexpr int kXPFactoryCount = 4;
156template <>
void GrFragmentProcessorTestFactory::VerifyFactoryCount() {
157 if (kFPFactoryCount != GetFactories()->
size()) {
158 SkDebugf(
"\nExpected %d fragment processor factories, found %d.\n", kFPFactoryCount,
159 GetFactories()->
size());
160 SK_ABORT(
"Wrong number of fragment processor factories!");
164template <>
void GrGeometryProcessorTestFactory::VerifyFactoryCount() {
165 if (kGPFactoryCount != GetFactories()->
size()) {
166 SkDebugf(
"\nExpected %d geometry processor factories, found %d.\n", kGPFactoryCount,
167 GetFactories()->
size());
168 SK_ABORT(
"Wrong number of geometry processor factories!");
172void GrXPFactoryTestFactory::VerifyFactoryCount() {
173 if (kXPFactoryCount != GetFactories()->
size()) {
174 SkDebugf(
"\nExpected %d xp factory factories, found %d.\n", kXPFactoryCount,
175 GetFactories()->
size());
176 SK_ABORT(
"Wrong number of xp factory factories!");
181 std::unique_ptr<GrFragmentProcessor>
fp;
183 ++
data->fCurrentTreeDepth;
184 if (
data->fCurrentTreeDepth >
data->fMaxTreeDepth) {
194 if (
data->fCurrentTreeDepth <
data->fMaxTreeDepth ||
195 fp->numNonNullChildProcessors() == 0) {
201 --
data->fCurrentTreeDepth;
205std::unique_ptr<GrFragmentProcessor> GrProcessorUnitTest::MakeOptionalChildFP(
206 GrProcessorTestData*
data) {
210template class GrProcessorTestFactory<GrGeometryProcessor*>;
211template class GrProcessorTestFactory<std::unique_ptr<GrFragmentProcessor>>;
static constexpr bool GrColorTypeIsAlphaOnly(GrColorType ct)
#define SK_ABORT(message,...)
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static std::unique_ptr< GrFragmentProcessor > MakeColor(SkPMColor4f color)
const GrXPFactory * Get(SkBlendMode mode)
GrFPResult MakeChildFP(const SkRuntimeEffect::ChildPtr &child, const GrFPArgs &childArgs)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data