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