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 GrStencilPathOp_DEFINED 9 #define GrStencilPathOp_DEFINED 10 11 #include "src/gpu/GrPath.h" 12 #include "src/gpu/GrPathRendering.h" 13 #include "src/gpu/GrScissorState.h" 14 #include "src/gpu/GrStencilSettings.h" 15 #include "src/gpu/ops/GrOp.h" 16 17 class GrOpFlushState; 18 class GrRecordingContext; 19 20 class GrStencilPathOp final : public GrOp { 21 public: 22 DEFINE_OP_CLASS_ID 23 24 static std::unique_ptr<GrOp> Make(GrRecordingContext* context, 25 const SkMatrix& viewMatrix, 26 bool useHWAA, 27 bool hasStencilClip, 28 const GrScissorState& scissor, 29 sk_sp<const GrPath> path); 30 name()31 const char* name() const override { return "StencilPathOp"; } 32 33 #ifdef SK_DEBUG dumpInfo()34 SkString dumpInfo() const override { 35 SkString string; 36 string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA); 37 string.append(INHERITED::dumpInfo()); 38 return string; 39 } 40 #endif 41 42 private: 43 friend class GrOpMemoryPool; // for ctor 44 GrStencilPathOp(const SkMatrix & viewMatrix,bool useHWAA,bool hasStencilClip,const GrScissorState & scissor,sk_sp<const GrPath> path)45 GrStencilPathOp(const SkMatrix& viewMatrix, 46 bool useHWAA, 47 bool hasStencilClip, 48 const GrScissorState& scissor, 49 sk_sp<const GrPath> path) 50 : INHERITED(ClassID()) 51 , fViewMatrix(viewMatrix) 52 , fUseHWAA(useHWAA) 53 , fHasStencilClip(hasStencilClip) 54 , fScissor(scissor) 55 , fPath(std::move(path)) { 56 this->setBounds(fPath->getBounds(), HasAABloat::kNo, IsHairline::kNo); 57 } 58 onPrepare(GrOpFlushState *)59 void onPrepare(GrOpFlushState*) override {} 60 61 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; 62 63 SkMatrix fViewMatrix; 64 bool fUseHWAA; 65 bool fHasStencilClip; 66 GrScissorState fScissor; 67 sk_sp<const GrPath> fPath; 68 69 typedef GrOp INHERITED; 70 }; 71 72 #endif 73