| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "GrShape.h" | 8 #include "GrShape.h" |
| 9 | 9 |
| 10 GrShape& GrShape::operator=(const GrShape& that) { | 10 GrShape& GrShape::operator=(const GrShape& that) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 case Type::kRRect: | 125 case Type::kRRect: |
| 126 SkASSERT(!fInheritedKey.count()); | 126 SkASSERT(!fInheritedKey.count()); |
| 127 SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t)); | 127 SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t)); |
| 128 // + 1 for the direction, start index, and inverseness. | 128 // + 1 for the direction, start index, and inverseness. |
| 129 return SkRRect::kSizeInMemory / sizeof(uint32_t) + 1; | 129 return SkRRect::kSizeInMemory / sizeof(uint32_t) + 1; |
| 130 case Type::kLine: | 130 case Type::kLine: |
| 131 GR_STATIC_ASSERT(2 * sizeof(uint32_t) == sizeof(SkPoint)); | 131 GR_STATIC_ASSERT(2 * sizeof(uint32_t) == sizeof(SkPoint)); |
| 132 // 4 for the end points and 1 for the inverseness | 132 // 4 for the end points and 1 for the inverseness |
| 133 return 5; | 133 return 5; |
| 134 case Type::kPath: { | 134 case Type::kPath: { |
| 135 if (0 == fPathData.fGenID) { |
| 136 return -1; |
| 137 } |
| 135 int dataKeySize = path_key_from_data_size(fPathData.fPath); | 138 int dataKeySize = path_key_from_data_size(fPathData.fPath); |
| 136 if (dataKeySize >= 0) { | 139 if (dataKeySize >= 0) { |
| 137 return dataKeySize; | 140 return dataKeySize; |
| 138 } | 141 } |
| 139 if (0 == fPathData.fGenID) { | |
| 140 return -1; | |
| 141 } | |
| 142 // The key is the path ID and fill type. | 142 // The key is the path ID and fill type. |
| 143 return 2; | 143 return 2; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 SkFAIL("Should never get here."); | 146 SkFAIL("Should never get here."); |
| 147 return 0; | 147 return 0; |
| 148 } | 148 } |
| 149 | 149 |
| 150 void GrShape::writeUnstyledKey(uint32_t* key) const { | 150 void GrShape::writeUnstyledKey(uint32_t* key) const { |
| 151 SkASSERT(this->unstyledKeySize()); | 151 SkASSERT(this->unstyledKeySize()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 165 *key |= fRRectData.fInverted ? (1 << 30) : 0; | 165 *key |= fRRectData.fInverted ? (1 << 30) : 0; |
| 166 *key++ |= fRRectData.fStart; | 166 *key++ |= fRRectData.fStart; |
| 167 SkASSERT(fRRectData.fStart < 8); | 167 SkASSERT(fRRectData.fStart < 8); |
| 168 break; | 168 break; |
| 169 case Type::kLine: | 169 case Type::kLine: |
| 170 memcpy(key, fLineData.fPts, 2 * sizeof(SkPoint)); | 170 memcpy(key, fLineData.fPts, 2 * sizeof(SkPoint)); |
| 171 key += 4; | 171 key += 4; |
| 172 *key++ = fLineData.fInverted ? 1 : 0; | 172 *key++ = fLineData.fInverted ? 1 : 0; |
| 173 break; | 173 break; |
| 174 case Type::kPath: { | 174 case Type::kPath: { |
| 175 SkASSERT(fPathData.fGenID); |
| 175 int dataKeySize = path_key_from_data_size(fPathData.fPath); | 176 int dataKeySize = path_key_from_data_size(fPathData.fPath); |
| 176 if (dataKeySize >= 0) { | 177 if (dataKeySize >= 0) { |
| 177 write_path_key_from_data(fPathData.fPath, key); | 178 write_path_key_from_data(fPathData.fPath, key); |
| 178 return; | 179 return; |
| 179 } | 180 } |
| 180 SkASSERT(fPathData.fGenID); | |
| 181 *key++ = fPathData.fGenID; | 181 *key++ = fPathData.fGenID; |
| 182 // We could canonicalize the fill rule for paths that don't diff
erentiate between | 182 // We could canonicalize the fill rule for paths that don't diff
erentiate between |
| 183 // even/odd or winding fill (e.g. convex). | 183 // even/odd or winding fill (e.g. convex). |
| 184 *key++ = this->path().getFillType(); | 184 *key++ = this->path().getFillType(); |
| 185 break; | 185 break; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 SkASSERT(key - origKey == this->unstyledKeySize()); | 189 SkASSERT(key - origKey == this->unstyledKeySize()); |
| 190 } | 190 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 fStyle = GrStyle::SimpleFill(); | 531 fStyle = GrStyle::SimpleFill(); |
| 532 return; | 532 return; |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 // Only path effects could care about the order of the points. Otherwise can
onicalize | 535 // Only path effects could care about the order of the points. Otherwise can
onicalize |
| 536 // the point order. | 536 // the point order. |
| 537 if (pts[1].fY < pts[0].fY || (pts[1].fY == pts[0].fY && pts[1].fX < pts[0].f
X)) { | 537 if (pts[1].fY < pts[0].fY || (pts[1].fY == pts[0].fY && pts[1].fX < pts[0].f
X)) { |
| 538 SkTSwap(pts[0], pts[1]); | 538 SkTSwap(pts[0], pts[1]); |
| 539 } | 539 } |
| 540 } | 540 } |
| OLD | NEW |