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 8 #ifndef GrClearStencilClipOp_DEFINED 9 #define GrClearStencilClipOp_DEFINED 10 11 #include "GrFixedClip.h" 12 #include "GrOp.h" 13 #include "GrRenderTargetProxy.h" 14 15 class GrOpFlushState; 16 17 class GrClearStencilClipOp final : public GrOp { 18 public: 19 DEFINE_OP_CLASS_ID 20 21 static std::unique_ptr<GrOp> Make(GrContext* context, 22 const GrFixedClip& clip, 23 bool insideStencilMask, 24 GrRenderTargetProxy* proxy); 25 name()26 const char* name() const override { return "ClearStencilClip"; } 27 28 #ifdef SK_DEBUG dumpInfo()29 SkString dumpInfo() const override { 30 SkString string("Scissor ["); 31 if (fClip.scissorEnabled()) { 32 const SkIRect& r = fClip.scissorRect(); 33 string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); 34 } else { 35 string.append("disabled"); 36 } 37 string.appendf("], insideMask: %s\n", fInsideStencilMask ? "true" : "false"); 38 string.append(INHERITED::dumpInfo()); 39 return string; 40 } 41 #endif 42 43 private: 44 friend class GrOpMemoryPool; // for ctor 45 GrClearStencilClipOp(const GrFixedClip & clip,bool insideStencilMask,GrRenderTargetProxy * proxy)46 GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask, 47 GrRenderTargetProxy* proxy) 48 : INHERITED(ClassID()) 49 , fClip(clip) 50 , fInsideStencilMask(insideStencilMask) { 51 const SkRect& bounds = fClip.scissorEnabled() 52 ? SkRect::Make(fClip.scissorRect()) 53 : SkRect::MakeIWH(proxy->width(), proxy->height()); 54 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); 55 } 56 onPrepare(GrOpFlushState *)57 void onPrepare(GrOpFlushState*) override {} 58 59 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; 60 61 const GrFixedClip fClip; 62 const bool fInsideStencilMask; 63 64 typedef GrOp INHERITED; 65 }; 66 67 #endif 68