Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Side by Side Diff: tests/PrimitiveProcessorTest.cpp

Issue 1914883002: Refactor drawContext/RenderTarget creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix variable name Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/ClipBoundsTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // This is a GPU-backend specific test. It relies on static intializers to work 8 // This is a GPU-backend specific test. It relies on static intializers to work
9 9
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 int fNumAttribs; 98 int fNumAttribs;
99 99
100 typedef GrVertexBatch INHERITED; 100 typedef GrVertexBatch INHERITED;
101 }; 101 };
102 } 102 }
103 103
104 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { 104 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
105 GrContext* context = ctxInfo.fGrContext; 105 GrContext* context = ctxInfo.fGrContext;
106 GrTextureDesc desc; 106
107 desc.fHeight = 1; 107 sk_sp<GrDrawContext> dc(context->newDrawContext(GrContext::kLoose_BackingFit ,
108 desc.fWidth = 1; 108 1, 1, kRGBA_8888_GrPixelConf ig));
109 desc.fFlags = kRenderTarget_GrSurfaceFlag;
110 desc.fConfig = kRGBA_8888_GrPixelConfig;
111 SkAutoTUnref<GrTexture> target(context->textureProvider()->createTexture(des c,
112 SkB udgeted::kYes));
113 if (!target) {
114 ERRORF(reporter, "Could not create render target.");
115 return;
116 }
117 sk_sp<GrDrawContext> dc(context->drawContext(sk_ref_sp(target->asRenderTarge t())));
118 if (!dc) { 109 if (!dc) {
119 ERRORF(reporter, "Could not create draw context."); 110 ERRORF(reporter, "Could not create draw context.");
120 return; 111 return;
121 } 112 }
122 int attribCnt = context->caps()->maxVertexAttributes(); 113 int attribCnt = context->caps()->maxVertexAttributes();
123 if (!attribCnt) { 114 if (!attribCnt) {
124 ERRORF(reporter, "No attributes allowed?!"); 115 ERRORF(reporter, "No attributes allowed?!");
125 return; 116 return;
126 } 117 }
127 context->flush(); 118 context->flush();
128 context->resetGpuStats(); 119 context->resetGpuStats();
129 #if GR_GPU_STATS 120 #if GR_GPU_STATS
130 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); 121 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
131 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0) ; 122 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0) ;
132 #endif 123 #endif
133 SkAutoTUnref<GrDrawBatch> batch; 124 SkAutoTUnref<GrDrawBatch> batch;
134 GrPipelineBuilder pb; 125 GrPipelineBuilder pb;
135 pb.setRenderTarget(target->asRenderTarget()); 126 pb.setRenderTarget(dc->accessRenderTarget());
136 // This one should succeed. 127 // This one should succeed.
137 batch.reset(new Batch(attribCnt)); 128 batch.reset(new Batch(attribCnt));
138 dc->drawContextPriv().testingOnly_drawBatch(pb, batch); 129 dc->drawContextPriv().testingOnly_drawBatch(pb, batch);
139 context->flush(); 130 context->flush();
140 #if GR_GPU_STATS 131 #if GR_GPU_STATS
141 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1); 132 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1);
142 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0) ; 133 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0) ;
143 #endif 134 #endif
144 context->resetGpuStats(); 135 context->resetGpuStats();
145 // This one should fail. 136 // This one should fail.
146 batch.reset(new Batch(attribCnt+1)); 137 batch.reset(new Batch(attribCnt+1));
147 dc->drawContextPriv().testingOnly_drawBatch(pb, batch); 138 dc->drawContextPriv().testingOnly_drawBatch(pb, batch);
148 context->flush(); 139 context->flush();
149 #if GR_GPU_STATS 140 #if GR_GPU_STATS
150 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); 141 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
151 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1) ; 142 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1) ;
152 #endif 143 #endif
153 } 144 }
154 #endif 145 #endif
OLDNEW
« no previous file with comments | « tests/ClipBoundsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698