SkIntToScalar(src.fBottom >> shift));
}
-int SkEdgeBuilder::buildPoly(const SkPath& path, const SkIRect* iclip, int shiftUp,
- bool clipToTheRight) {
+int SkEdgeBuilder::buildPoly(const SkPath& path, const SkIRect* iclip,
+ int shiftUp) {
SkPath::Iter iter(path, true);
SkPoint pts[4];
SkPath::Verb verb;
break;
case SkPath::kLine_Verb: {
SkPoint lines[SkLineClipper::kMaxPoints];
- int lineCount = SkLineClipper::ClipLine(pts, clip, lines, clipToTheRight);
+ int lineCount = SkLineClipper::ClipLine(pts, clip, lines);
SkASSERT(lineCount <= SkLineClipper::kMaxClippedLineSegments);
for (int i = 0; i < lineCount; i++) {
if (edge->setLine(lines[i], lines[i + 1], shiftUp)) {
}
}
-int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip, int shiftUp,
- bool clipToTheRight) {
+int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
+ int shiftUp) {
fAlloc.reset();
fList.reset();
fShiftUp = shiftUp;
if (SkPath::kLine_SegmentMask == path.getSegmentMasks()) {
- return this->buildPoly(path, iclip, shiftUp, clipToTheRight);
+ return this->buildPoly(path, iclip, shiftUp);
}
SkAutoConicToQuads quadder;
break;
case SkPath::kLine_Verb: {
SkPoint lines[SkLineClipper::kMaxPoints];
- int lineCount = SkLineClipper::ClipLine(pts, clip, lines, clipToTheRight);
+ int lineCount = SkLineClipper::ClipLine(pts, clip, lines);
for (int i = 0; i < lineCount; i++) {
this->addLine(&lines[i]);
}
// returns the number of built edges. The array of those edge pointers
// is returned from edgeList().
- int build(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToTheRight);
+ int build(const SkPath& path, const SkIRect* clip, int shiftUp);
SkEdge** edgeList() { return fEdgeList; }
* empty, as we will have preallocated room for the pointers in fAlloc's
* block, and fEdgeList will point into that.
*/
- SkEdge** fEdgeList;
+ SkEdge** fEdgeList;
- int fShiftUp;
+ int fShiftUp;
public:
void addLine(const SkPoint pts[]);
void addCubic(const SkPoint pts[]);
void addClipper(SkEdgeClipper*);
- int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToTheRight);
+ int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp);
};
#endif
edge->fNext->fPrev = edge->fPrev;
}
-static inline void insert_edge_after(SkEdge* edge, SkEdge* afterMe) {
- edge->fPrev = afterMe;
- edge->fNext = afterMe->fNext;
- afterMe->fNext->fPrev = edge;
- afterMe->fNext = edge;
+static inline void swap_edges(SkEdge* prev, SkEdge* next) {
+ SkASSERT(prev->fNext == next && next->fPrev == prev);
+
+ // remove prev from the list
+ prev->fPrev->fNext = next;
+ next->fPrev = prev->fPrev;
+
+ // insert prev after next
+ prev->fNext = next->fNext;
+ next->fNext->fPrev = prev;
+ next->fNext = prev;
+ prev->fPrev = next;
}
static void backward_insert_edge_based_on_x(SkEdge* edge SkDECLAREPARAM(int, curr_y)) {
SkFixed x = edge->fX;
- SkEdge* prev = edge->fPrev;
- while (prev->fX > x) {
- prev = prev->fPrev;
- }
- if (prev->fNext != edge) {
- remove_edge(edge);
- insert_edge_after(edge, prev);
+ for (;;) {
+ SkEdge* prev = edge->fPrev;
+
+ // add 1 to curr_y since we may have added new edges (built from curves)
+ // that start on the next scanline
+ SkASSERT(prev && prev->fFirstY <= curr_y + 1);
+
+ if (prev->fX <= x) {
+ break;
+ }
+ swap_edges(prev, edge);
}
}
static void walk_edges(SkEdge* prevHead, SkPath::FillType fillType,
SkBlitter* blitter, int start_y, int stop_y,
- PrePostProc proc, int rightClip) {
+ PrePostProc proc) {
validate_sort(prevHead->fNext);
int curr_y = start_y;
SkASSERT(currE);
}
- // was our right-edge culled away?
- if (in_interval) {
- int width = rightClip - left;
- if (width > 0) {
- blitter->blitH(left, curr_y, width);
- }
- }
-
if (proc) {
proc(blitter, curr_y, PREPOST_END); // post-proc
}
// clipRect (if no null) has already been shifted up
//
void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitter,
- int start_y, int stop_y, int shiftEdgesUp, const SkRegion& clipRgn) {
+ int start_y, int stop_y, int shiftEdgesUp,
+ const SkRegion& clipRgn) {
SkASSERT(blitter);
SkEdgeBuilder builder;
- // If we're convex, then we need both edges, even the right edge is past the clip
- const bool cullToTheRight = !path.isConvex();
-
- int count = builder.build(path, clipRect, shiftEdgesUp, cullToTheRight);
+ int count = builder.build(path, clipRect, shiftEdgesUp);
SkEdge** list = builder.edgeList();
if (count < 2) {
if (path.isConvex() && (NULL == proc)) {
walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, NULL);
} else {
- int rightEdge;
- if (clipRect) {
- rightEdge = clipRect->right();
- } else {
- rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdgesUp;
- }
-
- walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc, rightEdge);
+ walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc);
}
}