Flutter Engine
The Flutter Engine
SkEdgeClipper.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 SkEdgeClipper_DEFINED
10#define SkEdgeClipper_DEFINED
11
12#include "include/core/SkPath.h"
16
17struct SkRect;
18
19/** This is basically an iterator. It is initialized with an edge and a clip,
20 and then next() is called until it returns kDone_Verb.
21 */
23public:
24 SkEdgeClipper(bool canCullToTheRight) : fCanCullToTheRight(canCullToTheRight) {}
25
26 bool clipLine(SkPoint p0, SkPoint p1, const SkRect& clip);
27 bool clipQuad(const SkPoint pts[3], const SkRect& clip);
28 bool clipCubic(const SkPoint pts[4], const SkRect& clip);
29
31
32 bool canCullToTheRight() const { return fCanCullToTheRight; }
33
34 /**
35 * Clips each segment from the path, and passes the result (in a clipper) to the
36 * consume proc.
37 */
38 static void ClipPath(const SkPath& path, const SkRect& clip, bool canCullToTheRight,
39 void (*consume)(SkEdgeClipper*, bool newCtr, void* ctx), void* ctx);
40
41private:
42 SkPoint* fCurrPoint;
43 SkPath::Verb* fCurrVerb;
44 const bool fCanCullToTheRight;
45
46 enum {
47 kMaxVerbs = 18, // max curvature in X and Y split cubic into 9 pieces, * (line + cubic)
48 kMaxPoints = 54 // 2 lines + 1 cubic require 6 points; times 9 pieces
49 };
50 SkPoint fPoints[kMaxPoints];
51 SkPath::Verb fVerbs[kMaxVerbs];
52
53 void clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip);
54 void clipMonoCubic(const SkPoint srcPts[4], const SkRect& clip);
55 void appendLine(SkPoint p0, SkPoint p1);
56 void appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse);
57 void appendQuad(const SkPoint pts[3], bool reverse);
58 void appendCubic(const SkPoint pts[4], bool reverse);
59};
60
61#ifdef SK_DEBUG
62 void sk_assert_monotonic_x(const SkPoint pts[], int count);
63 void sk_assert_monotonic_y(const SkPoint pts[], int count);
64#else
65 #define sk_assert_monotonic_x(pts, count)
66 #define sk_assert_monotonic_y(pts, count)
67#endif
68
69#endif
int count
Definition: FontMgrTest.cpp:50
#define sk_assert_monotonic_y(pts, count)
Definition: SkEdgeClipper.h:66
#define sk_assert_monotonic_x(pts, count)
Definition: SkEdgeClipper.h:65
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
bool canCullToTheRight() const
Definition: SkEdgeClipper.h:32
static void ClipPath(const SkPath &path, const SkRect &clip, bool canCullToTheRight, void(*consume)(SkEdgeClipper *, bool newCtr, void *ctx), void *ctx)
SkPath::Verb next(SkPoint pts[])
bool clipCubic(const SkPoint pts[4], const SkRect &clip)
bool clipLine(SkPoint p0, SkPoint p1, const SkRect &clip)
bool clipQuad(const SkPoint pts[3], const SkRect &clip)
SkEdgeClipper(bool canCullToTheRight)
Definition: SkEdgeClipper.h:24
Definition: SkPath.h:59
float SkScalar
Definition: extension.cpp:12
double x
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57