Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/pathops/SkPathOpsCubic.h

Issue 12827020: Add base types for path ops (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathOpsBounds.cpp ('k') | src/pathops/SkPathOpsCubic.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
8 #ifndef SkPathOpsCubic_DEFINED
9 #define SkPathOpsCubic_DEFINED
10
11 #include "SkPathOpsPoint.h"
12 #include "SkTDArray.h"
13
14 struct SkDCubicPair {
15 const SkDCubic& first() const { return (const SkDCubic&) pts[0]; }
16 const SkDCubic& second() const { return (const SkDCubic&) pts[3]; }
17 SkDPoint pts[7];
18 };
19
20 struct SkDCubic {
21 SkDPoint fPts[4];
22
23 void set(const SkPoint pts[4]) {
24 fPts[0] = pts[0];
25 fPts[1] = pts[1];
26 fPts[2] = pts[2];
27 fPts[3] = pts[3];
28 }
29
30 static const int gPrecisionUnit;
31
32 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 4); return fPts[n]; }
33 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 4); return fPts[n]; }
34
35 double calcPrecision() const;
36 SkDCubicPair chopAt(double t) const;
37 bool clockwise() const;
38 static void Coefficients(const double* cubic, double* A, double* B, double* C, double* D);
39 bool controlsContainedByEnds() const;
40 SkDVector dxdyAtT(double t) const;
41 bool endsAreExtremaInXOrY() const;
42 static int FindExtrema(double a, double b, double c, double d, double tValue [2]);
43 int findInflections(double tValues[]) const;
44 int findMaxCurvature(double tValues[]) const;
45 bool isLinear(int startIndex, int endIndex) const;
46 bool monotonicInY() const;
47 static int RootsReal(double A, double B, double C, double D, double t[3]);
48 static int RootsValidT(const double A, const double B, const double C, doubl e D, double s[3]);
49 bool serpentine() const;
50 SkDCubic subDivide(double t1, double t2) const;
51 static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) {
52 SkDCubic cubic;
53 cubic.set(a);
54 return cubic.subDivide(t1, t2);
55 }
56 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S kDPoint p[2]) const;
57
58 static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoin t& d, double t1,
59 double t2, SkDPoint p[2]) {
60 SkDCubic cubic;
61 cubic.set(pts);
62 cubic.subDivide(a, d, t1, t2, p);
63 }
64
65 SkDPoint top(double startT, double endT) const;
66 void toQuadraticTs(double precision, SkTDArray<double>* ts) const;
67 SkDQuad toQuad() const;
68 SkDPoint xyAtT(double t) const;
69 };
70
71 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsBounds.cpp ('k') | src/pathops/SkPathOpsCubic.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698