| 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 634 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
| 635 fGpuCmdMarkers.push_back(activeTraceMarkers); | 635 fGpuCmdMarkers.push_back(activeTraceMarkers); |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, | 639 void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(int vertexCount, |
| 640 size_t vertexStride, | 640 size_t vertexStride, |
| 641 int indexCount) { | 641 int indexCount) { |
| 642 this->closeBatch(); | 642 this->closeBatch(); |
| 643 | 643 |
| 644 // We use geometryHints() to know whether to flush the draw buffer. We | 644 this->INHERITED::willReserveVertexAndIndexSpace(vertexCount, vertexStride, i
ndexCount); |
| 645 // can't flush if we are inside an unbalanced pushGeometrySource. | |
| 646 // Moreover, flushing blows away vertex and index data that was | |
| 647 // previously reserved. So if the vertex or index data is pulled from | |
| 648 // reserved space and won't be released by this request then we can't | |
| 649 // flush. | |
| 650 bool insideGeoPush = this->getGeoPoolStateStack().count() > 1; | |
| 651 | |
| 652 bool unreleasedVertexSpace = | |
| 653 !vertexCount && | |
| 654 kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc; | |
| 655 | |
| 656 bool unreleasedIndexSpace = | |
| 657 !indexCount && | |
| 658 kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc; | |
| 659 | |
| 660 int vcount = vertexCount; | |
| 661 int icount = indexCount; | |
| 662 | |
| 663 if (!insideGeoPush && | |
| 664 !unreleasedVertexSpace && | |
| 665 !unreleasedIndexSpace && | |
| 666 this->geometryHints(vertexStride, &vcount, &icount)) { | |
| 667 this->flush(); | |
| 668 } | |
| 669 } | 645 } |
| OLD | NEW |