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 "GrDeferredUpload.h" 13 #include "GrOp.h" 14 #include "GrPipeline.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 or mixed samples rendering. */ 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*) = 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 private: 57 typedef GrOp INHERITED; 58 }; 59 60 GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags); 61 62 #endif 63