bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 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 | |
Brian Salomon | 53e4c3c | 2016-12-21 11:38:53 -0500 | [diff] [blame] | 8 | #ifndef GrDrawOp_DEFINED |
| 9 | #define GrDrawOp_DEFINED |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 10 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 11 | #include <functional> |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 12 | #include "GrDeferredUpload.h" |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 13 | #include "GrOp.h" |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 14 | #include "GrPipeline.h" |
| 15 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 16 | class GrAppliedClip; |
| 17 | |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 18 | /** |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 19 | * Base class for GrOps that draw. These ops can draw into an op list's GrRenderTarget. |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 20 | */ |
Brian Salomon | 9afd371 | 2016-12-01 10:59:09 -0500 | [diff] [blame] | 21 | class GrDrawOp : public GrOp { |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 22 | public: |
Brian Salomon | b5cb683 | 2017-02-24 11:01:15 -0500 | [diff] [blame] | 23 | GrDrawOp(uint32_t classID) : INHERITED(classID) {} |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 24 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 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; |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 38 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 39 | /** |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 40 | * This is called after the GrAppliedClip has been computed and just prior to recording the op |
Brian Salomon | f86d37b | 2017-06-16 10:04:34 -0400 | [diff] [blame] | 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. |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 45 | */ |
Chris Dalton | 4b62aed | 2019-01-15 11:53:00 -0700 | [diff] [blame] | 46 | virtual GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*) = 0; |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 47 | |
Ethan Nicholas | 029b22c | 2018-10-18 16:49:56 -0400 | [diff] [blame] | 48 | #ifdef SK_DEBUG |
| 49 | bool fAddDrawOpCalled = false; |
| 50 | |
| 51 | void validate() const override { |
| 52 | SkASSERT(fAddDrawOpCalled); |
| 53 | } |
| 54 | #endif |
| 55 | |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 56 | private: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 57 | typedef GrOp INHERITED; |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 60 | GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags); |
| 61 | |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 62 | #endif |