Debian Codegraph @

src/core/SkQuadClipper.h

raw
1 /*
2 * Copyright 2009 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9 #ifndef SkQuadClipper_DEFINED
10 #define SkQuadClipper_DEFINED
11
12 #include "include/core/SkPath.h"
13 #include "include/core/SkPoint.h"
14 #include "include/core/SkRect.h"
15 #include "include/core/SkScalar.h"
16 #include "include/private/base/SkDebug.h"
17
18 /** This class is initialized with a clip rectangle, and then can be fed quads,
19 which must already be monotonic in Y.
20
21 In the future, it might return a series of segments, allowing it to clip
22 also in X, to ensure that all segments fit in a finite coordinate system.
23 */
24 class SkQuadClipper {
25 public:
26 SkQuadClipper();
27
28 void setClip(const SkIRect& clip);
29
30 bool clipQuad(const SkPoint src[3], SkPoint dst[3]);
31
32 private:
33 SkRect fClip;
34 };
35
36 /** Iterator that returns the clipped segements of a quad clipped to a rect.
37 The segments will be either lines or quads (based on SkPath::Verb), and
38 will all be monotonic in Y
39 */
40 class SkQuadClipper2 {
41 public:
42 bool clipQuad(const SkPoint pts[3], const SkRect& clip);
43 bool clipCubic(const SkPoint pts[4], const SkRect& clip);
44
45 SkPath::Verb next(SkPoint pts[]);
46
47 private:
48 SkPoint* fCurrPoint;
49 SkPath::Verb* fCurrVerb;
50
51 enum {
52 kMaxVerbs = 13,
53 kMaxPoints = 32
54 };
55 SkPoint fPoints[kMaxPoints];
56 SkPath::Verb fVerbs[kMaxVerbs];
57
58 void clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip);
59 void clipMonoCubic(const SkPoint srcPts[4], const SkRect& clip);
60 void appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse);
61 void appendQuad(const SkPoint pts[3], bool reverse);
62 void appendCubic(const SkPoint pts[4], bool reverse);
63 };
64
65 #ifdef SK_DEBUG
66 void sk_assert_monotonic_x(const SkPoint pts[], int count);
67 void sk_assert_monotonic_y(const SkPoint pts[], int count);
68 #else
69 #define sk_assert_monotonic_x(pts, count)
70 #define sk_assert_monotonic_y(pts, count)
71 #endif
72
73 #endif