Debian Codegraph @

src/gpu/graphite/geom/NonMSAAClip.h

raw
1 /*
2 * Copyright 2024 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 skgpu_graphite_geom_NonMSAAClip_DEFINED
9 #define skgpu_graphite_geom_NonMSAAClip_DEFINED
10
11 #include "src/gpu/graphite/TextureProxy.h"
12 #include "src/gpu/graphite/geom/Rect.h"
13
14 namespace skgpu::graphite {
15
16 /**
17 * Represents a rect or rrect clip with any non-rect corners having the same circular radii.
18 */
19 struct AnalyticClip {
20 // Indicate which edges are adjacent to circular corners.
21 enum EdgeFlags {
22 kLeft_EdgeFlag = 0b0001,
23 kTop_EdgeFlag = 0b0010,
24 kRight_EdgeFlag = 0b0100,
25 kBottom_EdgeFlag = 0b1000,
26
27 kNone_EdgeFlag = 0b0000,
28 kAll_EdgeFlag = 0b1111,
29 };
30 // These defaults will produce no clip
31 Rect fBounds = { 0, 0, 0, 0 }; // Bounds of clip
32 float fRadius = 0; // Circular radius, if any
33 uint32_t fEdgeFlags = kNone_EdgeFlag;
34 bool fInverted = true;
35
36 bool isEmpty() const { return fBounds.isEmptyNegativeOrNaN(); }
37 SkRect edgeSelectRect() const {
38 return { fEdgeFlags & kLeft_EdgeFlag ? 1.f : 0.f,
39 fEdgeFlags & kTop_EdgeFlag ? 1.f : 0.f,
40 fEdgeFlags & kRight_EdgeFlag ? 1.f : 0.f,
41 fEdgeFlags & kBottom_EdgeFlag ? 1.f : 0.f };
42 }
43 };
44
45 /**
46 * Represents a clip that uses a mask in an atlas
47 */
48 struct AtlasClip {
49 SkIRect fMaskBounds;
50 SkIPoint fOutPos;
51 sk_sp<TextureProxy> fAtlasTexture;
52
53 bool isEmpty() const { return !SkToBool(fAtlasTexture.get()); }
54 };
55
56 /**
57 * Combined non-MSAA clip structure
58 */
59 struct NonMSAAClip {
60 AnalyticClip fAnalyticClip;
61 AtlasClip fAtlasClip;
62
63 bool isEmpty() const { return fAnalyticClip.isEmpty() && fAtlasClip.isEmpty(); }
64 };
65
66 } // namespace skgpu::graphite
67
68 #endif // skgpu_graphite_geom_NonMSAAClip_DEFINED