reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2009 The Android Open Source Project |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 9 | #ifndef SkEdgeClipper_DEFINED |
| 10 | #define SkEdgeClipper_DEFINED |
| 11 | |
| 12 | #include "SkPath.h" |
| 13 | |
| 14 | /** This is basically an iterator. It is initialized with an edge and a clip, |
| 15 | and then next() is called until it returns kDone_Verb. |
| 16 | */ |
| 17 | class SkEdgeClipper { |
| 18 | public: |
reed | 31223e0 | 2015-02-09 08:33:07 -0800 | [diff] [blame] | 19 | SkEdgeClipper(bool canCullToTheRight) : fCanCullToTheRight(canCullToTheRight) {} |
| 20 | |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 21 | bool clipQuad(const SkPoint pts[3], const SkRect& clip); |
| 22 | bool clipCubic(const SkPoint pts[4], const SkRect& clip); |
| 23 | |
| 24 | SkPath::Verb next(SkPoint pts[]); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 25 | |
reed | 31223e0 | 2015-02-09 08:33:07 -0800 | [diff] [blame] | 26 | bool canCullToTheRight() const { return fCanCullToTheRight; } |
| 27 | |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 28 | private: |
| 29 | SkPoint* fCurrPoint; |
| 30 | SkPath::Verb* fCurrVerb; |
reed | 31223e0 | 2015-02-09 08:33:07 -0800 | [diff] [blame] | 31 | const bool fCanCullToTheRight; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 32 | |
reed@android.com | 909994f | 2009-11-18 16:09:51 +0000 | [diff] [blame] | 33 | enum { |
| 34 | kMaxVerbs = 13, |
| 35 | kMaxPoints = 32 |
| 36 | }; |
| 37 | SkPoint fPoints[kMaxPoints]; |
| 38 | SkPath::Verb fVerbs[kMaxVerbs]; |
| 39 | |
| 40 | void clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip); |
| 41 | void clipMonoCubic(const SkPoint srcPts[4], const SkRect& clip); |
| 42 | void appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse); |
| 43 | void appendQuad(const SkPoint pts[3], bool reverse); |
| 44 | void appendCubic(const SkPoint pts[4], bool reverse); |
| 45 | }; |
| 46 | |
| 47 | #ifdef SK_DEBUG |
| 48 | void sk_assert_monotonic_x(const SkPoint pts[], int count); |
| 49 | void sk_assert_monotonic_y(const SkPoint pts[], int count); |
| 50 | #else |
| 51 | #define sk_assert_monotonic_x(pts, count) |
| 52 | #define sk_assert_monotonic_y(pts, count) |
| 53 | #endif |
| 54 | |
| 55 | #endif |