| OLD | NEW |
| 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 Loading... |
| 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 | 106 GrTextureDesc desc; |
| 107 sk_sp<GrDrawContext> dc(context->newDrawContext(GrContext::kLoose_BackingFit
, | 107 desc.fHeight = 1; |
| 108 1, 1, kRGBA_8888_GrPixelConf
ig)); | 108 desc.fWidth = 1; |
| 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()))); |
| 109 if (!dc) { | 118 if (!dc) { |
| 110 ERRORF(reporter, "Could not create draw context."); | 119 ERRORF(reporter, "Could not create draw context."); |
| 111 return; | 120 return; |
| 112 } | 121 } |
| 113 int attribCnt = context->caps()->maxVertexAttributes(); | 122 int attribCnt = context->caps()->maxVertexAttributes(); |
| 114 if (!attribCnt) { | 123 if (!attribCnt) { |
| 115 ERRORF(reporter, "No attributes allowed?!"); | 124 ERRORF(reporter, "No attributes allowed?!"); |
| 116 return; | 125 return; |
| 117 } | 126 } |
| 118 context->flush(); | 127 context->flush(); |
| 119 context->resetGpuStats(); | 128 context->resetGpuStats(); |
| 120 #if GR_GPU_STATS | 129 #if GR_GPU_STATS |
| 121 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); | 130 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); |
| 122 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0)
; | 131 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0)
; |
| 123 #endif | 132 #endif |
| 124 SkAutoTUnref<GrDrawBatch> batch; | 133 SkAutoTUnref<GrDrawBatch> batch; |
| 125 GrPipelineBuilder pb; | 134 GrPipelineBuilder pb; |
| 126 pb.setRenderTarget(dc->accessRenderTarget()); | 135 pb.setRenderTarget(target->asRenderTarget()); |
| 127 // This one should succeed. | 136 // This one should succeed. |
| 128 batch.reset(new Batch(attribCnt)); | 137 batch.reset(new Batch(attribCnt)); |
| 129 dc->drawContextPriv().testingOnly_drawBatch(pb, batch); | 138 dc->drawContextPriv().testingOnly_drawBatch(pb, batch); |
| 130 context->flush(); | 139 context->flush(); |
| 131 #if GR_GPU_STATS | 140 #if GR_GPU_STATS |
| 132 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1); | 141 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1); |
| 133 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0)
; | 142 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 0)
; |
| 134 #endif | 143 #endif |
| 135 context->resetGpuStats(); | 144 context->resetGpuStats(); |
| 136 // This one should fail. | 145 // This one should fail. |
| 137 batch.reset(new Batch(attribCnt+1)); | 146 batch.reset(new Batch(attribCnt+1)); |
| 138 dc->drawContextPriv().testingOnly_drawBatch(pb, batch); | 147 dc->drawContextPriv().testingOnly_drawBatch(pb, batch); |
| 139 context->flush(); | 148 context->flush(); |
| 140 #if GR_GPU_STATS | 149 #if GR_GPU_STATS |
| 141 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); | 150 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0); |
| 142 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1)
; | 151 REPORTER_ASSERT(reporter, context->getGpu()->stats()->numFailedDraws() == 1)
; |
| 143 #endif | 152 #endif |
| 144 } | 153 } |
| 145 #endif | 154 #endif |
| OLD | NEW |