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 */
7 #include "SkPathOpsConic.h"
8 #include "SkPathOpsCubic.h"
9 #include "SkPathOpsLine.h"
10 #include "SkPathOpsQuad.h"
11 #include "SkPathOpsRect.h"
12
setBounds(const SkDQuad & curve,const SkDQuad & sub,double startT,double endT)13 void SkDRect::setBounds(const SkDQuad& curve, const SkDQuad& sub, double startT, double endT) {
14 set(sub[0]);
15 add(sub[2]);
16 double tValues[2];
17 int roots = 0;
18 if (!sub.monotonicInX()) {
19 roots = SkDQuad::FindExtrema(&sub[0].fX, tValues);
20 }
21 if (!sub.monotonicInY()) {
22 roots += SkDQuad::FindExtrema(&sub[0].fY, &tValues[roots]);
23 }
24 for (int index = 0; index < roots; ++index) {
25 double t = startT + (endT - startT) * tValues[index];
26 add(curve.ptAtT(t));
27 }
28 }
29
setBounds(const SkDConic & curve,const SkDConic & sub,double startT,double endT)30 void SkDRect::setBounds(const SkDConic& curve, const SkDConic& sub, double startT, double endT) {
31 set(sub[0]);
32 add(sub[2]);
33 double tValues[2];
34 int roots = 0;
35 if (!sub.monotonicInX()) {
36 roots = SkDConic::FindExtrema(&sub[0].fX, sub.fWeight, tValues);
37 }
38 if (!sub.monotonicInY()) {
39 roots += SkDConic::FindExtrema(&sub[0].fY, sub.fWeight, &tValues[roots]);
40 }
41 for (int index = 0; index < roots; ++index) {
42 double t = startT + (endT - startT) * tValues[index];
43 add(curve.ptAtT(t));
44 }
45 }
46
setBounds(const SkDCubic & curve,const SkDCubic & sub,double startT,double endT)47 void SkDRect::setBounds(const SkDCubic& curve, const SkDCubic& sub, double startT, double endT) {
48 set(sub[0]);
49 add(sub[3]);
50 double tValues[4];
51 int roots = 0;
52 if (!sub.monotonicInX()) {
53 roots = SkDCubic::FindExtrema(&sub[0].fX, tValues);
54 }
55 if (!sub.monotonicInY()) {
56 roots += SkDCubic::FindExtrema(&sub[0].fY, &tValues[roots]);
57 }
58 for (int index = 0; index < roots; ++index) {
59 double t = startT + (endT - startT) * tValues[index];
60 add(curve.ptAtT(t));
61 }
62 }
63