| 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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 SkAutoTUnref<const GrBuffer> quadIndexBuffer( | 55 SkAutoTUnref<const GrBuffer> quadIndexBuffer( |
| 56 target->resourceProvider()->refQuadIndexBuffer()); | 56 target->resourceProvider()->refQuadIndexBuffer()); |
| 57 if (!quadIndexBuffer) { | 57 if (!quadIndexBuffer) { |
| 58 SkDebugf("Could not get quad index buffer."); | 58 SkDebugf("Could not get quad index buffer."); |
| 59 return nullptr; | 59 return nullptr; |
| 60 } | 60 } |
| 61 return this->INHERITED::init(target, kTriangles_GrPrimitiveType, vertexStrid
e, | 61 return this->INHERITED::init(target, kTriangles_GrPrimitiveType, vertexStrid
e, |
| 62 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ
uad, quadsToDraw); | 62 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ
uad, quadsToDraw); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void GrVertexBatch::onDraw(GrBatchFlushState* state) { | 65 void GrVertexBatch::onDraw(GrBatchFlushState* state, GrGpuCommandBuffer* buffer)
{ |
| 66 int currUploadIdx = 0; | 66 int currUploadIdx = 0; |
| 67 int currMeshIdx = 0; | 67 int currMeshIdx = 0; |
| 68 | 68 |
| 69 SkASSERT(fQueuedDraws.empty() || fBaseDrawToken == state->nextTokenToFlush()
); | 69 SkASSERT(fQueuedDraws.empty() || fBaseDrawToken == state->nextTokenToFlush()
); |
| 70 | 70 |
| 71 for (int currDrawIdx = 0; currDrawIdx < fQueuedDraws.count(); ++currDrawIdx)
{ | 71 for (int currDrawIdx = 0; currDrawIdx < fQueuedDraws.count(); ++currDrawIdx)
{ |
| 72 GrBatchDrawToken drawToken = state->nextTokenToFlush(); | 72 GrBatchDrawToken drawToken = state->nextTokenToFlush(); |
| 73 while (currUploadIdx < fInlineUploads.count() && | 73 while (currUploadIdx < fInlineUploads.count() && |
| 74 fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) { | 74 fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) { |
| 75 state->doUpload(fInlineUploads[currUploadIdx++].fUpload); | 75 state->doUpload(fInlineUploads[currUploadIdx++].fUpload); |
| 76 } | 76 } |
| 77 const QueuedDraw &draw = fQueuedDraws[currDrawIdx]; | 77 const QueuedDraw &draw = fQueuedDraws[currDrawIdx]; |
| 78 state->gpu()->draw(*this->pipeline(), *draw.fGeometryProcessor.get(), | 78 buffer->draw(*this->pipeline(), *draw.fGeometryProcessor.get(), |
| 79 fMeshes.begin() + currMeshIdx, draw.fMeshCnt); | 79 fMeshes.begin() + currMeshIdx, draw.fMeshCnt); |
| 80 currMeshIdx += draw.fMeshCnt; | 80 currMeshIdx += draw.fMeshCnt; |
| 81 state->flushToken(); | 81 state->flushToken(); |
| 82 } | 82 } |
| 83 SkASSERT(currUploadIdx == fInlineUploads.count()); | 83 SkASSERT(currUploadIdx == fInlineUploads.count()); |
| 84 SkASSERT(currMeshIdx == fMeshes.count()); | 84 SkASSERT(currMeshIdx == fMeshes.count()); |
| 85 fQueuedDraws.reset(); | 85 fQueuedDraws.reset(); |
| 86 fInlineUploads.reset(); | 86 fInlineUploads.reset(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 ////////////////////////////////////////////////////////////////////////////// | 89 ////////////////////////////////////////////////////////////////////////////// |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 GrVertexBatch::QueuedDraw& draw = this->vertexBatch()->fQueuedDraws.push_bac
k(); | 105 GrVertexBatch::QueuedDraw& draw = this->vertexBatch()->fQueuedDraws.push_bac
k(); |
| 106 GrBatchDrawToken token = this->state()->issueDrawToken(); | 106 GrBatchDrawToken token = this->state()->issueDrawToken(); |
| 107 draw.fGeometryProcessor.reset(gp); | 107 draw.fGeometryProcessor.reset(gp); |
| 108 draw.fMeshCnt = 1; | 108 draw.fMeshCnt = 1; |
| 109 if (batch->fQueuedDraws.count() == 1) { | 109 if (batch->fQueuedDraws.count() == 1) { |
| 110 batch->fBaseDrawToken = token; | 110 batch->fBaseDrawToken = token; |
| 111 } | 111 } |
| 112 } | 112 } |
| OLD | NEW |