Debian Codegraph @

src/core/SkPathRaw.h

raw
1 /*
2 * Copyright 2025 Google LLC.
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 #ifndef SkPathRaw_DEFINED
9 #define SkPathRaw_DEFINED
10
11 #include "include/core/SkPathIter.h"
12 #include "include/core/SkPathTypes.h"
13 #include "include/core/SkPoint.h"
14 #include "include/core/SkRect.h"
15 #include "include/core/SkSpan.h"
16 #include "src/core/SkPathEnums.h" // SkPathConvexity
17
18 #include <array>
19 #include <cstddef>
20 #include <optional>
21
22 /**
23 * SkPathRaw is a non-owning, immutable view of the path geometry.
24 *
25 * It allows us to have stack-allocated paths, see SkPathRawShapes.h
26 *
27 * It is the responsibility of the creator to ensure that the spans in SkPathRaw point to valid
28 * data that outlives the SkPathRaw instance.
29 */
30 struct SkPathRaw {
31 SkSpan<const SkPoint> fPoints;
32 SkSpan<const SkPathVerb> fVerbs;
33 SkSpan<const float> fConics;
34 SkRect fBounds;
35 SkPathFillType fFillType;
36 SkPathConvexity fConvexity;
37 uint8_t fSegmentMask; // See SkPath::SegmentMask
38
39 SkSpan<const SkPoint> points() const { return fPoints; }
40 SkSpan<const SkPathVerb> verbs() const { return fVerbs; }
41 SkSpan<const float> conics() const { return fConics; }
42 SkRect bounds() const { return fBounds; }
43 SkPathFillType fillType() const { return fFillType; }
44 SkPathConvexity convexity() const { return fConvexity; }
45 unsigned segmentMasks() const { return fSegmentMask; }
46
47 bool empty() const { return fVerbs.empty(); }
48 bool isInverseFillType() const { return SkPathFillType_IsInverse(fFillType); }
49 bool isKnownToBeConvex() const { return SkPathConvexity_IsConvex(fConvexity); }
50
51 std::optional<SkRect> isRect() const;
52
53 SkPathIter iter() const { return {fPoints, fVerbs, fConics}; }
54
55 static SkPathRaw Empty(SkPathFillType ft = SkPathFillType::kDefault) {
56 return {
57 {}, {}, {}, SkRect::MakeEmpty(), ft, SkPathConvexity::kConvex_Degenerate, 0,
58 };
59 }
60 };
61
62 #endif