caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 7 | #include "SkPathOpsConic.h" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 8 | #include "SkPathOpsCubic.h" |
| 9 | #include "SkPathOpsLine.h" |
| 10 | #include "SkPathOpsQuad.h" |
| 11 | #include "SkPathOpsRect.h" |
| 12 | |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 13 | void SkDRect::setBounds(const SkDQuad& curve, const SkDQuad& sub, double startT, double endT) { |
| 14 | set(sub[0]); |
| 15 | add(sub[2]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 16 | double tValues[2]; |
| 17 | int roots = 0; |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 18 | if (!sub.monotonicInX()) { |
| 19 | roots = SkDQuad::FindExtrema(&sub[0].fX, tValues); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 20 | } |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 21 | if (!sub.monotonicInY()) { |
| 22 | roots += SkDQuad::FindExtrema(&sub[0].fY, &tValues[roots]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 23 | } |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 24 | for (int index = 0; index < roots; ++index) { |
| 25 | double t = startT + (endT - startT) * tValues[index]; |
| 26 | add(curve.ptAtT(t)); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 27 | } |
| 28 | } |
| 29 | |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 30 | void SkDRect::setBounds(const SkDConic& curve, const SkDConic& sub, double startT, double endT) { |
| 31 | set(sub[0]); |
| 32 | add(sub[2]); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 33 | double tValues[2]; |
| 34 | int roots = 0; |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 35 | if (!sub.monotonicInX()) { |
| 36 | roots = SkDConic::FindExtrema(&sub[0].fX, sub.fWeight, tValues); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 37 | } |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 38 | if (!sub.monotonicInY()) { |
| 39 | roots += SkDConic::FindExtrema(&sub[0].fY, sub.fWeight, &tValues[roots]); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 40 | } |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 41 | for (int index = 0; index < roots; ++index) { |
| 42 | double t = startT + (endT - startT) * tValues[index]; |
| 43 | add(curve.ptAtT(t)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 47 | void SkDRect::setBounds(const SkDCubic& curve, const SkDCubic& sub, double startT, double endT) { |
| 48 | set(sub[0]); |
| 49 | add(sub[3]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 50 | double tValues[4]; |
| 51 | int roots = 0; |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 52 | if (!sub.monotonicInX()) { |
| 53 | roots = SkDCubic::FindExtrema(&sub[0].fX, tValues); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 54 | } |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 55 | if (!sub.monotonicInY()) { |
| 56 | roots += SkDCubic::FindExtrema(&sub[0].fY, &tValues[roots]); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 57 | } |
caryclark | aec2510 | 2015-04-29 08:28:30 -0700 | [diff] [blame] | 58 | for (int index = 0; index < roots; ++index) { |
| 59 | double t = startT + (endT - startT) * tValues[index]; |
| 60 | add(curve.ptAtT(t)); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 61 | } |
| 62 | } |