convert pathops to use SkSTArray where possible.
Replace SkTDArray with SkTArray and use SkSTArray when
the probable array size is known.
In a couple of places (spans, chases) the arrays are
constructed using insert() so SkTArrays can't be used for
now.
Also, add an optimization to cubic subdivide if either end
is zero or one.
BUG=
Review URL: https://codereview.chromium.org/16951017
git-svn-id: http://skia.googlecode.com/svn/trunk@9635 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pathops/SkOpSegment.h b/src/pathops/SkOpSegment.h
index b26bad1..94efcb5 100644
--- a/src/pathops/SkOpSegment.h
+++ b/src/pathops/SkOpSegment.h
@@ -11,6 +11,7 @@
#include "SkOpSpan.h"
#include "SkPathOpsBounds.h"
#include "SkPathOpsCurve.h"
+#include "SkTArray.h"
#include "SkTDArray.h"
class SkPathWriter;
@@ -230,7 +231,7 @@
return xyAtT(span).fY;
}
- bool activeAngle(int index, int* done, SkTDArray<SkOpAngle>* angles);
+ bool activeAngle(int index, int* done, SkTArray<SkOpAngle, true>* angles);
SkPoint activeLeftTop(bool onlySortable, int* firstT) const;
bool activeOp(int index, int endIndex, int xorMiMask, int xorSuMask, SkPathOp op);
bool activeOp(int xorMiMask, int xorSuMask, int index, int endIndex, SkPathOp op,
@@ -294,7 +295,8 @@
kMustBeOrdered_SortAngleKind, // required for winding calc
kMayBeUnordered_SortAngleKind // ok for find top
};
- static bool SortAngles(const SkTDArray<SkOpAngle>& angles, SkTDArray<SkOpAngle*>* angleList,
+ static bool SortAngles(const SkTArray<SkOpAngle, true>& angles,
+ SkTArray<SkOpAngle*, true>* angleList,
SortAngleKind );
bool subDivide(int start, int end, SkPoint edge[4]) const;
bool subDivide(int start, int end, SkDCubic* result) const;
@@ -315,9 +317,9 @@
void debugShowActiveSpans() const;
#endif
#if DEBUG_SORT || DEBUG_SWAP_TOP
- void debugShowSort(const char* fun, const SkTDArray<SkOpAngle*>& angles, int first,
+ void debugShowSort(const char* fun, const SkTArray<SkOpAngle*, true>& angles, int first,
const int contourWinding, const int oppContourWinding) const;
- void debugShowSort(const char* fun, const SkTDArray<SkOpAngle*>& angles, int first);
+ void debugShowSort(const char* fun, const SkTArray<SkOpAngle*, true>& angles, int first);
#endif
#if DEBUG_CONCIDENT
void debugShowTs() const;
@@ -327,25 +329,25 @@
#endif
private:
- bool activeAngleOther(int index, int* done, SkTDArray<SkOpAngle>* angles);
- bool activeAngleInner(int index, int* done, SkTDArray<SkOpAngle>* angles);
- void addAngle(SkTDArray<SkOpAngle>* angles, int start, int end) const;
+ bool activeAngleOther(int index, int* done, SkTArray<SkOpAngle, true>* angles);
+ bool activeAngleInner(int index, int* done, SkTArray<SkOpAngle, true>* angles);
+ void addAngle(SkTArray<SkOpAngle, true>* angles, int start, int end) const;
void addCancelOutsides(double tStart, double oStart, SkOpSegment* other, double oEnd);
- void addCoinOutsides(const SkTDArray<double>& outsideTs, SkOpSegment* other, double oEnd);
- void addTwoAngles(int start, int end, SkTDArray<SkOpAngle>* angles) const;
+ void addCoinOutsides(const SkTArray<double, true>& outsideTs, SkOpSegment* other, double oEnd);
+ void addTwoAngles(int start, int end, SkTArray<SkOpAngle, true>* angles) const;
int advanceCoincidentOther(const SkOpSpan* test, double oEndT, int oIndex);
int advanceCoincidentThis(const SkOpSpan* oTest, bool opp, int index);
- void buildAngles(int index, SkTDArray<SkOpAngle>* angles, bool includeOpp) const;
- void buildAnglesInner(int index, SkTDArray<SkOpAngle>* angles) const;
+ void buildAngles(int index, SkTArray<SkOpAngle, true>* angles, bool includeOpp) const;
+ void buildAnglesInner(int index, SkTArray<SkOpAngle, true>* angles) const;
int bumpCoincidentThis(const SkOpSpan& oTest, bool opp, int index,
- SkTDArray<double>* outsideTs);
+ SkTArray<double, true>* outsideTs);
int bumpCoincidentOther(const SkOpSpan& test, double oEndT, int& oIndex,
- SkTDArray<double>* oOutsideTs);
+ SkTArray<double, true>* oOutsideTs);
bool bumpSpan(SkOpSpan* span, int windDelta, int oppDelta);
bool clockwise(int tStart, int tEnd) const;
void decrementSpan(SkOpSpan* span);
bool equalPoints(int greaterTIndex, int lesserTIndex);
- int findStartingEdge(const SkTDArray<SkOpAngle*>& sorted, int start, int end);
+ int findStartingEdge(const SkTArray<SkOpAngle*, true>& sorted, int start, int end);
void init(const SkPoint pts[], SkPath::Verb verb, bool operand, bool evenOdd);
void matchWindingValue(int tIndex, double t, bool borrowWind);
SkOpSpan* markAndChaseDone(int index, int endIndex, int winding);
@@ -365,7 +367,7 @@
SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last);
bool serpentine(int tStart, int tEnd) const;
void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const;
- static void TrackOutside(SkTDArray<double>* outsideTs, double end, double start);
+ static void TrackOutside(SkTArray<double, true>* outsideTs, double end, double start);
int updateOppWinding(int index, int endIndex) const;
int updateOppWinding(const SkOpAngle* angle) const;
int updateWinding(int index, int endIndex) const;
@@ -393,6 +395,7 @@
const SkPoint* fPts;
SkPathOpsBounds fBounds;
+ // FIXME: can't convert to SkTArray because it uses insert
SkTDArray<SkOpSpan> fTs; // two or more (always includes t=0 t=1)
// OPTIMIZATION: could pack donespans, verb, operand, xor into 1 int-sized value
int fDoneSpans; // quick check that segment is finished