1 /* 2 * Copyright 2015 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 GrDiscardOp_DEFINED 9 #define GrDiscardOp_DEFINED 10 11 #include "GrGpuCommandBuffer.h" 12 #include "GrOp.h" 13 #include "GrOpFlushState.h" 14 #include "GrRenderTargetProxy.h" 15 16 class GrDiscardOp final : public GrOp { 17 public: 18 DEFINE_OP_CLASS_ID 19 Make(GrRenderTargetProxy * proxy)20 static std::unique_ptr<GrOp> Make(GrRenderTargetProxy* proxy) { 21 return std::unique_ptr<GrOp>(new GrDiscardOp(proxy)); 22 } 23 name()24 const char* name() const override { return "Discard"; } 25 dumpInfo()26 SkString dumpInfo() const override { 27 SkString string; 28 string.append(INHERITED::dumpInfo()); 29 return string; 30 } 31 32 private: GrDiscardOp(GrRenderTargetProxy * proxy)33 GrDiscardOp(GrRenderTargetProxy* proxy) : INHERITED(ClassID()) { 34 this->setBounds(SkRect::MakeIWH(proxy->width(), proxy->height()), 35 HasAABloat::kNo, IsZeroArea::kNo); 36 } 37 onCombineIfPossible(GrOp * that,const GrCaps & caps)38 bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; } 39 onPrepare(GrOpFlushState *)40 void onPrepare(GrOpFlushState*) override {} 41 onExecute(GrOpFlushState * state)42 void onExecute(GrOpFlushState* state) override { 43 SkASSERT(state->drawOpArgs().fRenderTarget); 44 45 state->commandBuffer()->discard(state->drawOpArgs().fRenderTarget); 46 } 47 48 typedef GrOp INHERITED; 49 }; 50 51 #endif 52