| 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 19 matching lines...) Expand all Loading... |
| 30 fPath.set(*that.fPath.get()); | 30 fPath.set(*that.fPath.get()); |
| 31 } | 31 } |
| 32 break; | 32 break; |
| 33 } | 33 } |
| 34 fInheritedKey.reset(that.fInheritedKey.count()); | 34 fInheritedKey.reset(that.fInheritedKey.count()); |
| 35 sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(), | 35 sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(), |
| 36 sizeof(uint32_t) * fInheritedKey.count()); | 36 sizeof(uint32_t) * fInheritedKey.count()); |
| 37 return *this; | 37 return *this; |
| 38 } | 38 } |
| 39 | 39 |
| 40 const SkRect& GrShape::bounds() const { |
| 41 static constexpr SkRect kEmpty = SkRect::MakeEmpty(); |
| 42 switch (fType) { |
| 43 case Type::kEmpty: |
| 44 return kEmpty; |
| 45 case Type::kRRect: |
| 46 return fRRect.getBounds(); |
| 47 case Type::kPath: |
| 48 return fPath.get()->getBounds(); |
| 49 } |
| 50 SkFAIL("Unknown shape type"); |
| 51 return kEmpty; |
| 52 } |
| 53 |
| 54 void GrShape::styledBounds(SkRect* bounds) const { |
| 55 if (Type::kEmpty == fType && !fStyle.hasNonDashPathEffect()) { |
| 56 *bounds = SkRect::MakeEmpty(); |
| 57 } else { |
| 58 fStyle.adjustBounds(bounds, this->bounds()); |
| 59 } |
| 60 } |
| 61 |
| 40 int GrShape::unstyledKeySize() const { | 62 int GrShape::unstyledKeySize() const { |
| 41 if (fInheritedKey.count()) { | 63 if (fInheritedKey.count()) { |
| 42 return fInheritedKey.count(); | 64 return fInheritedKey.count(); |
| 43 } | 65 } |
| 44 switch (fType) { | 66 switch (fType) { |
| 45 case Type::kEmpty: | 67 case Type::kEmpty: |
| 46 return 1; | 68 return 1; |
| 47 case Type::kRRect: | 69 case Type::kRRect: |
| 48 SkASSERT(!fInheritedKey.count()); | 70 SkASSERT(!fInheritedKey.count()); |
| 49 SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t)); | 71 SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t)); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 SkStrokeRec::InitStyle fillOrHairline; | 248 SkStrokeRec::InitStyle fillOrHairline; |
| 227 SkASSERT(parent.fStyle.applies()); | 249 SkASSERT(parent.fStyle.applies()); |
| 228 SkASSERT(!parent.fStyle.pathEffect()); | 250 SkASSERT(!parent.fStyle.pathEffect()); |
| 229 SkAssertResult(parent.fStyle.applyToPath(fPath.get(), &fillOrHairline, *
srcForParentStyle, | 251 SkAssertResult(parent.fStyle.applyToPath(fPath.get(), &fillOrHairline, *
srcForParentStyle, |
| 230 scale)); | 252 scale)); |
| 231 fStyle.resetToInitStyle(fillOrHairline); | 253 fStyle.resetToInitStyle(fillOrHairline); |
| 232 } | 254 } |
| 233 this->attemptToReduceFromPath(); | 255 this->attemptToReduceFromPath(); |
| 234 this->setInheritedKey(*parentForKey, apply, scale); | 256 this->setInheritedKey(*parentForKey, apply, scale); |
| 235 } | 257 } |
| OLD | NEW |