Debian Codegraph @

src/core/SkPathRawShapes.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 SkPathRawShapes_DEFINED
9 #define SkPathRawShapes_DEFINED
10
11 #include "include/core/SkPathTypes.h"
12 #include "include/core/SkPoint.h"
13 #include "src/core/SkPathRaw.h"
14
15 class SkRRect;
16 struct SkRect;
17
18 /**
19 * These classes provide their own stack-based storage for path data, making them efficient
20 * alternatives to SkPath for known geometries, avoiding heap allocations.
21 *
22 * The defaults were chosen to match those in SkPathBuilder.h
23 */
24 namespace SkPathRawShapes {
25
26 struct Rect : public SkPathRaw {
27 SkPoint fStorage[4]; // move + 3 lines (+ close)
28
29 explicit Rect(const SkRect&, SkPathDirection = SkPathDirection::kCW, unsigned index = 0);
30 };
31
32 struct Oval : public SkPathRaw {
33 SkPoint fStorage[9]; // move + 4 conics (+ close)
34
35 explicit Oval(const SkRect&, SkPathDirection = SkPathDirection::kCW, unsigned index = 1);
36 };
37
38 struct RRect : public SkPathRaw {
39 SkPoint fStorage[13]; // worse case: move + 4 conics + 4 lines (+ close)
40
41 RRect(const SkRRect&, SkPathDirection dir, unsigned index);
42 RRect(const SkRRect& rr, SkPathDirection dir)
43 : RRect(rr, dir, (dir == SkPathDirection::kCW ? 6 : 7)) {}
44 explicit RRect(const SkRRect& rr) : RRect(rr, SkPathDirection::kCW, 6) {}
45 };
46
47 struct Triangle : public SkPathRaw {
48 Triangle(SkSpan<const SkPoint> threePoints, const SkRect& bounds);
49 };
50
51 } // namespace SkPathRawShapes
52
53 #endif