robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 GrClearStencilClipOp_DEFINED |
| 9 | #define GrClearStencilClipOp_DEFINED |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrFixedClip.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrRenderTargetProxy.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/ops/GrOp.h" |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 14 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 15 | class GrOpFlushState; |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 16 | class GrRecordingContext; |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 17 | |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 18 | class GrClearStencilClipOp final : public GrOp { |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 19 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 20 | DEFINE_OP_CLASS_ID |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 21 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 22 | static std::unique_ptr<GrOp> Make(GrRecordingContext* context, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 23 | const GrFixedClip& clip, |
| 24 | bool insideStencilMask, |
| 25 | GrRenderTargetProxy* proxy); |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 26 | |
| 27 | const char* name() const override { return "ClearStencilClip"; } |
| 28 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 29 | #ifdef SK_DEBUG |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 30 | SkString dumpInfo() const override { |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 31 | SkString string("Scissor ["); |
Brian Salomon | d818ebf | 2018-07-02 14:08:49 +0000 | [diff] [blame] | 32 | if (fClip.scissorEnabled()) { |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 33 | const SkIRect& r = fClip.scissorRect(); |
| 34 | string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); |
Robert Phillips | 2f4ddf6 | 2017-06-01 08:48:19 -0400 | [diff] [blame] | 35 | } else { |
| 36 | string.append("disabled"); |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 37 | } |
Robert Phillips | 2f4ddf6 | 2017-06-01 08:48:19 -0400 | [diff] [blame] | 38 | string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false"); |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 39 | string.append(INHERITED::dumpInfo()); |
| 40 | return string; |
| 41 | } |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 42 | #endif |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 43 | |
| 44 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 45 | friend class GrOpMemoryPool; // for ctor |
| 46 | |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 47 | GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, |
| 48 | GrRenderTargetProxy* proxy) |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 49 | : INHERITED(ClassID()) |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 50 | , fClip(clip) |
| 51 | , fInsideStencilMask(insideStencilMask) { |
Brian Salomon | 9f2b86c | 2019-10-22 10:37:46 -0400 | [diff] [blame] | 52 | const SkRect& bounds = |
| 53 | fClip.scissorEnabled() ? SkRect::Make(fClip.scissorRect()) : proxy->getBoundsRect(); |
Greg Daniel | 5faf474 | 2019-10-01 15:14:44 -0400 | [diff] [blame] | 54 | this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo); |
Brian Salomon | 2790c52 | 2016-12-09 16:32:23 -0500 | [diff] [blame] | 55 | } |
| 56 | |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 57 | void onPrePrepare(GrRecordingContext*, |
Brian Salomon | 8afde5f | 2020-04-01 16:22:00 -0400 | [diff] [blame^] | 58 | const GrSurfaceProxyView* writeView, |
Robert Phillips | c655c3a | 2020-03-18 13:23:45 -0400 | [diff] [blame] | 59 | GrAppliedClip*, |
| 60 | const GrXferProcessor::DstProxyView&) override {} |
| 61 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 62 | void onPrepare(GrOpFlushState*) override {} |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 63 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 64 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 65 | |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 66 | const GrFixedClip fClip; |
| 67 | const bool fInsideStencilMask; |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 68 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 69 | typedef GrOp INHERITED; |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | #endif |