blob: 68f825a7e406c112abdf574dea5d618fc51a1748 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrFixedClip.h"
Greg Danielf91aeb22019-06-18 09:58:02 -040012#include "src/gpu/GrRenderTargetProxy.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/ops/GrOp.h"
robertphillips9199a9f2016-07-13 07:48:43 -070014
Robert Phillips7c525e62018-06-12 10:11:12 -040015class GrOpFlushState;
Robert Phillipsb97da532019-02-12 15:24:12 -050016class GrRecordingContext;
Robert Phillips7c525e62018-06-12 10:11:12 -040017
Brian Salomon7dae46a2016-12-14 16:21:37 -050018class GrClearStencilClipOp final : public GrOp {
robertphillips9199a9f2016-07-13 07:48:43 -070019public:
Brian Salomon25a88092016-12-01 09:36:50 -050020 DEFINE_OP_CLASS_ID
robertphillips9199a9f2016-07-13 07:48:43 -070021
Robert Phillipsb97da532019-02-12 15:24:12 -050022 static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040023 const GrFixedClip& clip,
24 bool insideStencilMask,
25 GrRenderTargetProxy* proxy);
robertphillips9199a9f2016-07-13 07:48:43 -070026
27 const char* name() const override { return "ClearStencilClip"; }
28
Brian Osman9a390ac2018-11-12 09:47:48 -050029#ifdef SK_DEBUG
robertphillips9199a9f2016-07-13 07:48:43 -070030 SkString dumpInfo() const override {
csmartdalton29df7602016-08-31 11:55:52 -070031 SkString string("Scissor [");
Brian Salomond818ebf2018-07-02 14:08:49 +000032 if (fClip.scissorEnabled()) {
csmartdalton29df7602016-08-31 11:55:52 -070033 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 Phillips2f4ddf62017-06-01 08:48:19 -040035 } else {
36 string.append("disabled");
csmartdalton29df7602016-08-31 11:55:52 -070037 }
Robert Phillips2f4ddf62017-06-01 08:48:19 -040038 string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false");
robertphillips9199a9f2016-07-13 07:48:43 -070039 string.append(INHERITED::dumpInfo());
40 return string;
41 }
Brian Osman9a390ac2018-11-12 09:47:48 -050042#endif
robertphillips9199a9f2016-07-13 07:48:43 -070043
44private:
Robert Phillips7c525e62018-06-12 10:11:12 -040045 friend class GrOpMemoryPool; // for ctor
46
Jim Van Verth6a40abc2017-11-02 16:56:09 +000047 GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
48 GrRenderTargetProxy* proxy)
Brian Salomon7dae46a2016-12-14 16:21:37 -050049 : INHERITED(ClassID())
Jim Van Verth6a40abc2017-11-02 16:56:09 +000050 , fClip(clip)
51 , fInsideStencilMask(insideStencilMask) {
Brian Salomon9f2b86c2019-10-22 10:37:46 -040052 const SkRect& bounds =
53 fClip.scissorEnabled() ? SkRect::Make(fClip.scissorRect()) : proxy->getBoundsRect();
Greg Daniel5faf4742019-10-01 15:14:44 -040054 this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo);
Brian Salomon2790c522016-12-09 16:32:23 -050055 }
56
Robert Phillipsc655c3a2020-03-18 13:23:45 -040057 void onPrePrepare(GrRecordingContext*,
Brian Salomon8afde5f2020-04-01 16:22:00 -040058 const GrSurfaceProxyView* writeView,
Robert Phillipsc655c3a2020-03-18 13:23:45 -040059 GrAppliedClip*,
60 const GrXferProcessor::DstProxyView&) override {}
61
Brian Salomon742e31d2016-12-07 17:06:19 -050062 void onPrepare(GrOpFlushState*) override {}
robertphillips9199a9f2016-07-13 07:48:43 -070063
Brian Salomon588cec72018-11-14 13:56:37 -050064 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
robertphillips9199a9f2016-07-13 07:48:43 -070065
Jim Van Verth6a40abc2017-11-02 16:56:09 +000066 const GrFixedClip fClip;
67 const bool fInsideStencilMask;
robertphillips9199a9f2016-07-13 07:48:43 -070068
Brian Salomon25a88092016-12-01 09:36:50 -050069 typedef GrOp INHERITED;
robertphillips9199a9f2016-07-13 07:48:43 -070070};
71
72#endif