diff options
author | Robert Phillips <robertphillips@google.com> | 2018-06-12 10:11:12 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-12 14:43:03 +0000 |
commit | 7c525e62d405d57ae7a7742cf607b9770a83a0ab (patch) | |
tree | 8dabe9ed08bddd398b8fac935decaf2743f5a6f7 /tests | |
parent | 7deacf4833dcdb6c1101a18a2b46a8c516a96f9a (diff) |
Plumb GrContext everywhere
There is no good way to split the monster CL up. This breaks out
the GrContext plumbing but doesn't use it.
Change-Id: I90856d428d372bcec3f8821e6364667b367927d4
Reviewed-on: https://skia-review.googlesource.com/133382
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GrMeshTest.cpp | 3 | ||||
-rw-r--r-- | tests/GrPipelineDynamicStateTest.cpp | 3 | ||||
-rw-r--r-- | tests/LazyProxyTest.cpp | 9 | ||||
-rw-r--r-- | tests/OnFlushCallbackTest.cpp | 24 | ||||
-rw-r--r-- | tests/PrimitiveProcessorTest.cpp | 9 | ||||
-rw-r--r-- | tests/ProcessorTest.cpp | 22 |
6 files changed, 51 insertions, 19 deletions
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index e612fb4b5f..4535f13975 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -15,6 +15,7 @@ #include "GrContextPriv.h" #include "GrGeometryProcessor.h" #include "GrGpuCommandBuffer.h" +#include "GrMemoryPool.h" #include "GrOpFlushState.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" @@ -261,6 +262,8 @@ public: } private: + friend class GrOpMemoryPool; // for ctor + GrMeshTestOp(std::function<void(DrawMeshHelper*)> testFn) : INHERITED(ClassID()) , fTestFn(testFn) { diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index 227fd7c3e0..0f786e7c23 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -12,6 +12,7 @@ #include "GrColor.h" #include "GrGeometryProcessor.h" #include "GrGpuCommandBuffer.h" +#include "GrMemoryPool.h" #include "GrOpFlushState.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" @@ -113,6 +114,8 @@ public: } private: + friend class GrOpMemoryPool; + GrPipelineDynamicStateTestOp(ScissorState scissorState, sk_sp<const GrBuffer> vbuff) : INHERITED(ClassID()) , fScissorState(scissorState) diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp index 536ef36307..c0dcbf9647 100644 --- a/tests/LazyProxyTest.cpp +++ b/tests/LazyProxyTest.cpp @@ -9,8 +9,9 @@ #include "GrClip.h" #include "GrContextPriv.h" -#include "GrProxyProvider.h" +#include "GrMemoryPool.h" #include "GrOnFlushResourceProvider.h" +#include "GrProxyProvider.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" #include "GrSurfaceProxy.h" @@ -71,6 +72,8 @@ public: } private: + friend class GrOpMemoryPool; // for ctor + Op(GrProxyProvider* proxyProvider, LazyProxyTest* test, bool nullTexture) : GrDrawOp(ClassID()), fTest(test) { fProxy = proxyProvider->createFullyLazyProxy([this, nullTexture]( @@ -276,6 +279,8 @@ public: } private: + friend class GrOpMemoryPool; // for ctor + LazyFailedInstantiationTestOp(GrProxyProvider* proxyProvider, int* testExecuteValue, bool shouldFailInstantiation) : INHERITED(ClassID()) @@ -370,6 +375,8 @@ public: } private: + friend class GrOpMemoryPool; // for ctor + LazyUninstantiateTestOp(sk_sp<GrTextureProxy> proxy) : INHERITED(ClassID()) , fLazyProxy(std::move(proxy)) { diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp index e9e4dd0462..7932fdc458 100644 --- a/tests/OnFlushCallbackTest.cpp +++ b/tests/OnFlushCallbackTest.cpp @@ -34,13 +34,18 @@ public: DEFINE_OP_CLASS_ID // This creates an instance of a simple non-AA solid color rect-drawing Op - static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkRect& r) { - return Helper::FactoryHelper<NonAARectOp>(std::move(paint), r, nullptr, ClassID()); + static std::unique_ptr<GrDrawOp> Make(GrContext* context, + GrPaint&& paint, + const SkRect& r) { + return Helper::FactoryHelper<NonAARectOp>(context, std::move(paint), r, nullptr, ClassID()); } // This creates an instance of a simple non-AA textured rect-drawing Op - static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkRect& r, const SkRect& local) { - return Helper::FactoryHelper<NonAARectOp>(std::move(paint), r, &local, ClassID()); + static std::unique_ptr<GrDrawOp> Make(GrContext* context, + GrPaint&& paint, + const SkRect& r, + const SkRect& local) { + return Helper::FactoryHelper<NonAARectOp>(context, std::move(paint), r, &local, ClassID()); } GrColor color() const { return fColor; } @@ -189,8 +194,12 @@ public: int id() const { return fID; } - static std::unique_ptr<AtlasedRectOp> Make(GrPaint&& paint, const SkRect& r, int id) { - GrDrawOp* op = Helper::FactoryHelper<AtlasedRectOp>(std::move(paint), r, id).release(); + static std::unique_ptr<AtlasedRectOp> Make(GrContext* context, + GrPaint&& paint, + const SkRect& r, + int id) { + GrDrawOp* op = Helper::FactoryHelper<AtlasedRectOp>(context, std::move(paint), + r, id).release(); return std::unique_ptr<AtlasedRectOp>(static_cast<AtlasedRectOp*>(op)); } @@ -435,7 +444,8 @@ static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject GrPaint paint; paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - std::unique_ptr<AtlasedRectOp> op(AtlasedRectOp::Make(std::move(paint), r, start + i)); + std::unique_ptr<AtlasedRectOp> op(AtlasedRectOp::Make(context, + std::move(paint), r, start + i)); AtlasedRectOp* sparePtr = op.get(); diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 36709f8694..3a76e6c5e0 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -14,6 +14,7 @@ #include "GrContextPriv.h" #include "GrGeometryProcessor.h" #include "GrGpu.h" +#include "GrMemoryPool.h" #include "GrOpFlushState.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" @@ -31,7 +32,7 @@ public: const char* name() const override { return "Dummy Op"; } - static std::unique_ptr<GrDrawOp> Make(int numAttribs) { + static std::unique_ptr<GrDrawOp> Make(GrContext* context, int numAttribs) { return std::unique_ptr<GrDrawOp>(new Op(numAttribs)); } @@ -45,6 +46,8 @@ public: } private: + friend class ::GrOpMemoryPool; + Op(int numAttribs) : INHERITED(ClassID()), fNumAttribs(numAttribs) { this->setBounds(SkRect::MakeWH(1.f, 1.f), HasAABloat::kNo, IsZeroArea::kNo); } @@ -140,14 +143,14 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { GrPaint grPaint; // This one should succeed. - renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt)); + renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(context, attribCnt)); context->flush(); #if GR_GPU_STATS REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 1); REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0); #endif context->contextPriv().resetGpuStats(); - renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt + 1)); + renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(context, attribCnt + 1)); context->flush(); #if GR_GPU_STATS REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 0); diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index b1da1b5419..3916436cfc 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -13,6 +13,7 @@ #include "GrContext.h" #include "GrContextPriv.h" #include "GrGpuResource.h" +#include "GrMemoryPool.h" #include "GrProxyProvider.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" @@ -26,7 +27,8 @@ namespace { class TestOp : public GrMeshDrawOp { public: DEFINE_OP_CLASS_ID - static std::unique_ptr<GrDrawOp> Make(std::unique_ptr<GrFragmentProcessor> fp) { + static std::unique_ptr<GrDrawOp> Make(GrContext* context, + std::unique_ptr<GrFragmentProcessor> fp) { return std::unique_ptr<GrDrawOp>(new TestOp(std::move(fp))); } @@ -48,6 +50,8 @@ public: } private: + friend class ::GrOpMemoryPool; // for ctor + TestOp(std::unique_ptr<GrFragmentProcessor> fp) : INHERITED(ClassID()), fProcessors(std::move(fp)) { this->setBounds(SkRect::MakeWH(100, 100), HasAABloat::kNo, IsZeroArea::kNo); @@ -201,10 +205,10 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { if (makeClone) { clone = fp->clone(); } - std::unique_ptr<GrDrawOp> op(TestOp::Make(std::move(fp))); + std::unique_ptr<GrDrawOp> op(TestOp::Make(context, std::move(fp))); renderTargetContext->priv().testingOnly_addDrawOp(std::move(op)); if (clone) { - op = TestOp::Make(std::move(clone)); + op = TestOp::Make(context, std::move(clone)); renderTargetContext->priv().testingOnly_addDrawOp(std::move(op)); } } @@ -276,14 +280,16 @@ static GrColor4f input_texel_color4f(int i, int j) { return GrColor4f::FromGrColor(input_texel_color(i, j)); } -void test_draw_op(GrRenderTargetContext* rtc, std::unique_ptr<GrFragmentProcessor> fp, +void test_draw_op(GrContext* context, + GrRenderTargetContext* rtc, + std::unique_ptr<GrFragmentProcessor> fp, sk_sp<GrTextureProxy> inputDataProxy) { GrPaint paint; paint.addColorTextureProcessor(std::move(inputDataProxy), SkMatrix::I()); paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - auto op = GrRectOpFactory::MakeNonAAFill(std::move(paint), SkMatrix::I(), + auto op = GrRectOpFactory::MakeNonAAFill(context, std::move(paint), SkMatrix::I(), SkRect::MakeWH(rtc->width(), rtc->height()), GrAAType::kNone); rtc->addDrawOp(GrNoClip(), std::move(op)); @@ -402,7 +408,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor // Since we transfer away ownership of the original FP, we make a clone. auto clone = fp->clone(); - test_draw_op(rtc.get(), std::move(fp), inputTexture); + test_draw_op(context, rtc.get(), std::move(fp), inputTexture); memset(readData.get(), 0x0, sizeof(GrColor) * kRenderSize * kRenderSize); rtc->readPixels(SkImageInfo::Make(kRenderSize, kRenderSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType), @@ -536,12 +542,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) { REPORTER_ASSERT(reporter, fp->numChildProcessors() == clone->numChildProcessors()); REPORTER_ASSERT(reporter, fp->usesLocalCoords() == clone->usesLocalCoords()); // Draw with original and read back the results. - test_draw_op(rtc.get(), std::move(fp), inputTexture); + test_draw_op(context, rtc.get(), std::move(fp), inputTexture); memset(readData1.get(), 0x0, sizeof(GrColor) * kRenderSize * kRenderSize); rtc->readPixels(readInfo, readData1.get(), 0, 0, 0); // Draw with clone and read back the results. - test_draw_op(rtc.get(), std::move(clone), inputTexture); + test_draw_op(context, rtc.get(), std::move(clone), inputTexture); memset(readData2.get(), 0x0, sizeof(GrColor) * kRenderSize * kRenderSize); rtc->readPixels(readInfo, readData2.get(), 0, 0, 0); |