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 #ifndef SkPathOpsLine_DEFINED 8 #define SkPathOpsLine_DEFINED 9 10 #include "SkPathOpsPoint.h" 11 12 struct SkDLine { 13 SkDPoint fPts[2]; 14 15 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 2); return fPts[n]; } 16 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 2); return fPts[n]; } 17 18 const SkDLine& set(const SkPoint pts[2]) { 19 fPts[0] = pts[0]; 20 fPts[1] = pts[1]; 21 return *this; 22 } 23 24 double exactPoint(const SkDPoint& xy) const; 25 static double ExactPointH(const SkDPoint& xy, double left, double right, double y); 26 static double ExactPointV(const SkDPoint& xy, double top, double bottom, double x); 27 28 double nearPoint(const SkDPoint& xy, bool* unequal) const; 29 bool nearRay(const SkDPoint& xy) const; 30 static double NearPointH(const SkDPoint& xy, double left, double right, double y); 31 static double NearPointV(const SkDPoint& xy, double top, double bottom, double x); 32 SkDPoint ptAtT(double t) const; 33 34 void dump() const; 35 void dumpID(int ) const; 36 void dumpInner() const; 37 }; 38 39 #endif 40