blob: 05f9a3f878f006a2ddfb98ebe889ff09314d7555 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#include "GrInOrderDrawBuffer.h"
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000012#include "GrRenderTarget.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000013#include "GrTexture.h"
bsalomon@google.com1c13c962011-02-14 16:51:21 +000014#include "GrBufferAllocPool.h"
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000015#include "GrIndexBuffer.h"
16#include "GrVertexBuffer.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000017#include "GrGpu.h"
18
bsalomon@google.com471d4712011-08-23 15:45:25 +000019GrInOrderDrawBuffer::GrInOrderDrawBuffer(const GrGpu* gpu,
20 GrVertexBufferAllocPool* vertexPool,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000021 GrIndexBufferAllocPool* indexPool)
bsalomon@google.com97805382012-03-13 14:32:07 +000022 : fAutoFlushTarget(NULL)
23 , fClipSet(true)
robertphillips@google.com69705572012-03-21 19:46:50 +000024 , fVertexPool(*vertexPool)
25 , fIndexPool(*indexPool)
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000026 , fLastRectVertexLayout(0)
27 , fQuadIndexBuffer(NULL)
28 , fMaxQuads(0)
robertphillips@google.com69705572012-03-21 19:46:50 +000029 , fCurrQuad(0) {
bsalomon@google.com18c9c192011-09-22 21:01:31 +000030
31 fCaps = gpu->getCaps();
32
bsalomon@google.com1c13c962011-02-14 16:51:21 +000033 GrAssert(NULL != vertexPool);
34 GrAssert(NULL != indexPool);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000035
36 GeometryPoolState& poolState = fGeoPoolStateStack.push_back();
37 poolState.fUsedPoolVertexBytes = 0;
38 poolState.fUsedPoolIndexBytes = 0;
39#if GR_DEBUG
40 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
41 poolState.fPoolStartVertex = ~0;
42 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
43 poolState.fPoolStartIndex = ~0;
44#endif
bsalomon@google.com934c5702012-03-20 21:17:58 +000045 fInstancedDrawTracker.reset();
reed@google.comac10a2d2010-12-22 21:39:39 +000046}
47
48GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000049 this->reset();
bsalomon@google.com4a018bb2011-10-28 19:50:21 +000050 // This must be called by before the GrDrawTarget destructor
51 this->releaseGeometry();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000052 GrSafeUnref(fQuadIndexBuffer);
bsalomon@google.com97805382012-03-13 14:32:07 +000053 GrSafeUnref(fAutoFlushTarget);
reed@google.comac10a2d2010-12-22 21:39:39 +000054}
55
56void GrInOrderDrawBuffer::initializeDrawStateAndClip(const GrDrawTarget& target) {
57 this->copyDrawState(target);
58 this->setClip(target.getClip());
59}
60
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000061void GrInOrderDrawBuffer::setQuadIndexBuffer(const GrIndexBuffer* indexBuffer) {
62 bool newIdxBuffer = fQuadIndexBuffer != indexBuffer;
63 if (newIdxBuffer) {
64 GrSafeUnref(fQuadIndexBuffer);
65 fQuadIndexBuffer = indexBuffer;
66 GrSafeRef(fQuadIndexBuffer);
67 fCurrQuad = 0;
68 fMaxQuads = (NULL == indexBuffer) ? 0 : indexBuffer->maxQuads();
69 } else {
bsalomon@google.comd302f142011-03-03 13:54:13 +000070 GrAssert((NULL == indexBuffer && 0 == fMaxQuads) ||
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000071 (indexBuffer->maxQuads() == fMaxQuads));
72 }
73}
74
bsalomon@google.com934c5702012-03-20 21:17:58 +000075////////////////////////////////////////////////////////////////////////////////
76
77void GrInOrderDrawBuffer::resetDrawTracking() {
78 fCurrQuad = 0;
79 fInstancedDrawTracker.reset();
80}
81
bsalomon@google.comd302f142011-03-03 13:54:13 +000082void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000083 const GrMatrix* matrix,
bsalomon@google.com39ee0ff2011-12-06 15:32:52 +000084 StageMask stageMask,
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000085 const GrRect* srcRects[],
86 const GrMatrix* srcMatrices[]) {
bsalomon@google.comd302f142011-03-03 13:54:13 +000087
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000088 GrAssert(!(NULL == fQuadIndexBuffer && fCurrQuad));
89 GrAssert(!(fDraws.empty() && fCurrQuad));
90 GrAssert(!(0 != fMaxQuads && NULL == fQuadIndexBuffer));
91
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000092 GrDrawState* drawState = this->drawState();
93
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000094 // if we have a quad IB then either append to the previous run of
95 // rects or start a new run
96 if (fMaxQuads) {
bsalomon@google.comd302f142011-03-03 13:54:13 +000097
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000098 bool appendToPreviousDraw = false;
bsalomon@google.com39ee0ff2011-12-06 15:32:52 +000099 GrVertexLayout layout = GetRectVertexLayout(stageMask, srcRects);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000100 AutoReleaseGeometry geo(this, layout, 4, 0);
bsalomon@google.com6513cd02011-08-05 20:12:30 +0000101 if (!geo.succeeded()) {
102 GrPrintf("Failed to get space for vertices!\n");
103 return;
104 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000105 GrMatrix combinedMatrix = drawState->getViewMatrix();
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000106 // We go to device space so that matrix changes allow us to concat
107 // rect draws. When the caller has provided explicit source rects
108 // then we don't want to modify the sampler matrices. Otherwise we do
109 // we have to account for the view matrix change in the sampler
110 // matrices.
111 StageMask devCoordMask = (NULL == srcRects) ? stageMask : 0;
112 GrDrawTarget::AutoDeviceCoordDraw adcd(this, devCoordMask);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000113 if (NULL != matrix) {
114 combinedMatrix.preConcat(*matrix);
115 }
116
117 SetRectVertices(rect, &combinedMatrix, srcRects, srcMatrices, layout, geo.vertices());
118
119 // we don't want to miss an opportunity to batch rects together
120 // simply because the clip has changed if the clip doesn't affect
121 // the rect.
122 bool disabledClip = false;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000123 if (drawState->isClipState() && fClip.isRect()) {
bsalomon@google.comd302f142011-03-03 13:54:13 +0000124
bsalomon@google.com0b50b2e2011-03-08 21:07:21 +0000125 GrRect clipRect = fClip.getRect(0);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000126 // If the clip rect touches the edge of the viewport, extended it
127 // out (close) to infinity to avoid bogus intersections.
bsalomon@google.comd302f142011-03-03 13:54:13 +0000128 // We might consider a more exact clip to viewport if this
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000129 // conservative test fails.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000130 const GrRenderTarget* target = drawState->getRenderTarget();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000131 if (0 >= clipRect.fLeft) {
132 clipRect.fLeft = GR_ScalarMin;
133 }
134 if (target->width() <= clipRect.fRight) {
135 clipRect.fRight = GR_ScalarMax;
136 }
137 if (0 >= clipRect.top()) {
138 clipRect.fTop = GR_ScalarMin;
139 }
140 if (target->height() <= clipRect.fBottom) {
141 clipRect.fBottom = GR_ScalarMax;
142 }
143 int stride = VertexSize(layout);
144 bool insideClip = true;
145 for (int v = 0; v < 4; ++v) {
146 const GrPoint& p = *GetVertexPoint(geo.vertices(), v, stride);
147 if (!clipRect.contains(p)) {
148 insideClip = false;
149 break;
150 }
151 }
152 if (insideClip) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000153 drawState->disableState(GrDrawState::kClip_StateBit);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000154 disabledClip = true;
155 }
156 }
bsalomon@google.comd302f142011-03-03 13:54:13 +0000157 if (!needsNewClip() && !needsNewState() && fCurrQuad > 0 &&
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000158 fCurrQuad < fMaxQuads && layout == fLastRectVertexLayout) {
159
160 int vsize = VertexSize(layout);
bsalomon@google.comd302f142011-03-03 13:54:13 +0000161
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000162 Draw& lastDraw = fDraws.back();
163
164 GrAssert(lastDraw.fIndexBuffer == fQuadIndexBuffer);
165 GrAssert(kTriangles_PrimitiveType == lastDraw.fPrimitiveType);
166 GrAssert(0 == lastDraw.fVertexCount % 4);
167 GrAssert(0 == lastDraw.fIndexCount % 6);
168 GrAssert(0 == lastDraw.fStartIndex);
169
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000170 GeometryPoolState& poolState = fGeoPoolStateStack.back();
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000171 bool clearSinceLastDraw =
172 fClears.count() &&
173 fClears.back().fBeforeDrawIdx == fDraws.count();
174
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000175 appendToPreviousDraw =
176 !clearSinceLastDraw &&
177 lastDraw.fVertexBuffer == poolState.fPoolVertexBuffer &&
178 (fCurrQuad * 4 + lastDraw.fStartVertex) == poolState.fPoolStartVertex;
179
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000180 if (appendToPreviousDraw) {
181 lastDraw.fVertexCount += 4;
182 lastDraw.fIndexCount += 6;
183 fCurrQuad += 1;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000184 // we reserved above, so we should be the first
185 // use of this vertex reserveation.
186 GrAssert(0 == poolState.fUsedPoolVertexBytes);
187 poolState.fUsedPoolVertexBytes = 4 * vsize;
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000188 }
189 }
190 if (!appendToPreviousDraw) {
191 this->setIndexSourceToBuffer(fQuadIndexBuffer);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000192 this->drawIndexed(kTriangles_PrimitiveType, 0, 0, 4, 6);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000193 fCurrQuad = 1;
194 fLastRectVertexLayout = layout;
195 }
196 if (disabledClip) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000197 drawState->enableState(GrDrawState::kClip_StateBit);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000198 }
bsalomon@google.com934c5702012-03-20 21:17:58 +0000199 fInstancedDrawTracker.reset();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000200 } else {
bsalomon@google.com39ee0ff2011-12-06 15:32:52 +0000201 INHERITED::drawRect(rect, matrix, stageMask, srcRects, srcMatrices);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000202 }
203}
204
bsalomon@google.com934c5702012-03-20 21:17:58 +0000205void GrInOrderDrawBuffer::drawIndexedInstances(GrPrimitiveType type,
206 int instanceCount,
207 int verticesPerInstance,
208 int indicesPerInstance) {
209 if (!verticesPerInstance || !indicesPerInstance) {
210 return;
211 }
212
213 const GeometrySrcState& geomSrc = this->getGeomSrc();
214
215 // we only attempt to concat the case when reserved verts are used with
216 // an index buffer.
217 if (kReserved_GeometrySrcType == geomSrc.fVertexSrc &&
218 kBuffer_GeometrySrcType == geomSrc.fIndexSrc) {
219
220 Draw* draw = NULL;
221 // if the last draw used the same indices/vertices per shape then we
222 // may be able to append to it.
223 if (verticesPerInstance == fInstancedDrawTracker.fVerticesPerInstance &&
224 indicesPerInstance == fInstancedDrawTracker.fIndicesPerInstance) {
225 GrAssert(fDraws.count());
226 draw = &fDraws.back();
227 }
228
229 bool clipChanged = this->needsNewClip();
230 bool stateChanged = this->needsNewState();
231 if (clipChanged) {
232 this->pushClip();
233 }
234 if (stateChanged) {
235 this->pushState();
236 }
237
238 GeometryPoolState& poolState = fGeoPoolStateStack.back();
239 const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer;
240
241 // Check whether the draw is compatible with this draw in order to
242 // append
243 if (NULL == draw ||
244 clipChanged ||
245 stateChanged ||
246 draw->fIndexBuffer != geomSrc.fIndexBuffer ||
247 draw->fPrimitiveType != type ||
248 draw->fVertexBuffer != vertexBuffer) {
249
250 draw = &fDraws.push_back();
251 draw->fClipChanged = clipChanged;
252 draw->fStateChanged = stateChanged;
253 draw->fIndexBuffer = geomSrc.fIndexBuffer;
254 geomSrc.fIndexBuffer->ref();
255 draw->fVertexBuffer = vertexBuffer;
256 vertexBuffer->ref();
257 draw->fPrimitiveType = type;
258 draw->fStartIndex = 0;
259 draw->fIndexCount = 0;
260 draw->fStartVertex = poolState.fPoolStartVertex;
261 draw->fVertexCount = 0;
262 draw->fVertexLayout = geomSrc.fVertexLayout;
263 } else {
264 GrAssert(!(draw->fIndexCount % indicesPerInstance));
265 GrAssert(!(draw->fVertexCount % verticesPerInstance));
266 GrAssert(poolState.fPoolStartVertex == draw->fStartVertex +
267 draw->fVertexCount);
268 }
269
270 // how many instances can be in a single draw
271 int maxInstancesPerDraw = this->indexCountInCurrentSource() /
272 indicesPerInstance;
273 if (!maxInstancesPerDraw) {
274 return;
275 }
276 // how many instances should be concat'ed onto draw
277 int instancesToConcat = maxInstancesPerDraw - draw->fVertexCount /
278 verticesPerInstance;
279 if (maxInstancesPerDraw > instanceCount) {
280 maxInstancesPerDraw = instanceCount;
281 if (instancesToConcat > instanceCount) {
282 instancesToConcat = instanceCount;
283 }
284 }
285
286 // update the amount of reserved data actually referenced in draws
287 size_t vertexBytes = instanceCount * verticesPerInstance *
288 VertexSize(draw->fVertexLayout);
289 poolState.fUsedPoolVertexBytes =
290 GrMax(poolState.fUsedPoolVertexBytes, vertexBytes);
291
292 while (instanceCount) {
293 if (!instancesToConcat) {
294 int startVertex = draw->fStartVertex + draw->fVertexCount;
295 draw = &fDraws.push_back();
296 draw->fClipChanged = false;
297 draw->fStateChanged = false;
298 draw->fIndexBuffer = geomSrc.fIndexBuffer;
299 geomSrc.fIndexBuffer->ref();
300 draw->fVertexBuffer = vertexBuffer;
301 vertexBuffer->ref();
302 draw->fPrimitiveType = type;
303 draw->fStartIndex = 0;
304 draw->fStartVertex = startVertex;
305 draw->fVertexCount = 0;
306 draw->fVertexLayout = geomSrc.fVertexLayout;
307 instancesToConcat = maxInstancesPerDraw;
308 }
309 draw->fVertexCount += instancesToConcat * verticesPerInstance;
310 draw->fIndexCount += instancesToConcat * indicesPerInstance;
311 instanceCount -= instancesToConcat;
312 instancesToConcat = 0;
313 }
314
315 // update draw tracking for next draw
316 fCurrQuad = 0;
317 fInstancedDrawTracker.fVerticesPerInstance = verticesPerInstance;
318 fInstancedDrawTracker.fIndicesPerInstance = indicesPerInstance;
319 } else {
320 this->INHERITED::drawIndexedInstances(type,
321 instanceCount,
322 verticesPerInstance,
323 indicesPerInstance);
324 }
325
326}
327
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000328void GrInOrderDrawBuffer::onDrawIndexed(GrPrimitiveType primitiveType,
329 int startVertex,
330 int startIndex,
331 int vertexCount,
332 int indexCount) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000333
334 if (!vertexCount || !indexCount) {
335 return;
336 }
337
bsalomon@google.com934c5702012-03-20 21:17:58 +0000338 this->resetDrawTracking();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000339
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000340 GeometryPoolState& poolState = fGeoPoolStateStack.back();
341
reed@google.comac10a2d2010-12-22 21:39:39 +0000342 Draw& draw = fDraws.push_back();
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000343 draw.fPrimitiveType = primitiveType;
reed@google.comac10a2d2010-12-22 21:39:39 +0000344 draw.fStartVertex = startVertex;
345 draw.fStartIndex = startIndex;
346 draw.fVertexCount = vertexCount;
347 draw.fIndexCount = indexCount;
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000348
349 draw.fClipChanged = this->needsNewClip();
350 if (draw.fClipChanged) {
351 this->pushClip();
352 }
353
354 draw.fStateChanged = this->needsNewState();
355 if (draw.fStateChanged) {
356 this->pushState();
357 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000358
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000359 draw.fVertexLayout = this->getGeomSrc().fVertexLayout;
360 switch (this->getGeomSrc().fVertexSrc) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000361 case kBuffer_GeometrySrcType:
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000362 draw.fVertexBuffer = this->getGeomSrc().fVertexBuffer;
reed@google.comac10a2d2010-12-22 21:39:39 +0000363 break;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000364 case kReserved_GeometrySrcType: // fallthrough
365 case kArray_GeometrySrcType: {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000366 size_t vertexBytes = (vertexCount + startVertex) *
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000367 VertexSize(this->getGeomSrc().fVertexLayout);
368 poolState.fUsedPoolVertexBytes =
369 GrMax(poolState.fUsedPoolVertexBytes, vertexBytes);
370 draw.fVertexBuffer = poolState.fPoolVertexBuffer;
371 draw.fStartVertex += poolState.fPoolStartVertex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000372 break;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000373 }
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000374 default:
375 GrCrash("unknown geom src type");
reed@google.comac10a2d2010-12-22 21:39:39 +0000376 }
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000377 draw.fVertexBuffer->ref();
reed@google.comac10a2d2010-12-22 21:39:39 +0000378
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000379 switch (this->getGeomSrc().fIndexSrc) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000380 case kBuffer_GeometrySrcType:
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000381 draw.fIndexBuffer = this->getGeomSrc().fIndexBuffer;
reed@google.comac10a2d2010-12-22 21:39:39 +0000382 break;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000383 case kReserved_GeometrySrcType: // fallthrough
384 case kArray_GeometrySrcType: {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000385 size_t indexBytes = (indexCount + startIndex) * sizeof(uint16_t);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000386 poolState.fUsedPoolIndexBytes =
387 GrMax(poolState.fUsedPoolIndexBytes, indexBytes);
388 draw.fIndexBuffer = poolState.fPoolIndexBuffer;
bsalomon@google.comd127ffe2012-02-24 20:11:52 +0000389 draw.fStartIndex += poolState.fPoolStartIndex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000390 break;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000391 }
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000392 default:
393 GrCrash("unknown geom src type");
reed@google.comac10a2d2010-12-22 21:39:39 +0000394 }
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000395 draw.fIndexBuffer->ref();
reed@google.comac10a2d2010-12-22 21:39:39 +0000396}
397
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000398void GrInOrderDrawBuffer::onDrawNonIndexed(GrPrimitiveType primitiveType,
399 int startVertex,
400 int vertexCount) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000401 if (!vertexCount) {
402 return;
403 }
404
bsalomon@google.com934c5702012-03-20 21:17:58 +0000405 this->resetDrawTracking();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000406
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000407 GeometryPoolState& poolState = fGeoPoolStateStack.back();
408
reed@google.comac10a2d2010-12-22 21:39:39 +0000409 Draw& draw = fDraws.push_back();
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000410 draw.fPrimitiveType = primitiveType;
reed@google.comac10a2d2010-12-22 21:39:39 +0000411 draw.fStartVertex = startVertex;
412 draw.fStartIndex = 0;
413 draw.fVertexCount = vertexCount;
414 draw.fIndexCount = 0;
415
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000416 draw.fClipChanged = this->needsNewClip();
417 if (draw.fClipChanged) {
418 this->pushClip();
419 }
420
421 draw.fStateChanged = this->needsNewState();
422 if (draw.fStateChanged) {
423 this->pushState();
424 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000425
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000426 draw.fVertexLayout = this->getGeomSrc().fVertexLayout;
427 switch (this->getGeomSrc().fVertexSrc) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000428 case kBuffer_GeometrySrcType:
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000429 draw.fVertexBuffer = this->getGeomSrc().fVertexBuffer;
reed@google.comac10a2d2010-12-22 21:39:39 +0000430 break;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000431 case kReserved_GeometrySrcType: // fallthrough
432 case kArray_GeometrySrcType: {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000433 size_t vertexBytes = (vertexCount + startVertex) *
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000434 VertexSize(this->getGeomSrc().fVertexLayout);
435 poolState.fUsedPoolVertexBytes =
436 GrMax(poolState.fUsedPoolVertexBytes, vertexBytes);
437 draw.fVertexBuffer = poolState.fPoolVertexBuffer;
438 draw.fStartVertex += poolState.fPoolStartVertex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000439 break;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000440 }
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000441 default:
442 GrCrash("unknown geom src type");
reed@google.comac10a2d2010-12-22 21:39:39 +0000443 }
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000444 draw.fVertexBuffer->ref();
445 draw.fIndexBuffer = NULL;
reed@google.comac10a2d2010-12-22 21:39:39 +0000446}
447
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000448void GrInOrderDrawBuffer::clear(const GrIRect* rect, GrColor color) {
449 GrIRect r;
450 if (NULL == rect) {
451 // We could do something smart and remove previous draws and clears to
452 // the current render target. If we get that smart we have to make sure
453 // those draws aren't read before this clear (render-to-texture).
454 r.setLTRB(0, 0,
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000455 this->getDrawState().getRenderTarget()->width(),
456 this->getDrawState().getRenderTarget()->height());
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000457 rect = &r;
458 }
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000459 Clear& clr = fClears.push_back();
460 clr.fColor = color;
461 clr.fBeforeDrawIdx = fDraws.count();
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000462 clr.fRect = *rect;
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000463}
464
reed@google.comac10a2d2010-12-22 21:39:39 +0000465void GrInOrderDrawBuffer::reset() {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000466 GrAssert(1 == fGeoPoolStateStack.count());
467 this->resetVertexSource();
468 this->resetIndexSource();
reed@google.comac10a2d2010-12-22 21:39:39 +0000469 uint32_t numStates = fStates.count();
470 for (uint32_t i = 0; i < numStates; ++i) {
tomhudson@google.com93813632011-10-27 20:21:16 +0000471 const GrDrawState& dstate = this->accessSavedDrawState(fStates[i]);
472 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000473 GrSafeUnref(dstate.getTexture(s));
reed@google.comac10a2d2010-12-22 21:39:39 +0000474 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000475 GrSafeUnref(dstate.getRenderTarget());
reed@google.comac10a2d2010-12-22 21:39:39 +0000476 }
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000477 int numDraws = fDraws.count();
478 for (int d = 0; d < numDraws; ++d) {
479 // we always have a VB, but not always an IB
480 GrAssert(NULL != fDraws[d].fVertexBuffer);
481 fDraws[d].fVertexBuffer->unref();
482 GrSafeUnref(fDraws[d].fIndexBuffer);
483 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000484 fDraws.reset();
485 fStates.reset();
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000486
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000487 fClears.reset();
488
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000489 fVertexPool.reset();
490 fIndexPool.reset();
491
reed@google.comac10a2d2010-12-22 21:39:39 +0000492 fClips.reset();
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000493
bsalomon@google.com934c5702012-03-20 21:17:58 +0000494 this->resetDrawTracking();
reed@google.comac10a2d2010-12-22 21:39:39 +0000495}
496
497void GrInOrderDrawBuffer::playback(GrDrawTarget* target) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000498 GrAssert(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc);
499 GrAssert(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000500
reed@google.comac10a2d2010-12-22 21:39:39 +0000501 GrAssert(NULL != target);
502 GrAssert(target != this); // not considered and why?
503
bsalomon@google.com898d9e52011-04-26 13:22:33 +0000504 int numDraws = fDraws.count();
reed@google.comac10a2d2010-12-22 21:39:39 +0000505 if (!numDraws) {
506 return;
507 }
508
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000509 fVertexPool.unlock();
510 fIndexPool.unlock();
reed@google.comac10a2d2010-12-22 21:39:39 +0000511
bsalomon@google.com290e5362012-03-27 14:34:08 +0000512 GrDrawTarget::AutoStateRestore asr(target);
reed@google.comac10a2d2010-12-22 21:39:39 +0000513 GrDrawTarget::AutoClipRestore acr(target);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000514 AutoGeometryPush agp(target);
reed@google.comac10a2d2010-12-22 21:39:39 +0000515
bsalomon@google.com6a77cc52011-04-28 17:33:34 +0000516 int currState = ~0;
517 int currClip = ~0;
518 int currClear = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000519
bsalomon@google.com898d9e52011-04-26 13:22:33 +0000520 for (int i = 0; i < numDraws; ++i) {
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000521 while (currClear < fClears.count() &&
522 i == fClears[currClear].fBeforeDrawIdx) {
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000523 target->clear(&fClears[currClear].fRect, fClears[currClear].fColor);
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000524 ++currClear;
525 }
526
reed@google.comac10a2d2010-12-22 21:39:39 +0000527 const Draw& draw = fDraws[i];
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000528 if (draw.fStateChanged) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000529 ++currState;
bsalomon@google.com290e5362012-03-27 14:34:08 +0000530 target->restoreDrawState(fStates[currState]);
reed@google.comac10a2d2010-12-22 21:39:39 +0000531 }
532 if (draw.fClipChanged) {
533 ++currClip;
534 target->setClip(fClips[currClip]);
535 }
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000536
537 target->setVertexSourceToBuffer(draw.fVertexLayout, draw.fVertexBuffer);
538
reed@google.comac10a2d2010-12-22 21:39:39 +0000539 if (draw.fIndexCount) {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000540 target->setIndexSourceToBuffer(draw.fIndexBuffer);
541 }
542
543 if (draw.fIndexCount) {
544 target->drawIndexed(draw.fPrimitiveType,
reed@google.comac10a2d2010-12-22 21:39:39 +0000545 draw.fStartVertex,
546 draw.fStartIndex,
547 draw.fVertexCount,
548 draw.fIndexCount);
549 } else {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000550 target->drawNonIndexed(draw.fPrimitiveType,
reed@google.comac10a2d2010-12-22 21:39:39 +0000551 draw.fStartVertex,
552 draw.fVertexCount);
553 }
554 }
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000555 while (currClear < fClears.count()) {
556 GrAssert(fDraws.count() == fClears[currClear].fBeforeDrawIdx);
bsalomon@google.com6aa25c32011-04-27 19:55:29 +0000557 target->clear(&fClears[currClear].fRect, fClears[currClear].fColor);
bsalomon@google.com0b335c12011-04-25 19:17:44 +0000558 ++currClear;
559 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000560}
561
bsalomon@google.com97805382012-03-13 14:32:07 +0000562void GrInOrderDrawBuffer::setAutoFlushTarget(GrDrawTarget* target) {
563 GrSafeAssign(fAutoFlushTarget, target);
564}
565
566void GrInOrderDrawBuffer::willReserveVertexAndIndexSpace(
567 GrVertexLayout vertexLayout,
568 int vertexCount,
569 int indexCount) {
570 if (NULL != fAutoFlushTarget) {
571 // We use geometryHints() to know whether to flush the draw buffer. We
572 // can't flush if we are inside an unbalanced pushGeometrySource.
573 // Moreover, flushing blows away vertex and index data that was
574 // previously reserved. So if the vertex or index data is pulled from
575 // reserved space and won't be released by this request then we can't
576 // flush.
577 bool insideGeoPush = fGeoPoolStateStack.count() > 1;
578
579 bool unreleasedVertexSpace =
580 !vertexCount &&
581 kReserved_GeometrySrcType == this->getGeomSrc().fVertexSrc;
582
583 bool unreleasedIndexSpace =
584 !indexCount &&
585 kReserved_GeometrySrcType == this->getGeomSrc().fIndexSrc;
586
587 // we don't want to finalize any reserved geom on the target since
588 // we don't know that the client has finished writing to it.
589 bool targetHasReservedGeom =
590 fAutoFlushTarget->hasReservedVerticesOrIndices();
591
592 int vcount = vertexCount;
593 int icount = indexCount;
594
595 if (!insideGeoPush &&
596 !unreleasedVertexSpace &&
597 !unreleasedIndexSpace &&
598 !targetHasReservedGeom &&
599 this->geometryHints(vertexLayout, &vcount, &icount)) {
600
601 this->flushTo(fAutoFlushTarget);
602 }
603 }
604}
605
reed@google.comac10a2d2010-12-22 21:39:39 +0000606bool GrInOrderDrawBuffer::geometryHints(GrVertexLayout vertexLayout,
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000607 int* vertexCount,
608 int* indexCount) const {
609 // we will recommend a flush if the data could fit in a single
610 // preallocated buffer but none are left and it can't fit
611 // in the current buffer (which may not be prealloced).
reed@google.comac10a2d2010-12-22 21:39:39 +0000612 bool flush = false;
613 if (NULL != indexCount) {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000614 int32_t currIndices = fIndexPool.currentBufferIndices();
615 if (*indexCount > currIndices &&
616 (!fIndexPool.preallocatedBuffersRemaining() &&
617 *indexCount <= fIndexPool.preallocatedBufferIndices())) {
618
619 flush = true;
620 }
621 *indexCount = currIndices;
reed@google.comac10a2d2010-12-22 21:39:39 +0000622 }
623 if (NULL != vertexCount) {
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000624 int32_t currVertices = fVertexPool.currentBufferVertices(vertexLayout);
625 if (*vertexCount > currVertices &&
626 (!fVertexPool.preallocatedBuffersRemaining() &&
627 *vertexCount <= fVertexPool.preallocatedBufferVertices(vertexLayout))) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000628
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000629 flush = true;
reed@google.comac10a2d2010-12-22 21:39:39 +0000630 }
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000631 *vertexCount = currVertices;
reed@google.comac10a2d2010-12-22 21:39:39 +0000632 }
633 return flush;
634}
635
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000636bool GrInOrderDrawBuffer::onReserveVertexSpace(GrVertexLayout vertexLayout,
637 int vertexCount,
638 void** vertices) {
639 GeometryPoolState& poolState = fGeoPoolStateStack.back();
640 GrAssert(vertexCount > 0);
641 GrAssert(NULL != vertices);
642 GrAssert(0 == poolState.fUsedPoolVertexBytes);
643
644 *vertices = fVertexPool.makeSpace(vertexLayout,
645 vertexCount,
646 &poolState.fPoolVertexBuffer,
647 &poolState.fPoolStartVertex);
648 return NULL != *vertices;
649}
650
651bool GrInOrderDrawBuffer::onReserveIndexSpace(int indexCount, void** indices) {
652 GeometryPoolState& poolState = fGeoPoolStateStack.back();
653 GrAssert(indexCount > 0);
654 GrAssert(NULL != indices);
655 GrAssert(0 == poolState.fUsedPoolIndexBytes);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000656
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000657 *indices = fIndexPool.makeSpace(indexCount,
658 &poolState.fPoolIndexBuffer,
659 &poolState.fPoolStartIndex);
660 return NULL != *indices;
reed@google.comac10a2d2010-12-22 21:39:39 +0000661}
662
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000663void GrInOrderDrawBuffer::releaseReservedVertexSpace() {
664 GeometryPoolState& poolState = fGeoPoolStateStack.back();
665 const GeometrySrcState& geoSrc = this->getGeomSrc();
666
667 GrAssert(kReserved_GeometrySrcType == geoSrc.fVertexSrc);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000668
669 // When the caller reserved vertex buffer space we gave it back a pointer
670 // provided by the vertex buffer pool. At each draw we tracked the largest
671 // offset into the pool's pointer that was referenced. Now we return to the
672 // pool any portion at the tail of the allocation that no draw referenced.
673 size_t reservedVertexBytes = VertexSize(geoSrc.fVertexLayout) *
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000674 geoSrc.fVertexCount;
675 fVertexPool.putBack(reservedVertexBytes -
676 poolState.fUsedPoolVertexBytes);
677 poolState.fUsedPoolVertexBytes = 0;
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000678 poolState.fPoolVertexBuffer = NULL;
679 poolState.fPoolStartVertex = 0;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000680}
681
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000682void GrInOrderDrawBuffer::releaseReservedIndexSpace() {
683 GeometryPoolState& poolState = fGeoPoolStateStack.back();
684 const GeometrySrcState& geoSrc = this->getGeomSrc();
685
686 GrAssert(kReserved_GeometrySrcType == geoSrc.fIndexSrc);
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000687
688 // Similar to releaseReservedVertexSpace we return any unused portion at
689 // the tail
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000690 size_t reservedIndexBytes = sizeof(uint16_t) * geoSrc.fIndexCount;
691 fIndexPool.putBack(reservedIndexBytes - poolState.fUsedPoolIndexBytes);
692 poolState.fUsedPoolIndexBytes = 0;
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000693 poolState.fPoolIndexBuffer = NULL;
694 poolState.fPoolStartIndex = 0;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000695}
696
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000697void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray,
698 int vertexCount) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000699
700 GeometryPoolState& poolState = fGeoPoolStateStack.back();
701 GrAssert(0 == poolState.fUsedPoolVertexBytes);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000702#if GR_DEBUG
703 bool success =
704#endif
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000705 fVertexPool.appendVertices(this->getGeomSrc().fVertexLayout,
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000706 vertexCount,
707 vertexArray,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000708 &poolState.fPoolVertexBuffer,
709 &poolState.fPoolStartVertex);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000710 GR_DEBUGASSERT(success);
711}
712
bsalomon@google.combcdbbe62011-04-12 15:40:00 +0000713void GrInOrderDrawBuffer::onSetIndexSourceToArray(const void* indexArray,
714 int indexCount) {
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000715 GeometryPoolState& poolState = fGeoPoolStateStack.back();
716 GrAssert(0 == poolState.fUsedPoolIndexBytes);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000717#if GR_DEBUG
718 bool success =
719#endif
720 fIndexPool.appendIndices(indexCount,
721 indexArray,
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000722 &poolState.fPoolIndexBuffer,
723 &poolState.fPoolStartIndex);
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000724 GR_DEBUGASSERT(success);
reed@google.comac10a2d2010-12-22 21:39:39 +0000725}
726
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000727void GrInOrderDrawBuffer::releaseVertexArray() {
728 // When the client provides an array as the vertex source we handled it
729 // by copying their array into reserved space.
730 this->GrInOrderDrawBuffer::releaseReservedVertexSpace();
731}
732
733void GrInOrderDrawBuffer::releaseIndexArray() {
734 // When the client provides an array as the index source we handled it
735 // by copying their array into reserved space.
736 this->GrInOrderDrawBuffer::releaseReservedIndexSpace();
737}
738
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000739void GrInOrderDrawBuffer::geometrySourceWillPush() {
740 GeometryPoolState& poolState = fGeoPoolStateStack.push_back();
741 poolState.fUsedPoolVertexBytes = 0;
742 poolState.fUsedPoolIndexBytes = 0;
bsalomon@google.com934c5702012-03-20 21:17:58 +0000743 this->resetDrawTracking();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000744#if GR_DEBUG
745 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
746 poolState.fPoolStartVertex = ~0;
747 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
748 poolState.fPoolStartIndex = ~0;
749#endif
750}
751
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000752void GrInOrderDrawBuffer::geometrySourceWillPop(
753 const GeometrySrcState& restoredState) {
754 GrAssert(fGeoPoolStateStack.count() > 1);
755 fGeoPoolStateStack.pop_back();
756 GeometryPoolState& poolState = fGeoPoolStateStack.back();
757 // we have to assume that any slack we had in our vertex/index data
758 // is now unreleasable because data may have been appended later in the
759 // pool.
760 if (kReserved_GeometrySrcType == restoredState.fVertexSrc ||
761 kArray_GeometrySrcType == restoredState.fVertexSrc) {
762 poolState.fUsedPoolVertexBytes =
763 VertexSize(restoredState.fVertexLayout) *
764 restoredState.fVertexCount;
765 }
766 if (kReserved_GeometrySrcType == restoredState.fIndexSrc ||
767 kArray_GeometrySrcType == restoredState.fIndexSrc) {
bsalomon@google.com3f5a95e2012-03-08 16:41:42 +0000768 poolState.fUsedPoolIndexBytes = sizeof(uint16_t) *
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000769 restoredState.fIndexCount;
770 }
bsalomon@google.com934c5702012-03-20 21:17:58 +0000771 this->resetDrawTracking();
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000772}
773
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000774bool GrInOrderDrawBuffer::needsNewState() const {
775 if (fStates.empty()) {
776 return true;
777 } else {
tomhudson@google.com93813632011-10-27 20:21:16 +0000778 const GrDrawState& old = this->accessSavedDrawState(fStates.back());
bsalomon@google.com290e5362012-03-27 14:34:08 +0000779 return old != fCurrDrawState;
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000780 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000781}
782
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000783void GrInOrderDrawBuffer::pushState() {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000784 const GrDrawState& drawState = this->getDrawState();
tomhudson@google.com93813632011-10-27 20:21:16 +0000785 for (int s = 0; s < GrDrawState::kNumStages; ++s) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000786 GrSafeRef(drawState.getTexture(s));
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000787 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000788 GrSafeRef(drawState.getRenderTarget());
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000789 this->saveCurrentDrawState(&fStates.push_back());
790 }
bsalomon@google.comd302f142011-03-03 13:54:13 +0000791
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000792bool GrInOrderDrawBuffer::needsNewClip() const {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000793 if (this->getDrawState().isClipState()) {
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000794 if (fClips.empty() || (fClipSet && fClips.back() != fClip)) {
795 return true;
796 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000797 }
798 return false;
799}
bsalomon@google.comd302f142011-03-03 13:54:13 +0000800
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000801void GrInOrderDrawBuffer::pushClip() {
802 fClips.push_back() = fClip;
803 fClipSet = false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000804}
bsalomon@google.comd302f142011-03-03 13:54:13 +0000805
bsalomon@google.comdea2f8d2011-08-01 15:51:05 +0000806void GrInOrderDrawBuffer::clipWillBeSet(const GrClip& newClip) {
807 INHERITED::clipWillBeSet(newClip);
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000808 fClipSet = true;
809}