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 | |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 11 | #include "GrFixedClip.h" |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 12 | #include "GrOp.h" |
Hal Canary | 466c7d6 | 2017-07-03 15:11:49 -0400 | [diff] [blame] | 13 | #include "GrRenderTargetProxy.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; |
| 16 | |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 17 | class GrClearStencilClipOp final : public GrOp { |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 18 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 19 | DEFINE_OP_CLASS_ID |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 20 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 21 | static std::unique_ptr<GrOp> Make(GrContext* context, |
| 22 | const GrFixedClip& clip, |
| 23 | bool insideStencilMask, |
| 24 | GrRenderTargetProxy* proxy); |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 25 | |
| 26 | const char* name() const override { return "ClearStencilClip"; } |
| 27 | |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 28 | SkString dumpInfo() const override { |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 29 | SkString string("Scissor ["); |
Brian Salomon | d818ebf | 2018-07-02 14:08:49 +0000 | [diff] [blame] | 30 | if (fClip.scissorEnabled()) { |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 31 | const SkIRect& r = fClip.scissorRect(); |
| 32 | 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] | 33 | } else { |
| 34 | string.append("disabled"); |
csmartdalton | 29df760 | 2016-08-31 11:55:52 -0700 | [diff] [blame] | 35 | } |
Robert Phillips | 2f4ddf6 | 2017-06-01 08:48:19 -0400 | [diff] [blame] | 36 | string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false"); |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 37 | string.append(INHERITED::dumpInfo()); |
| 38 | return string; |
| 39 | } |
| 40 | |
| 41 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 42 | friend class GrOpMemoryPool; // for ctor |
| 43 | |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 44 | GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, |
| 45 | GrRenderTargetProxy* proxy) |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 46 | : INHERITED(ClassID()) |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 47 | , fClip(clip) |
| 48 | , fInsideStencilMask(insideStencilMask) { |
Brian Salomon | d818ebf | 2018-07-02 14:08:49 +0000 | [diff] [blame] | 49 | const SkRect& bounds = fClip.scissorEnabled() |
| 50 | ? SkRect::Make(fClip.scissorRect()) |
| 51 | : SkRect::MakeIWH(proxy->width(), proxy->height()); |
Brian Salomon | 2790c52 | 2016-12-09 16:32:23 -0500 | [diff] [blame] | 52 | this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); |
| 53 | } |
| 54 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 55 | void onPrepare(GrOpFlushState*) override {} |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 56 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 57 | void onExecute(GrOpFlushState* state) override; |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 58 | |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 59 | const GrFixedClip fClip; |
| 60 | const bool fInsideStencilMask; |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 61 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 62 | typedef GrOp INHERITED; |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | #endif |