blob: 5eaff4bb19cd09ac80491416b0cb51ab9235b21b [file] [log] [blame]
bsalomon53469832015-08-18 09:20:09 -07001/*
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
Brian Salomon7dae46a2016-12-14 16:21:37 -05008#ifndef GrClearOp_DEFINED
9#define GrClearOp_DEFINED
bsalomon53469832015-08-18 09:20:09 -070010
Michael Ludwig9cced932020-06-08 09:30:09 -040011#include "include/gpu/GrTypes.h"
Michael Ludwig1e632792020-05-21 12:45:31 -040012#include "src/gpu/GrScissorState.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/ops/GrOp.h"
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040014
15class GrOpFlushState;
Robert Phillipsb97da532019-02-12 15:24:12 -050016class GrRecordingContext;
bsalomon53469832015-08-18 09:20:09 -070017
Brian Salomon7dae46a2016-12-14 16:21:37 -050018class GrClearOp final : public GrOp {
bsalomon53469832015-08-18 09:20:09 -070019public:
Brian Salomon25a88092016-12-01 09:36:50 -050020 DEFINE_OP_CLASS_ID
reed1b55a962015-09-17 20:16:13 -070021
Michael Ludwigd1d997e2020-06-04 15:52:44 -040022 // A fullscreen or scissored clear, depending on the clip and proxy dimensions
Michael Ludwig9cced932020-06-08 09:30:09 -040023 static std::unique_ptr<GrClearOp> MakeColor(GrRecordingContext* context,
24 const GrScissorState& scissor,
25 const SkPMColor4f& color);
26
27 static std::unique_ptr<GrClearOp> MakeStencilClip(GrRecordingContext* context,
28 const GrScissorState& scissor,
29 bool insideMask);
Robert Phillips784b7bf2016-12-09 13:35:02 -050030
bsalomon53469832015-08-18 09:20:09 -070031 const char* name() const override { return "Clear"; }
32
Brian Osman9a390ac2018-11-12 09:47:48 -050033#ifdef SK_DEBUG
Brian Salomon9dc2a9a2015-08-18 12:46:51 -040034 SkString dumpInfo() const override {
Robert Phillips1119dc32017-04-11 12:54:57 -040035 SkString string;
Robert Phillipsf5442bb2017-04-17 14:18:34 -040036 string.append(INHERITED::dumpInfo());
Robert Phillips5efd5ea2017-05-30 13:47:32 -040037 string.appendf("Scissor [ ");
Michael Ludwig1e632792020-05-21 12:45:31 -040038 if (fScissor.enabled()) {
39 const SkIRect& r = fScissor.rect();
csmartdalton29df7602016-08-31 11:55:52 -070040 string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
Robert Phillipsf7a72612017-03-31 10:03:45 -040041 } else {
42 string.append("disabled");
csmartdalton29df7602016-08-31 11:55:52 -070043 }
Brian Osman9a9baae2018-11-05 15:06:26 -050044 string.appendf("], Color: 0x%08x\n", fColor.toBytes_RGBA());
bsalomon53469832015-08-18 09:20:09 -070045 return string;
46 }
Brian Osman9a390ac2018-11-12 09:47:48 -050047#endif
bsalomon53469832015-08-18 09:20:09 -070048
49private:
Robert Phillips7c525e62018-06-12 10:11:12 -040050 friend class GrOpMemoryPool; // for ctors
51
Michael Ludwig9cced932020-06-08 09:30:09 -040052 enum class Buffer {
53 kColor = 0b01,
54 kStencilClip = 0b10,
55
56 kBoth = 0b11,
57 };
58 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Buffer);
59
60 GrClearOp(Buffer buffer, const GrScissorState& scissor, const SkPMColor4f& color, bool stencil);
Robert Phillips784b7bf2016-12-09 13:35:02 -050061
Michael Ludwig28b0c5d2019-12-19 14:51:00 -050062 CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,
Michael Ludwig9cced932020-06-08 09:30:09 -040063 const GrCaps& caps) override;
bsalomon53469832015-08-18 09:20:09 -070064
Michael Ludwig9cced932020-06-08 09:30:09 -040065 void onPrePrepare(GrRecordingContext*, const GrSurfaceProxyView* writeView, GrAppliedClip*,
Robert Phillipsc655c3a2020-03-18 13:23:45 -040066 const GrXferProcessor::DstProxyView&) override {}
67
Brian Salomon742e31d2016-12-07 17:06:19 -050068 void onPrepare(GrOpFlushState*) override {}
bsalomon53469832015-08-18 09:20:09 -070069
Brian Salomon588cec72018-11-14 13:56:37 -050070 void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override;
bsalomon53469832015-08-18 09:20:09 -070071
Michael Ludwig1e632792020-05-21 12:45:31 -040072 GrScissorState fScissor;
73 SkPMColor4f fColor;
Michael Ludwig9cced932020-06-08 09:30:09 -040074 bool fStencilInsideMask;
75 Buffer fBuffer;
Robert Phillips33f83152017-05-18 20:57:43 +000076
Brian Salomon25a88092016-12-01 09:36:50 -050077 typedef GrOp INHERITED;
bsalomon53469832015-08-18 09:20:09 -070078};
79
Michael Ludwig9cced932020-06-08 09:30:09 -040080GR_MAKE_BITFIELD_CLASS_OPS(GrClearOp::Buffer)
81
bsalomon53469832015-08-18 09:20:09 -070082#endif