| 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" |
| 11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
| 12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
| 13 #include "GrIndexBuffer.h" | 13 #include "GrIndexBuffer.h" |
| 14 #include "GrPath.h" | 14 #include "GrPath.h" |
| 15 #include "GrPoint.h" | 15 #include "GrPoint.h" |
| 16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
| 17 #include "GrTemplates.h" | 17 #include "GrTemplates.h" |
| 18 #include "GrTexture.h" | 18 #include "GrTexture.h" |
| 19 #include "GrVertexBuffer.h" | 19 #include "GrVertexBuffer.h" |
| 20 | 20 |
| 21 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, | 21 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, |
| 22 GrVertexBufferAllocPool* vertexPool, | 22 GrVertexBufferAllocPool* vertexPool, |
| 23 GrIndexBufferAllocPool* indexPool) | 23 GrIndexBufferAllocPool* indexPool) |
| 24 : GrDrawTarget(gpu->getContext()) | 24 : GrDrawTarget(gpu->getContext()) |
| 25 , fDstGpu(gpu) | 25 , fDstGpu(gpu) |
| 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 | 32 |
| 32 fDstGpu->ref(); | 33 fDstGpu->ref(); |
| 33 fCaps.reset(SkRef(fDstGpu->caps())); | 34 fCaps.reset(SkRef(fDstGpu->caps())); |
| 34 | 35 |
| 35 GrAssert(NULL != vertexPool); | 36 GrAssert(NULL != vertexPool); |
| 36 GrAssert(NULL != indexPool); | 37 GrAssert(NULL != indexPool); |
| 37 | 38 |
| 38 GeometryPoolState& poolState = fGeoPoolStateStack.push_back(); | 39 GeometryPoolState& poolState = fGeoPoolStateStack.push_back(); |
| 39 poolState.fUsedPoolVertexBytes = 0; | 40 poolState.fUsedPoolVertexBytes = 0; |
| 40 poolState.fUsedPoolIndexBytes = 0; | 41 poolState.fUsedPoolIndexBytes = 0; |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 GrAssert(fStates.count() == currState); | 530 GrAssert(fStates.count() == currState); |
| 530 GrAssert(fClips.count() == currClip); | 531 GrAssert(fClips.count() == currClip); |
| 531 GrAssert(fClipOrigins.count() == currClip); | 532 GrAssert(fClipOrigins.count() == currClip); |
| 532 GrAssert(fClears.count() == currClear); | 533 GrAssert(fClears.count() == currClear); |
| 533 GrAssert(fDraws.count() == currDraw); | 534 GrAssert(fDraws.count() == currDraw); |
| 534 GrAssert(fCopySurfaces.count() == currCopySurface); | 535 GrAssert(fCopySurfaces.count() == currCopySurface); |
| 535 | 536 |
| 536 fDstGpu->setDrawState(prevDrawState); | 537 fDstGpu->setDrawState(prevDrawState); |
| 537 prevDrawState->unref(); | 538 prevDrawState->unref(); |
| 538 this->reset(); | 539 this->reset(); |
| 540 ++fDrawID; |
| 539 } | 541 } |
| 540 | 542 |
| 541 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, | 543 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, |
| 542 GrSurface* src, | 544 GrSurface* src, |
| 543 const SkIRect& srcRect, | 545 const SkIRect& srcRect, |
| 544 const SkIPoint& dstPoint) { | 546 const SkIPoint& dstPoint) { |
| 545 if (fDstGpu->canCopySurface(dst, src, srcRect, dstPoint)) { | 547 if (fDstGpu->canCopySurface(dst, src, srcRect, dstPoint)) { |
| 546 CopySurface* cs = this->recordCopySurface(); | 548 CopySurface* cs = this->recordCopySurface(); |
| 547 cs->fDst.reset(SkRef(dst)); | 549 cs->fDst.reset(SkRef(dst)); |
| 548 cs->fSrc.reset(SkRef(src)); | 550 cs->fSrc.reset(SkRef(src)); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 fCmds.push_back(kCopySurface_Cmd); | 820 fCmds.push_back(kCopySurface_Cmd); |
| 819 return &fCopySurfaces.push_back(); | 821 return &fCopySurfaces.push_back(); |
| 820 } | 822 } |
| 821 | 823 |
| 822 | 824 |
| 823 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { | 825 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { |
| 824 INHERITED::clipWillBeSet(newClipData); | 826 INHERITED::clipWillBeSet(newClipData); |
| 825 fClipSet = true; | 827 fClipSet = true; |
| 826 fClipProxyState = kUnknown_ClipProxyState; | 828 fClipProxyState = kUnknown_ClipProxyState; |
| 827 } | 829 } |
| OLD | NEW |