GrDrawOp.h 1.9 KB

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