bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 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 | |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 8 | #ifndef GrClearOp_DEFINED |
| 9 | #define GrClearOp_DEFINED |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 10 | |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 11 | #include "include/gpu/GrTypes.h" |
Michael Ludwig | 1e63279 | 2020-05-21 12:45:31 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrScissorState.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/ops/GrOp.h" |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 14 | |
| 15 | class GrOpFlushState; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 16 | class GrRecordingContext; |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 17 | |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 18 | class GrClearOp final : public GrOp { |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 19 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 20 | DEFINE_OP_CLASS_ID |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 21 | |
Michael Ludwig | d1d997e | 2020-06-04 15:52:44 -0400 | [diff] [blame] | 22 | // A fullscreen or scissored clear, depending on the clip and proxy dimensions |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 23 | 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 Phillips | 784b7bf | 2016-12-09 13:35:02 -0500 | [diff] [blame] | 30 | |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 31 | const char* name() const override { return "Clear"; } |
| 32 | |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 33 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 34 | friend class GrOpMemoryPool; // for ctors |
| 35 | |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 36 | enum class Buffer { |
| 37 | kColor = 0b01, |
| 38 | kStencilClip = 0b10, |
| 39 | |
| 40 | kBoth = 0b11, |
| 41 | }; |
| 42 | GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Buffer); |
| 43 | |
| 44 | GrClearOp(Buffer buffer, const GrScissorState& scissor, const SkPMColor4f& color, bool stencil); |
Robert Phillips | 784b7bf | 2016-12-09 13:35:02 -0500 | [diff] [blame] | 45 | |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 46 | CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*, |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 47 | const GrCaps& caps) override; |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 48 | |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 49 | void onPrePrepare(GrRecordingContext*, const GrSurfaceProxyView* writeView, GrAppliedClip*, |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 50 | const GrXferProcessor::DstProxyView&) override {} |
| 51 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 52 | void onPrepare(GrOpFlushState*) override {} |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 53 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 54 | void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override; |
John Stiles | af36652 | 2020-08-13 09:57:34 -0400 | [diff] [blame^] | 55 | #if GR_TEST_UTILS |
| 56 | SkString onDumpInfo() const override { |
| 57 | SkString string("Scissor [ "); |
| 58 | if (fScissor.enabled()) { |
| 59 | const SkIRect& r = fScissor.rect(); |
| 60 | string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); |
| 61 | } else { |
| 62 | string.append("disabled"); |
| 63 | } |
| 64 | string.appendf("], Color: 0x%08x\n", fColor.toBytes_RGBA()); |
| 65 | return string; |
| 66 | } |
| 67 | #endif |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 68 | |
Michael Ludwig | 1e63279 | 2020-05-21 12:45:31 -0400 | [diff] [blame] | 69 | GrScissorState fScissor; |
| 70 | SkPMColor4f fColor; |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 71 | bool fStencilInsideMask; |
| 72 | Buffer fBuffer; |
Robert Phillips | 33f8315 | 2017-05-18 20:57:43 +0000 | [diff] [blame] | 73 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 74 | typedef GrOp INHERITED; |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Michael Ludwig | 9cced93 | 2020-06-08 09:30:09 -0400 | [diff] [blame] | 77 | GR_MAKE_BITFIELD_CLASS_OPS(GrClearOp::Buffer) |
| 78 | |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 79 | #endif |