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 GrDrawOp_DEFINED 9 #define GrDrawOp_DEFINED 10 11 #include <functional> 12 #include "src/gpu/GrDeferredUpload.h" 13 #include "src/gpu/GrPipeline.h" 14 #include "src/gpu/ops/GrOp.h" 15 16 class GrAppliedClip; 17 18 /** 19 * Base class for GrOps that draw. These ops can draw into an op list's GrRenderTarget. 20 */ 21 class GrDrawOp : public GrOp { 22 public: GrDrawOp(uint32_t classID)23 GrDrawOp(uint32_t classID) : INHERITED(classID) {} 24 25 /** 26 * This information is required to determine how to compute a GrAppliedClip from a GrClip for 27 * this op. 28 */ 29 enum class FixedFunctionFlags : uint32_t { 30 kNone = 0x0, 31 /** Indices that the op will enable MSAA. */ 32 kUsesHWAA = 0x1, 33 /** Indices that the op reads and/or writes the stencil buffer */ 34 kUsesStencil = 0x2, 35 }; 36 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(FixedFunctionFlags); 37 virtual FixedFunctionFlags fixedFunctionFlags() const = 0; 38 39 /** 40 * This is called after the GrAppliedClip has been computed and just prior to recording the op 41 * or combining it with a previously recorded op. The op should convert any proxies or resources 42 * it owns to "pending io" status so that resource allocation can be more optimal. Additionally, 43 * at this time the op must report whether a copy of the destination (or destination texture 44 * itself) needs to be provided to the GrXferProcessor when this op executes. 45 */ 46 virtual GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, GrClampType) = 0; 47 48 #ifdef SK_DEBUG 49 bool fAddDrawOpCalled = false; 50 validate()51 void validate() const override { 52 SkASSERT(fAddDrawOpCalled); 53 } 54 #endif 55 56 #if GR_TEST_UTILS 57 // This is really only intended for GrTextureOp and GrFillRectOp to override numQuads()58 virtual int numQuads() const { return -1; } 59 #endif 60 61 private: 62 using INHERITED = GrOp; 63 }; 64 65 GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags); 66 67 #endif 68