Flutter Engine
The Flutter Engine
SkQuadClipper.h
Go to the documentation of this file.
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"
14#include "include/core/SkRect.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 */
25public:
27
28 void setClip(const SkIRect& clip);
29
30 bool clipQuad(const SkPoint src[3], SkPoint dst[3]);
31
32private:
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 */
41public:
42 bool clipQuad(const SkPoint pts[3], const SkRect& clip);
43 bool clipCubic(const SkPoint pts[4], const SkRect& clip);
44
46
47private:
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
int count
Definition: FontMgrTest.cpp:50
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
#define sk_assert_monotonic_y(pts, count)
Definition: SkQuadClipper.h:70
#define sk_assert_monotonic_x(pts, count)
Definition: SkQuadClipper.h:69
bool clipQuad(const SkPoint pts[3], const SkRect &clip)
SkPath::Verb next(SkPoint pts[])
bool clipCubic(const SkPoint pts[4], const SkRect &clip)
void setClip(const SkIRect &clip)
bool clipQuad(const SkPoint src[3], SkPoint dst[3])
float SkScalar
Definition: extension.cpp:12
double x
dst
Definition: cp.py:12
Definition: SkRect.h:32