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

Side by Side Diff: src/pathops/SkOpCubicHull.cpp

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux build 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 #include "SkPathOpsCubic.h" 7 #include "SkPathOpsCubic.h"
8 8
9 static bool rotate(const SkDCubic& cubic, int zero, int index, SkDCubic& rotPath ) { 9 static bool rotate(const SkDCubic& cubic, int zero, int index, SkDCubic& rotPath ) {
10 double dy = cubic[index].fY - cubic[zero].fY; 10 double dy = cubic[index].fY - cubic[zero].fY;
11 double dx = cubic[index].fX - cubic[zero].fX; 11 double dx = cubic[index].fX - cubic[zero].fX;
12 if (approximately_zero(dy)) { 12 if (approximately_zero(dy)) {
13 if (approximately_zero(dx)) { 13 if (approximately_zero(dx)) {
14 return false; 14 return false;
15 } 15 }
16 rotPath = cubic; 16 rotPath = cubic;
17 if (dy) {
18 rotPath[index].fY = cubic[zero].fY;
19 int mask = other_two(index, zero);
20 int side1 = index ^ mask;
21 int side2 = zero ^ mask;
22 if (approximately_equal(cubic[side1].fY, cubic[zero].fY)) {
23 rotPath[side1].fY = cubic[zero].fY;
24 }
25 if (approximately_equal(cubic[side2].fY, cubic[zero].fY)) {
26 rotPath[side2].fY = cubic[zero].fY;
27 }
28 }
17 return true; 29 return true;
18 } 30 }
19 for (int index = 0; index < 4; ++index) { 31 for (int index = 0; index < 4; ++index) {
20 rotPath[index].fX = cubic[index].fX * dx + cubic[index].fY * dy; 32 rotPath[index].fX = cubic[index].fX * dx + cubic[index].fY * dy;
21 rotPath[index].fY = cubic[index].fY * dx - cubic[index].fX * dy; 33 rotPath[index].fY = cubic[index].fY * dx - cubic[index].fX * dy;
22 } 34 }
23 return true; 35 return true;
24 } 36 }
25 37
26 38
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 int midSides = side(midPath[yMin].fY - midPath[least].fY); 129 int midSides = side(midPath[yMin].fY - midPath[least].fY);
118 midSides ^= side(midPath[midX].fY - midPath[least].fY); 130 midSides ^= side(midPath[midX].fY - midPath[least].fY);
119 if (midSides != 2) { // if mid point is not between 131 if (midSides != 2) { // if mid point is not between
120 order[2] = most; 132 order[2] = most;
121 return 3; // result is a triangle 133 return 3; // result is a triangle
122 } 134 }
123 order[2] = midX; 135 order[2] = midX;
124 order[3] = most; 136 order[3] = most;
125 return 4; // result is a quadralateral 137 return 4; // result is a quadralateral
126 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698