michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkPathOpsLine_DEFINED michael@0: #define SkPathOpsLine_DEFINED michael@0: michael@0: #include "SkPathOpsPoint.h" michael@0: michael@0: struct SkDLine { michael@0: SkDPoint fPts[2]; michael@0: michael@0: const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 2); return fPts[n]; } michael@0: SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 2); return fPts[n]; } michael@0: michael@0: void set(const SkPoint pts[2]) { michael@0: fPts[0] = pts[0]; michael@0: fPts[1] = pts[1]; michael@0: } michael@0: michael@0: static SkDLine SubDivide(const SkPoint a[2], double t1, double t2) { michael@0: SkDLine line; michael@0: line.set(a); michael@0: return line.subDivide(t1, t2); michael@0: } michael@0: michael@0: double exactPoint(const SkDPoint& xy) const; michael@0: static double ExactPointH(const SkDPoint& xy, double left, double right, double y); michael@0: static double ExactPointV(const SkDPoint& xy, double top, double bottom, double x); michael@0: double isLeft(const SkDPoint& pt) const; michael@0: double nearPoint(const SkDPoint& xy) const; michael@0: bool nearRay(const SkDPoint& xy) const; michael@0: static double NearPointH(const SkDPoint& xy, double left, double right, double y); michael@0: static double NearPointV(const SkDPoint& xy, double top, double bottom, double x); michael@0: static bool NearRay(double dx1, double dy1, double dx2, double dy2); michael@0: SkDPoint ptAtT(double t) const; michael@0: SkDLine subDivide(double t1, double t2) const; michael@0: michael@0: #ifdef SK_DEBUG michael@0: void dump(); michael@0: #endif michael@0: private: michael@0: SkDVector tangent() const { return fPts[0] - fPts[1]; } michael@0: }; michael@0: michael@0: #endif