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

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

Issue 1952383003: Incorporate scale into GrStyle and GrShape (Closed) Base URL: https://skia.googlesource.com/skia.git@fixapply
Patch Set: rebase 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/GrShape.cpp ('k') | 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // The shape being styled has no open contours. 53 // The shape being styled has no open contours.
54 kClosed_KeyFlag = 0x1 54 kClosed_KeyFlag = 0x1
55 }; 55 };
56 56
57 /** 57 /**
58 * Computes the key length for a GrStyle. The return will be negative if it cannot be turned 58 * Computes the key length for a GrStyle. The return will be negative if it cannot be turned
59 * into a key. This occurs when there is a path effect that is not a dash. T he key can 59 * into a key. This occurs when there is a path effect that is not a dash. T he key can
60 * either reflect just the path effect (if one) or the path effect and the s trokerec. Note 60 * either reflect just the path effect (if one) or the path effect and the s trokerec. Note
61 * that a simple fill has a zero sized key. 61 * that a simple fill has a zero sized key.
62 */ 62 */
63 static int KeySize(const GrStyle& , Apply, uint32_t flags = 0); 63 static int KeySize(const GrStyle&, Apply, uint32_t flags = 0);
64 64
65 /** 65 /**
66 * Writes a unique key for the style into the provided buffer. This function assumes the buffer 66 * Writes a unique key for the style into the provided buffer. This function assumes the buffer
67 * has room for at least KeySize() values. It assumes that KeySize() returns a non-negative 67 * has room for at least KeySize() values. It assumes that KeySize() returns a non-negative
68 * value for the combination of GrStyle, Apply and flags params. This is wri tten so that the key 68 * value for the combination of GrStyle, Apply and flags params. This is wri tten so that the key
69 * 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
70 * the key for applying dashing and SkStrokeRec all at once. 70 * the key for applying dashing and SkStrokeRec all at once.
71 */ 71 */
72 static void WriteKey(uint32_t*, const GrStyle&, Apply, uint32_t flags = 0); 72 static void WriteKey(uint32_t*, const GrStyle&, Apply, SkScalar scale, uint3 2_t flags = 0);
73 73
74 GrStyle() : GrStyle(SkStrokeRec::kFill_InitStyle) {} 74 GrStyle() : GrStyle(SkStrokeRec::kFill_InitStyle) {}
75 75
76 explicit GrStyle(SkStrokeRec::InitStyle initStyle) : fStrokeRec(initStyle) { } 76 explicit GrStyle(SkStrokeRec::InitStyle initStyle) : fStrokeRec(initStyle) { }
77 77
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; }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 const SkStrokeRec& strokeRec() const { return fStrokeRec; } 129 const SkStrokeRec& strokeRec() const { return fStrokeRec; }
130 130
131 /** 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. */
132 bool applies() const { 132 bool applies() const {
133 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i sHairlineStyle()); 133 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i sHairlineStyle());
134 } 134 }
135 135
136 /** 136 /**
137 * 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
138 * there is no path effect. dst may or may not have been overwritten on fail ure. 138 * there is no path effect. dst may or may not have been overwritten on fail ure. Scale controls
139 * geometric approximations made by the path effect. It is typically compute d from the view
140 * matrix.
139 */ 141 */
140 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r emainingStoke, 142 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r emainingStoke,
141 const SkPath& src) const; 143 const SkPath& src, SkScalar scale) const;
142 144
143 /** If this succeeds then the result path should be filled or hairlined as i ndicated by the 145 /**
144 returned SkStrokeRec::InitStyle value. Will fail if there is no path eff ect and the 146 * If this succeeds then the result path should be filled or hairlined as in dicated by the
145 strokerec doesn't change the geometry. When this fails the outputs may o r may not have 147 * returned SkStrokeRec::InitStyle value. Will fail if there is no path effe ct and the
146 been overwritten. 148 * strokerec doesn't change the geometry. When this fails the outputs may or may not have
147 */ 149 * been overwritten. Scale controls geometric approximations made by the pat h effect and
150 * stroker. It is typically computed from the view matrix.
151 */
148 bool SK_WARN_UNUSED_RESULT applyToPath(SkPath* dst, SkStrokeRec::InitStyle* fillOrHairline, 152 bool SK_WARN_UNUSED_RESULT applyToPath(SkPath* dst, SkStrokeRec::InitStyle* fillOrHairline,
149 const SkPath& src) const; 153 const SkPath& src, SkScalar scale) co nst;
150 154
151 /** Given bounds of a path compute the bounds of path with the style applied . */ 155 /** Given bounds of a path compute the bounds of path with the style applied . */
152 void adjustBounds(SkRect* dst, const SkRect& src) const { 156 void adjustBounds(SkRect* dst, const SkRect& src) const {
153 if (this->pathEffect()) { 157 if (this->pathEffect()) {
154 this->pathEffect()->computeFastBounds(dst, src); 158 this->pathEffect()->computeFastBounds(dst, src);
155 } else { 159 } else {
156 SkScalar radius = fStrokeRec.getInflationRadius(); 160 SkScalar radius = fStrokeRec.getInflationRadius();
157 *dst = src.makeOutset(radius, radius); 161 *dst = src.makeOutset(radius, radius);
158 } 162 }
159 } 163 }
(...skipping 19 matching lines...) Expand all
179 SkScalar fPhase; 183 SkScalar fPhase;
180 SkAutoSTArray<4, SkScalar> fIntervals; 184 SkAutoSTArray<4, SkScalar> fIntervals;
181 }; 185 };
182 186
183 SkStrokeRec fStrokeRec; 187 SkStrokeRec fStrokeRec;
184 sk_sp<SkPathEffect> fPathEffect; 188 sk_sp<SkPathEffect> fPathEffect;
185 DashInfo fDashInfo; 189 DashInfo fDashInfo;
186 }; 190 };
187 191
188 #endif 192 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrShape.cpp ('k') | src/gpu/GrStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698