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

Unified Diff: src/core/SkPathPriv.h

Issue 1176953002: move SkPath direction-as-computed into SkPathPriv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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
Index: src/core/SkPathPriv.h
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h
new file mode 100644
index 0000000000000000000000000000000000000000..98e50e302589e788d2fb48d1c00c72606ce640ca
--- /dev/null
+++ b/src/core/SkPathPriv.h
@@ -0,0 +1,60 @@
+/*
+ * 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 SkPathPriv_DEFINED
+#define SkPathPriv_DEFINED
+
+#include "SkPath.h"
+
+class SkPathPriv {
+public:
+ enum FirstDirection {
+ kCW_FirstDirection, // == SkPath::kCW_Direction
bsalomon 2015/06/11 01:37:08 why not just uncomment this? or static assert?
robertphillips 2015/06/15 15:22:35 I second the static asserts
+ kCCW_FirstDirection, // == SkPath::kCCW_Direction
+ kUnknown_FirstDirection,
+ };
+
+ static FirstDirection AsFirstDirection(SkPath::Direction dir) {
+ // since we agree numerically for the values in Direction, we can just cast.
+ return (FirstDirection)dir;
+ }
+
+ /**
+ * Return the opposite of the specified direction. kUnknown is its own
+ * opposite.
+ */
+ static FirstDirection OppositeFirstDirection(FirstDirection dir) {
+ static const FirstDirection gOppositeDir[] = {
+ kCCW_FirstDirection, kCW_FirstDirection, kUnknown_FirstDirection,
+ };
+ return gOppositeDir[dir];
+ }
+
+ /**
+ * Tries to quickly compute the direction of the first non-degenerate
+ * contour. If it can be computed, return true and set dir to that
+ * direction. If it cannot be (quickly) determined, return false and ignore
+ * the dir parameter. If the direction was determined, it is cached to make
+ * subsequent calls return quickly.
+ */
+ static bool CheapComputeFirstDirection(const SkPath&, FirstDirection* dir);
+
+ /**
+ * Returns true if the path's direction can be computed via
+ * cheapComputDirection() and if that computed direction matches the
+ * specified direction. If dir is kUnknown, returns true if the direction
+ * cannot be computed.
+ */
+ static bool CheapIsFirstDirection(const SkPath& path, FirstDirection dir) {
+ FirstDirection computedDir = kUnknown_FirstDirection;
+ (void)CheapComputeFirstDirection(path, &computedDir);
+ return computedDir == dir;
+ }
+
+};
+
+#endif
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | src/core/SkRecords.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698