blob: e16ed552ca225cf56f3fa9a2cca3b1bb8aceb725 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com909994f2009-11-18 16:09:51 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2009 The Android Open Source Project
reed@android.com909994f2009-11-18 16:09:51 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com909994f2009-11-18 16:09:51 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com909994f2009-11-18 16:09:51 +000010#ifndef SkEdgeClipper_DEFINED
11#define SkEdgeClipper_DEFINED
12
13#include "SkPath.h"
14
15/** This is basically an iterator. It is initialized with an edge and a clip,
16 and then next() is called until it returns kDone_Verb.
17 */
18class SkEdgeClipper {
19public:
20 bool clipQuad(const SkPoint pts[3], const SkRect& clip);
21 bool clipCubic(const SkPoint pts[4], const SkRect& clip);
22
23 SkPath::Verb next(SkPoint pts[]);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000024
reed@android.com909994f2009-11-18 16:09:51 +000025private:
26 SkPoint* fCurrPoint;
27 SkPath::Verb* fCurrVerb;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000028
reed@android.com909994f2009-11-18 16:09:51 +000029 enum {
30 kMaxVerbs = 13,
31 kMaxPoints = 32
32 };
33 SkPoint fPoints[kMaxPoints];
34 SkPath::Verb fVerbs[kMaxVerbs];
35
36 void clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip);
37 void clipMonoCubic(const SkPoint srcPts[4], const SkRect& clip);
38 void appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse);
39 void appendQuad(const SkPoint pts[3], bool reverse);
40 void appendCubic(const SkPoint pts[4], bool reverse);
41};
42
43#ifdef SK_DEBUG
44 void sk_assert_monotonic_x(const SkPoint pts[], int count);
45 void sk_assert_monotonic_y(const SkPoint pts[], int count);
46#else
47 #define sk_assert_monotonic_x(pts, count)
48 #define sk_assert_monotonic_y(pts, count)
49#endif
50
51#endif