Remove SK_ALLOW_STATIC_GLOBAL_INITIALIZERS from tests.
The tests themselves should run fine if no factories were actually registered. This isolates the last uses of this flag to the gpu code which is actually depending on it. Change-Id: Ief9c01abfc37c4e071d946d70ef85f13f94ae0f6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213301 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
4167215daf
commit
f1344ac239
@ -27,7 +27,6 @@ GrProxyProvider* GrProcessorTestData::proxyProvider() {
|
||||
|
||||
const GrCaps* GrProcessorTestData::caps() { return fContext->priv().caps(); }
|
||||
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
class GrFragmentProcessor;
|
||||
class GrGeometryProcessor;
|
||||
|
||||
@ -57,9 +56,15 @@ SkTArray<GrXPFactoryTestFactory*, true>* GrXPFactoryTestFactory::GetFactories()
|
||||
* we verify the count is as expected. If a new factory is added, then these numbers must be
|
||||
* manually adjusted.
|
||||
*/
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
static const int kFPFactoryCount = 36;
|
||||
static const int kGPFactoryCount = 14;
|
||||
static const int kXPFactoryCount = 4;
|
||||
#else
|
||||
static const int kFPFactoryCount = 0;
|
||||
static const int kGPFactoryCount = 0;
|
||||
static const int kXPFactoryCount = 0;
|
||||
#endif
|
||||
|
||||
template <>
|
||||
void GrFragmentProcessorTestFactory::VerifyFactoryCount() {
|
||||
@ -88,7 +93,6 @@ void GrXPFactoryTestFactory::VerifyFactoryCount() {
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on
|
||||
|
@ -73,8 +73,6 @@ private:
|
||||
sk_sp<GrTextureProxy> fProxies[2];
|
||||
};
|
||||
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
||||
class GrProcessor;
|
||||
class GrTexture;
|
||||
|
||||
@ -92,7 +90,9 @@ public:
|
||||
/** Pick a random factory function and create a processor. */
|
||||
static ProcessorSmartPtr Make(GrProcessorTestData* data) {
|
||||
VerifyFactoryCount();
|
||||
SkASSERT(GetFactories()->count());
|
||||
if (GetFactories()->count() == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
|
||||
return MakeIdx(idx, data);
|
||||
}
|
||||
@ -102,6 +102,7 @@ public:
|
||||
|
||||
/** Use factory function at Index idx to create a processor. */
|
||||
static ProcessorSmartPtr MakeIdx(int idx, GrProcessorTestData* data) {
|
||||
SkASSERT(idx < GetFactories()->count());
|
||||
GrProcessorTestFactory<ProcessorSmartPtr>* factory = (*GetFactories())[idx];
|
||||
ProcessorSmartPtr processor = factory->fMakeProc(data);
|
||||
SkASSERT(processor);
|
||||
@ -130,7 +131,9 @@ public:
|
||||
|
||||
static const GrXPFactory* Get(GrProcessorTestData* data) {
|
||||
VerifyFactoryCount();
|
||||
SkASSERT(GetFactories()->count());
|
||||
if (GetFactories()->count() == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
|
||||
const GrXPFactory* xpf = (*GetFactories())[idx]->fGetProc(data);
|
||||
SkASSERT(xpf);
|
||||
@ -144,6 +147,8 @@ private:
|
||||
static SkTArray<GrXPFactoryTestFactory*, true>* GetFactories();
|
||||
};
|
||||
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
||||
/** GrProcessor subclasses should insert this macro in their declaration to be included in the
|
||||
* program generation unit test.
|
||||
*/
|
||||
|
@ -5,12 +5,10 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
// This is a GPU-backend specific test. It relies on static intializers to work
|
||||
// This is a GPU-backend specific test.
|
||||
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
||||
#include "include/private/SkChecksum.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
#include "src/gpu/GrAutoLocaleSetter.h"
|
||||
@ -189,7 +187,9 @@ static std::unique_ptr<GrFragmentProcessor> create_random_proc_tree(GrProcessorT
|
||||
std::unique_ptr<GrFragmentProcessor> fp;
|
||||
while (true) {
|
||||
fp = GrFragmentProcessorTestFactory::Make(d);
|
||||
SkASSERT(fp);
|
||||
if (!fp) {
|
||||
return nullptr;
|
||||
}
|
||||
if (0 == fp->numChildProcessors()) {
|
||||
break;
|
||||
}
|
||||
@ -205,6 +205,9 @@ static std::unique_ptr<GrFragmentProcessor> create_random_proc_tree(GrProcessorT
|
||||
}
|
||||
auto minLevelsChild = create_random_proc_tree(d, minLevels, maxLevels - 1);
|
||||
std::unique_ptr<GrFragmentProcessor> otherChild(create_random_proc_tree(d, 1, maxLevels - 1));
|
||||
if (!minLevelsChild || !otherChild) {
|
||||
return nullptr;
|
||||
}
|
||||
SkBlendMode mode = static_cast<SkBlendMode>(d->fRandom->nextRangeU(0,
|
||||
(int)SkBlendMode::kLastMode));
|
||||
std::unique_ptr<GrFragmentProcessor> fp;
|
||||
@ -235,17 +238,17 @@ static void set_random_color_coverage_stages(GrPaint* paint,
|
||||
int numProcs = d->fRandom->nextULessThan(maxStages + 1);
|
||||
int numColorProcs = d->fRandom->nextULessThan(numProcs + 1);
|
||||
|
||||
for (int s = 0; s < numProcs;) {
|
||||
for (int s = 0; s < numProcs; ++s) {
|
||||
std::unique_ptr<GrFragmentProcessor> fp(GrFragmentProcessorTestFactory::Make(d));
|
||||
SkASSERT(fp);
|
||||
|
||||
if (!fp) {
|
||||
continue;
|
||||
}
|
||||
// finally add the stage to the correct pipeline in the drawstate
|
||||
if (s < numColorProcs) {
|
||||
paint->addColorFragmentProcessor(std::move(fp));
|
||||
} else {
|
||||
paint->addCoverageFragmentProcessor(std::move(fp));
|
||||
}
|
||||
++s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -426,4 +429,3 @@ DEF_GPUTEST(GLPrograms, reporter, options) {
|
||||
opts);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -227,9 +227,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
// This test uses the random GrFragmentProcessor test factory, which relies on static initializers.
|
||||
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
||||
#include "tools/flags/CommandLineFlags.h"
|
||||
static DEFINE_bool(randomProcessorTest, false,
|
||||
"Use non-deterministic seed for random processor tests?");
|
||||
@ -758,4 +755,3 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
#endif // GR_TEST_UTILS
|
||||
#endif // SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
|
||||
|
Loading…
Reference in New Issue
Block a user