Debian Codegraph @

src/gpu/ganesh/ops/ClearOp.h

raw
1 /*
2 * Copyright 2015 Google Inc.
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 ClearOp_DEFINED
9 #define ClearOp_DEFINED
10
11 #include "include/core/SkRect.h"
12 #include "include/core/SkString.h"
13 #include "include/private/base/SkMacros.h"
14 #include "src/gpu/ganesh/GrCaps.h"
15 #include "src/gpu/ganesh/GrScissorState.h"
16 #include "src/gpu/ganesh/ops/GrOp.h"
17
18 #include <array>
19
20 class GrAppliedClip;
21 class GrDstProxyView;
22 class GrOpFlushState;
23 class GrRecordingContext;
24 class GrSurfaceProxyView;
25 class SkArenaAlloc;
26 enum class GrLoadOp;
27 enum class GrXferBarrierFlags;
28
29 namespace skgpu::ganesh {
30
31 class ClearOp final : public GrOp {
32 public:
33 DEFINE_OP_CLASS_ID
34
35 // A fullscreen or scissored clear, depending on the clip and proxy dimensions
36 static GrOp::Owner MakeColor(GrRecordingContext* context,
37 const GrScissorState& scissor,
38 std::array<float, 4> color);
39
40 static GrOp::Owner MakeStencilClip(GrRecordingContext* context,
41 const GrScissorState& scissor,
42 bool insideMask);
43
44 const char* name() const override { return "Clear"; }
45
46 const std::array<float, 4>& color() const { return fColor; }
47 bool stencilInsideMask() const { return fStencilInsideMask; }
48 private:
49 friend class GrOp; // for ctors
50
51 enum class Buffer {
52 kColor = 0b01,
53 kStencilClip = 0b10,
54
55 kBoth = 0b11,
56 };
57 SK_DECL_BITFIELD_CLASS_OPS_FRIENDS(Buffer);
58
59 ClearOp(Buffer buffer,
60 const GrScissorState& scissor,
61 std::array<float, 4> color,
62 bool stencil);
63
64 CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override;
65
66 void onPrePrepare(GrRecordingContext*, const GrSurfaceProxyView& writeView, GrAppliedClip*,
67 const GrDstProxyView&, GrXferBarrierFlags renderPassXferBarriers,
68 GrLoadOp colorLoadOp) override {}
69
70 void onPrepare(GrOpFlushState*) override {}
71
72 void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override;
73 #if defined(GPU_TEST_UTILS)
74 SkString onDumpInfo() const override {
75 SkString string("Scissor [ ");
76 if (fScissor.enabled()) {
77 const SkIRect& r = fScissor.rect();
78 string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
79 } else {
80 string.append("disabled");
81 }
82 string.appendf("], Color: {%g, %g, %g, %g}\n", fColor[0], fColor[1], fColor[2], fColor[3]);
83 return string;
84 }
85 #endif
86
87 GrScissorState fScissor;
88 std::array<float, 4> fColor;
89 bool fStencilInsideMask;
90 Buffer fBuffer;
91 };
92
93 SK_MAKE_BITFIELD_CLASS_OPS(ClearOp::Buffer)
94
95 } // namespace skgpu::ganesh
96
97 #endif // ClearOp_DEFINED