Flutter Engine
The Flutter Engine
SkPathOpsRect.cpp
Go to the documentation of this file.
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 */
8
13
14void 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
31void 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
48void 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
65void SkDRect::setBounds(const SkTCurve& curve) {
66 curve.setBounds(this);
67}
virtual void setBounds(SkDRect *) const =0
SkDPoint ptAtT(double t) const
static int FindExtrema(const double src[], SkScalar weight, double tValue[1])
bool monotonicInY() const
bool monotonicInX() const
SkScalar fWeight
bool monotonicInX() const
bool monotonicInY() const
static int FindExtrema(const double src[], double tValue[2])
SkDPoint ptAtT(double t) const
bool monotonicInY() const
bool monotonicInX() const
static int FindExtrema(const double src[], double tValue[1])
SkDPoint ptAtT(double t) const
void add(const SkDPoint &pt)
Definition: SkPathOpsRect.h:24
void set(const SkDPoint &pt)
Definition: SkPathOpsRect.h:46
void setBounds(const SkDConic &curve)
Definition: SkPathOpsRect.h:59