aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-11-16 11:02:05 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-16 11:02:05 -0800
commit504ce5dc772e14be2f5697b00ac82fcf82127763 (patch)
tree08d896e660c8ac5487152bd84ffb98d26107a17c
parent3c2d32b8e27820a6e149d9ded67cbdf2411cc5c9 (diff)
Optionally pass rendertarget to getTestTarget
This shouldn't really make any difference but allocating and holding on to a GrRenderTarget for each test target generates image differences for Mali GPUs. This CL allows an existing render target to be used for the test target. TBR=bsalomon@google.com Review URL: https://codereview.chromium.org/1447113002
-rw-r--r--gm/beziereffects.cpp12
-rw-r--r--gm/bigrrectaaeffect.cpp2
-rw-r--r--gm/constcolorprocessor.cpp2
-rw-r--r--gm/convexpolyeffect.cpp4
-rw-r--r--gm/rrects.cpp2
-rw-r--r--gm/texturedomaineffect.cpp2
-rw-r--r--gm/yuvtorgbeffect.cpp2
-rw-r--r--include/gpu/GrContext.h2
-rw-r--r--src/gpu/GrTest.cpp29
-rw-r--r--tests/GLProgramsTest.cpp4
-rw-r--r--tests/TessellatingPathRendererTests.cpp2
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();