diff options
-rw-r--r-- | gm/beziereffects.cpp | 12 | ||||
-rw-r--r-- | gm/bigrrectaaeffect.cpp | 2 | ||||
-rw-r--r-- | gm/constcolorprocessor.cpp | 2 | ||||
-rw-r--r-- | gm/convexpolyeffect.cpp | 4 | ||||
-rw-r--r-- | gm/rrects.cpp | 2 | ||||
-rw-r--r-- | gm/texturedomaineffect.cpp | 2 | ||||
-rw-r--r-- | gm/yuvtorgbeffect.cpp | 2 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 2 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 29 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 4 | ||||
-rw-r--r-- | tests/TessellatingPathRendererTests.cpp | 2 |
11 files changed, 33 insertions, 30 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index 5313919994..58d7fef3d3 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -157,7 +157,7 @@ protected: SkAutoTUnref<GrGeometryProcessor> gp; { // scope to contain GrTestTarget GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { continue; } @@ -217,7 +217,7 @@ protected: canvas->drawRect(bounds, boundsPaint); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); SkASSERT(tt.target()); GrPipelineBuilder pipelineBuilder; @@ -305,7 +305,7 @@ protected: SkAutoTUnref<GrGeometryProcessor> gp; { // scope to contain GrTestTarget GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { continue; } @@ -362,7 +362,7 @@ protected: canvas->drawRect(bounds, boundsPaint); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); SkASSERT(tt.target()); GrPipelineBuilder pipelineBuilder; @@ -546,7 +546,7 @@ protected: SkAutoTUnref<GrGeometryProcessor> gp; { // scope to contain GrTestTarget GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { continue; } @@ -600,7 +600,7 @@ protected: canvas->drawRect(bounds, boundsPaint); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); SkASSERT(tt.target()); GrPipelineBuilder pipelineBuilder; diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp index bc0b56a72c..472910b5df 100644 --- a/gm/bigrrectaaeffect.cpp +++ b/gm/bigrrectaaeffect.cpp @@ -65,7 +65,7 @@ protected: canvas->save(); canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp index 539119e040..3b2605e7a3 100644 --- a/gm/constcolorprocessor.cpp +++ b/gm/constcolorprocessor.cpp @@ -91,7 +91,7 @@ protected: SkRect renderRect = SkRect::MakeXYWH(0, 0, kRectSize, kRectSize); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp index de0b692a46..d35997b950 100644 --- a/gm/convexpolyeffect.cpp +++ b/gm/convexpolyeffect.cpp @@ -174,7 +174,7 @@ protected: for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; @@ -225,7 +225,7 @@ protected: for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; diff --git a/gm/rrects.cpp b/gm/rrects.cpp index 279f4a6957..e48b8c8c8d 100644 --- a/gm/rrects.cpp +++ b/gm/rrects.cpp @@ -101,7 +101,7 @@ protected: if (kEffect_Type == fType) { #if SK_SUPPORT_GPU GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index cf772f5f1b..a2dc4b01b8 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -80,7 +80,7 @@ protected: } GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index 25dca35e02..5f7cc1314d 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -78,7 +78,7 @@ protected: } GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); if (nullptr == tt.target()) { SkDEBUGFAIL("Couldn't get Gr test target."); return; diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 098fdd2fe9..7621f8b826 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -328,7 +328,7 @@ public: GrResourceCache* getResourceCache() { return fResourceCache; } // Called by tests that draw directly to the context via GrDrawTarget - void getTestTarget(GrTestTarget*); + void getTestTarget(GrTestTarget*, GrRenderTarget* rt); /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ void dumpCacheStats(SkString*) const; diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index f6ece6c79e..f0f6370254 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -52,25 +52,28 @@ void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt fRenderTarget.reset(SkRef(rt)); } -void GrContext::getTestTarget(GrTestTarget* tar) { +void GrContext::getTestTarget(GrTestTarget* tar, GrRenderTarget* rt) { this->flush(); // We could create a proxy GrDrawTarget that passes through to fGpu until ~GrTextTarget() and // then disconnects. This would help prevent test writers from mixing using the returned // GrDrawTarget and regular drawing. We could also assert or fail in GrContext drawing methods // until ~GrTestTarget(). - GrSurfaceDesc desc; - desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fWidth = 32; - desc.fHeight = 32; - desc.fConfig = kRGBA_8888_GrPixelConfig; - desc.fSampleCnt = 0; - - SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc, false, nullptr, 0)); - if (nullptr == texture) { - return; + if (!rt) { + GrSurfaceDesc desc; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fWidth = 32; + desc.fHeight = 32; + desc.fConfig = kRGBA_8888_GrPixelConfig; + desc.fSampleCnt = 0; + + SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(desc, false, + nullptr, 0)); + if (nullptr == texture) { + return; + } + SkASSERT(nullptr != texture->asRenderTarget()); + rt = texture->asRenderTarget(); } - SkASSERT(nullptr != texture->asRenderTarget()); - GrRenderTarget* rt = texture->asRenderTarget(); SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt)); tar->init(this, dt, rt); diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index ce247df59c..47a88fcbb5 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -357,7 +357,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { set_random_stencil(&pipelineBuilder, &random); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); tt.target()->drawBatch(pipelineBuilder, batch); } @@ -391,7 +391,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { builder.addColorFragmentProcessor(blockFP); GrTestTarget tt; - context->getTestTarget(&tt); + context->getTestTarget(&tt, rt); tt.target()->drawBatch(builder, batch); drawingManager->flush(); diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp index ae648accde..219397bc11 100644 --- a/tests/TessellatingPathRendererTests.cpp +++ b/tests/TessellatingPathRendererTests.cpp @@ -263,8 +263,8 @@ DEF_GPUTEST(TessellatingPathRendererTests, reporter, factory) { desc.fOrigin = kTopLeft_GrSurfaceOrigin; SkAutoTUnref<GrTexture> texture(context->textureProvider()->createApproxTexture(desc)); GrTestTarget tt; - context->getTestTarget(&tt); GrRenderTarget* rt = texture->asRenderTarget(); + context->getTestTarget(&tt, rt); GrDrawTarget* dt = tt.target(); GrResourceProvider* rp = tt.resourceProvider(); |