OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkPathPriv_DEFINED | 8 #ifndef SkPathPriv_DEFINED |
9 #define SkPathPriv_DEFINED | 9 #define SkPathPriv_DEFINED |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 * cheapComputDirection() and if that computed direction matches the | 48 * cheapComputDirection() and if that computed direction matches the |
49 * specified direction. If dir is kUnknown, returns true if the direction | 49 * specified direction. If dir is kUnknown, returns true if the direction |
50 * cannot be computed. | 50 * cannot be computed. |
51 */ | 51 */ |
52 static bool CheapIsFirstDirection(const SkPath& path, FirstDirection dir) { | 52 static bool CheapIsFirstDirection(const SkPath& path, FirstDirection dir) { |
53 FirstDirection computedDir = kUnknown_FirstDirection; | 53 FirstDirection computedDir = kUnknown_FirstDirection; |
54 (void)CheapComputeFirstDirection(path, &computedDir); | 54 (void)CheapComputeFirstDirection(path, &computedDir); |
55 return computedDir == dir; | 55 return computedDir == dir; |
56 } | 56 } |
57 | 57 |
58 static bool LastVerbIsClose(const SkPath& path) { | 58 static bool IsClosedSingleContour(const SkPath& path) { |
59 int count = path.countVerbs(); | 59 int verbCount = path.countVerbs(); |
60 return count >= 1 && path.fPathRef->verbs()[~(count - 1)] == SkPath::Ver
b::kClose_Verb; | 60 if (verbCount == 0) |
| 61 return false; |
| 62 int moveCount = 0; |
| 63 auto verbs = path.fPathRef->verbs(); |
| 64 for (int i = 0; i < verbCount; i++) { |
| 65 switch (verbs[~i]) { // verbs are stored backwards; we use [~i] to g
et the i'th verb |
| 66 case SkPath::Verb::kMove_Verb: |
| 67 moveCount += 1; |
| 68 if (moveCount > 1) { |
| 69 return false; |
| 70 } |
| 71 break; |
| 72 case SkPath::Verb::kClose_Verb: |
| 73 if (i == verbCount - 1) { |
| 74 return true; |
| 75 } |
| 76 return false; |
| 77 default: break; |
| 78 } |
| 79 } |
| 80 return false; |
61 } | 81 } |
62 | 82 |
63 static void AddGenIDChangeListener(const SkPath& path, SkPathRef::GenIDChang
eListener* listener) { | 83 static void AddGenIDChangeListener(const SkPath& path, SkPathRef::GenIDChang
eListener* listener) { |
64 path.fPathRef->addGenIDChangeListener(listener); | 84 path.fPathRef->addGenIDChangeListener(listener); |
65 } | 85 } |
66 }; | 86 }; |
67 | 87 |
68 #endif | 88 #endif |
OLD | NEW |