michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project 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: michael@0: michael@0: #ifndef SkCullPoints_DEFINED michael@0: #define SkCullPoints_DEFINED michael@0: michael@0: #include "SkRect.h" michael@0: michael@0: class SkCullPoints { michael@0: public: michael@0: SkCullPoints(); michael@0: SkCullPoints(const SkIRect& r); michael@0: michael@0: void reset(const SkIRect& r); michael@0: michael@0: /** Start a contour at (x,y). Follow this with call(s) to lineTo(...) michael@0: */ michael@0: void moveTo(int x, int y); michael@0: michael@0: enum LineToResult { michael@0: kNo_Result, //!< line segment was completely clipped out michael@0: kLineTo_Result, //!< path.lineTo(pts[1]); michael@0: kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]); michael@0: }; michael@0: /** Connect a line to the previous call to lineTo (or moveTo). michael@0: */ michael@0: LineToResult lineTo(int x, int y, SkIPoint pts[2]); michael@0: michael@0: private: michael@0: SkIRect fR; // the caller's rectangle michael@0: SkIPoint fAsQuad[4]; // cache of fR as 4 points michael@0: SkIPoint fPrevPt; // private state michael@0: LineToResult fPrevResult; // private state michael@0: michael@0: bool sect_test(int x0, int y0, int x1, int y1) const; michael@0: }; michael@0: michael@0: ///////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: class SkPath; michael@0: michael@0: /** \class SkCullPointsPath michael@0: michael@0: Similar to SkCullPoints, but this class handles the return values michael@0: from lineTo, and automatically builds a SkPath with the result(s). michael@0: */ michael@0: class SkCullPointsPath { michael@0: public: michael@0: SkCullPointsPath(); michael@0: SkCullPointsPath(const SkIRect& r, SkPath* dst); michael@0: michael@0: void reset(const SkIRect& r, SkPath* dst); michael@0: michael@0: void moveTo(int x, int y); michael@0: void lineTo(int x, int y); michael@0: michael@0: private: michael@0: SkCullPoints fCP; michael@0: SkPath* fPath; michael@0: }; michael@0: michael@0: bool SkHitTestPath(const SkPath&, SkRect& target, bool hires); michael@0: bool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires); michael@0: michael@0: #endif