OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrPath.h" | 8 #include "GrPath.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 18 matching lines...) Expand all Loading... |
29 memcpy(&builder[1], &pts, sizeof(pts)); | 29 memcpy(&builder[1], &pts, sizeof(pts)); |
30 if (strokeDataCnt > 0) { | 30 if (strokeDataCnt > 0) { |
31 stroke.asUniqueKeyFragment(&builder[kBaseData32Cnt]); | 31 stroke.asUniqueKeyFragment(&builder[kBaseData32Cnt]); |
32 } | 32 } |
33 return true; | 33 return true; |
34 } | 34 } |
35 | 35 |
36 inline static bool compute_key_for_oval_path(const SkPath& path, const GrStrokeI
nfo& stroke, | 36 inline static bool compute_key_for_oval_path(const SkPath& path, const GrStrokeI
nfo& stroke, |
37 GrUniqueKey* key) { | 37 GrUniqueKey* key) { |
38 SkRect rect; | 38 SkRect rect; |
39 if (!path.isOval(&rect)) { | 39 // Point order is significant when dashing, so we cannot devolve to a rect k
ey. |
| 40 if (stroke.isDashed() || !path.isOval(&rect)) { |
40 return false; | 41 return false; |
41 } | 42 } |
42 static_assert((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeo
f(uint32_t), | 43 static_assert((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeo
f(uint32_t), |
43 "rect_needs_padding"); | 44 "rect_needs_padding"); |
44 | 45 |
45 const int kBaseData32Cnt = 1 + sizeof(rect) / sizeof(uint32_t); | 46 const int kBaseData32Cnt = 1 + sizeof(rect) / sizeof(uint32_t); |
46 int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt(); | 47 int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt(); |
47 static const GrUniqueKey::Domain kOvalPathDomain = GrUniqueKey::GenerateDoma
in(); | 48 static const GrUniqueKey::Domain kOvalPathDomain = GrUniqueKey::GenerateDoma
in(); |
48 GrUniqueKey::Builder builder(key, kOvalPathDomain, kBaseData32Cnt + strokeDa
taCnt); | 49 GrUniqueKey::Builder builder(key, kOvalPathDomain, kBaseData32Cnt + strokeDa
taCnt); |
49 builder[0] = path.getFillType(); | 50 builder[0] = path.getFillType(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 165 |
165 if (compute_key_for_simple_path(path, stroke, key)) { | 166 if (compute_key_for_simple_path(path, stroke, key)) { |
166 *outIsVolatile = false; | 167 *outIsVolatile = false; |
167 return; | 168 return; |
168 } | 169 } |
169 | 170 |
170 compute_key_for_general_path(path, stroke, key); | 171 compute_key_for_general_path(path, stroke, key); |
171 *outIsVolatile = path.isVolatile(); | 172 *outIsVolatile = path.isVolatile(); |
172 } | 173 } |
173 | 174 |
| 175 #ifdef SK_DEBUG |
| 176 bool GrPath::isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) const { |
| 177 if (!fStroke.hasEqualEffect(stroke)) { |
| 178 return false; |
| 179 } |
| 180 |
| 181 // We treat same-rect ovals as identical - but only when not dashing. |
| 182 SkRect ovalBounds; |
| 183 if (!fStroke.isDashed() && fSkPath.isOval(&ovalBounds)) { |
| 184 SkRect otherOvalBounds; |
| 185 return path.isOval(&otherOvalBounds) && ovalBounds == otherOvalBounds; |
| 186 } |
| 187 |
| 188 return fSkPath == path; |
| 189 } |
| 190 #endif |
| 191 |
OLD | NEW |