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

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

Issue 2151313002: In GrShape detect that stroked axis-aligned lines are rrects. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Add accidentally delete semicolon back Created 4 years, 5 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/GrStyle.h ('k') | tests/DFPathRendererTest.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 #include "GrStyle.h" 8 #include "GrStyle.h"
9 #include "SkDashPathPriv.h" 9 #include "SkDashPathPriv.h"
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 kCapBits = 32 - kStyleBits - kJoinBits, 68 kCapBits = 32 - kStyleBits - kJoinBits,
69 69
70 kJoinShift = kStyleBits, 70 kJoinShift = kStyleBits,
71 kCapShift = kJoinShift + kJoinBits, 71 kCapShift = kJoinShift + kJoinBits,
72 }; 72 };
73 GR_STATIC_ASSERT(SkStrokeRec::kStyleCount <= (1 << kStyleBits)); 73 GR_STATIC_ASSERT(SkStrokeRec::kStyleCount <= (1 << kStyleBits));
74 GR_STATIC_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits)); 74 GR_STATIC_ASSERT(SkPaint::kJoinCount <= (1 << kJoinBits));
75 GR_STATIC_ASSERT(SkPaint::kCapCount <= (1 << kCapBits)); 75 GR_STATIC_ASSERT(SkPaint::kCapCount <= (1 << kCapBits));
76 // The cap type only matters for unclosed shapes. However, a path effect could unclose 76 // The cap type only matters for unclosed shapes. However, a path effect could unclose
77 // the shape before it is stroked. 77 // the shape before it is stroked.
78 SkPaint::Cap cap; 78 SkPaint::Cap cap = SkPaint::kDefault_Cap;
79 if ((flags & kClosed_KeyFlag) && !style.pathEffect()) { 79 if (!(flags & kClosed_KeyFlag) || style.pathEffect()) {
80 cap = SkPaint::kButt_Cap;
81 } else {
82 cap = style.strokeRec().getCap(); 80 cap = style.strokeRec().getCap();
83 } 81 }
82 SkScalar miter = -1.f;
83 SkPaint::Join join = SkPaint::kDefault_Join;
84
85 // Dashing will not insert joins but other path effects may.
86 if (!(flags & kNoJoins_KeyFlag) || style.hasNonDashPathEffect()) {
87 join = style.strokeRec().getJoin();
88 // Miter limit only affects miter joins
89 if (SkPaint::kMiter_Join == join) {
90 miter = style.strokeRec().getMiter();
91 }
92 }
93
84 key[i++] = style.strokeRec().getStyle() | 94 key[i++] = style.strokeRec().getStyle() |
85 style.strokeRec().getJoin() << kJoinShift | 95 join << kJoinShift |
86 cap << kCapShift; 96 cap << kCapShift;
87 97
88 SkScalar scalar; 98 memcpy(&key[i++], &miter, sizeof(miter));
89 // Miter limit only affects miter joins
90 scalar = SkPaint::kMiter_Join == style.strokeRec().getJoin()
91 ? style.strokeRec().getMiter()
92 : -1.f;
93 memcpy(&key[i++], &scalar, sizeof(scalar));
94 99
95 scalar = style.strokeRec().getWidth(); 100 SkScalar width = style.strokeRec().getWidth();
96 memcpy(&key[i++], &scalar, sizeof(scalar)); 101 memcpy(&key[i++], &width, sizeof(width));
97 } 102 }
98 SkASSERT(KeySize(style, apply) == i); 103 SkASSERT(KeySize(style, apply) == i);
99 } 104 }
100 105
101 void GrStyle::initPathEffect(SkPathEffect* pe) { 106 void GrStyle::initPathEffect(SkPathEffect* pe) {
102 SkASSERT(!fPathEffect) 107 SkASSERT(!fPathEffect)
103 SkASSERT(SkPathEffect::kNone_DashType == fDashInfo.fType); 108 SkASSERT(SkPathEffect::kNone_DashType == fDashInfo.fType);
104 SkASSERT(0 == fDashInfo.fIntervals.count()); 109 SkASSERT(0 == fDashInfo.fIntervals.count());
105 if (!pe) { 110 if (!pe) {
106 return; 111 return;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return false; 190 return false;
186 } else { 191 } else {
187 SkASSERT(SkStrokeRec::kFill_Style == strokeRec.getStyle() || 192 SkASSERT(SkStrokeRec::kFill_Style == strokeRec.getStyle() ||
188 SkStrokeRec::kHairline_Style == strokeRec.getStyle()); 193 SkStrokeRec::kHairline_Style == strokeRec.getStyle());
189 *style = strokeRec.getStyle() == SkStrokeRec::kFill_Style 194 *style = strokeRec.getStyle() == SkStrokeRec::kFill_Style
190 ? SkStrokeRec::kFill_InitStyle 195 ? SkStrokeRec::kFill_InitStyle
191 : SkStrokeRec::kHairline_InitStyle; 196 : SkStrokeRec::kHairline_InitStyle;
192 } 197 }
193 return true; 198 return true;
194 } 199 }
OLDNEW
« no previous file with comments | « src/gpu/GrStyle.h ('k') | tests/DFPathRendererTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698