aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkEdgeBuilder.cpp9
-rw-r--r--src/core/SkEdgeClipper.cpp25
-rw-r--r--src/core/SkEdgeClipper.h2
3 files changed, 30 insertions, 6 deletions
diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp
index 22ee9ed346..22942f4d2a 100644
--- a/src/core/SkEdgeBuilder.cpp
+++ b/src/core/SkEdgeBuilder.cpp
@@ -377,14 +377,11 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip, int shiftUp,
// we ignore these, and just get the whole segment from
// the corresponding line/quad/cubic verbs
break;
- case SkPath::kLine_Verb: {
- SkPoint lines[SkLineClipper::kMaxPoints];
- int lineCount = SkLineClipper::ClipLine(pts, clip, lines, canCullToTheRight);
- for (int i = 0; i < lineCount; i++) {
- this->addLine(&lines[i]);
+ case SkPath::kLine_Verb:
+ if (clipper.clipLine(pts[0], pts[1], clip)) {
+ this->addClipper(&clipper);
}
break;
- }
case SkPath::kQuad_Verb:
if (clipper.clipQuad(pts, clip)) {
this->addClipper(&clipper);
diff --git a/src/core/SkEdgeClipper.cpp b/src/core/SkEdgeClipper.cpp
index b5ac27ae59..97d716986b 100644
--- a/src/core/SkEdgeClipper.cpp
+++ b/src/core/SkEdgeClipper.cpp
@@ -8,6 +8,7 @@
#include "SkEdgeClipper.h"
#include "SkGeometry.h"
+#include "SkLineClipper.h"
static bool quick_reject(const SkRect& bounds, const SkRect& clip) {
return bounds.fTop >= clip.fBottom || bounds.fBottom <= clip.fTop;
@@ -42,6 +43,23 @@ static bool sort_increasing_Y(SkPoint dst[], const SkPoint src[], int count) {
}
}
+bool SkEdgeClipper::clipLine(SkPoint p0, SkPoint p1, const SkRect& clip) {
+ fCurrPoint = fPoints;
+ fCurrVerb = fVerbs;
+
+ SkPoint lines[SkLineClipper::kMaxPoints];
+ const SkPoint pts[] = { p0, p1 };
+ int lineCount = SkLineClipper::ClipLine(pts, clip, lines, fCanCullToTheRight);
+ for (int i = 0; i < lineCount; i++) {
+ this->appendLine(lines[i], lines[i + 1]);
+ }
+
+ *fCurrVerb = SkPath::kDone_Verb;
+ fCurrPoint = fPoints;
+ fCurrVerb = fVerbs;
+ return SkPath::kDone_Verb != fVerbs[0];
+}
+
///////////////////////////////////////////////////////////////////////////////
static bool chopMonoQuadAt(SkScalar c0, SkScalar c1, SkScalar c2,
@@ -407,6 +425,13 @@ bool SkEdgeClipper::clipCubic(const SkPoint srcPts[4], const SkRect& clip) {
///////////////////////////////////////////////////////////////////////////////
+void SkEdgeClipper::appendLine(SkPoint p0, SkPoint p1) {
+ *fCurrVerb++ = SkPath::kLine_Verb;
+ fCurrPoint[0] = p0;
+ fCurrPoint[1] = p1;
+ fCurrPoint += 2;
+}
+
void SkEdgeClipper::appendVLine(SkScalar x, SkScalar y0, SkScalar y1,
bool reverse) {
*fCurrVerb++ = SkPath::kLine_Verb;
diff --git a/src/core/SkEdgeClipper.h b/src/core/SkEdgeClipper.h
index e460c1cd87..b20c0a183b 100644
--- a/src/core/SkEdgeClipper.h
+++ b/src/core/SkEdgeClipper.h
@@ -18,6 +18,7 @@ class SkEdgeClipper {
public:
SkEdgeClipper(bool canCullToTheRight) : fCanCullToTheRight(canCullToTheRight) {}
+ bool clipLine(SkPoint p0, SkPoint p1, const SkRect& clip);
bool clipQuad(const SkPoint pts[3], const SkRect& clip);
bool clipCubic(const SkPoint pts[4], const SkRect& clip);
@@ -39,6 +40,7 @@ private:
void clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip);
void clipMonoCubic(const SkPoint srcPts[4], const SkRect& clip);
+ void appendLine(SkPoint p0, SkPoint p1);
void appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse);
void appendQuad(const SkPoint pts[3], bool reverse);
void appendCubic(const SkPoint pts[4], bool reverse);