1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/pathops/SkPathOpsLine.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* 1.5 + * Copyright 2012 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 +#ifndef SkPathOpsLine_DEFINED 1.11 +#define SkPathOpsLine_DEFINED 1.12 + 1.13 +#include "SkPathOpsPoint.h" 1.14 + 1.15 +struct SkDLine { 1.16 + SkDPoint fPts[2]; 1.17 + 1.18 + const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 2); return fPts[n]; } 1.19 + SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 2); return fPts[n]; } 1.20 + 1.21 + void set(const SkPoint pts[2]) { 1.22 + fPts[0] = pts[0]; 1.23 + fPts[1] = pts[1]; 1.24 + } 1.25 + 1.26 + static SkDLine SubDivide(const SkPoint a[2], double t1, double t2) { 1.27 + SkDLine line; 1.28 + line.set(a); 1.29 + return line.subDivide(t1, t2); 1.30 + } 1.31 + 1.32 + double exactPoint(const SkDPoint& xy) const; 1.33 + static double ExactPointH(const SkDPoint& xy, double left, double right, double y); 1.34 + static double ExactPointV(const SkDPoint& xy, double top, double bottom, double x); 1.35 + double isLeft(const SkDPoint& pt) const; 1.36 + double nearPoint(const SkDPoint& xy) const; 1.37 + bool nearRay(const SkDPoint& xy) const; 1.38 + static double NearPointH(const SkDPoint& xy, double left, double right, double y); 1.39 + static double NearPointV(const SkDPoint& xy, double top, double bottom, double x); 1.40 + static bool NearRay(double dx1, double dy1, double dx2, double dy2); 1.41 + SkDPoint ptAtT(double t) const; 1.42 + SkDLine subDivide(double t1, double t2) const; 1.43 + 1.44 +#ifdef SK_DEBUG 1.45 + void dump(); 1.46 +#endif 1.47 +private: 1.48 + SkDVector tangent() const { return fPts[0] - fPts[1]; } 1.49 +}; 1.50 + 1.51 +#endif