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

Unified Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 362023002: Reduce integer divides in GrAllocator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: iter getters Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrInOrderDrawBuffer.cpp
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index deea72b90d961197fb148a4f0bf5090078122d34..45c38848288233c0efac7210e2af550c315db808 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -530,12 +530,13 @@ void GrInOrderDrawBuffer::reset() {
SkASSERT(1 == fGeoPoolStateStack.count());
this->resetVertexSource();
this->resetIndexSource();
- int numDraws = fDraws.count();
- for (int d = 0; d < numDraws; ++d) {
+
+ DrawAllocator::Iter drawIter(&fDraws);
+ while (drawIter.next()) {
// we always have a VB, but not always an IB
- SkASSERT(NULL != fDraws[d].fVertexBuffer);
- fDraws[d].fVertexBuffer->unref();
- SkSafeUnref(fDraws[d].fIndexBuffer);
+ SkASSERT(NULL != drawIter->fVertexBuffer);
+ drawIter->fVertexBuffer->unref();
+ SkSafeUnref(drawIter->fIndexBuffer);
}
fCmds.reset();
fDraws.reset();
@@ -584,14 +585,16 @@ void GrInOrderDrawBuffer::flush() {
GrClipData clipData;
- int currState = 0;
- int currClip = 0;
- int currClear = 0;
- int currDraw = 0;
- int currStencilPath = 0;
- int currDrawPath = 0;
- int currDrawPaths = 0;
- int currCopySurface = 0;
+ StateAllocator::Iter stateIter(&fStates);
+ ClipAllocator::Iter clipIter(&fClips);
+ ClipOriginAllocator::Iter clipOriginIter(&fClipOrigins);
+ ClearAllocator::Iter clearIter(&fClears);
+ DrawAllocator::Iter drawIter(&fDraws);
+ StencilPathAllocator::Iter stencilPathIter(&fStencilPaths);
+ DrawPathAllocator::Iter drawPathIter(&fDrawPath);
+ DrawPathsAllocator::Iter drawPathsIter(&fDrawPaths);
+ CopySurfaceAllocator::Iter copySurfaceIter(&fCopySurfaces);
+
int currCmdMarker = 0;
fDstGpu->saveActiveTraceMarkers();
@@ -605,65 +608,64 @@ void GrInOrderDrawBuffer::flush() {
}
switch (strip_trace_bit(fCmds[c])) {
case kDraw_Cmd: {
- const DrawRecord& draw = fDraws[currDraw];
- fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer);
- if (draw.isIndexed()) {
- fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer);
+ SkAssertResult(drawIter.next());
+ fDstGpu->setVertexSourceToBuffer(drawIter->fVertexBuffer);
+ if (drawIter->isIndexed()) {
+ fDstGpu->setIndexSourceToBuffer(drawIter->fIndexBuffer);
}
- fDstGpu->executeDraw(draw);
- ++currDraw;
+ fDstGpu->executeDraw(*drawIter);
break;
}
case kStencilPath_Cmd: {
- const StencilPath& sp = fStencilPaths[currStencilPath];
- fDstGpu->stencilPath(sp.fPath.get(), sp.fFill);
- ++currStencilPath;
+ SkAssertResult(stencilPathIter.next());
+ fDstGpu->stencilPath(stencilPathIter->fPath.get(), stencilPathIter->fFill);
break;
}
case kDrawPath_Cmd: {
- const DrawPath& cp = fDrawPath[currDrawPath];
- fDstGpu->executeDrawPath(cp.fPath.get(), cp.fFill,
- NULL != cp.fDstCopy.texture() ? &cp.fDstCopy : NULL);
- ++currDrawPath;
+ SkAssertResult(drawPathIter.next());
+ fDstGpu->executeDrawPath(drawPathIter->fPath.get(), drawPathIter->fFill,
+ NULL != drawPathIter->fDstCopy.texture() ?
+ &drawPathIter->fDstCopy :
+ NULL);
break;
}
case kDrawPaths_Cmd: {
- DrawPaths& dp = fDrawPaths[currDrawPaths];
+ SkAssertResult(drawPathsIter.next());
const GrDeviceCoordTexture* dstCopy =
- NULL != dp.fDstCopy.texture() ? &dp.fDstCopy : NULL;
- fDstGpu->executeDrawPaths(dp.fPathCount, dp.fPaths,
- dp.fTransforms, dp.fFill, dp.fStroke,
- dstCopy);
- ++currDrawPaths;
+ NULL !=drawPathsIter->fDstCopy.texture() ? &drawPathsIter->fDstCopy : NULL;
+ fDstGpu->executeDrawPaths(drawPathsIter->fPathCount, drawPathsIter->fPaths,
+ drawPathsIter->fTransforms, drawPathsIter->fFill,
+ drawPathsIter->fStroke, dstCopy);
break;
}
case kSetState_Cmd:
- fStates[currState].restoreTo(&playbackState);
- ++currState;
+ SkAssertResult(stateIter.next());
+ stateIter->restoreTo(&playbackState);
break;
case kSetClip_Cmd:
- clipData.fClipStack = &fClips[currClip];
- clipData.fOrigin = fClipOrigins[currClip];
+ SkAssertResult(clipIter.next());
+ SkAssertResult(clipOriginIter.next());
+ clipData.fClipStack = clipIter.get();
+ clipData.fOrigin = *clipOriginIter;
fDstGpu->setClip(&clipData);
- ++currClip;
break;
case kClear_Cmd:
- if (GrColor_ILLEGAL == fClears[currClear].fColor) {
- fDstGpu->discard(fClears[currClear].fRenderTarget);
+ SkAssertResult(clearIter.next());
+ if (GrColor_ILLEGAL == clearIter->fColor) {
+ fDstGpu->discard(clearIter->fRenderTarget);
} else {
- fDstGpu->clear(&fClears[currClear].fRect,
- fClears[currClear].fColor,
- fClears[currClear].fCanIgnoreRect,
- fClears[currClear].fRenderTarget);
+ fDstGpu->clear(&clearIter->fRect,
+ clearIter->fColor,
+ clearIter->fCanIgnoreRect,
+ clearIter->fRenderTarget);
}
- ++currClear;
break;
case kCopySurface_Cmd:
- fDstGpu->copySurface(fCopySurfaces[currCopySurface].fDst.get(),
- fCopySurfaces[currCopySurface].fSrc.get(),
- fCopySurfaces[currCopySurface].fSrcRect,
- fCopySurfaces[currCopySurface].fDstPoint);
- ++currCopySurface;
+ SkAssertResult(copySurfaceIter.next());
+ fDstGpu->copySurface(copySurfaceIter->fDst.get(),
+ copySurfaceIter->fSrc.get(),
+ copySurfaceIter->fSrcRect,
+ copySurfaceIter->fDstPoint);
break;
}
if (cmd_has_trace_marker(fCmds[c])) {
@@ -672,12 +674,16 @@ void GrInOrderDrawBuffer::flush() {
}
fDstGpu->restoreActiveTraceMarkers();
// we should have consumed all the states, clips, etc.
- SkASSERT(fStates.count() == currState);
- SkASSERT(fClips.count() == currClip);
- SkASSERT(fClipOrigins.count() == currClip);
- SkASSERT(fClears.count() == currClear);
- SkASSERT(fDraws.count() == currDraw);
- SkASSERT(fCopySurfaces.count() == currCopySurface);
+ SkASSERT(!stateIter.next());
+ SkASSERT(!clipIter.next());
+ SkASSERT(!clipOriginIter.next());
+ SkASSERT(!clearIter.next());
+ SkASSERT(!drawIter.next());
+ SkASSERT(!copySurfaceIter.next());
+ SkASSERT(!stencilPathIter.next());
+ SkASSERT(!drawPathIter.next());
+ SkASSERT(!drawPathsIter.next());
+
SkASSERT(fGpuCmdMarkers.count() == currCmdMarker);
fDstGpu->setDrawState(prevDrawState);
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698