diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-10-09 10:54:08 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-09 15:20:33 +0000 |
commit | abff956455637b12eab374fd44b99e1338799113 (patch) | |
tree | 77f932f38b3f00f904faeae1c847f1218f61d0c4 /tests | |
parent | 4e7cdd5a0052aa76bed6f80ec325be19e09e6ab1 (diff) |
initClassID no longer auto-allocates ids
Auto-allocated IDs mean that the IDs depend upon the order in which
classes happen to get initialized and are therefore not consistent
from run to run. This change paves the way for a persistent shader
cache by fixing the IDs in an enum.
Bug: skia:
Change-Id: I3e923c6c54f41b3b3eb616458abee83e0909c09f
Reviewed-on: https://skia-review.googlesource.com/56401
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GLProgramsTest.cpp | 5 | ||||
-rw-r--r-- | tests/GrMeshTest.cpp | 4 | ||||
-rw-r--r-- | tests/GrPipelineDynamicStateTest.cpp | 7 | ||||
-rw-r--r-- | tests/ImageStorageTest.cpp | 6 | ||||
-rw-r--r-- | tests/PrimitiveProcessorTest.cpp | 6 | ||||
-rw-r--r-- | tests/ProcessorTest.cpp | 12 | ||||
-rw-r--r-- | tests/SkSLFPTest.cpp | 8 |
7 files changed, 22 insertions, 26 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 522bb71db7..55ffca911f 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -78,7 +78,7 @@ public: std::unique_ptr<GrFragmentProcessor> clone() const override { return Make(); } private: - BigKeyProcessor() : INHERITED(kNone_OptimizationFlags) { this->initClassID<BigKeyProcessor>(); } + BigKeyProcessor() : INHERITED(kBigKeyProcessor_ClassID, kNone_OptimizationFlags) { } virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { GLBigKeyProcessor::GenKey(*this, caps, b); @@ -126,8 +126,7 @@ private: }; BlockInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> child) - : INHERITED(kNone_OptimizationFlags) { - this->initClassID<BlockInputFragmentProcessor>(); + : INHERITED(kBlockInputFragmentProcessor_ClassID, kNone_OptimizationFlags) { this->registerChildProcessor(std::move(child)); } diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index 1ae3926699..c2b1f2d3a1 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -281,7 +281,8 @@ private: class GrMeshTestProcessor : public GrGeometryProcessor { public: GrMeshTestProcessor(bool instanced, bool hasVertexBuffer) - : fInstanceLocation(nullptr) + : INHERITED(kGrMeshTestProcessor_ClassID) + , fInstanceLocation(nullptr) , fVertex(nullptr) , fColor(nullptr) { if (instanced) { @@ -294,7 +295,6 @@ public: fVertex = &this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType); fColor = &this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType); } - this->initClassID<GrMeshTestProcessor>(); } const char* name() const override { return "GrMeshTest Processor"; } diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index 4b8621db04..6b518abdb2 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -59,10 +59,9 @@ struct Vertex { class GrPipelineDynamicStateTestProcessor : public GrGeometryProcessor { public: GrPipelineDynamicStateTestProcessor() - : fVertex(this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType)) - , fColor(this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType)) { - this->initClassID<GrPipelineDynamicStateTestProcessor>(); - } + : INHERITED(kGrPipelineDynamicStateTestProcessor_ClassID) + , fVertex(this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType)) + , fColor(this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType)) {} const char* name() const override { return "GrPipelineDynamicStateTest Processor"; } diff --git a/tests/ImageStorageTest.cpp b/tests/ImageStorageTest.cpp index 445a72fcb9..a8704c6264 100644 --- a/tests/ImageStorageTest.cpp +++ b/tests/ImageStorageTest.cpp @@ -33,16 +33,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) { private: TestFP(sk_sp<GrTextureProxy> proxy, GrSLMemoryModel mm, GrSLRestrict restrict) - : INHERITED(kNone_OptimizationFlags) + : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags) , fImageStorageAccess(std::move(proxy), kRead_GrIOType, mm, restrict) { - this->initClassID<TestFP>(); this->addImageStorageAccess(&fImageStorageAccess); } explicit TestFP(const TestFP& that) - : INHERITED(that.optimizationFlags()) + : INHERITED(kTestFP_ClassID, that.optimizationFlags()) , fImageStorageAccess(that.fImageStorageAccess) { - this->initClassID<TestFP>(); this->addImageStorageAccess(&fImageStorageAccess); } diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 8898e35266..004ec88cc2 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -53,8 +53,8 @@ private: void onPrepareDraws(Target* target) override { class GP : public GrGeometryProcessor { public: - GP(int numAttribs) { - this->initClassID<GP>(); + GP(int numAttribs) + : INHERITED(kGP_ClassID) { SkASSERT(numAttribs > 1); for (auto i = 0; i < numAttribs; ++i) { fAttribNames.push_back().printf("attr%d", i); @@ -89,6 +89,8 @@ private: private: SkTArray<SkString> fAttribNames; + + typedef GrGeometryProcessor INHERITED; }; sk_sp<GrGeometryProcessor> gp(new GP(fNumAttribs)); QuadHelper helper; diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 056302ea66..ba90dc2ca6 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -97,8 +97,8 @@ private: TestFP(const SkTArray<sk_sp<GrTextureProxy>>& proxies, const SkTArray<sk_sp<GrBuffer>>& buffers, const SkTArray<Image>& images) - : INHERITED(kNone_OptimizationFlags), fSamplers(4), fBuffers(4), fImages(4) { - this->initClassID<TestFP>(); + : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4), fBuffers(4), + fImages(4) { for (const auto& proxy : proxies) { this->addTextureSampler(&fSamplers.emplace_back(proxy)); } @@ -113,14 +113,14 @@ private: } TestFP(std::unique_ptr<GrFragmentProcessor> child) - : INHERITED(kNone_OptimizationFlags), fSamplers(4), fBuffers(4), fImages(4) { - this->initClassID<TestFP>(); + : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4), fBuffers(4), + fImages(4) { this->registerChildProcessor(std::move(child)); } explicit TestFP(const TestFP& that) - : INHERITED(that.optimizationFlags()), fSamplers(4), fBuffers(4), fImages(4) { - this->initClassID<TestFP>(); + : INHERITED(kTestFP_ClassID, that.optimizationFlags()), fSamplers(4), fBuffers(4), + fImages(4) { for (int i = 0; i < that.fSamplers.count(); ++i) { fSamplers.emplace_back(that.fSamplers[i]); this->addTextureSampler(&fSamplers.back()); diff --git a/tests/SkSLFPTest.cpp b/tests/SkSLFPTest.cpp index dc9279573d..3e95d9975f 100644 --- a/tests/SkSLFPTest.cpp +++ b/tests/SkSLFPTest.cpp @@ -93,8 +93,7 @@ DEF_TEST(SkSLFPHelloWorld, r) { " const char* name() const override { return \"Test\"; }\n" "private:\n" " GrTest()\n" - " : INHERITED(kNone_OptimizationFlags) {\n" - " this->initClassID<GrTest>();\n" + " : INHERITED(kGrTest_ClassID, kNone_OptimizationFlags) {\n" " }\n" " GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;\n" " void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) " @@ -151,8 +150,7 @@ DEF_TEST(SkSLFPHelloWorld, r) { " return true;\n" "}\n" "GrTest::GrTest(const GrTest& src)\n" - ": INHERITED(src.optimizationFlags()) {\n" - " this->initClassID<GrTest>();\n" + ": INHERITED(kGrTest_ClassID, src.optimizationFlags()) {\n" "}\n" "std::unique_ptr<GrFragmentProcessor> GrTest::clone() const {\n" " return std::unique_ptr<GrFragmentProcessor>(new GrTest(*this));\n" @@ -279,7 +277,7 @@ DEF_TEST(SkSLFPSections, r) { "}", *SkSL::ShaderCapsFactory::Default(), { - ": INHERITED(kNone_OptimizationFlags)\n , initializers section" + ": INHERITED(kGrTest_ClassID, kNone_OptimizationFlags)\n , initializers section" }, {}); test(r, |