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

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

Issue 1967513002: Revert of Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
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 | « src/gpu/GrStrokeInfo.cpp ('k') | src/gpu/GrTestUtils.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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR ec) { 78 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR ec) {
79 this->initPathEffect(pe); 79 this->initPathEffect(pe);
80 } 80 }
81 81
82 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { *t his = that; } 82 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { *t his = that; }
83 83
84 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) { 84 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) {
85 this->initPathEffect(paint.getPathEffect()); 85 this->initPathEffect(paint.getPathEffect());
86 } 86 }
87 87
88 explicit GrStyle(const SkPaint& paint, SkPaint::Style overrideStyle)
89 : fStrokeRec(paint, overrideStyle) {
90 this->initPathEffect(paint.getPathEffect());
91 }
92
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
100 void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline) { 95 void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline) {
101 fDashInfo.reset(); 96 fDashInfo.reset();
102 fPathEffect.reset(nullptr); 97 fPathEffect.reset(nullptr);
(...skipping 28 matching lines...) Expand all
131 return fDashInfo.fIntervals.get(); 126 return fDashInfo.fIntervals.get();
132 } 127 }
133 128
134 const SkStrokeRec& strokeRec() const { return fStrokeRec; } 129 const SkStrokeRec& strokeRec() const { return fStrokeRec; }
135 130
136 /** Hairline or fill styles without path effects make no alterations to a ge ometry. */ 131 /** Hairline or fill styles without path effects make no alterations to a ge ometry. */
137 bool applies() const { 132 bool applies() const {
138 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i sHairlineStyle()); 133 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i sHairlineStyle());
139 } 134 }
140 135
141 static SkScalar MatrixToScaleFactor(const SkMatrix& matrix) {
142 // getMaxScale will return -1 if the matrix has perspective. In that cas e we can use a scale
143 // factor of 1. This isn't necessarily a good choice and in the future w e might consider
144 // taking a bounds here for the perspective case.
145 return SkScalarAbs(matrix.getMaxScale());
146 }
147 /** 136 /**
148 * Applies just the path effect and returns remaining stroke information. Th is will fail if 137 * Applies just the path effect and returns remaining stroke information. Th is will fail if
149 * there is no path effect. dst may or may not have been overwritten on fail ure. Scale controls 138 * there is no path effect. dst may or may not have been overwritten on fail ure. Scale controls
150 * geometric approximations made by the path effect. It is typically compute d from the view 139 * geometric approximations made by the path effect. It is typically compute d from the view
151 * matrix. 140 * matrix.
152 */ 141 */
153 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r emainingStoke, 142 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r emainingStoke,
154 const SkPath& src, SkScalar scale) const; 143 const SkPath& src, SkScalar scale) const;
155 144
156 /** 145 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 SkScalar fPhase; 183 SkScalar fPhase;
195 SkAutoSTArray<4, SkScalar> fIntervals; 184 SkAutoSTArray<4, SkScalar> fIntervals;
196 }; 185 };
197 186
198 SkStrokeRec fStrokeRec; 187 SkStrokeRec fStrokeRec;
199 sk_sp<SkPathEffect> fPathEffect; 188 sk_sp<SkPathEffect> fPathEffect;
200 DashInfo fDashInfo; 189 DashInfo fDashInfo;
201 }; 190 };
202 191
203 #endif 192 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrStrokeInfo.cpp ('k') | src/gpu/GrTestUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698