Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrMemoryPool.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 , fClipSet(true) 26 , fClipSet(true)
27 , fClipProxyState(kUnknown_ClipProxyState) 27 , fClipProxyState(kUnknown_ClipProxyState)
28 , fVertexPool(*vertexPool) 28 , fVertexPool(*vertexPool)
29 , fIndexPool(*indexPool) 29 , fIndexPool(*indexPool)
30 , fFlushing(false) 30 , fFlushing(false)
31 , fDrawID(0) { 31 , fDrawID(0) {
32 32
33 fDstGpu->ref(); 33 fDstGpu->ref();
34 fCaps.reset(SkRef(fDstGpu->caps())); 34 fCaps.reset(SkRef(fDstGpu->caps()));
35 35
36 GrAssert(NULL != vertexPool); 36 SkASSERT(NULL != vertexPool);
37 GrAssert(NULL != indexPool); 37 SkASSERT(NULL != indexPool);
38 38
39 GeometryPoolState& poolState = fGeoPoolStateStack.push_back(); 39 GeometryPoolState& poolState = fGeoPoolStateStack.push_back();
40 poolState.fUsedPoolVertexBytes = 0; 40 poolState.fUsedPoolVertexBytes = 0;
41 poolState.fUsedPoolIndexBytes = 0; 41 poolState.fUsedPoolIndexBytes = 0;
42 #if GR_DEBUG 42 #if GR_DEBUG
43 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0; 43 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
44 poolState.fPoolStartVertex = ~0; 44 poolState.fPoolStartVertex = ~0;
45 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0; 45 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
46 poolState.fPoolStartIndex = ~0; 46 poolState.fPoolStartIndex = ~0;
47 #endif 47 #endif
48 this->reset(); 48 this->reset();
49 } 49 }
50 50
51 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { 51 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
52 this->reset(); 52 this->reset();
53 // This must be called by before the GrDrawTarget destructor 53 // This must be called by before the GrDrawTarget destructor
54 this->releaseGeometry(); 54 this->releaseGeometry();
55 fDstGpu->unref(); 55 fDstGpu->unref();
56 } 56 }
57 57
58 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
59 59
60 namespace { 60 namespace {
61 void get_vertex_bounds(const void* vertices, 61 void get_vertex_bounds(const void* vertices,
62 size_t vertexSize, 62 size_t vertexSize,
63 int vertexCount, 63 int vertexCount,
64 SkRect* bounds) { 64 SkRect* bounds) {
65 GrAssert(vertexSize >= sizeof(GrPoint)); 65 SkASSERT(vertexSize >= sizeof(GrPoint));
66 GrAssert(vertexCount > 0); 66 SkASSERT(vertexCount > 0);
67 const GrPoint* point = static_cast<const GrPoint*>(vertices); 67 const GrPoint* point = static_cast<const GrPoint*>(vertices);
68 bounds->fLeft = bounds->fRight = point->fX; 68 bounds->fLeft = bounds->fRight = point->fX;
69 bounds->fTop = bounds->fBottom = point->fY; 69 bounds->fTop = bounds->fBottom = point->fY;
70 for (int i = 1; i < vertexCount; ++i) { 70 for (int i = 1; i < vertexCount; ++i) {
71 point = reinterpret_cast<GrPoint*>(reinterpret_cast<intptr_t>(point) + v ertexSize); 71 point = reinterpret_cast<GrPoint*>(reinterpret_cast<intptr_t>(point) + v ertexSize);
72 bounds->growToInclude(point->fX, point->fY); 72 bounds->growToInclude(point->fX, point->fY);
73 } 73 }
74 } 74 }
75 } 75 }
76 76
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 for (int i = 0; i < 4; ++i) { 189 for (int i = 0; i < 4; ++i) {
190 *vertColor = color; 190 *vertColor = color;
191 vertColor = (GrColor*) ((intptr_t) vertColor + vsize); 191 vertColor = (GrColor*) ((intptr_t) vertColor + vsize);
192 } 192 }
193 } 193 }
194 194
195 this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer()); 195 this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer());
196 this->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds); 196 this->drawIndexedInstances(kTriangles_GrPrimitiveType, 1, 4, 6, &devBounds);
197 197
198 // to ensure that stashing the drawState ptr is valid 198 // to ensure that stashing the drawState ptr is valid
199 GrAssert(this->drawState() == drawState); 199 SkASSERT(this->drawState() == drawState);
200 } 200 }
201 201
202 bool GrInOrderDrawBuffer::quickInsideClip(const SkRect& devBounds) { 202 bool GrInOrderDrawBuffer::quickInsideClip(const SkRect& devBounds) {
203 if (!this->getDrawState().isClipState()) { 203 if (!this->getDrawState().isClipState()) {
204 return true; 204 return true;
205 } 205 }
206 if (kUnknown_ClipProxyState == fClipProxyState) { 206 if (kUnknown_ClipProxyState == fClipProxyState) {
207 SkIRect rect; 207 SkIRect rect;
208 bool iior; 208 bool iior;
209 this->getClip()->getConservativeBounds(this->getDrawState().getRenderTar get(), &rect, &iior); 209 this->getClip()->getConservativeBounds(this->getDrawState().getRenderTar get(), &rect, &iior);
(...skipping 25 matching lines...) Expand all
235 return fClipProxy.contains(devBounds); 235 return fClipProxy.contains(devBounds);
236 } 236 }
237 SkPoint originOffset = {SkIntToScalar(this->getClip()->fOrigin.fX), 237 SkPoint originOffset = {SkIntToScalar(this->getClip()->fOrigin.fX),
238 SkIntToScalar(this->getClip()->fOrigin.fY)}; 238 SkIntToScalar(this->getClip()->fOrigin.fY)};
239 SkRect clipSpaceBounds = devBounds; 239 SkRect clipSpaceBounds = devBounds;
240 clipSpaceBounds.offset(originOffset); 240 clipSpaceBounds.offset(originOffset);
241 return this->getClip()->fClipStack->quickContains(clipSpaceBounds); 241 return this->getClip()->fClipStack->quickContains(clipSpaceBounds);
242 } 242 }
243 243
244 int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) { 244 int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) {
245 GrAssert(info.isInstanced()); 245 SkASSERT(info.isInstanced());
246 246
247 const GeometrySrcState& geomSrc = this->getGeomSrc(); 247 const GeometrySrcState& geomSrc = this->getGeomSrc();
248 const GrDrawState& drawState = this->getDrawState(); 248 const GrDrawState& drawState = this->getDrawState();
249 249
250 // we only attempt to concat the case when reserved verts are used with a cl ient-specified index 250 // we only attempt to concat the case when reserved verts are used with a cl ient-specified index
251 // buffer. To make this work with client-specified VBs we'd need to know if the VB was updated 251 // buffer. To make this work with client-specified VBs we'd need to know if the VB was updated
252 // between draws. 252 // between draws.
253 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || 253 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc ||
254 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { 254 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) {
255 return 0; 255 return 0;
(...skipping 15 matching lines...) Expand all
271 draw->fIndexBuffer != geomSrc.fIndexBuffer) { 271 draw->fIndexBuffer != geomSrc.fIndexBuffer) {
272 return 0; 272 return 0;
273 } 273 }
274 // info does not yet account for the offset from the start of the pool's VB while the previous 274 // info does not yet account for the offset from the start of the pool's VB while the previous
275 // draw record does. 275 // draw record does.
276 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex(); 276 int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex();
277 if (draw->startVertex() + draw->vertexCount() != adjustedStartVertex) { 277 if (draw->startVertex() + draw->vertexCount() != adjustedStartVertex) {
278 return 0; 278 return 0;
279 } 279 }
280 280
281 GrAssert(poolState.fPoolStartVertex == draw->startVertex() + draw->vertexCou nt()); 281 SkASSERT(poolState.fPoolStartVertex == draw->startVertex() + draw->vertexCou nt());
282 282
283 // how many instances can be concat'ed onto draw given the size of the index buffer 283 // how many instances can be concat'ed onto draw given the size of the index buffer
284 int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerI nstance(); 284 int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerI nstance();
285 instancesToConcat -= draw->instanceCount(); 285 instancesToConcat -= draw->instanceCount();
286 instancesToConcat = GrMin(instancesToConcat, info.instanceCount()); 286 instancesToConcat = GrMin(instancesToConcat, info.instanceCount());
287 287
288 // update the amount of reserved vertex data actually referenced in draws 288 // update the amount of reserved vertex data actually referenced in draws
289 size_t vertexBytes = instancesToConcat * info.verticesPerInstance() * 289 size_t vertexBytes = instancesToConcat * info.verticesPerInstance() *
290 drawState.getVertexSize(); 290 drawState.getVertexSize();
291 poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, verte xBytes); 291 poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, verte xBytes);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 sp->fPath.reset(path); 399 sp->fPath.reset(path);
400 path->ref(); 400 path->ref();
401 sp->fFill = fill; 401 sp->fFill = fill;
402 sp->fStroke = stroke; 402 sp->fStroke = stroke;
403 } 403 }
404 404
405 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg et* renderTarget) { 405 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg et* renderTarget) {
406 SkIRect r; 406 SkIRect r;
407 if (NULL == renderTarget) { 407 if (NULL == renderTarget) {
408 renderTarget = this->drawState()->getRenderTarget(); 408 renderTarget = this->drawState()->getRenderTarget();
409 GrAssert(NULL != renderTarget); 409 SkASSERT(NULL != renderTarget);
410 } 410 }
411 if (NULL == rect) { 411 if (NULL == rect) {
412 // We could do something smart and remove previous draws and clears to 412 // We could do something smart and remove previous draws and clears to
413 // the current render target. If we get that smart we have to make sure 413 // the current render target. If we get that smart we have to make sure
414 // those draws aren't read before this clear (render-to-texture). 414 // those draws aren't read before this clear (render-to-texture).
415 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height()); 415 r.setLTRB(0, 0, renderTarget->width(), renderTarget->height());
416 rect = &r; 416 rect = &r;
417 } 417 }
418 Clear* clr = this->recordClear(); 418 Clear* clr = this->recordClear();
419 clr->fColor = color; 419 clr->fColor = color;
420 clr->fRect = *rect; 420 clr->fRect = *rect;
421 clr->fRenderTarget = renderTarget; 421 clr->fRenderTarget = renderTarget;
422 renderTarget->ref(); 422 renderTarget->ref();
423 } 423 }
424 424
425 void GrInOrderDrawBuffer::reset() { 425 void GrInOrderDrawBuffer::reset() {
426 GrAssert(1 == fGeoPoolStateStack.count()); 426 SkASSERT(1 == fGeoPoolStateStack.count());
427 this->resetVertexSource(); 427 this->resetVertexSource();
428 this->resetIndexSource(); 428 this->resetIndexSource();
429 int numDraws = fDraws.count(); 429 int numDraws = fDraws.count();
430 for (int d = 0; d < numDraws; ++d) { 430 for (int d = 0; d < numDraws; ++d) {
431 // we always have a VB, but not always an IB 431 // we always have a VB, but not always an IB
432 GrAssert(NULL != fDraws[d].fVertexBuffer); 432 SkASSERT(NULL != fDraws[d].fVertexBuffer);
433 fDraws[d].fVertexBuffer->unref(); 433 fDraws[d].fVertexBuffer->unref();
434 GrSafeUnref(fDraws[d].fIndexBuffer); 434 GrSafeUnref(fDraws[d].fIndexBuffer);
435 } 435 }
436 fCmds.reset(); 436 fCmds.reset();
437 fDraws.reset(); 437 fDraws.reset();
438 fStencilPaths.reset(); 438 fStencilPaths.reset();
439 fStates.reset(); 439 fStates.reset();
440 fClears.reset(); 440 fClears.reset();
441 fVertexPool.reset(); 441 fVertexPool.reset();
442 fIndexPool.reset(); 442 fIndexPool.reset();
443 fClips.reset(); 443 fClips.reset();
444 fClipOrigins.reset(); 444 fClipOrigins.reset();
445 fCopySurfaces.reset(); 445 fCopySurfaces.reset();
446 fClipSet = true; 446 fClipSet = true;
447 } 447 }
448 448
449 void GrInOrderDrawBuffer::flush() { 449 void GrInOrderDrawBuffer::flush() {
450 if (fFlushing) { 450 if (fFlushing) {
451 return; 451 return;
452 } 452 }
453 453
454 GrAssert(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc); 454 SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fVertexSrc);
455 GrAssert(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc); 455 SkASSERT(kReserved_GeometrySrcType != this->getGeomSrc().fIndexSrc);
456 456
457 int numCmds = fCmds.count(); 457 int numCmds = fCmds.count();
458 if (0 == numCmds) { 458 if (0 == numCmds) {
459 return; 459 return;
460 } 460 }
461 461
462 GrAutoTRestore<bool> flushRestore(&fFlushing); 462 GrAutoTRestore<bool> flushRestore(&fFlushing);
463 fFlushing = true; 463 fFlushing = true;
464 464
465 fVertexPool.unlock(); 465 fVertexPool.unlock();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 case kCopySurface_Cmd: 520 case kCopySurface_Cmd:
521 fDstGpu->copySurface(fCopySurfaces[currCopySurface].fDst.get(), 521 fDstGpu->copySurface(fCopySurfaces[currCopySurface].fDst.get(),
522 fCopySurfaces[currCopySurface].fSrc.get(), 522 fCopySurfaces[currCopySurface].fSrc.get(),
523 fCopySurfaces[currCopySurface].fSrcRect, 523 fCopySurfaces[currCopySurface].fSrcRect,
524 fCopySurfaces[currCopySurface].fDstPoint); 524 fCopySurfaces[currCopySurface].fDstPoint);
525 ++currCopySurface; 525 ++currCopySurface;
526 break; 526 break;
527 } 527 }
528 } 528 }
529 // we should have consumed all the states, clips, etc. 529 // we should have consumed all the states, clips, etc.
530 GrAssert(fStates.count() == currState); 530 SkASSERT(fStates.count() == currState);
531 GrAssert(fClips.count() == currClip); 531 SkASSERT(fClips.count() == currClip);
532 GrAssert(fClipOrigins.count() == currClip); 532 SkASSERT(fClipOrigins.count() == currClip);
533 GrAssert(fClears.count() == currClear); 533 SkASSERT(fClears.count() == currClear);
534 GrAssert(fDraws.count() == currDraw); 534 SkASSERT(fDraws.count() == currDraw);
535 GrAssert(fCopySurfaces.count() == currCopySurface); 535 SkASSERT(fCopySurfaces.count() == currCopySurface);
536 536
537 fDstGpu->setDrawState(prevDrawState); 537 fDstGpu->setDrawState(prevDrawState);
538 prevDrawState->unref(); 538 prevDrawState->unref();
539 this->reset(); 539 this->reset();
540 ++fDrawID; 540 ++fDrawID;
541 } 541 }
542 542
543 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, 543 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
544 GrSurface* src, 544 GrSurface* src,
545 const SkIRect& srcRect, 545 const SkIRect& srcRect,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 630 }
631 *vertexCount = currVertices; 631 *vertexCount = currVertices;
632 } 632 }
633 return flush; 633 return flush;
634 } 634 }
635 635
636 bool GrInOrderDrawBuffer::onReserveVertexSpace(size_t vertexSize, 636 bool GrInOrderDrawBuffer::onReserveVertexSpace(size_t vertexSize,
637 int vertexCount, 637 int vertexCount,
638 void** vertices) { 638 void** vertices) {
639 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 639 GeometryPoolState& poolState = fGeoPoolStateStack.back();
640 GrAssert(vertexCount > 0); 640 SkASSERT(vertexCount > 0);
641 GrAssert(NULL != vertices); 641 SkASSERT(NULL != vertices);
642 GrAssert(0 == poolState.fUsedPoolVertexBytes); 642 SkASSERT(0 == poolState.fUsedPoolVertexBytes);
643 643
644 *vertices = fVertexPool.makeSpace(vertexSize, 644 *vertices = fVertexPool.makeSpace(vertexSize,
645 vertexCount, 645 vertexCount,
646 &poolState.fPoolVertexBuffer, 646 &poolState.fPoolVertexBuffer,
647 &poolState.fPoolStartVertex); 647 &poolState.fPoolStartVertex);
648 return NULL != *vertices; 648 return NULL != *vertices;
649 } 649 }
650 650
651 bool GrInOrderDrawBuffer::onReserveIndexSpace(int indexCount, void** indices) { 651 bool GrInOrderDrawBuffer::onReserveIndexSpace(int indexCount, void** indices) {
652 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 652 GeometryPoolState& poolState = fGeoPoolStateStack.back();
653 GrAssert(indexCount > 0); 653 SkASSERT(indexCount > 0);
654 GrAssert(NULL != indices); 654 SkASSERT(NULL != indices);
655 GrAssert(0 == poolState.fUsedPoolIndexBytes); 655 SkASSERT(0 == poolState.fUsedPoolIndexBytes);
656 656
657 *indices = fIndexPool.makeSpace(indexCount, 657 *indices = fIndexPool.makeSpace(indexCount,
658 &poolState.fPoolIndexBuffer, 658 &poolState.fPoolIndexBuffer,
659 &poolState.fPoolStartIndex); 659 &poolState.fPoolStartIndex);
660 return NULL != *indices; 660 return NULL != *indices;
661 } 661 }
662 662
663 void GrInOrderDrawBuffer::releaseReservedVertexSpace() { 663 void GrInOrderDrawBuffer::releaseReservedVertexSpace() {
664 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 664 GeometryPoolState& poolState = fGeoPoolStateStack.back();
665 const GeometrySrcState& geoSrc = this->getGeomSrc(); 665 const GeometrySrcState& geoSrc = this->getGeomSrc();
666 666
667 // If we get a release vertex space call then our current source should eith er be reserved 667 // If we get a release vertex space call then our current source should eith er be reserved
668 // or array (which we copied into reserved space). 668 // or array (which we copied into reserved space).
669 GrAssert(kReserved_GeometrySrcType == geoSrc.fVertexSrc || 669 SkASSERT(kReserved_GeometrySrcType == geoSrc.fVertexSrc ||
670 kArray_GeometrySrcType == geoSrc.fVertexSrc); 670 kArray_GeometrySrcType == geoSrc.fVertexSrc);
671 671
672 // When the caller reserved vertex buffer space we gave it back a pointer 672 // When the caller reserved vertex buffer space we gave it back a pointer
673 // provided by the vertex buffer pool. At each draw we tracked the largest 673 // provided by the vertex buffer pool. At each draw we tracked the largest
674 // offset into the pool's pointer that was referenced. Now we return to the 674 // offset into the pool's pointer that was referenced. Now we return to the
675 // pool any portion at the tail of the allocation that no draw referenced. 675 // pool any portion at the tail of the allocation that no draw referenced.
676 size_t reservedVertexBytes = geoSrc.fVertexSize * geoSrc.fVertexCount; 676 size_t reservedVertexBytes = geoSrc.fVertexSize * geoSrc.fVertexCount;
677 fVertexPool.putBack(reservedVertexBytes - 677 fVertexPool.putBack(reservedVertexBytes -
678 poolState.fUsedPoolVertexBytes); 678 poolState.fUsedPoolVertexBytes);
679 poolState.fUsedPoolVertexBytes = 0; 679 poolState.fUsedPoolVertexBytes = 0;
680 poolState.fPoolVertexBuffer = NULL; 680 poolState.fPoolVertexBuffer = NULL;
681 poolState.fPoolStartVertex = 0; 681 poolState.fPoolStartVertex = 0;
682 } 682 }
683 683
684 void GrInOrderDrawBuffer::releaseReservedIndexSpace() { 684 void GrInOrderDrawBuffer::releaseReservedIndexSpace() {
685 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 685 GeometryPoolState& poolState = fGeoPoolStateStack.back();
686 const GeometrySrcState& geoSrc = this->getGeomSrc(); 686 const GeometrySrcState& geoSrc = this->getGeomSrc();
687 687
688 // If we get a release index space call then our current source should eithe r be reserved 688 // If we get a release index space call then our current source should eithe r be reserved
689 // or array (which we copied into reserved space). 689 // or array (which we copied into reserved space).
690 GrAssert(kReserved_GeometrySrcType == geoSrc.fIndexSrc || 690 SkASSERT(kReserved_GeometrySrcType == geoSrc.fIndexSrc ||
691 kArray_GeometrySrcType == geoSrc.fIndexSrc); 691 kArray_GeometrySrcType == geoSrc.fIndexSrc);
692 692
693 // Similar to releaseReservedVertexSpace we return any unused portion at 693 // Similar to releaseReservedVertexSpace we return any unused portion at
694 // the tail 694 // the tail
695 size_t reservedIndexBytes = sizeof(uint16_t) * geoSrc.fIndexCount; 695 size_t reservedIndexBytes = sizeof(uint16_t) * geoSrc.fIndexCount;
696 fIndexPool.putBack(reservedIndexBytes - poolState.fUsedPoolIndexBytes); 696 fIndexPool.putBack(reservedIndexBytes - poolState.fUsedPoolIndexBytes);
697 poolState.fUsedPoolIndexBytes = 0; 697 poolState.fUsedPoolIndexBytes = 0;
698 poolState.fPoolIndexBuffer = NULL; 698 poolState.fPoolIndexBuffer = NULL;
699 poolState.fPoolStartIndex = 0; 699 poolState.fPoolStartIndex = 0;
700 } 700 }
701 701
702 void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray, 702 void GrInOrderDrawBuffer::onSetVertexSourceToArray(const void* vertexArray,
703 int vertexCount) { 703 int vertexCount) {
704 704
705 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 705 GeometryPoolState& poolState = fGeoPoolStateStack.back();
706 GrAssert(0 == poolState.fUsedPoolVertexBytes); 706 SkASSERT(0 == poolState.fUsedPoolVertexBytes);
707 #if GR_DEBUG 707 #if GR_DEBUG
708 bool success = 708 bool success =
709 #endif 709 #endif
710 fVertexPool.appendVertices(this->getVertexSize(), 710 fVertexPool.appendVertices(this->getVertexSize(),
711 vertexCount, 711 vertexCount,
712 vertexArray, 712 vertexArray,
713 &poolState.fPoolVertexBuffer, 713 &poolState.fPoolVertexBuffer,
714 &poolState.fPoolStartVertex); 714 &poolState.fPoolStartVertex);
715 GR_DEBUGASSERT(success); 715 GR_DEBUGASSERT(success);
716 } 716 }
717 717
718 void GrInOrderDrawBuffer::onSetIndexSourceToArray(const void* indexArray, 718 void GrInOrderDrawBuffer::onSetIndexSourceToArray(const void* indexArray,
719 int indexCount) { 719 int indexCount) {
720 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 720 GeometryPoolState& poolState = fGeoPoolStateStack.back();
721 GrAssert(0 == poolState.fUsedPoolIndexBytes); 721 SkASSERT(0 == poolState.fUsedPoolIndexBytes);
722 #if GR_DEBUG 722 #if GR_DEBUG
723 bool success = 723 bool success =
724 #endif 724 #endif
725 fIndexPool.appendIndices(indexCount, 725 fIndexPool.appendIndices(indexCount,
726 indexArray, 726 indexArray,
727 &poolState.fPoolIndexBuffer, 727 &poolState.fPoolIndexBuffer,
728 &poolState.fPoolStartIndex); 728 &poolState.fPoolStartIndex);
729 GR_DEBUGASSERT(success); 729 GR_DEBUGASSERT(success);
730 } 730 }
731 731
(...skipping 16 matching lines...) Expand all
748 #if GR_DEBUG 748 #if GR_DEBUG
749 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0; 749 poolState.fPoolVertexBuffer = (GrVertexBuffer*)~0;
750 poolState.fPoolStartVertex = ~0; 750 poolState.fPoolStartVertex = ~0;
751 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0; 751 poolState.fPoolIndexBuffer = (GrIndexBuffer*)~0;
752 poolState.fPoolStartIndex = ~0; 752 poolState.fPoolStartIndex = ~0;
753 #endif 753 #endif
754 } 754 }
755 755
756 void GrInOrderDrawBuffer::geometrySourceWillPop( 756 void GrInOrderDrawBuffer::geometrySourceWillPop(
757 const GeometrySrcState& restoredState) { 757 const GeometrySrcState& restoredState) {
758 GrAssert(fGeoPoolStateStack.count() > 1); 758 SkASSERT(fGeoPoolStateStack.count() > 1);
759 fGeoPoolStateStack.pop_back(); 759 fGeoPoolStateStack.pop_back();
760 GeometryPoolState& poolState = fGeoPoolStateStack.back(); 760 GeometryPoolState& poolState = fGeoPoolStateStack.back();
761 // we have to assume that any slack we had in our vertex/index data 761 // we have to assume that any slack we had in our vertex/index data
762 // is now unreleasable because data may have been appended later in the 762 // is now unreleasable because data may have been appended later in the
763 // pool. 763 // pool.
764 if (kReserved_GeometrySrcType == restoredState.fVertexSrc || 764 if (kReserved_GeometrySrcType == restoredState.fVertexSrc ||
765 kArray_GeometrySrcType == restoredState.fVertexSrc) { 765 kArray_GeometrySrcType == restoredState.fVertexSrc) {
766 poolState.fUsedPoolVertexBytes = restoredState.fVertexSize * restoredSta te.fVertexCount; 766 poolState.fUsedPoolVertexBytes = restoredState.fVertexSize * restoredSta te.fVertexCount;
767 } 767 }
768 if (kReserved_GeometrySrcType == restoredState.fIndexSrc || 768 if (kReserved_GeometrySrcType == restoredState.fIndexSrc ||
769 kArray_GeometrySrcType == restoredState.fIndexSrc) { 769 kArray_GeometrySrcType == restoredState.fIndexSrc) {
770 poolState.fUsedPoolIndexBytes = sizeof(uint16_t) * 770 poolState.fUsedPoolIndexBytes = sizeof(uint16_t) *
771 restoredState.fIndexCount; 771 restoredState.fIndexCount;
772 } 772 }
773 } 773 }
774 774
775 bool GrInOrderDrawBuffer::needsNewState() const { 775 bool GrInOrderDrawBuffer::needsNewState() const {
776 return fStates.empty() || !fStates.back().isEqual(this->getDrawState()); 776 return fStates.empty() || !fStates.back().isEqual(this->getDrawState());
777 } 777 }
778 778
779 bool GrInOrderDrawBuffer::needsNewClip() const { 779 bool GrInOrderDrawBuffer::needsNewClip() const {
780 GrAssert(fClips.count() == fClipOrigins.count()); 780 SkASSERT(fClips.count() == fClipOrigins.count());
781 if (this->getDrawState().isClipState()) { 781 if (this->getDrawState().isClipState()) {
782 if (fClipSet && 782 if (fClipSet &&
783 (fClips.empty() || 783 (fClips.empty() ||
784 fClips.back() != *this->getClip()->fClipStack || 784 fClips.back() != *this->getClip()->fClipStack ||
785 fClipOrigins.back() != this->getClip()->fOrigin)) { 785 fClipOrigins.back() != this->getClip()->fOrigin)) {
786 return true; 786 return true;
787 } 787 }
788 } 788 }
789 return false; 789 return false;
790 } 790 }
(...skipping 29 matching lines...) Expand all
820 fCmds.push_back(kCopySurface_Cmd); 820 fCmds.push_back(kCopySurface_Cmd);
821 return &fCopySurfaces.push_back(); 821 return &fCopySurfaces.push_back();
822 } 822 }
823 823
824 824
825 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { 825 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
826 INHERITED::clipWillBeSet(newClipData); 826 INHERITED::clipWillBeSet(newClipData);
827 fClipSet = true; 827 fClipSet = true;
828 fClipProxyState = kUnknown_ClipProxyState; 828 fClipProxyState = kUnknown_ClipProxyState;
829 } 829 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrMemoryPool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698