From 96271cd1805d55b1a985652eebd0399ebe415283 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 31 Jul 2017 16:27:23 -0400 Subject: Require clone() be implemented by GrFragmentProcessor subclasses Change-Id: I66ba0978e5748806d563ff4f26000e4e0095ed24 Reviewed-on: https://skia-review.googlesource.com/29042 Reviewed-by: Ethan Nicholas Commit-Queue: Brian Salomon --- tests/ProcessorTest.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'tests/ProcessorTest.cpp') diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 3bfd62e3a4..e2625a7e31 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -84,15 +84,7 @@ public: } sk_sp clone() const override { - sk_sp child; - if (this->numChildProcessors()) { - SkASSERT(1 == this->numChildProcessors()); - child = this->childProcessor(0).clone(); - if (!child) { - return nullptr; - } - } - return sk_sp (new TestFP(*this, std::move(child))); + return sk_sp(new TestFP(*this)); } private: @@ -120,7 +112,7 @@ private: this->registerChildProcessor(std::move(child)); } - explicit TestFP(const TestFP& that, sk_sp child) + explicit TestFP(const TestFP& that) : INHERITED(that.optimizationFlags()), fSamplers(4), fBuffers(4), fImages(4) { this->initClassID(); for (int i = 0; i < that.fSamplers.count(); ++i) { @@ -135,8 +127,8 @@ private: fImages.emplace_back(that.fImages[i]); this->addImageStorageAccess(&fImages.back()); } - if (child) { - this->registerChildProcessor(std::move(child)); + for (int i = 0; i < that.numChildProcessors(); ++i) { + this->registerChildProcessor(that.childProcessor(i).clone()); } } @@ -554,8 +546,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) { for (int j = 0; j < kTimesToInvokeFactory; ++j) { auto fp = GrFragmentProcessorTestFactory::MakeIdx(i, &testData); auto clone = fp->clone(); - // Currently clone() is allowed to fail. if (!clone) { + ERRORF(reporter, "Clone of processor %s failed.", fp->name()); continue; } if (!fp->instantiate(context->resourceProvider()) || -- cgit v1.2.3