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

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

Issue 1116123003: Improve caching of dashed paths in GrStencilAndCoverPathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr-01
Patch Set: Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 GrStrokeInfo_DEFINED 8 #ifndef GrStrokeInfo_DEFINED
9 #define GrStrokeInfo_DEFINED 9 #define GrStrokeInfo_DEFINED
10 10
11 #include "SkStrokeRec.h" 11 #include "SkStrokeRec.h"
12 #include "SkPathEffect.h" 12 #include "SkPathEffect.h"
13 13
14 class GrUniqueKey;
15
14 /* 16 /*
15 * GrStrokeInfo encapsulates all the pertinent infomation regarding the stroke. The SkStrokeRec 17 * GrStrokeInfo encapsulates all the pertinent infomation regarding the stroke. The SkStrokeRec
16 * which holds information on fill style, width, miter, cap, and join. It also h olds information 18 * which holds information on fill style, width, miter, cap, and join. It also h olds information
17 * about the dash like intervals, count, and phase. 19 * about the dash like intervals, count, and phase.
18 */ 20 */
19 class GrStrokeInfo : public SkStrokeRec { 21 class GrStrokeInfo : public SkStrokeRec {
20 public: 22 public:
21 GrStrokeInfo(SkStrokeRec::InitStyle style) 23 GrStrokeInfo(SkStrokeRec::InitStyle style)
22 : INHERITED(style) 24 : INHERITED(style)
23 , fDashType(SkPathEffect::kNone_DashType) { 25 , fDashType(SkPathEffect::kNone_DashType) {
(...skipping 29 matching lines...) Expand all
53 fDashPhase = other.fDashPhase; 55 fDashPhase = other.fDashPhase;
54 fIntervals.reset(other.getDashCount()); 56 fIntervals.reset(other.getDashCount());
55 memcpy(fIntervals.get(), other.fIntervals.get(), fIntervals.count() * sizeof(SkScalar)); 57 memcpy(fIntervals.get(), other.fIntervals.get(), fIntervals.count() * sizeof(SkScalar));
56 } else { 58 } else {
57 this->removeDash(); 59 this->removeDash();
58 } 60 }
59 this->INHERITED::operator=(other); 61 this->INHERITED::operator=(other);
60 return *this; 62 return *this;
61 } 63 }
62 64
65 bool hasEqualEffect(const GrStrokeInfo& other) const {
66 if (this->isDashed() != other.isDashed()) {
67 return false;
68 }
69 if (this->isDashed()) {
70 if (fDashPhase != other.fDashPhase ||
71 fIntervals.count() != other.fIntervals.count() ||
72 memcmp(fIntervals.get(), other.fIntervals.get(),
73 fIntervals.count() * sizeof(SkScalar)) != 0) {
74 return false;
75 }
76 }
77 return this->INHERITED::hasEqualEffect(other);
78 }
79
63 /* 80 /*
64 * This functions takes in a patheffect and updates the dashing information if the path effect 81 * This functions takes in a patheffect and updates the dashing information if the path effect
65 * is a Dash type. Returns true if the path effect is a dashed effect and we are stroking, 82 * is a Dash type. Returns true if the path effect is a dashed effect and we are stroking,
66 * otherwise it returns false. 83 * otherwise it returns false.
67 */ 84 */
68 bool setDashInfo(const SkPathEffect* pe) { 85 bool setDashInfo(const SkPathEffect* pe) {
69 if (pe && !this->isFillStyle()) { 86 if (pe && !this->isFillStyle()) {
70 SkPathEffect::DashInfo dashInfo; 87 SkPathEffect::DashInfo dashInfo;
71 fDashType = pe->asADash(&dashInfo); 88 fDashType = pe->asADash(&dashInfo);
72 if (SkPathEffect::kDash_DashType == fDashType) { 89 if (SkPathEffect::kDash_DashType == fDashType) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 137 }
121 138
122 /** Applies the dash to a path, if the stroke info has dashing. 139 /** Applies the dash to a path, if the stroke info has dashing.
123 * @return true if the dashing was applied (dst and dstStrokeInfo will be mo dified). 140 * @return true if the dashing was applied (dst and dstStrokeInfo will be mo dified).
124 * false if the stroke info did not have dashing. The dst and dstStr okeInfo 141 * false if the stroke info did not have dashing. The dst and dstStr okeInfo
125 * will be unmodified. The stroking in the SkStrokeRec might s till 142 * will be unmodified. The stroking in the SkStrokeRec might s till
126 * be applicable. 143 * be applicable.
127 */ 144 */
128 bool applyDashToPath(SkPath* dst, GrStrokeInfo* dstStrokeInfo, const SkPath& src) const; 145 bool applyDashToPath(SkPath* dst, GrStrokeInfo* dstStrokeInfo, const SkPath& src) const;
129 146
147
148 int computeUniqueKeyFragmentData32Cnt() const {
egdaniel 2015/05/15 15:28:53 This function definitely needs some comments
Kimmo Kinnunen 2015/05/18 06:48:40 Done.
149 const int kSkScalarData32Cnt = sizeof(SkScalar) / sizeof(uint32_t);
150 int strokeKeyData32Cnt = 1 + 2 * kSkScalarData32Cnt;
egdaniel 2015/05/15 15:28:53 Is this trying to account for values that are is S
Kimmo Kinnunen 2015/05/18 06:48:40 Yeah. I'll add the comments
151 if (this->isDashed()) {
152 strokeKeyData32Cnt += (1 + this->getDashCount()) * kSkScalarData32Cn t;
egdaniel 2015/05/15 15:28:53 is the 1 for the phase here?
Kimmo Kinnunen 2015/05/18 06:48:40 Yeah
153 }
154 return strokeKeyData32Cnt;
155 }
156
157 void asUniqueKeyFragment(uint32_t*) const;
158
130 private: 159 private:
131 160
132 void init(const SkPaint& paint) { 161 void init(const SkPaint& paint) {
133 const SkPathEffect* pe = paint.getPathEffect(); 162 const SkPathEffect* pe = paint.getPathEffect();
134 this->setDashInfo(pe); 163 this->setDashInfo(pe);
135 } 164 }
136 165
137 bool operator==(const SkStrokeRec& other) const;
138 bool operator!=(const SkStrokeRec& other) const;
139
140 SkPathEffect::DashType fDashType; 166 SkPathEffect::DashType fDashType;
141 SkScalar fDashPhase; 167 SkScalar fDashPhase;
142 SkAutoSTArray<2, SkScalar> fIntervals; 168 SkAutoSTArray<2, SkScalar> fIntervals;
143 typedef SkStrokeRec INHERITED; 169 typedef SkStrokeRec INHERITED;
144 }; 170 };
145 171
146 #endif 172 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698