OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 <cmath> | 8 #include <cmath> |
9 #include "SkBuffer.h" | 9 #include "SkBuffer.h" |
10 #include "SkCubicClipper.h" | 10 #include "SkCubicClipper.h" |
(...skipping 3277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 } | 3288 } |
3289 if (rectPtCnt < 5) { | 3289 if (rectPtCnt < 5) { |
3290 return false; | 3290 return false; |
3291 } | 3291 } |
3292 if (rectPts[0] != rectPts[4]) { | 3292 if (rectPts[0] != rectPts[4]) { |
3293 return false; | 3293 return false; |
3294 } | 3294 } |
3295 int verticalCnt = 0; | 3295 int verticalCnt = 0; |
3296 int horizontalCnt = 0; | 3296 int horizontalCnt = 0; |
3297 // dirs are 0 - right, 1 - down, 2 - left, 3 - up. | 3297 // dirs are 0 - right, 1 - down, 2 - left, 3 - up. |
3298 int firstDir; | 3298 int firstDir = 0; |
3299 int secondDir; | 3299 int secondDir = 0; |
3300 SkRect tempRect; | 3300 SkRect tempRect; |
3301 for (int i = 0; i < 4; ++i) { | 3301 for (int i = 0; i < 4; ++i) { |
3302 int sameCnt = 0; | 3302 int sameCnt = 0; |
3303 if (rectPts[i].fX == rectPts[i + 1].fX) { | 3303 if (rectPts[i].fX == rectPts[i + 1].fX) { |
3304 verticalCnt += 1; | 3304 verticalCnt += 1; |
3305 sameCnt = 1; | 3305 sameCnt = 1; |
3306 if (0 == i) { | 3306 if (0 == i) { |
3307 if (rectPts[1].fY > rectPts[0].fY) { | 3307 if (rectPts[1].fY > rectPts[0].fY) { |
3308 firstDir = 1; | 3308 firstDir = 1; |
3309 tempRect.fTop = rectPts[0].fY; | 3309 tempRect.fTop = rectPts[0].fY; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3358 return false; | 3358 return false; |
3359 } | 3359 } |
3360 // low bit indicates a vertical dir | 3360 // low bit indicates a vertical dir |
3361 SkASSERT((firstDir ^ secondDir) & 0b1); | 3361 SkASSERT((firstDir ^ secondDir) & 0b1); |
3362 if (((firstDir + 1) & 0b11) == secondDir) { | 3362 if (((firstDir + 1) & 0b11) == secondDir) { |
3363 *direction = SkPath::kCW_Direction; | 3363 *direction = SkPath::kCW_Direction; |
3364 *start = firstDir; | 3364 *start = firstDir; |
3365 } else { | 3365 } else { |
3366 SkASSERT(((secondDir + 1) & 0b11) == firstDir); | 3366 SkASSERT(((secondDir + 1) & 0b11) == firstDir); |
3367 *direction = SkPath::kCCW_Direction; | 3367 *direction = SkPath::kCCW_Direction; |
3368 *start = secondDir; | 3368 *start = secondDir; |
3369 } | 3369 } |
3370 *rect = tempRect; | 3370 *rect = tempRect; |
3371 return true; | 3371 return true; |
3372 } | 3372 } |
OLD | NEW |