blob: a04088e9649d28787b895a7a101bb4efa6bed353 [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
Brian Osman9a390ac2018-11-12 09:47:48 -050028#ifdef SK_DEBUG
robertphillips9199a9f2016-07-13 07:48:43 -070029 SkString dumpInfo() const override {
csmartdalton29df7602016-08-31 11:55:52 -070030 SkString string("Scissor [");
Brian Salomond818ebf2018-07-02 14:08:49 +000031 if (fClip.scissorEnabled()) {
csmartdalton29df7602016-08-31 11:55:52 -070032 const SkIRect& r = fClip.scissorRect();
33 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 -040034 } else {
35 string.append("disabled");
csmartdalton29df7602016-08-31 11:55:52 -070036 }
Robert Phillips2f4ddf62017-06-01 08:48:19 -040037 string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false");
robertphillips9199a9f2016-07-13 07:48:43 -070038 string.append(INHERITED::dumpInfo());
39 return string;
40 }
Brian Osman9a390ac2018-11-12 09:47:48 -050041#endif
robertphillips9199a9f2016-07-13 07:48:43 -070042
43private:
Robert Phillips7c525e62018-06-12 10:11:12 -040044 friend class GrOpMemoryPool; // for ctor
45
Jim Van Verth6a40abc2017-11-02 16:56:09 +000046 GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
47 GrRenderTargetProxy* proxy)
Brian Salomon7dae46a2016-12-14 16:21:37 -050048 : INHERITED(ClassID())
Jim Van Verth6a40abc2017-11-02 16:56:09 +000049 , fClip(clip)
50 , fInsideStencilMask(insideStencilMask) {
Brian Salomond818ebf2018-07-02 14:08:49 +000051 const SkRect& bounds = fClip.scissorEnabled()
52 ? SkRect::Make(fClip.scissorRect())
53 : SkRect::MakeIWH(proxy->width(), proxy->height());
Brian Salomon2790c522016-12-09 16:32:23 -050054 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
55 }
56
Brian Salomon742e31d2016-12-07 17:06:19 -050057 void onPrepare(GrOpFlushState*) override {}
robertphillips9199a9f2016-07-13 07:48:43 -070058
Brian Salomon588cec72018-11-14 13:56:37 -050059 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
robertphillips9199a9f2016-07-13 07:48:43 -070060
Jim Van Verth6a40abc2017-11-02 16:56:09 +000061 const GrFixedClip fClip;
62 const bool fInsideStencilMask;
robertphillips9199a9f2016-07-13 07:48:43 -070063
Brian Salomon25a88092016-12-01 09:36:50 -050064 typedef GrOp INHERITED;
robertphillips9199a9f2016-07-13 07:48:43 -070065};
66
67#endif