| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
| 9 | 9 |
| 10 #include "GrBufferAllocPool.h" | 10 #include "GrBufferAllocPool.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 this->closeBatch(); | 453 this->closeBatch(); |
| 454 this->getVertexAllocPool()->unmap(); | 454 this->getVertexAllocPool()->unmap(); |
| 455 this->getIndexAllocPool()->unmap(); | 455 this->getIndexAllocPool()->unmap(); |
| 456 fBatchTarget.preFlush(); | 456 fBatchTarget.preFlush(); |
| 457 | 457 |
| 458 currentState = NULL; | 458 currentState = NULL; |
| 459 CmdBuffer::Iter iter(fCmdBuffer); | 459 CmdBuffer::Iter iter(fCmdBuffer); |
| 460 | 460 |
| 461 int currCmdMarker = 0; | 461 int currCmdMarker = 0; |
| 462 | 462 |
| 463 int i = 0; |
| 463 while (iter.next()) { | 464 while (iter.next()) { |
| 465 i++; |
| 464 GrGpuTraceMarker newMarker("", -1); | 466 GrGpuTraceMarker newMarker("", -1); |
| 465 SkString traceString; | 467 SkString traceString; |
| 466 if (cmd_has_trace_marker(iter->fType)) { | 468 if (cmd_has_trace_marker(iter->fType)) { |
| 467 traceString = fGpuCmdMarkers[currCmdMarker].toString(); | 469 traceString = fGpuCmdMarkers[currCmdMarker].toString(); |
| 468 newMarker.fMarker = traceString.c_str(); | 470 newMarker.fMarker = traceString.c_str(); |
| 469 this->getGpu()->addGpuTraceMarker(&newMarker); | 471 this->getGpu()->addGpuTraceMarker(&newMarker); |
| 470 ++currCmdMarker; | 472 ++currCmdMarker; |
| 471 } | 473 } |
| 472 | 474 |
| 473 // TODO temporary hack | 475 // TODO temporary hack |
| 474 if (kDrawBatch_Cmd == strip_trace_bit(iter->fType)) { | 476 if (kDrawBatch_Cmd == strip_trace_bit(iter->fType)) { |
| 475 fBatchTarget.flushNext(); | 477 DrawBatch* db = reinterpret_cast<DrawBatch*>(iter.get()); |
| 478 fBatchTarget.flushNext(db->fBatch->numberOfDraws()); |
| 476 continue; | 479 continue; |
| 477 } | 480 } |
| 478 | 481 |
| 479 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType); | 482 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType); |
| 480 if (isSetState) { | 483 if (isSetState) { |
| 481 SetState* ss = reinterpret_cast<SetState*>(iter.get()); | 484 SetState* ss = reinterpret_cast<SetState*>(iter.get()); |
| 482 | 485 |
| 483 // TODO sometimes we have a prim proc, othertimes we have a GrBatch.
Eventually we will | 486 // TODO sometimes we have a prim proc, othertimes we have a GrBatch.
Eventually we will |
| 484 // only have GrBatch and we can delete this | 487 // only have GrBatch and we can delete this |
| 485 if (ss->fPrimitiveProcessor) { | 488 if (ss->fPrimitiveProcessor) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); | 648 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); |
| 646 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 649 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
| 647 if (activeTraceMarkers.count() > 0) { | 650 if (activeTraceMarkers.count() > 0) { |
| 648 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 651 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
| 649 fGpuCmdMarkers.push_back(activeTraceMarkers); | 652 fGpuCmdMarkers.push_back(activeTraceMarkers); |
| 650 } | 653 } |
| 651 } | 654 } |
| 652 | 655 |
| 653 void GrInOrderDrawBuffer::closeBatch() { | 656 void GrInOrderDrawBuffer::closeBatch() { |
| 654 if (fDrawBatch) { | 657 if (fDrawBatch) { |
| 658 fBatchTarget.resetNumberOfDraws(); |
| 655 fDrawBatch->execute(this, fPrevState); | 659 fDrawBatch->execute(this, fPrevState); |
| 660 fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
| 656 fDrawBatch = NULL; | 661 fDrawBatch = NULL; |
| 657 } | 662 } |
| 658 } | 663 } |
| 659 | 664 |
| 660 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, | 665 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, |
| 661 size_t vertexStride, | 666 size_t vertexStride, |
| 662 int indexCount) { | 667 int indexCount) { |
| 663 this->closeBatch(); | 668 this->closeBatch(); |
| 664 | 669 |
| 665 // We use geometryHints() to know whether to flush the draw buffer. We | 670 // We use geometryHints() to know whether to flush the draw buffer. We |
| (...skipping 15 matching lines...) Expand all Loading... |
| 681 int vcount = vertexCount; | 686 int vcount = vertexCount; |
| 682 int icount = indexCount; | 687 int icount = indexCount; |
| 683 | 688 |
| 684 if (!insideGeoPush && | 689 if (!insideGeoPush && |
| 685 !unreleasedVertexSpace && | 690 !unreleasedVertexSpace && |
| 686 !unreleasedIndexSpace && | 691 !unreleasedIndexSpace && |
| 687 this->geometryHints(vertexStride, &vcount, &icount)) { | 692 this->geometryHints(vertexStride, &vcount, &icount)) { |
| 688 this->flush(); | 693 this->flush(); |
| 689 } | 694 } |
| 690 } | 695 } |
| OLD | NEW |