Faster SkPathEdgeIter
nanobench -m pathiter_edge -q --samples 1000 Before: micros bench 7.32 ! pathiter_edge nonrendering After: micros bench 2.94 ! pathiter_edge nonrendering Change-Id: Ic548ad270589ecced855ba101ad241109c0f16ef Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235800 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
3b0e7f627b
commit
6f1ff9fca1
@ -340,14 +340,15 @@ public:
|
||||
for (;;) {
|
||||
SkASSERT(fVerbs >= fVerbsStart);
|
||||
if (fVerbs == fVerbsStart) {
|
||||
if (fNeedsCloseLine) {
|
||||
return closeline();
|
||||
}
|
||||
return { nullptr, Edge(kIllegalEdgeValue) };
|
||||
return fNeedsCloseLine
|
||||
? closeline()
|
||||
: Result{ nullptr, Edge(kIllegalEdgeValue) };
|
||||
}
|
||||
|
||||
SkDEBUGCODE(fIsConic = false;)
|
||||
switch (*--fVerbs) {
|
||||
|
||||
const auto v = *--fVerbs;
|
||||
switch (v) {
|
||||
case SkPath::kMove_Verb: {
|
||||
if (fNeedsCloseLine) {
|
||||
auto res = closeline();
|
||||
@ -356,32 +357,24 @@ public:
|
||||
}
|
||||
fMoveToPtr = fPts++;
|
||||
} break;
|
||||
case SkPath::kLine_Verb:
|
||||
fNeedsCloseLine = true;
|
||||
fPts += 1;
|
||||
return { &fPts[-2], Edge::kLine };
|
||||
case SkPath::kConic_Verb:
|
||||
SkDEBUGCODE(fIsConic = true;)
|
||||
fNeedsCloseLine = true;
|
||||
fConicWeights++;
|
||||
fPts += 2;
|
||||
return { &fPts[-3], Edge::kConic };
|
||||
case SkPath::kQuad_Verb:
|
||||
fNeedsCloseLine = true;
|
||||
fPts += 2;
|
||||
return { &fPts[-3], Edge::kQuad };
|
||||
case SkPath::kCubic_Verb:
|
||||
fNeedsCloseLine = true;
|
||||
fPts += 3;
|
||||
return { &fPts[-4], Edge::kCubic };
|
||||
case SkPath::kClose_Verb:
|
||||
if (fNeedsCloseLine) {
|
||||
return closeline();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SkASSERT(false);
|
||||
if (fNeedsCloseLine) return closeline();
|
||||
break;
|
||||
default: {
|
||||
// Actual edge.
|
||||
const int pts_count = (v+2) / 2,
|
||||
cws_count = (v & (v-1)) / 2;
|
||||
SkASSERT(pts_count == SkPathPriv::PtsInIter(v) - 1);
|
||||
|
||||
fNeedsCloseLine = true;
|
||||
fPts += pts_count;
|
||||
fConicWeights += cws_count;
|
||||
|
||||
SkDEBUGCODE(fIsConic = (v == SkPath::kConic_Verb);)
|
||||
SkASSERT(fIsConic == (cws_count > 0));
|
||||
|
||||
return { &fPts[-(pts_count + 1)], Edge(v) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user