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

Side by Side Diff: src/core/SkLineClipper.cpp

Issue 1079343002: use fast/inline SkRect::set(p0, p1) for 2 points (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkLineClipper.h" 8 #include "SkLineClipper.h"
9 9
10 template <typename T> T pin_unsorted(T value, T limit0, T limit1) { 10 template <typename T> T pin_unsorted(T value, T limit0, T limit1) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 static inline bool containsNoEmptyCheck(const SkRect& outer, 71 static inline bool containsNoEmptyCheck(const SkRect& outer,
72 const SkRect& inner) { 72 const SkRect& inner) {
73 return outer.fLeft <= inner.fLeft && outer.fTop <= inner.fTop && 73 return outer.fLeft <= inner.fLeft && outer.fTop <= inner.fTop &&
74 outer.fRight >= inner.fRight && outer.fBottom >= inner.fBottom; 74 outer.fRight >= inner.fRight && outer.fBottom >= inner.fBottom;
75 } 75 }
76 76
77 bool SkLineClipper::IntersectLine(const SkPoint src[2], const SkRect& clip, 77 bool SkLineClipper::IntersectLine(const SkPoint src[2], const SkRect& clip,
78 SkPoint dst[2]) { 78 SkPoint dst[2]) {
79 SkRect bounds; 79 SkRect bounds;
80 80
81 bounds.set(src, 2); 81 bounds.set(src[0], src[1]);
82 if (containsNoEmptyCheck(clip, bounds)) { 82 if (containsNoEmptyCheck(clip, bounds)) {
83 if (src != dst) { 83 if (src != dst) {
84 memcpy(dst, src, 2 * sizeof(SkPoint)); 84 memcpy(dst, src, 2 * sizeof(SkPoint));
85 } 85 }
86 return true; 86 return true;
87 } 87 }
88 // check for no overlap, and only permit coincident edges if the line 88 // check for no overlap, and only permit coincident edges if the line
89 // and the edge are colinear 89 // and the edge are colinear
90 if (nestedLT(bounds.fRight, clip.fLeft, bounds.width()) || 90 if (nestedLT(bounds.fRight, clip.fLeft, bounds.width()) ||
91 nestedLT(clip.fRight, bounds.fLeft, bounds.width()) || 91 nestedLT(clip.fRight, bounds.fLeft, bounds.width()) ||
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return false; 130 return false;
131 } 131 }
132 132
133 if (tmp[index0].fX < clip.fLeft) { 133 if (tmp[index0].fX < clip.fLeft) {
134 tmp[index0].set(clip.fLeft, sect_with_vertical(src, clip.fLeft)); 134 tmp[index0].set(clip.fLeft, sect_with_vertical(src, clip.fLeft));
135 } 135 }
136 if (tmp[index1].fX > clip.fRight) { 136 if (tmp[index1].fX > clip.fRight) {
137 tmp[index1].set(clip.fRight, sect_with_vertical(src, clip.fRight)); 137 tmp[index1].set(clip.fRight, sect_with_vertical(src, clip.fRight));
138 } 138 }
139 #ifdef SK_DEBUG 139 #ifdef SK_DEBUG
140 bounds.set(tmp, 2); 140 bounds.set(tmp[0], tmp[1]);
141 SkASSERT(containsNoEmptyCheck(clip, bounds)); 141 SkASSERT(containsNoEmptyCheck(clip, bounds));
142 #endif 142 #endif
143 memcpy(dst, tmp, sizeof(tmp)); 143 memcpy(dst, tmp, sizeof(tmp));
144 return true; 144 return true;
145 } 145 }
146 146
147 #ifdef SK_DEBUG 147 #ifdef SK_DEBUG
148 // return value between the two limits, where the limits are either ascending 148 // return value between the two limits, where the limits are either ascending
149 // or descending. 149 // or descending.
150 static bool is_between_unsorted(SkScalar value, 150 static bool is_between_unsorted(SkScalar value,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (reverse) { 278 if (reverse) {
279 // copy the pts in reverse order to maintain winding order 279 // copy the pts in reverse order to maintain winding order
280 for (int i = 0; i <= lineCount; i++) { 280 for (int i = 0; i <= lineCount; i++) {
281 lines[lineCount - i] = result[i]; 281 lines[lineCount - i] = result[i];
282 } 282 }
283 } else { 283 } else {
284 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); 284 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint));
285 } 285 }
286 return lineCount; 286 return lineCount;
287 } 287 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698