Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/gpu/GrStyle.h

Issue 1943973002: Revert of Make GrStyle more sk_sp savy (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrStyle.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 11 matching lines...) Expand all
22 * is handled by drawing a stroke and a fill separately. 22 * is handled by drawing a stroke and a fill separately.
23 * 23 *
24 * This will replace GrStrokeInfo as GrShape is deployed. 24 * This will replace GrStrokeInfo as GrShape is deployed.
25 */ 25 */
26 class GrStyle { 26 class GrStyle {
27 public: 27 public:
28 GrStyle() : fStrokeRec(SkStrokeRec::kFill_InitStyle) { 28 GrStyle() : fStrokeRec(SkStrokeRec::kFill_InitStyle) {
29 fDashInfo.fType = SkPathEffect::kNone_DashType; 29 fDashInfo.fType = SkPathEffect::kNone_DashType;
30 } 30 }
31 31
32 GrStyle(const SkStrokeRec& strokeRec, sk_sp<SkPathEffect> pe) : fStrokeRec(s trokeRec) { 32 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR ec) {
33 SkASSERT(SkStrokeRec::kStrokeAndFill_Style != strokeRec.getStyle()); 33 SkASSERT(SkStrokeRec::kStrokeAndFill_Style != strokeRec.getStyle());
34 this->initPathEffect(std::move(pe)); 34 this->initPathEffect(pe);
35 } 35 }
36 36
37 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { 37 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) {
38 *this = that; 38 *this = that;
39 } 39 }
40 40
41 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) { 41 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) {
42 SkASSERT(SkStrokeRec::kStrokeAndFill_Style != fStrokeRec.getStyle()); 42 SkASSERT(SkStrokeRec::kStrokeAndFill_Style != fStrokeRec.getStyle());
43 this->initPathEffect(sk_ref_sp(paint.getPathEffect())); 43 this->initPathEffect(paint.getPathEffect());
44 } 44 }
45 45
46 GrStyle& operator=(const GrStyle& that) { 46 GrStyle& operator=(const GrStyle& that) {
47 fPathEffect = that.fPathEffect; 47 fPathEffect = that.fPathEffect;
48 fDashInfo = that.fDashInfo; 48 fDashInfo = that.fDashInfo;
49 fStrokeRec = that.fStrokeRec; 49 fStrokeRec = that.fStrokeRec;
50 return *this; 50 return *this;
51 } 51 }
52 SkPathEffect* pathEffect() const { return fPathEffect.get(); } 52 SkPathEffect* pathEffect() const { return fPathEffect.get(); }
53 53
54 bool isDashed() const { return SkPathEffect::kDash_DashType == fDashInfo.fTy pe; } 54 bool isDashed() const { return SkPathEffect::kDash_DashType == fDashInfo.fTy pe; }
55 SkScalar dashPhase() const { 55 SkScalar dashPhase() const {
56 SkASSERT(this->isDashed()); 56 SkASSERT(this->isDashed());
57 return fDashInfo.fPhase; 57 return fDashInfo.fPhase;
58 } 58 }
59 int dashIntervalCnt() const { 59 int dashIntervalCnt() const {
60 SkASSERT(this->isDashed()); 60 SkASSERT(this->isDashed());
61 return fDashInfo.fIntervals.count(); 61 return fDashInfo.fIntervals.count();
62 } 62 }
63 const SkScalar* dashIntervals() const { 63 const SkScalar* dashIntervals() const {
64 SkASSERT(this->isDashed()); 64 SkASSERT(this->isDashed());
65 return fDashInfo.fIntervals.get(); 65 return fDashInfo.fIntervals.get();
66 } 66 }
67 67
68 const SkStrokeRec& strokeRec() const { return fStrokeRec; } 68 const SkStrokeRec& strokeRec() const { return fStrokeRec; }
69 69
70 private: 70 private:
71 void initPathEffect(sk_sp<SkPathEffect> pe); 71 void initPathEffect(SkPathEffect* pe);
72 72
73 struct DashInfo { 73 struct DashInfo {
74 DashInfo& operator=(const DashInfo& that) { 74 DashInfo& operator=(const DashInfo& that) {
75 fType = that.fType; 75 fType = that.fType;
76 fPhase = that.fPhase; 76 fPhase = that.fPhase;
77 fIntervals.reset(that.fIntervals.count()); 77 fIntervals.reset(that.fIntervals.count());
78 memcpy(fIntervals.get(), that.fIntervals.get(), 78 memcpy(fIntervals.get(), that.fIntervals.get(),
79 sizeof(SkScalar) * that.fIntervals.count()); 79 sizeof(SkScalar) * that.fIntervals.count());
80 return *this; 80 return *this;
81 } 81 }
82 SkPathEffect::DashType fType; 82 SkPathEffect::DashType fType;
83 SkScalar fPhase; 83 SkScalar fPhase;
84 SkAutoSTArray<4, SkScalar> fIntervals; 84 SkAutoSTArray<4, SkScalar> fIntervals;
85 }; 85 };
86 86
87 SkStrokeRec fStrokeRec; 87 SkStrokeRec fStrokeRec;
88 sk_sp<SkPathEffect> fPathEffect; 88 sk_sp<SkPathEffect> fPathEffect;
89 DashInfo fDashInfo; 89 DashInfo fDashInfo;
90 }; 90 };
91 91
92 #endif 92 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698