| 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 // Point order is significant when dashing, so we cannot devolve to a rect k
ey. | 39 if (!path.isOval(&rect)) { |
| 40 if (stroke.isDashed() || !path.isOval(&rect)) { | |
| 41 return false; | 40 return false; |
| 42 } | 41 } |
| 43 static_assert((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeo
f(uint32_t), | 42 static_assert((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeo
f(uint32_t), |
| 44 "rect_needs_padding"); | 43 "rect_needs_padding"); |
| 45 | 44 |
| 46 const int kBaseData32Cnt = 1 + sizeof(rect) / sizeof(uint32_t); | 45 const int kBaseData32Cnt = 1 + sizeof(rect) / sizeof(uint32_t); |
| 47 int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt(); | 46 int strokeDataCnt = stroke.computeUniqueKeyFragmentData32Cnt(); |
| 48 static const GrUniqueKey::Domain kOvalPathDomain = GrUniqueKey::GenerateDoma
in(); | 47 static const GrUniqueKey::Domain kOvalPathDomain = GrUniqueKey::GenerateDoma
in(); |
| 49 GrUniqueKey::Builder builder(key, kOvalPathDomain, kBaseData32Cnt + strokeDa
taCnt); | 48 GrUniqueKey::Builder builder(key, kOvalPathDomain, kBaseData32Cnt + strokeDa
taCnt); |
| 50 builder[0] = path.getFillType(); | 49 builder[0] = path.getFillType(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 164 |
| 166 if (compute_key_for_simple_path(path, stroke, key)) { | 165 if (compute_key_for_simple_path(path, stroke, key)) { |
| 167 *outIsVolatile = false; | 166 *outIsVolatile = false; |
| 168 return; | 167 return; |
| 169 } | 168 } |
| 170 | 169 |
| 171 compute_key_for_general_path(path, stroke, key); | 170 compute_key_for_general_path(path, stroke, key); |
| 172 *outIsVolatile = path.isVolatile(); | 171 *outIsVolatile = path.isVolatile(); |
| 173 } | 172 } |
| 174 | 173 |
| 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 |