diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-05-09 13:10:44 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-09 19:54:11 +0000 |
commit | f112ea2cb2dd7e6a45d0c35c7f514879eb92deb8 (patch) | |
tree | 1d0548cf3fbecafa8b2319c541ad88a535ff293e /src | |
parent | e0dc9432d8836ec34a3ef90eabc39eadc3d1db90 (diff) |
Support C++11 range-for loops in SkTInternalLList
Bug: skia:
Change-Id: Iad5e06fac95c5b805f3735c106103e5a07975b5d
Reviewed-on: https://skia-review.googlesource.com/127106
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkTInternalLList.h | 15 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp | 26 |
2 files changed, 22 insertions, 19 deletions
diff --git a/src/core/SkTInternalLList.h b/src/core/SkTInternalLList.h index df06d8a255..2f43f1c1eb 100644 --- a/src/core/SkTInternalLList.h +++ b/src/core/SkTInternalLList.h @@ -250,10 +250,25 @@ public: return fCurr; } + /** + * C++11 range-for interface. + */ + bool operator!=(const Iter& that) { return fCurr != that.fCurr; } + T* operator*() { return this->get(); } + void operator++() { this->next(); } + private: T* fCurr; }; + Iter begin() const { + Iter iter; + iter.init(*this, Iter::kHead_IterStart); + return iter; + } + + Iter end() const { return Iter(); } + #ifdef SK_DEBUG void validate() const { SkASSERT(!fHead == !fTail); diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp index 4358d21e24..eadd9a7d7c 100644 --- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp +++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp @@ -178,21 +178,17 @@ void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlush } const GrCCRTPendingPaths& rtPendingPaths = iter->second; - SkTInternalLList<GrCCDrawPathsOp>::Iter drawOpsIter; - drawOpsIter.init(rtPendingPaths.fDrawOps, - SkTInternalLList<GrCCDrawPathsOp>::Iter::kHead_IterStart); - while (GrCCDrawPathsOp* op = drawOpsIter.get()) { + for (const GrCCDrawPathsOp* op : rtPendingPaths.fDrawOps) { for (const GrCCDrawPathsOp::SingleDraw* draw = op->head(); draw; draw = draw->fNext) { - ++numPathDraws; flushingPathStats.statPath(draw->fPath); + ++numPathDraws; } - drawOpsIter.next(); } - numClipPaths += rtPendingPaths.fClipPaths.size(); for (const auto& clipsIter : rtPendingPaths.fClipPaths) { flushingPathStats.statPath(clipsIter.second.deviceSpacePath()); } + numClipPaths += rtPendingPaths.fClipPaths.size(); fFlushingRTPathIters.push_back(std::move(iter)); } @@ -209,23 +205,15 @@ void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlush // Layout atlas(es) and parse paths. SkDEBUGCODE(int numSkippedPaths = 0); - for (int i = 0; i < numOpListIDs; ++i) { - auto it = fRTPendingPathsMap.find(opListIDs[i]); - if (fRTPendingPathsMap.end() == it) { - continue; - } - GrCCRTPendingPaths& rtPendingPaths = it->second; + for (const auto& iter : fFlushingRTPathIters) { + GrCCRTPendingPaths* rtPendingPaths = &iter->second; - SkTInternalLList<GrCCDrawPathsOp>::Iter drawOpsIter; - drawOpsIter.init(rtPendingPaths.fDrawOps, - SkTInternalLList<GrCCDrawPathsOp>::Iter::kHead_IterStart); - while (GrCCDrawPathsOp* op = drawOpsIter.get()) { + for (GrCCDrawPathsOp* op : rtPendingPaths->fDrawOps) { op->setupResources(resources.get(), onFlushRP); - drawOpsIter.next(); SkDEBUGCODE(numSkippedPaths += op->numSkippedInstances_debugOnly()); } - for (auto& clipsIter : rtPendingPaths.fClipPaths) { + for (auto& clipsIter : rtPendingPaths->fClipPaths) { clipsIter.second.placePathInAtlas(resources.get(), onFlushRP); } } |