| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "GrVertexBatch.h" | 8 #include "GrVertexBatch.h" |
| 9 #include "GrBatchFlushState.h" | 9 #include "GrBatchFlushState.h" |
| 10 #include "GrResourceProvider.h" | 10 #include "GrResourceProvider.h" |
| 11 | 11 |
| 12 GrVertexBatch::GrVertexBatch() : fDrawArrays(1) {} | 12 GrVertexBatch::GrVertexBatch() : fDrawArrays(1) {} |
| 13 | 13 |
| 14 void GrVertexBatch::prepareDraws(GrBatchFlushState* state) { | 14 void GrVertexBatch::onPrepare(GrBatchFlushState* state) { |
| 15 Target target(state, this); | 15 Target target(state, this); |
| 16 this->onPrepareDraws(&target); | 16 this->onPrepareDraws(&target); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void* GrVertexBatch::InstancedHelper::init(Target* target, GrPrimitiveType primT
ype, | 19 void* GrVertexBatch::InstancedHelper::init(Target* target, GrPrimitiveType primT
ype, |
| 20 size_t vertexStride, const GrIndexBuf
fer* indexBuffer, | 20 size_t vertexStride, const GrIndexBuf
fer* indexBuffer, |
| 21 int verticesPerInstance, int indicesP
erInstance, | 21 int verticesPerInstance, int indicesP
erInstance, |
| 22 int instancesToDraw) { | 22 int instancesToDraw) { |
| 23 SkASSERT(target); | 23 SkASSERT(target); |
| 24 if (!indexBuffer) { | 24 if (!indexBuffer) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer( | 52 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer( |
| 53 target->resourceProvider()->refQuadIndexBuffer()); | 53 target->resourceProvider()->refQuadIndexBuffer()); |
| 54 if (!quadIndexBuffer) { | 54 if (!quadIndexBuffer) { |
| 55 SkDebugf("Could not get quad index buffer."); | 55 SkDebugf("Could not get quad index buffer."); |
| 56 return NULL; | 56 return NULL; |
| 57 } | 57 } |
| 58 return this->INHERITED::init(target, kTriangles_GrPrimitiveType, vertexStrid
e, | 58 return this->INHERITED::init(target, kTriangles_GrPrimitiveType, vertexStrid
e, |
| 59 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ
uad, quadsToDraw); | 59 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ
uad, quadsToDraw); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void GrVertexBatch::issueDraws(GrBatchFlushState* state) { | 62 void GrVertexBatch::onDraw(GrBatchFlushState* state) { |
| 63 int uploadCnt = fInlineUploads.count(); | 63 int uploadCnt = fInlineUploads.count(); |
| 64 int currUpload = 0; | 64 int currUpload = 0; |
| 65 | 65 |
| 66 // Iterate of all the drawArrays. Before issuing the draws in each array, pe
rform any inline | 66 // Iterate of all the drawArrays. Before issuing the draws in each array, pe
rform any inline |
| 67 // uploads. | 67 // uploads. |
| 68 for (SkTLList<DrawArray>::Iter da(fDrawArrays); da.get(); da.next()) { | 68 for (SkTLList<DrawArray>::Iter da(fDrawArrays); da.get(); da.next()) { |
| 69 state->advanceLastFlushedToken(); | 69 state->advanceLastFlushedToken(); |
| 70 while (currUpload < uploadCnt && | 70 while (currUpload < uploadCnt && |
| 71 fInlineUploads[currUpload]->lastUploadToken() <= state->lastFlush
edToken()) { | 71 fInlineUploads[currUpload]->lastUploadToken() <= state->lastFlush
edToken()) { |
| 72 fInlineUploads[currUpload++]->upload(state->uploader()); | 72 fInlineUploads[currUpload++]->upload(state->uploader()); |
| 73 } | 73 } |
| 74 const GrVertexBatch::DrawArray& drawArray = *da.get(); | 74 const GrVertexBatch::DrawArray& drawArray = *da.get(); |
| 75 GrProgramDesc desc; | 75 GrProgramDesc desc; |
| 76 const GrPipeline* pipeline = this->pipeline(); | 76 const GrPipeline* pipeline = this->pipeline(); |
| 77 const GrPrimitiveProcessor* primProc = drawArray.fPrimitiveProcessor.get
(); | 77 const GrPrimitiveProcessor* primProc = drawArray.fPrimitiveProcessor.get
(); |
| 78 state->gpu()->buildProgramDesc(&desc, *primProc, *pipeline, fBatchTracke
r); | 78 state->gpu()->buildProgramDesc(&desc, *primProc, *pipeline, fBatchTracke
r); |
| 79 GrGpu::DrawArgs args(primProc, pipeline, &desc, &fBatchTracker); | 79 GrGpu::DrawArgs args(primProc, pipeline, &desc, &fBatchTracker); |
| 80 | 80 |
| 81 int drawCount = drawArray.fDraws.count(); | 81 int drawCount = drawArray.fDraws.count(); |
| 82 for (int i = 0; i < drawCount; i++) { | 82 for (int i = 0; i < drawCount; i++) { |
| 83 state->gpu()->draw(args, drawArray.fDraws[i]); | 83 state->gpu()->draw(args, drawArray.fDraws[i]); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| OLD | NEW |