| 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 #ifndef GrStyle_DEFINED | 8 #ifndef GrStyle_DEFINED |
| 9 #define GrStyle_DEFINED | 9 #define GrStyle_DEFINED |
| 10 | 10 |
| 11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "SkPathEffect.h" | 12 #include "SkPathEffect.h" |
| 13 #include "SkStrokeRec.h" | 13 #include "SkStrokeRec.h" |
| 14 #include "SkTemplates.h" | 14 #include "SkTemplates.h" |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Represents the various ways that a GrShape can be styled. It has fill/strokin
g information | 17 * Represents the various ways that a GrShape can be styled. It has fill/strokin
g information |
| 18 * as well as an optional path effect. If the path effect represents dashing, th
e dashing | 18 * as well as an optional path effect. If the path effect represents dashing, th
e dashing |
| 19 * information is extracted from the path effect and stored explicitly. | 19 * information is extracted from the path effect and stored explicitly. |
| 20 * | 20 * |
| 21 * This object does not support stroke-and-fill styling. It is expected that str
oking and filling | |
| 22 * is handled by drawing a stroke and a fill separately. | |
| 23 * | |
| 24 * This will replace GrStrokeInfo as GrShape is deployed. | 21 * This will replace GrStrokeInfo as GrShape is deployed. |
| 25 */ | 22 */ |
| 26 class GrStyle { | 23 class GrStyle { |
| 27 public: | 24 public: |
| 28 /** | 25 /** |
| 29 * A style object that represents a fill with no path effect. | 26 * A style object that represents a fill with no path effect. |
| 30 * TODO: constexpr with C++14 | 27 * TODO: constexpr with C++14 |
| 31 */ | 28 */ |
| 32 static const GrStyle& SimpleFill() { | 29 static const GrStyle& SimpleFill() { |
| 33 static const GrStyle kFill(SkStrokeRec::kFill_InitStyle); | 30 static const GrStyle kFill(SkStrokeRec::kFill_InitStyle); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 * for just dash application followed by the key for the remaining SkStrokeR
ec is the same as | 69 * for just dash application followed by the key for the remaining SkStrokeR
ec is the same as |
| 73 * the key for applying dashing and SkStrokeRec all at once. | 70 * the key for applying dashing and SkStrokeRec all at once. |
| 74 */ | 71 */ |
| 75 static void WriteKey(uint32_t*, const GrStyle&, Apply, uint32_t flags = 0); | 72 static void WriteKey(uint32_t*, const GrStyle&, Apply, uint32_t flags = 0); |
| 76 | 73 |
| 77 GrStyle() : GrStyle(SkStrokeRec::kFill_InitStyle) {} | 74 GrStyle() : GrStyle(SkStrokeRec::kFill_InitStyle) {} |
| 78 | 75 |
| 79 explicit GrStyle(SkStrokeRec::InitStyle initStyle) : fStrokeRec(initStyle) {
} | 76 explicit GrStyle(SkStrokeRec::InitStyle initStyle) : fStrokeRec(initStyle) {
} |
| 80 | 77 |
| 81 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR
ec) { | 78 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR
ec) { |
| 82 SkASSERT(SkStrokeRec::kStrokeAndFill_Style != strokeRec.getStyle()); | |
| 83 this->initPathEffect(pe); | 79 this->initPathEffect(pe); |
| 84 } | 80 } |
| 85 | 81 |
| 86 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { *t
his = that; } | 82 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { *t
his = that; } |
| 87 | 83 |
| 88 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) { | 84 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) { |
| 89 SkASSERT(SkStrokeRec::kStrokeAndFill_Style != fStrokeRec.getStyle()); | |
| 90 this->initPathEffect(paint.getPathEffect()); | 85 this->initPathEffect(paint.getPathEffect()); |
| 91 } | 86 } |
| 92 | 87 |
| 93 GrStyle& operator=(const GrStyle& that) { | 88 GrStyle& operator=(const GrStyle& that) { |
| 94 fPathEffect = that.fPathEffect; | 89 fPathEffect = that.fPathEffect; |
| 95 fDashInfo = that.fDashInfo; | 90 fDashInfo = that.fDashInfo; |
| 96 fStrokeRec = that.fStrokeRec; | 91 fStrokeRec = that.fStrokeRec; |
| 97 return *this; | 92 return *this; |
| 98 } | 93 } |
| 99 | 94 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 SkScalar fPhase; | 175 SkScalar fPhase; |
| 181 SkAutoSTArray<4, SkScalar> fIntervals; | 176 SkAutoSTArray<4, SkScalar> fIntervals; |
| 182 }; | 177 }; |
| 183 | 178 |
| 184 SkStrokeRec fStrokeRec; | 179 SkStrokeRec fStrokeRec; |
| 185 sk_sp<SkPathEffect> fPathEffect; | 180 sk_sp<SkPathEffect> fPathEffect; |
| 186 DashInfo fDashInfo; | 181 DashInfo fDashInfo; |
| 187 }; | 182 }; |
| 188 | 183 |
| 189 #endif | 184 #endif |
| OLD | NEW |