reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 2 | * Copyright 2019 Google Inc. |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 8 | #ifndef GrOpsTask_DEFINED |
| 9 | #define GrOpsTask_DEFINED |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkMatrix.h" |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 12 | #include "include/core/SkRefCnt.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/core/SkStrokeRec.h" |
| 14 | #include "include/core/SkTypes.h" |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 15 | #include "include/private/GrRecordingContext.h" |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 16 | #include "include/private/SkColorData.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "include/private/SkTArray.h" |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 18 | #include "include/private/SkTDArray.h" |
Ben Wagner | 729a23f | 2019-05-17 16:29:34 -0400 | [diff] [blame] | 19 | #include "src/core/SkArenaAlloc.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/core/SkClipStack.h" |
| 21 | #include "src/core/SkStringUtils.h" |
| 22 | #include "src/core/SkTLazy.h" |
| 23 | #include "src/gpu/GrAppliedClip.h" |
| 24 | #include "src/gpu/GrPathRendering.h" |
| 25 | #include "src/gpu/GrPrimitiveProcessor.h" |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 26 | #include "src/gpu/GrRenderTask.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 27 | #include "src/gpu/ops/GrDrawOp.h" |
| 28 | #include "src/gpu/ops/GrOp.h" |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 29 | |
joshualitt | 086cee1 | 2016-01-12 06:45:24 -0800 | [diff] [blame] | 30 | class GrAuditTrail; |
Greg Daniel | f21bf9e | 2019-08-22 20:12:20 +0000 | [diff] [blame] | 31 | class GrCaps; |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 32 | class GrClearOp; |
| 33 | class GrGpuBuffer; |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 34 | class GrRenderTargetProxy; |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 35 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 36 | class GrOpsTask : public GrRenderTask { |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 37 | private: |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 38 | using DstProxyView = GrXferProcessor::DstProxyView; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 39 | |
bsalomon@google.com | f660187 | 2012-08-28 21:11:35 +0000 | [diff] [blame] | 40 | public: |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 41 | // The Arenas must outlive the GrOpsTask, either by preserving the context that owns |
Michael Ludwig | cb10e4d | 2019-12-12 13:59:20 -0500 | [diff] [blame] | 42 | // the pool, or by moving the pool to the DDL that takes over the GrOpsTask. |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 43 | GrOpsTask(GrRecordingContext::Arenas, GrSurfaceProxyView, GrAuditTrail*); |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 44 | ~GrOpsTask() override; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 45 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 46 | GrOpsTask* asOpsTask() override { return this; } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 47 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 48 | bool isEmpty() const { return fOpChains.empty(); } |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 49 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 50 | /** |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 51 | * Empties the draw buffer of any queued up draws. |
| 52 | */ |
Chris Dalton | a84cacf | 2017-10-04 10:30:29 -0600 | [diff] [blame] | 53 | void endFlush() override; |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 54 | |
Robert Phillips | 29f3854 | 2019-10-16 09:20:25 -0400 | [diff] [blame] | 55 | void onPrePrepare(GrRecordingContext*) override; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 56 | /** |
bsalomon | dc43898 | 2016-08-31 11:53:49 -0700 | [diff] [blame] | 57 | * Together these two functions flush all queued up draws to GrCommandBuffer. The return value |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 58 | * of executeOps() indicates whether any commands were actually issued to the GPU. |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 59 | */ |
Brian Osman | 407b342 | 2017-08-22 15:01:32 -0400 | [diff] [blame] | 60 | void onPrepare(GrOpFlushState* flushState) override; |
| 61 | bool onExecute(GrOpFlushState* flushState) override; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 62 | |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 63 | void addSampledTexture(GrSurfaceProxy* proxy) { |
| 64 | // This function takes a GrSurfaceProxy because all subsequent uses of the proxy do not |
| 65 | // require the specifics of GrTextureProxy, so this avoids a number of unnecessary virtual |
| 66 | // asTextureProxy() calls. However, sampling the proxy implicitly requires that the proxy |
| 67 | // be a texture. Eventually, when proxies are a unified type with flags, this can just |
| 68 | // assert that capability. |
| 69 | SkASSERT(proxy->asTextureProxy()); |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 70 | fSampledProxies.push_back(proxy); |
| 71 | } |
| 72 | |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 73 | void addOp(std::unique_ptr<GrOp> op, GrTextureResolveManager textureResolveManager, |
| 74 | const GrCaps& caps) { |
| 75 | auto addDependency = [ textureResolveManager, &caps, this ] ( |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 76 | GrSurfaceProxy* p, GrMipMapped mipmapped) { |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 77 | this->addDependency(p, mipmapped, textureResolveManager, caps); |
Robert Phillips | b493eeb | 2017-09-13 13:10:52 -0400 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | op->visitProxies(addDependency); |
| 81 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 82 | this->recordOp(std::move(op), GrProcessorSet::EmptySetAnalysis(), nullptr, nullptr, caps); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 83 | } |
Robert Phillips | b493eeb | 2017-09-13 13:10:52 -0400 | [diff] [blame] | 84 | |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 85 | void addWaitOp(std::unique_ptr<GrOp> op, GrTextureResolveManager textureResolveManager, |
| 86 | const GrCaps& caps) { |
| 87 | fHasWaitOp = true; |
| 88 | this->addOp(std::move(op), textureResolveManager, caps); |
Greg Daniel | cb32415 | 2019-02-25 11:36:53 -0500 | [diff] [blame] | 89 | } |
| 90 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 91 | void addDrawOp(std::unique_ptr<GrDrawOp> op, const GrProcessorSet::Analysis& processorAnalysis, |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 92 | GrAppliedClip&& clip, const DstProxyView& dstProxyView, |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 93 | GrTextureResolveManager textureResolveManager, const GrCaps& caps) { |
| 94 | auto addDependency = [ textureResolveManager, &caps, this ] ( |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 95 | GrSurfaceProxy* p, GrMipMapped mipmapped) { |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 96 | this->addSampledTexture(p); |
Chris Dalton | 0875512 | 2019-08-05 16:13:47 -0600 | [diff] [blame] | 97 | this->addDependency(p, mipmapped, textureResolveManager, caps); |
Robert Phillips | b493eeb | 2017-09-13 13:10:52 -0400 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | op->visitProxies(addDependency); |
| 101 | clip.visitProxies(addDependency); |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 102 | if (dstProxyView.proxy()) { |
| 103 | this->addSampledTexture(dstProxyView.proxy()); |
| 104 | addDependency(dstProxyView.proxy(), GrMipMapped::kNo); |
Robert Phillips | 2739ab0 | 2018-07-27 07:35:55 -0400 | [diff] [blame] | 105 | } |
Robert Phillips | b493eeb | 2017-09-13 13:10:52 -0400 | [diff] [blame] | 106 | |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 107 | this->recordOp(std::move(op), processorAnalysis, clip.doesClip() ? &clip : nullptr, |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 108 | &dstProxyView, caps); |
Brian Salomon | 69868af | 2016-12-22 15:42:51 -0500 | [diff] [blame] | 109 | } |
robertphillips | 9199a9f | 2016-07-13 07:48:43 -0700 | [diff] [blame] | 110 | |
Robert Phillips | 380b90c | 2017-08-30 07:41:07 -0400 | [diff] [blame] | 111 | void discard(); |
| 112 | |
Robert Phillips | 44e2c5f | 2020-04-14 13:00:04 -0400 | [diff] [blame^] | 113 | #ifdef SK_DEBUG |
| 114 | void dump(bool printDependencies) const override; |
| 115 | const char* name() const final { return "Ops"; } |
| 116 | int numClips() const override { return fNumClips; } |
| 117 | void visitProxies_debugOnly(const GrOp::VisitProxyFunc&) const override; |
| 118 | #endif |
Robert Phillips | c84c030 | 2017-05-08 15:35:11 -0400 | [diff] [blame] | 119 | |
Robert Phillips | 438d986 | 2019-11-14 12:46:05 -0500 | [diff] [blame] | 120 | #if GR_TEST_UTILS |
| 121 | int numOpChains() const { return fOpChains.count(); } |
| 122 | const GrOp* getChain(int index) const { return fOpChains[index].head(); } |
| 123 | #endif |
| 124 | |
Brian Salomon | 1354048 | 2018-07-09 10:31:47 -0400 | [diff] [blame] | 125 | private: |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 126 | bool isNoOp() const { |
Chris Dalton | a43e2d2 | 2019-08-30 01:14:33 -0600 | [diff] [blame] | 127 | // TODO: GrLoadOp::kDiscard (i.e., storing a discard) should also be grounds for skipping |
| 128 | // execution. We currently don't because of Vulkan. See http://skbug.com/9373. |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 129 | // |
| 130 | // TODO: We should also consider stencil load/store here. We get away with it for now |
| 131 | // because we never discard stencil buffers. |
Chris Dalton | a43e2d2 | 2019-08-30 01:14:33 -0600 | [diff] [blame] | 132 | return fOpChains.empty() && GrLoadOp::kLoad == fColorLoadOp; |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 133 | } |
| 134 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 135 | void deleteOps(); |
Robert Phillips | 9313aa7 | 2019-04-09 18:41:27 -0400 | [diff] [blame] | 136 | |
Chris Dalton | 674f77a | 2019-09-30 20:49:39 -0600 | [diff] [blame] | 137 | enum class StencilContent { |
| 138 | kDontCare, |
| 139 | kUserBitsCleared, // User bits: cleared |
| 140 | // Clip bit: don't care (Ganesh always pre-clears the clip bit.) |
| 141 | kPreserved |
| 142 | }; |
| 143 | |
| 144 | // Lets the caller specify what the content of the stencil buffer should be at the beginning |
| 145 | // of the render pass. |
| 146 | // |
| 147 | // When requesting kClear: Tilers will load the stencil buffer with a "clear" op; non-tilers |
| 148 | // will clear the stencil on first load, and then preserve it on subsequent loads. (Preserving |
| 149 | // works because renderTargetContexts are required to leave the user bits in a cleared state |
| 150 | // once finished.) |
| 151 | // |
| 152 | // NOTE: initialContent must not be kClear if caps.performStencilClearsAsDraws() is true. |
| 153 | void setInitialStencilContent(StencilContent initialContent) { |
| 154 | fInitialStencilContent = initialContent; |
| 155 | } |
| 156 | |
| 157 | // If a renderTargetContext splits its opsTask, it uses this method to guarantee stencil values |
| 158 | // get preserved across its split tasks. |
| 159 | void setMustPreserveStencil() { fMustPreserveStencil = true; } |
| 160 | |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 161 | // Must only be called if native color buffer clearing is enabled. |
| 162 | void setColorLoadOp(GrLoadOp op, const SkPMColor4f& color); |
| 163 | // Sets the clear color to transparent black |
| 164 | void setColorLoadOp(GrLoadOp op) { |
| 165 | static const SkPMColor4f kDefaultClearColor = {0.f, 0.f, 0.f, 0.f}; |
| 166 | this->setColorLoadOp(op, kDefaultClearColor); |
| 167 | } |
| 168 | |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 169 | enum class CanDiscardPreviousOps : bool { |
| 170 | kYes = true, |
| 171 | kNo = false |
| 172 | }; |
| 173 | |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 174 | // Perform book-keeping for a fullscreen clear, regardless of how the clear is implemented later |
| 175 | // (i.e. setColorLoadOp(), adding a ClearOp, or adding a GrFillRectOp that covers the device). |
| 176 | // Returns true if the clear can be converted into a load op (barring device caps). |
Chris Dalton | 6b98280 | 2019-06-27 13:53:46 -0600 | [diff] [blame] | 177 | bool resetForFullscreenClear(CanDiscardPreviousOps); |
Michael Ludwig | c39d0c8 | 2019-01-15 10:03:43 -0500 | [diff] [blame] | 178 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 179 | class OpChain { |
| 180 | public: |
| 181 | OpChain(const OpChain&) = delete; |
| 182 | OpChain& operator=(const OpChain&) = delete; |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 183 | OpChain(std::unique_ptr<GrOp>, GrProcessorSet::Analysis, GrAppliedClip*, |
| 184 | const DstProxyView*); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 185 | |
| 186 | ~OpChain() { |
| 187 | // The ops are stored in a GrMemoryPool and must be explicitly deleted via the pool. |
| 188 | SkASSERT(fList.empty()); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 189 | } |
Chris Dalton | 8816b93 | 2017-11-29 16:48:25 -0700 | [diff] [blame] | 190 | |
Chris Dalton | 1706cbf | 2019-05-21 19:35:29 -0600 | [diff] [blame] | 191 | void visitProxies(const GrOp::VisitProxyFunc&) const; |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 192 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 193 | GrOp* head() const { return fList.head(); } |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 194 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 195 | GrAppliedClip* appliedClip() const { return fAppliedClip; } |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 196 | const DstProxyView& dstProxyView() const { return fDstProxyView; } |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 197 | const SkRect& bounds() const { return fBounds; } |
Chris Dalton | 8816b93 | 2017-11-29 16:48:25 -0700 | [diff] [blame] | 198 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 199 | // Deletes all the ops in the chain via the pool. |
| 200 | void deleteOps(GrOpMemoryPool* pool); |
| 201 | |
| 202 | // Attempts to move the ops from the passed chain to this chain at the head. Also attempts |
| 203 | // to merge ops between the chains. Upon success the passed chain is empty. |
| 204 | // Fails when the chains aren't of the same op type, have different clips or dst proxies. |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 205 | bool prependChain(OpChain*, const GrCaps&, GrRecordingContext::Arenas*, GrAuditTrail*); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 206 | |
| 207 | // Attempts to add 'op' to this chain either by merging or adding to the tail. Returns |
| 208 | // 'op' to the caller upon failure, otherwise null. Fails when the op and chain aren't of |
| 209 | // the same op type, have different clips or dst proxies. |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 210 | std::unique_ptr<GrOp> appendOp(std::unique_ptr<GrOp> op, GrProcessorSet::Analysis, |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 211 | const DstProxyView*, const GrAppliedClip*, const GrCaps&, |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 212 | GrRecordingContext::Arenas*, GrAuditTrail*); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 213 | |
Greg Daniel | 15ecdf9 | 2019-08-30 15:35:23 -0400 | [diff] [blame] | 214 | void setSkipExecuteFlag() { fSkipExecute = true; } |
| 215 | bool shouldExecute() const { |
| 216 | return SkToBool(this->head()) && !fSkipExecute; |
| 217 | } |
| 218 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 219 | private: |
| 220 | class List { |
| 221 | public: |
| 222 | List() = default; |
| 223 | List(std::unique_ptr<GrOp>); |
| 224 | List(List&&); |
| 225 | List& operator=(List&& that); |
| 226 | |
| 227 | bool empty() const { return !SkToBool(fHead); } |
| 228 | GrOp* head() const { return fHead.get(); } |
| 229 | GrOp* tail() const { return fTail; } |
| 230 | |
| 231 | std::unique_ptr<GrOp> popHead(); |
| 232 | std::unique_ptr<GrOp> removeOp(GrOp* op); |
| 233 | void pushHead(std::unique_ptr<GrOp> op); |
| 234 | void pushTail(std::unique_ptr<GrOp>); |
| 235 | |
| 236 | void validate() const; |
| 237 | |
| 238 | private: |
| 239 | std::unique_ptr<GrOp> fHead; |
| 240 | GrOp* fTail = nullptr; |
| 241 | }; |
| 242 | |
| 243 | void validate() const; |
| 244 | |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 245 | bool tryConcat(List*, GrProcessorSet::Analysis, const DstProxyView&, const GrAppliedClip*, |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 246 | const SkRect& bounds, const GrCaps&, GrRecordingContext::Arenas*, |
Michael Ludwig | d0840ec | 2019-12-12 09:48:38 -0500 | [diff] [blame] | 247 | GrAuditTrail*); |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 248 | static List DoConcat(List, List, const GrCaps&, GrRecordingContext::Arenas*, GrAuditTrail*); |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 249 | |
| 250 | List fList; |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 251 | GrProcessorSet::Analysis fProcessorAnalysis; |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 252 | DstProxyView fDstProxyView; |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 253 | GrAppliedClip* fAppliedClip; |
| 254 | SkRect fBounds; |
Greg Daniel | 15ecdf9 | 2019-08-30 15:35:23 -0400 | [diff] [blame] | 255 | |
| 256 | // We set this flag to true if any of the ops' proxies fail to instantiate so that we know |
| 257 | // not to try and draw the op. |
| 258 | bool fSkipExecute = false; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 259 | }; |
| 260 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 261 | |
| 262 | bool onIsUsed(GrSurfaceProxy*) const override; |
| 263 | |
Chris Dalton | 6b49810 | 2019-08-01 14:14:52 -0600 | [diff] [blame] | 264 | void handleInternalAllocationFailure() override; |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 265 | |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 266 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
| 267 | |
Greg Daniel | 524e28b | 2019-11-01 11:48:53 -0400 | [diff] [blame] | 268 | void recordOp(std::unique_ptr<GrOp>, GrProcessorSet::Analysis, GrAppliedClip*, |
| 269 | const DstProxyView*, const GrCaps& caps); |
Brian Salomon | 2790c52 | 2016-12-09 16:32:23 -0500 | [diff] [blame] | 270 | |
Robert Phillips | ee68365 | 2017-04-26 11:53:10 -0400 | [diff] [blame] | 271 | void forwardCombine(const GrCaps&); |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 272 | |
Chris Dalton | 16a33c6 | 2019-09-24 22:19:17 -0600 | [diff] [blame] | 273 | ExpectedOutcome onMakeClosed(const GrCaps& caps, SkIRect* targetUpdateBounds) override; |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 274 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 275 | friend class GrRenderTargetContextPriv; // for stencil clip state. TODO: this is invasive |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 276 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 277 | // The RTC and OpsTask have to work together to handle buffer clears. In most cases, buffer |
| 278 | // clearing can be done natively, in which case the op list's load ops are sufficient. In other |
| 279 | // cases, draw ops must be used, which makes the RTC the best place for those decisions. This, |
| 280 | // however, requires that the RTC be able to coordinate with the op list to achieve similar ends |
| 281 | friend class GrRenderTargetContext; |
| 282 | |
Michael Ludwig | 28b0c5d | 2019-12-19 14:51:00 -0500 | [diff] [blame] | 283 | // This is a backpointer to the Arenas that holds the memory for this GrOpsTask's ops. In the |
| 284 | // DDL case, the Arenas must have been detached from the original recording context and moved |
| 285 | // into the owning DDL. |
| 286 | GrRecordingContext::Arenas fArenas; |
| 287 | GrAuditTrail* fAuditTrail; |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 288 | |
| 289 | GrLoadOp fColorLoadOp = GrLoadOp::kLoad; |
| 290 | SkPMColor4f fLoadClearColor = SK_PMColor4fTRANSPARENT; |
Chris Dalton | 674f77a | 2019-09-30 20:49:39 -0600 | [diff] [blame] | 291 | StencilContent fInitialStencilContent = StencilContent::kDontCare; |
| 292 | bool fMustPreserveStencil = false; |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 293 | |
| 294 | uint32_t fLastClipStackGenID; |
| 295 | SkIRect fLastDevClipBounds; |
| 296 | int fLastClipNumAnalyticFPs; |
csmartdalton | 7cdda99 | 2016-11-01 07:03:03 -0700 | [diff] [blame] | 297 | |
Greg Daniel | cb32415 | 2019-02-25 11:36:53 -0500 | [diff] [blame] | 298 | // We must track if we have a wait op so that we don't delete the op when we have a full clear. |
| 299 | bool fHasWaitOp = false;; |
| 300 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 301 | // For ops/opsTask we have mean: 5 stdDev: 28 |
| 302 | SkSTArray<25, OpChain, true> fOpChains; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 303 | |
Robert Phillips | f6d7eb1 | 2017-04-26 14:55:34 -0400 | [diff] [blame] | 304 | // MDB TODO: 4096 for the first allocation of the clip space will be huge overkill. |
| 305 | // Gather statistics to determine the correct size. |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 306 | SkArenaAlloc fClipAllocator{4096}; |
| 307 | SkDEBUGCODE(int fNumClips;) |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 308 | |
Greg Daniel | b20d7e5 | 2019-09-03 13:54:39 -0400 | [diff] [blame] | 309 | // TODO: We could look into this being a set if we find we're adding a lot of duplicates that is |
| 310 | // causing slow downs. |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 311 | SkTArray<GrSurfaceProxy*, true> fSampledProxies; |
Chris Dalton | 16a33c6 | 2019-09-24 22:19:17 -0600 | [diff] [blame] | 312 | |
| 313 | SkRect fTotalBounds = SkRect::MakeEmpty(); |
Greg Daniel | 94ed83f | 2019-09-27 13:05:43 -0400 | [diff] [blame] | 314 | SkIRect fClippedContentBounds = SkIRect::MakeEmpty(); |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 315 | }; |
| 316 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 317 | #endif |