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() { | |
41 static constexpr SkRect kEmpty = SkRect::MakeEmpty(); | |
42 switch (fType) { | |
43 case Type::kEmpty: | |
robertphillips
2016/05/12 17:18:47
Why not just return SkRect::MakeEmpty here ?
bsalomon
2016/05/12 18:37:57
Becausethe return is a const& to a SkRect, so I ca
| |
44 return kEmpty; | |
45 case Type::kRRect: | |
46 return fRRect.getBounds(); | |
47 case Type::kPath: | |
48 return fPath.get()->getBounds(); | |
49 } | |
50 } | |
51 | |
52 void GrShape::styledBounds(SkRect* bounds) { | |
53 if (Type::kEmpty == fType && !fStyle.hasNonDashPathEffect()) { | |
robertphillips
2016/05/12 17:18:47
Is it an empty path or a path with a single point
| |
54 *bounds = SkRect::MakeEmpty(); | |
55 } else { | |
56 fStyle.adjustBounds(bounds, this->bounds()); | |
57 } | |
58 } | |
59 | |
40 int GrShape::unstyledKeySize() const { | 60 int GrShape::unstyledKeySize() const { |
41 if (fInheritedKey.count()) { | 61 if (fInheritedKey.count()) { |
42 return fInheritedKey.count(); | 62 return fInheritedKey.count(); |
43 } | 63 } |
44 switch (fType) { | 64 switch (fType) { |
45 case Type::kEmpty: | 65 case Type::kEmpty: |
46 return 1; | 66 return 1; |
47 case Type::kRRect: | 67 case Type::kRRect: |
48 SkASSERT(!fInheritedKey.count()); | 68 SkASSERT(!fInheritedKey.count()); |
49 SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t)); | 69 SkASSERT(0 == SkRRect::kSizeInMemory % sizeof(uint32_t)); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 SkStrokeRec::InitStyle fillOrHairline; | 246 SkStrokeRec::InitStyle fillOrHairline; |
227 SkASSERT(parent.fStyle.applies()); | 247 SkASSERT(parent.fStyle.applies()); |
228 SkASSERT(!parent.fStyle.pathEffect()); | 248 SkASSERT(!parent.fStyle.pathEffect()); |
229 SkAssertResult(parent.fStyle.applyToPath(fPath.get(), &fillOrHairline, * srcForParentStyle, | 249 SkAssertResult(parent.fStyle.applyToPath(fPath.get(), &fillOrHairline, * srcForParentStyle, |
230 scale)); | 250 scale)); |
231 fStyle.resetToInitStyle(fillOrHairline); | 251 fStyle.resetToInitStyle(fillOrHairline); |
232 } | 252 } |
233 this->attemptToReduceFromPath(); | 253 this->attemptToReduceFromPath(); |
234 this->setInheritedKey(*parentForKey, apply, scale); | 254 this->setInheritedKey(*parentForKey, apply, scale); |
235 } | 255 } |
OLD | NEW |