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

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

Issue 913503002: cull edges that are to the right of the clip (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
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) {
11 if (limit1 < limit0) { 11 if (limit1 < limit0) {
12 SkTSwap(limit0, limit1); 12 SkTSwap(limit0, limit1);
13 } 13 }
14 // now the limits are sorted 14 // now the limits are sorted
15 SkASSERT(limit0 <= limit1); 15 SkASSERT(limit0 <= limit1);
16 16
17 if (value < limit0) { 17 if (value < limit0) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 static void sect_with_horizontal_test_for_pin_results() { 165 static void sect_with_horizontal_test_for_pin_results() {
166 const SkPoint pts[] = { 166 const SkPoint pts[] = {
167 { -540000, -720000 }, 167 { -540000, -720000 },
168 { -9.10000017e-05f, 9.99999996e-13f } 168 { -9.10000017e-05f, 9.99999996e-13f }
169 }; 169 };
170 float x = sect_with_horizontal(pts, 0); 170 float x = sect_with_horizontal(pts, 0);
171 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX)); 171 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX));
172 } 172 }
173 #endif 173 #endif
174 174
175 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, 175 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, SkPoint lin es[],
176 SkPoint lines[], bool canClipToTheRight) { 176 bool canCullToTheRight) {
177 #if 1
178 // Disable this while we investigate layouttest failures
179 canClipToTheRight = false;
180 #endif
181 177
182 #ifdef SK_DEBUG 178 #ifdef SK_DEBUG
183 { 179 {
184 static bool gOnce; 180 static bool gOnce;
185 if (!gOnce) { 181 if (!gOnce) {
186 sect_with_horizontal_test_for_pin_results(); 182 sect_with_horizontal_test_for_pin_results();
187 gOnce = true; 183 gOnce = true;
188 } 184 }
189 } 185 }
190 #endif 186 #endif
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 index0 = 1; 235 index0 = 1;
240 index1 = 0; 236 index1 = 0;
241 reverse = true; 237 reverse = true;
242 } 238 }
243 239
244 if (tmp[index1].fX <= clip.fLeft) { // wholly to the left 240 if (tmp[index1].fX <= clip.fLeft) { // wholly to the left
245 tmp[0].fX = tmp[1].fX = clip.fLeft; 241 tmp[0].fX = tmp[1].fX = clip.fLeft;
246 result = tmp; 242 result = tmp;
247 reverse = false; 243 reverse = false;
248 } else if (tmp[index0].fX >= clip.fRight) { // wholly to the right 244 } else if (tmp[index0].fX >= clip.fRight) { // wholly to the right
249 if (canClipToTheRight) { 245 if (canCullToTheRight) {
250 return 0; 246 return 0;
251 } 247 }
252 tmp[0].fX = tmp[1].fX = clip.fRight; 248 tmp[0].fX = tmp[1].fX = clip.fRight;
253 result = tmp; 249 result = tmp;
254 reverse = false; 250 reverse = false;
255 } else { 251 } else {
256 result = resultStorage; 252 result = resultStorage;
257 SkPoint* r = result; 253 SkPoint* r = result;
258 254
259 if (tmp[index0].fX < clip.fLeft) { 255 if (tmp[index0].fX < clip.fLeft) {
(...skipping 22 matching lines...) Expand all
282 if (reverse) { 278 if (reverse) {
283 // copy the pts in reverse order to maintain winding order 279 // copy the pts in reverse order to maintain winding order
284 for (int i = 0; i <= lineCount; i++) { 280 for (int i = 0; i <= lineCount; i++) {
285 lines[lineCount - i] = result[i]; 281 lines[lineCount - i] = result[i];
286 } 282 }
287 } else { 283 } else {
288 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); 284 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint));
289 } 285 }
290 return lineCount; 286 return lineCount;
291 } 287 }
OLDNEW
« no previous file with comments | « src/core/SkLineClipper.h ('k') | src/core/SkScan_Path.cpp » ('j') | src/core/SkScan_Path.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698