blob: 5861fca3000fc8df13c75fdb263b1596517f7d70 [file] [log] [blame]
robertphillips9199a9f2016-07-13 07:48:43 -07001/*
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 Salomon7dae46a2016-12-14 16:21:37 -05008#ifndef GrClearStencilClipOp_DEFINED
9#define GrClearStencilClipOp_DEFINED
robertphillips9199a9f2016-07-13 07:48:43 -070010
csmartdalton29df7602016-08-31 11:55:52 -070011#include "GrFixedClip.h"
Brian Salomon25a88092016-12-01 09:36:50 -050012#include "GrOp.h"
Hal Canary466c7d62017-07-03 15:11:49 -040013#include "GrRenderTargetProxy.h"
robertphillips9199a9f2016-07-13 07:48:43 -070014
Robert Phillips7c525e62018-06-12 10:11:12 -040015class GrOpFlushState;
16
Brian Salomon7dae46a2016-12-14 16:21:37 -050017class GrClearStencilClipOp final : public GrOp {
robertphillips9199a9f2016-07-13 07:48:43 -070018public:
Brian Salomon25a88092016-12-01 09:36:50 -050019 DEFINE_OP_CLASS_ID
robertphillips9199a9f2016-07-13 07:48:43 -070020
Robert Phillips7c525e62018-06-12 10:11:12 -040021 static std::unique_ptr<GrOp> Make(GrContext* context,
22 const GrFixedClip& clip,
23 bool insideStencilMask,
24 GrRenderTargetProxy* proxy);
robertphillips9199a9f2016-07-13 07:48:43 -070025
26 const char* name() const override { return "ClearStencilClip"; }
27
robertphillips9199a9f2016-07-13 07:48:43 -070028 SkString dumpInfo() const override {
csmartdalton29df7602016-08-31 11:55:52 -070029 SkString string("Scissor [");
Brian Salomond818ebf2018-07-02 14:08:49 +000030 if (fClip.scissorEnabled()) {
csmartdalton29df7602016-08-31 11:55:52 -070031 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 Phillips2f4ddf62017-06-01 08:48:19 -040033 } else {
34 string.append("disabled");
csmartdalton29df7602016-08-31 11:55:52 -070035 }
Robert Phillips2f4ddf62017-06-01 08:48:19 -040036 string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false");
robertphillips9199a9f2016-07-13 07:48:43 -070037 string.append(INHERITED::dumpInfo());
38 return string;
39 }
40
41private:
Robert Phillips7c525e62018-06-12 10:11:12 -040042 friend class GrOpMemoryPool; // for ctor
43
Jim Van Verth6a40abc2017-11-02 16:56:09 +000044 GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
45 GrRenderTargetProxy* proxy)
Brian Salomon7dae46a2016-12-14 16:21:37 -050046 : INHERITED(ClassID())
Jim Van Verth6a40abc2017-11-02 16:56:09 +000047 , fClip(clip)
48 , fInsideStencilMask(insideStencilMask) {
Brian Salomond818ebf2018-07-02 14:08:49 +000049 const SkRect& bounds = fClip.scissorEnabled()
50 ? SkRect::Make(fClip.scissorRect())
51 : SkRect::MakeIWH(proxy->width(), proxy->height());
Brian Salomon2790c522016-12-09 16:32:23 -050052 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
53 }
54
Brian Salomon742e31d2016-12-07 17:06:19 -050055 void onPrepare(GrOpFlushState*) override {}
robertphillips9199a9f2016-07-13 07:48:43 -070056
Robert Phillips7c525e62018-06-12 10:11:12 -040057 void onExecute(GrOpFlushState* state) override;
robertphillips9199a9f2016-07-13 07:48:43 -070058
Jim Van Verth6a40abc2017-11-02 16:56:09 +000059 const GrFixedClip fClip;
60 const bool fInsideStencilMask;
robertphillips9199a9f2016-07-13 07:48:43 -070061
Brian Salomon25a88092016-12-01 09:36:50 -050062 typedef GrOp INHERITED;
robertphillips9199a9f2016-07-13 07:48:43 -070063};
64
65#endif