diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-25 19:17:44 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-25 19:17:44 +0000 |
commit | 0b335c1ac100aeacf79a4c98a052286fd46661e7 (patch) | |
tree | 79f61ffb6168d0fafc84966d4be2f87eb4641ef2 /gpu/src/GrInOrderDrawBuffer.cpp | |
parent | 580aec6f7f8b27979fb5d677fd427eb9362edb8e (diff) |
Make clear a GrDrawTarget virtual method and implement in GrInOrderDrawBuffer
Review URL: http://codereview.appspot.com/4442081/
git-svn-id: http://skia.googlecode.com/svn/trunk@1176 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrInOrderDrawBuffer.cpp')
-rw-r--r-- | gpu/src/GrInOrderDrawBuffer.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gpu/src/GrInOrderDrawBuffer.cpp b/gpu/src/GrInOrderDrawBuffer.cpp index eebae0067f..93acc12432 100644 --- a/gpu/src/GrInOrderDrawBuffer.cpp +++ b/gpu/src/GrInOrderDrawBuffer.cpp @@ -26,6 +26,7 @@ GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrVertexBufferAllocPool* vertexPool, GrIndexBufferAllocPool* indexPool) : fDraws(&fDrawStorage), fStates(&fStateStorage), + fClears(&fClearStorage), fClips(&fClipStorage), fClipSet(true), @@ -287,6 +288,16 @@ void GrInOrderDrawBuffer::drawNonIndexed(GrPrimitiveType primitiveType, draw.fIndexBuffer = NULL; } +void GrInOrderDrawBuffer::clear(GrColor color) { + Clear& clr = fClears.push_back(); + clr.fColor = color; + clr.fBeforeDrawIdx = fDraws.count(); + + // We could do something smart and remove previous draws and clears to the + // current render target. If we get that smart we have to make sure those + // draws aren't read before this clear (render-to-texture). +} + void GrInOrderDrawBuffer::reset() { GrAssert(!fReservedGeometry.fLocked); uint32_t numStates = fStates.count(); @@ -307,6 +318,8 @@ void GrInOrderDrawBuffer::reset() { fDraws.reset(); fStates.reset(); + fClears.reset(); + fVertexPool.reset(); fIndexPool.reset(); @@ -336,8 +349,15 @@ void GrInOrderDrawBuffer::playback(GrDrawTarget* target) { uint32_t currState = ~0; uint32_t currClip = ~0; + uint32_t currClear = 0; for (uint32_t i = 0; i < numDraws; ++i) { + while (currClear < fClears.count() && + i == fClears[currClear].fBeforeDrawIdx) { + target->clear(fClears[currClear].fColor); + ++currClear; + } + const Draw& draw = fDraws[i]; if (draw.fStateChanged) { ++currState; @@ -366,6 +386,11 @@ void GrInOrderDrawBuffer::playback(GrDrawTarget* target) { draw.fVertexCount); } } + while (currClear < fClears.count()) { + GrAssert(fDraws.count() == fClears[currClear].fBeforeDrawIdx); + target->clear(fClears[currClear].fColor); + ++currClear; + } } bool GrInOrderDrawBuffer::geometryHints(GrVertexLayout vertexLayout, |