Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: include/core/SkPathIter.h

Issue 1126993003: experimental path-builder Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPathBuilder.h ('k') | include/core/SkPathTypes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPathIter.h
diff --git a/include/core/SkPathIter.h b/include/core/SkPathIter.h
new file mode 100644
index 0000000000000000000000000000000000000000..da0a9da13f609c47fc64a74e321739e937f1ae4f
--- /dev/null
+++ b/include/core/SkPathIter.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPathIter_DEFINED
+#define SkPathIter_DEFINED
+
+#include "SkPathTypes.h"
+#include "SkPoint.h"
+
+class SkPath;
+
+class SkPathIter {
+public:
+ SkPathIter(const SkPoint pts[], const uint8_t verbs[], const SkScalar conicW[], int count)
+ : fCurrPts(pts)
+ , fNextPts(pts + 1)
+ , fConicW(conicW)
+ , fVerbs(verbs)
+ , fStopVerbs(verbs - count)
+ , fPrevPtsPerVerb(0)
+ {
+ if (count > 0) {
+ SkASSERT(kMove_SkPathVerb == verbs[-1]);
+ }
+ }
+
+ SkPathIter(const SkPath&);
+
+ bool done() const { return fStopVerbs == fVerbs; }
+ SkPathVerb currVerb() const { return (SkPathVerb)fVerbs[0]; }
+ const SkPoint* currPts() const { return fCurrPts; }
+ SkScalar currConicW() const { return *fConicW; }
+
+#if 0
+ bool next() {
+ if (fStopVerbs == fVerbs) {
+ return false;
+ }
+
+ static const uint8_t gPtsPerVerb[] = {
+ 1, // Move
+ 1, // Line
+ 2, // Quad
+ 2, // Conic
+ 3, // Cubic
+ 0, // Close
+ };
+
+ fCurrPts += fPrevPtsPerVerb;
+ SkPathVerb verb = (SkPathVerb)(*--fVerbs);
+ fNextPts += (fPrevPtsPerVerb = gPtsPerVerb[verb]);
+ fConicW += (kConic_SkPathVerb == verb);
+ return true;
+ }
+#else
+ bool next();
+#endif
+
+private:
+ const SkPoint* fCurrPts;
+ const SkPoint* fNextPts;
+ const SkScalar* fConicW;
+ const uint8_t* fVerbs;
+ const uint8_t* fStopVerbs;
+ int fPrevPtsPerVerb;
+};
+
+#endif
« no previous file with comments | « include/core/SkPathBuilder.h ('k') | include/core/SkPathTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698