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

Side by Side Diff: src/gpu/GrShape.cpp

Issue 2064753003: Remove style application from GrPathRenderer subclasses (Closed) Base URL: https://chromium.googlesource.com/skia.git@pathshape
Patch Set: rebase Created 4 years, 6 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.h » ('j') | src/gpu/batches/GrAADistanceFieldPathRenderer.h » ('J')
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 #include "GrShape.h" 8 #include "GrShape.h"
9 9
10 GrShape& GrShape::operator=(const GrShape& that) { 10 GrShape& GrShape::operator=(const GrShape& that) {
(...skipping 20 matching lines...) Expand all
31 *fPath.get() = *that.fPath.get(); 31 *fPath.get() = *that.fPath.get();
32 } else { 32 } else {
33 fPath.set(*that.fPath.get()); 33 fPath.set(*that.fPath.get());
34 } 34 }
35 fPathGenID = that.fPathGenID; 35 fPathGenID = that.fPathGenID;
36 break; 36 break;
37 } 37 }
38 fInheritedKey.reset(that.fInheritedKey.count()); 38 fInheritedKey.reset(that.fInheritedKey.count());
39 sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(), 39 sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(),
40 sizeof(uint32_t) * fInheritedKey.count()); 40 sizeof(uint32_t) * fInheritedKey.count());
41 SkASSERT((Type::kPath == fType) == SkToBool(fPath.getMaybeNull()));
bsalomon 2016/06/24 20:53:33 Ignore all these. I meant to delete these asserts.
41 return *this; 42 return *this;
42 } 43 }
43 44
44 const SkRect& GrShape::bounds() const { 45 const SkRect& GrShape::bounds() const {
45 static constexpr SkRect kEmpty = SkRect::MakeEmpty(); 46 static constexpr SkRect kEmpty = SkRect::MakeEmpty();
46 switch (fType) { 47 switch (fType) {
47 case Type::kEmpty: 48 case Type::kEmpty:
48 return kEmpty; 49 return kEmpty;
49 case Type::kRRect: 50 case Type::kRRect:
50 return fRRect.getBounds(); 51 return fRRect.getBounds();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 fRRectIsInverted = that.fRRectIsInverted; 176 fRRectIsInverted = that.fRRectIsInverted;
176 break; 177 break;
177 case Type::kPath: 178 case Type::kPath:
178 fPath.set(*that.fPath.get()); 179 fPath.set(*that.fPath.get());
179 fPathGenID = that.fPathGenID; 180 fPathGenID = that.fPathGenID;
180 break; 181 break;
181 } 182 }
182 fInheritedKey.reset(that.fInheritedKey.count()); 183 fInheritedKey.reset(that.fInheritedKey.count());
183 sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(), 184 sk_careful_memcpy(fInheritedKey.get(), that.fInheritedKey.get(),
184 sizeof(uint32_t) * fInheritedKey.count()); 185 sizeof(uint32_t) * fInheritedKey.count());
186 SkASSERT((Type::kPath == fType) == SkToBool(fPath.getMaybeNull()));
185 } 187 }
186 188
187 GrShape::GrShape(const GrShape& parent, GrStyle::Apply apply, SkScalar scale) { 189 GrShape::GrShape(const GrShape& parent, GrStyle::Apply apply, SkScalar scale) {
188 // TODO: Add some quantization of scale for better cache performance here or leave that up 190 // TODO: Add some quantization of scale for better cache performance here or leave that up
189 // to caller? 191 // to caller?
190 // TODO: For certain shapes and stroke params we could ignore the scale. (e. g. miter or bevel 192 // TODO: For certain shapes and stroke params we could ignore the scale. (e. g. miter or bevel
191 // stroke of a rect). 193 // stroke of a rect).
192 if (!parent.style().applies() || 194 if (!parent.style().applies() ||
193 (GrStyle::Apply::kPathEffectOnly == apply && !parent.style().pathEffect( ))) { 195 (GrStyle::Apply::kPathEffectOnly == apply && !parent.style().pathEffect( ))) {
194 fType = Type::kEmpty; 196 fType = Type::kEmpty;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 263 }
262 SkStrokeRec::InitStyle fillOrHairline; 264 SkStrokeRec::InitStyle fillOrHairline;
263 SkASSERT(parent.fStyle.applies()); 265 SkASSERT(parent.fStyle.applies());
264 SkASSERT(!parent.fStyle.pathEffect()); 266 SkASSERT(!parent.fStyle.pathEffect());
265 SkAssertResult(parent.fStyle.applyToPath(fPath.get(), &fillOrHairline, * srcForParentStyle, 267 SkAssertResult(parent.fStyle.applyToPath(fPath.get(), &fillOrHairline, * srcForParentStyle,
266 scale)); 268 scale));
267 fStyle.resetToInitStyle(fillOrHairline); 269 fStyle.resetToInitStyle(fillOrHairline);
268 } 270 }
269 this->attemptToSimplifyPath(); 271 this->attemptToSimplifyPath();
270 this->setInheritedKey(*parentForKey, apply, scale); 272 this->setInheritedKey(*parentForKey, apply, scale);
273 SkASSERT((Type::kPath == fType) == SkToBool(fPath.getMaybeNull()));
271 } 274 }
272 275
273 void GrShape::attemptToSimplifyPath() { 276 void GrShape::attemptToSimplifyPath() {
274 SkASSERT(Type::kPath == fType); 277 SkASSERT(Type::kPath == fType);
275 SkRect rect; 278 SkRect rect;
276 if (fPath.get()->isEmpty()) { 279 if (fPath.get()->isEmpty()) {
277 fType = Type::kEmpty; 280 fType = Type::kEmpty;
278 } else if (fPath.get()->isRRect(&fRRect, &fRRectDir, &fRRectStart)) { 281 } else if (fPath.get()->isRRect(&fRRect, &fRRectDir, &fRRectStart)) {
279 // Currently SkPath does not acknowledge that empty, rect, or oval subty pes as rrects. 282 // Currently SkPath does not acknowledge that empty, rect, or oval subty pes as rrects.
280 SkASSERT(!fRRect.isEmpty()); 283 SkASSERT(!fRRect.isEmpty());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return; 367 return;
365 } 368 }
366 if (!this->style().hasPathEffect()) { 369 if (!this->style().hasPathEffect()) {
367 fRRectDir = kDefaultRRectDir; 370 fRRectDir = kDefaultRRectDir;
368 fRRectStart = kDefaultRRectStart; 371 fRRectStart = kDefaultRRectStart;
369 } else if (fStyle.isDashed()) { 372 } else if (fStyle.isDashed()) {
370 // Dashing ignores the inverseness (currently). skbug.com/5421 373 // Dashing ignores the inverseness (currently). skbug.com/5421
371 fRRectIsInverted = false; 374 fRRectIsInverted = false;
372 } 375 }
373 } 376 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrStyle.h » ('j') | src/gpu/batches/GrAADistanceFieldPathRenderer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698