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 #ifndef SkStrokeRec_DEFINED | 8 #ifndef SkStrokeRec_DEFINED |
9 #define SkStrokeRec_DEFINED | 9 #define SkStrokeRec_DEFINED |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 kStroke_Style, | 28 kStroke_Style, |
29 kStrokeAndFill_Style | 29 kStrokeAndFill_Style |
30 }; | 30 }; |
31 enum { | 31 enum { |
32 kStyleCount = kStrokeAndFill_Style + 1 | 32 kStyleCount = kStrokeAndFill_Style + 1 |
33 }; | 33 }; |
34 | 34 |
35 Style getStyle() const; | 35 Style getStyle() const; |
36 SkScalar getWidth() const { return fWidth; } | 36 SkScalar getWidth() const { return fWidth; } |
37 SkScalar getMiter() const { return fMiterLimit; } | 37 SkScalar getMiter() const { return fMiterLimit; } |
38 SkPaint::Cap getCap() const { return fCap; } | 38 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; } |
39 SkPaint::Join getJoin() const { return fJoin; } | 39 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; } |
40 | 40 |
41 bool isHairlineStyle() const { | 41 bool isHairlineStyle() const { |
42 return kHairline_Style == this->getStyle(); | 42 return kHairline_Style == this->getStyle(); |
43 } | 43 } |
44 | 44 |
45 bool isFillStyle() const { | 45 bool isFillStyle() const { |
46 return kFill_Style == this->getStyle(); | 46 return kFill_Style == this->getStyle(); |
47 } | 47 } |
48 | 48 |
49 void setFillStyle(); | 49 void setFillStyle(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 fJoin == other.fJoin && | 108 fJoin == other.fJoin && |
109 fStrokeAndFill == other.fStrokeAndFill; | 109 fStrokeAndFill == other.fStrokeAndFill; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 void init(const SkPaint&, SkPaint::Style, SkScalar resScale); | 113 void init(const SkPaint&, SkPaint::Style, SkScalar resScale); |
114 | 114 |
115 SkScalar fResScale; | 115 SkScalar fResScale; |
116 SkScalar fWidth; | 116 SkScalar fWidth; |
117 SkScalar fMiterLimit; | 117 SkScalar fMiterLimit; |
118 SkPaint::Cap fCap; | 118 // The following three members are packed together into a single u32. |
119 SkPaint::Join fJoin; | 119 // This is to avoid unnecessary padding and ensure binary equality for |
120 bool fStrokeAndFill; | 120 // hashing (because the padded areas might contain garbage values). |
| 121 // |
| 122 // fCap and fJoin are larger than needed to avoid having to initialize |
| 123 // any pad values |
| 124 uint32_t fCap : 16; // SkPaint::Cap |
| 125 uint32_t fJoin : 15; // SkPaint::Join |
| 126 uint32_t fStrokeAndFill : 1; // bool |
121 }; | 127 }; |
122 | 128 |
123 #endif | 129 #endif |
OLD | NEW |