OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrStrokeInfo.h" | 8 #include "GrStrokeInfo.h" |
9 #include "GrResourceKey.h" | 9 #include "GrResourceKey.h" |
10 #include "SkDashPathPriv.h" | 10 #include "SkDashPathPriv.h" |
11 | 11 |
| 12 bool all_dash_intervals_zero(const SkScalar* intervals, int count) { |
| 13 for (int i = 0 ; i < count; ++i) { |
| 14 if (intervals[i] != 0) { |
| 15 return false; |
| 16 } |
| 17 } |
| 18 return true; |
| 19 } |
| 20 |
12 bool GrStrokeInfo::applyDashToPath(SkPath* dst, GrStrokeInfo* dstStrokeInfo, | 21 bool GrStrokeInfo::applyDashToPath(SkPath* dst, GrStrokeInfo* dstStrokeInfo, |
13 const SkPath& src) const { | 22 const SkPath& src) const { |
14 if (this->isDashed()) { | 23 if (this->isDashed()) { |
15 SkPathEffect::DashInfo info; | 24 SkPathEffect::DashInfo info; |
16 info.fIntervals = fIntervals.get(); | 25 info.fIntervals = fIntervals.get(); |
17 info.fCount = fIntervals.count(); | 26 info.fCount = fIntervals.count(); |
18 info.fPhase = fDashPhase; | 27 info.fPhase = fDashPhase; |
19 GrStrokeInfo filteredStroke(*this, false); | 28 GrStrokeInfo filteredStroke(*this, false); |
| 29 // Handle the case where all intervals are 0 and we simply drop the dash
effect |
| 30 if (all_dash_intervals_zero(fIntervals.get(), fIntervals.count())) { |
| 31 *dstStrokeInfo = filteredStroke; |
| 32 *dst = src; |
| 33 return true; |
| 34 } |
| 35 // See if we can filter the dash into a path on cpu |
20 if (SkDashPath::FilterDashPath(dst, src, &filteredStroke, nullptr, info)
) { | 36 if (SkDashPath::FilterDashPath(dst, src, &filteredStroke, nullptr, info)
) { |
21 *dstStrokeInfo = filteredStroke; | 37 *dstStrokeInfo = filteredStroke; |
22 return true; | 38 return true; |
23 } | 39 } |
24 } | 40 } |
25 return false; | 41 return false; |
26 } | 42 } |
27 | 43 |
28 void GrStrokeInfo::asUniqueKeyFragment(uint32_t* data) const { | 44 void GrStrokeInfo::asUniqueKeyFragment(uint32_t* data) const { |
29 const int kSkScalarData32Cnt = sizeof(SkScalar) / sizeof(uint32_t); | 45 const int kSkScalarData32Cnt = sizeof(SkScalar) / sizeof(uint32_t); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const SkScalar* intervals = this->getDashIntervals(); | 85 const SkScalar* intervals = this->getDashIntervals(); |
70 int intervalByteCnt = count * sizeof(SkScalar); | 86 int intervalByteCnt = count * sizeof(SkScalar); |
71 memcpy(&data[i], intervals, intervalByteCnt); | 87 memcpy(&data[i], intervals, intervalByteCnt); |
72 // Enable the line below if fields are added after dashing. | 88 // Enable the line below if fields are added after dashing. |
73 SkDEBUGCODE(i += kSkScalarData32Cnt * count); | 89 SkDEBUGCODE(i += kSkScalarData32Cnt * count); |
74 } | 90 } |
75 | 91 |
76 SkASSERT(this->computeUniqueKeyFragmentData32Cnt() == i); | 92 SkASSERT(this->computeUniqueKeyFragmentData32Cnt() == i); |
77 } | 93 } |
78 | 94 |
OLD | NEW |