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