epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkCullPoints_DEFINED |
| 11 | #define SkCullPoints_DEFINED |
| 12 | |
| 13 | #include "SkRect.h" |
| 14 | |
| 15 | class SkCullPoints { |
| 16 | public: |
| 17 | SkCullPoints(); |
| 18 | SkCullPoints(const SkIRect& r); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame^] | 19 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 20 | void reset(const SkIRect& r); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame^] | 21 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 22 | /** Start a contour at (x,y). Follow this with call(s) to lineTo(...) |
| 23 | */ |
| 24 | void moveTo(int x, int y); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame^] | 25 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | enum LineToResult { |
| 27 | kNo_Result, //!< line segment was completely clipped out |
| 28 | kLineTo_Result, //!< path.lineTo(pts[1]); |
| 29 | kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]); |
| 30 | }; |
| 31 | /** Connect a line to the previous call to lineTo (or moveTo). |
| 32 | */ |
| 33 | LineToResult lineTo(int x, int y, SkIPoint pts[2]); |
| 34 | |
| 35 | private: |
| 36 | SkIRect fR; // the caller's rectangle |
| 37 | SkIPoint fAsQuad[4]; // cache of fR as 4 points |
| 38 | SkIPoint fPrevPt; // private state |
| 39 | LineToResult fPrevResult; // private state |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame^] | 40 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 41 | bool sect_test(int x0, int y0, int x1, int y1) const; |
| 42 | }; |
| 43 | |
| 44 | ///////////////////////////////////////////////////////////////////////////////// |
| 45 | |
| 46 | class SkPath; |
| 47 | |
| 48 | /** \class SkCullPointsPath |
| 49 | |
| 50 | Similar to SkCullPoints, but this class handles the return values |
| 51 | from lineTo, and automatically builds a SkPath with the result(s). |
| 52 | */ |
| 53 | class SkCullPointsPath { |
| 54 | public: |
| 55 | SkCullPointsPath(); |
| 56 | SkCullPointsPath(const SkIRect& r, SkPath* dst); |
| 57 | |
| 58 | void reset(const SkIRect& r, SkPath* dst); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame^] | 59 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 60 | void moveTo(int x, int y); |
| 61 | void lineTo(int x, int y); |
| 62 | |
| 63 | private: |
| 64 | SkCullPoints fCP; |
| 65 | SkPath* fPath; |
| 66 | }; |
| 67 | |
mike@reedtribe.org | a2a95f9 | 2012-07-03 02:35:36 +0000 | [diff] [blame] | 68 | bool SkHitTestPath(const SkPath&, SkRect& target, bool hires); |
| 69 | bool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires); |
mike@reedtribe.org | a2a95f9 | 2012-07-03 02:35:36 +0000 | [diff] [blame] | 70 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 71 | #endif |