robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -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 | |
bsalomon | 5eb41fd | 2016-09-06 13:49:32 -0700 | [diff] [blame] | 8 | #include "GrDrawingManager.h" |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 9 | #include "GrBackendSemaphore.h" |
bsalomon | b77a907 | 2016-09-07 10:02:04 -0700 | [diff] [blame] | 10 | #include "GrContext.h" |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 11 | #include "GrContextPriv.h" |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 12 | #include "GrGpu.h" |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 13 | #include "GrMemoryPool.h" |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 14 | #include "GrOnFlushResourceProvider.h" |
Robert Phillips | 9d6c64f | 2017-09-14 10:56:45 -0400 | [diff] [blame] | 15 | #include "GrOpList.h" |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 16 | #include "GrRenderTargetContext.h" |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 17 | #include "GrRenderTargetProxy.h" |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 18 | #include "GrResourceAllocator.h" |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 19 | #include "GrResourceProvider.h" |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 20 | #include "GrSoftwarePathRenderer.h" |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 21 | #include "GrSurfaceProxyPriv.h" |
Brian Salomon | 930f939 | 2018-06-20 16:25:26 -0400 | [diff] [blame] | 22 | #include "GrTexture.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 23 | #include "GrTextureContext.h" |
| 24 | #include "GrTextureOpList.h" |
Brian Salomon | 930f939 | 2018-06-20 16:25:26 -0400 | [diff] [blame] | 25 | #include "GrTexturePriv.h" |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 26 | #include "GrTextureProxy.h" |
| 27 | #include "GrTextureProxyPriv.h" |
Brian Salomon | 930f939 | 2018-06-20 16:25:26 -0400 | [diff] [blame] | 28 | #include "GrTracing.h" |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 29 | #include "SkDeferredDisplayList.h" |
brianosman | 0e22eb8 | 2016-08-30 07:07:59 -0700 | [diff] [blame] | 30 | #include "SkSurface_Gpu.h" |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 31 | #include "SkTTopoSort.h" |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 32 | #include "ccpr/GrCoverageCountingPathRenderer.h" |
Herb Derby | 26cbe51 | 2018-05-24 14:39:01 -0400 | [diff] [blame] | 33 | #include "text/GrTextContext.h" |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 34 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 35 | GrDrawingManager::OpListDAG::OpListDAG(bool explicitlyAllocating, |
| 36 | GrContextOptions::Enable sortOpLists) { |
| 37 | if (GrContextOptions::Enable::kNo == sortOpLists) { |
| 38 | fSortOpLists = false; |
| 39 | } else if (GrContextOptions::Enable::kYes == sortOpLists) { |
| 40 | fSortOpLists = true; |
Robert Phillips | a3f7026 | 2018-02-08 10:59:38 -0500 | [diff] [blame] | 41 | } else { |
Robert Phillips | 64ecdce | 2018-04-02 10:26:39 -0400 | [diff] [blame] | 42 | // By default we always enable sorting when we're explicitly allocating GPU resources |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 43 | fSortOpLists = explicitlyAllocating; |
Robert Phillips | a3f7026 | 2018-02-08 10:59:38 -0500 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 47 | GrDrawingManager::OpListDAG::~OpListDAG() {} |
| 48 | |
| 49 | void GrDrawingManager::OpListDAG::gatherIDs(SkSTArray<8, uint32_t, true>* idArray) const { |
| 50 | idArray->reset(fOpLists.count()); |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 51 | for (int i = 0; i < fOpLists.count(); ++i) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 52 | if (fOpLists[i]) { |
| 53 | (*idArray)[i] = fOpLists[i]->uniqueID(); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | void GrDrawingManager::OpListDAG::reset() { |
| 59 | fOpLists.reset(); |
| 60 | } |
| 61 | |
| 62 | void GrDrawingManager::OpListDAG::removeOpList(int index) { |
| 63 | if (!fOpLists[index]->unique()) { |
| 64 | // TODO: Eventually this should be guaranteed unique: http://skbug.com/7111 |
| 65 | fOpLists[index]->endFlush(); |
| 66 | } |
| 67 | |
| 68 | fOpLists[index] = nullptr; |
| 69 | } |
| 70 | |
| 71 | void GrDrawingManager::OpListDAG::removeOpLists(int startIndex, int stopIndex) { |
| 72 | for (int i = startIndex; i < stopIndex; ++i) { |
| 73 | if (!fOpLists[i]) { |
| 74 | continue; |
| 75 | } |
| 76 | this->removeOpList(i); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | void GrDrawingManager::OpListDAG::add(sk_sp<GrOpList> opList) { |
| 81 | fOpLists.emplace_back(std::move(opList)); |
| 82 | } |
| 83 | |
| 84 | void GrDrawingManager::OpListDAG::add(const SkTArray<sk_sp<GrOpList>>& opLists) { |
| 85 | fOpLists.push_back_n(opLists.count(), opLists.begin()); |
| 86 | } |
| 87 | |
| 88 | void GrDrawingManager::OpListDAG::swap(SkTArray<sk_sp<GrOpList>>* opLists) { |
| 89 | SkASSERT(opLists->empty()); |
| 90 | opLists->swap(fOpLists); |
| 91 | } |
| 92 | |
| 93 | void GrDrawingManager::OpListDAG::prepForFlush() { |
| 94 | if (fSortOpLists) { |
| 95 | SkDEBUGCODE(bool result =) SkTTopoSort<GrOpList, GrOpList::TopoSortTraits>(&fOpLists); |
| 96 | SkASSERT(result); |
| 97 | } |
| 98 | |
| 99 | #ifdef SK_DEBUG |
| 100 | // This block checks for any unnecessary splits in the opLists. If two sequential opLists |
| 101 | // share the same backing GrSurfaceProxy it means the opList was artificially split. |
| 102 | if (fOpLists.count()) { |
| 103 | GrRenderTargetOpList* prevOpList = fOpLists[0]->asRenderTargetOpList(); |
| 104 | for (int i = 1; i < fOpLists.count(); ++i) { |
| 105 | GrRenderTargetOpList* curOpList = fOpLists[i]->asRenderTargetOpList(); |
| 106 | |
| 107 | if (prevOpList && curOpList) { |
| 108 | SkASSERT(prevOpList->fTarget.get() != curOpList->fTarget.get()); |
| 109 | } |
| 110 | |
| 111 | prevOpList = curOpList; |
| 112 | } |
| 113 | } |
| 114 | #endif |
| 115 | } |
| 116 | |
| 117 | void GrDrawingManager::OpListDAG::closeAll(const GrCaps* caps) { |
| 118 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 119 | if (fOpLists[i]) { |
| 120 | fOpLists[i]->makeClosed(*caps); |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | void GrDrawingManager::OpListDAG::cleanup(const GrCaps* caps) { |
| 126 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 127 | if (!fOpLists[i]) { |
| 128 | continue; |
| 129 | } |
| 130 | |
Robert Phillips | ee68365 | 2017-04-26 11:53:10 -0400 | [diff] [blame] | 131 | // no opList should receive a new command after this |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 132 | fOpLists[i]->makeClosed(*caps); |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 133 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 134 | // We shouldn't need to do this, but it turns out some clients still hold onto opLists |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 135 | // after a cleanup. |
| 136 | // MDB TODO: is this still true? |
Chris Dalton | a84cacf | 2017-10-04 10:30:29 -0600 | [diff] [blame] | 137 | if (!fOpLists[i]->unique()) { |
| 138 | // TODO: Eventually this should be guaranteed unique. |
| 139 | // https://bugs.chromium.org/p/skia/issues/detail?id=7111 |
| 140 | fOpLists[i]->endFlush(); |
| 141 | } |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 144 | fOpLists.reset(); |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 148 | GrDrawingManager::GrDrawingManager(GrContext* context, |
| 149 | const GrPathRendererChain::Options& optionsForPathRendererChain, |
| 150 | const GrTextContext::Options& optionsForTextContext, |
| 151 | GrSingleOwner* singleOwner, |
| 152 | bool explicitlyAllocating, |
Robert Phillips | 46acf9d | 2018-10-09 09:31:40 -0400 | [diff] [blame] | 153 | GrContextOptions::Enable sortOpLists, |
| 154 | GrContextOptions::Enable reduceOpListSplitting) |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 155 | : fContext(context) |
| 156 | , fOptionsForPathRendererChain(optionsForPathRendererChain) |
| 157 | , fOptionsForTextContext(optionsForTextContext) |
| 158 | , fSingleOwner(singleOwner) |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 159 | , fDAG(explicitlyAllocating, sortOpLists) |
| 160 | , fTextContext(nullptr) |
| 161 | , fPathRendererChain(nullptr) |
| 162 | , fSoftwarePathRenderer(nullptr) |
| 163 | , fFlushing(false) { |
Robert Phillips | 46acf9d | 2018-10-09 09:31:40 -0400 | [diff] [blame] | 164 | if (GrContextOptions::Enable::kNo == reduceOpListSplitting) { |
| 165 | fReduceOpListSplitting = false; |
| 166 | } else if (GrContextOptions::Enable::kYes == reduceOpListSplitting) { |
| 167 | fReduceOpListSplitting = true; |
| 168 | } else { |
| 169 | // For now, this is only turned on when explicitly enabled. Once mini-flushes are |
| 170 | // implemented it should be enabled whenever sorting is enabled. |
| 171 | fReduceOpListSplitting = false; // sortOpLists |
| 172 | } |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | void GrDrawingManager::cleanup() { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 176 | fDAG.cleanup(fContext->priv().caps()); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 177 | |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 178 | fPathRendererChain = nullptr; |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 179 | fSoftwarePathRenderer = nullptr; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 180 | |
| 181 | fOnFlushCBObjects.reset(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | GrDrawingManager::~GrDrawingManager() { |
| 185 | this->cleanup(); |
| 186 | } |
| 187 | |
Robert Phillips | a9162df | 2019-02-11 14:12:03 -0500 | [diff] [blame] | 188 | bool GrDrawingManager::wasAbandoned() const { |
| 189 | return fContext->abandoned(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 190 | } |
| 191 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 192 | void GrDrawingManager::freeGpuResources() { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 193 | for (int i = fOnFlushCBObjects.count() - 1; i >= 0; --i) { |
| 194 | if (!fOnFlushCBObjects[i]->retainOnFreeGpuResources()) { |
| 195 | // it's safe to just do this because we're iterating in reverse |
| 196 | fOnFlushCBObjects.removeShuffle(i); |
| 197 | } |
| 198 | } |
| 199 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 200 | // a path renderer may be holding onto resources |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 201 | fPathRendererChain = nullptr; |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 202 | fSoftwarePathRenderer = nullptr; |
Robert Phillips | e3302df | 2017-04-24 07:31:02 -0400 | [diff] [blame] | 203 | } |
| 204 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 205 | // MDB TODO: make use of the 'proxy' parameter. |
Brian Salomon | 57d2beab | 2018-09-10 09:35:41 -0400 | [diff] [blame] | 206 | GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy*, |
| 207 | int numSemaphores, |
| 208 | GrBackendSemaphore backendSemaphores[]) { |
| 209 | GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext); |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 210 | |
robertphillips | 7761d61 | 2016-05-16 09:14:53 -0700 | [diff] [blame] | 211 | if (fFlushing || this->wasAbandoned()) { |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 212 | return GrSemaphoresSubmitted::kNo; |
joshualitt | b8918c4 | 2015-12-18 09:59:46 -0800 | [diff] [blame] | 213 | } |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 214 | SkDEBUGCODE(this->validate()); |
| 215 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 216 | GrGpu* gpu = fContext->priv().getGpu(); |
Robert Phillips | 874b535 | 2018-03-16 08:48:24 -0400 | [diff] [blame] | 217 | if (!gpu) { |
| 218 | return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording |
| 219 | } |
joshualitt | b8918c4 | 2015-12-18 09:59:46 -0800 | [diff] [blame] | 220 | fFlushing = true; |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 221 | |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 222 | // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh |
| 223 | // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed |
| 224 | // but need to be flushed anyway. Closing such GrOpLists here will mean new |
| 225 | // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 226 | fDAG.closeAll(fContext->priv().caps()); |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 227 | fActiveOpList = nullptr; |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 228 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 229 | fDAG.prepForFlush(); |
Brian Salomon | 601ac80 | 2019-02-07 13:37:16 -0500 | [diff] [blame] | 230 | if (!fCpuBufferCache) { |
| 231 | // We cache more buffers when the backend is using client side arrays. Otherwise, we |
| 232 | // expect each pool will use a CPU buffer as a staging buffer before uploading to a GPU |
| 233 | // buffer object. Each pool only requires one staging buffer at a time. |
| 234 | int maxCachedBuffers = fContext->priv().caps()->preferClientSideDynamicBuffers() ? 2 : 6; |
| 235 | fCpuBufferCache = GrBufferAllocPool::CpuBufferCache::Make(maxCachedBuffers); |
Brian Salomon | 58f153c | 2018-10-18 21:51:15 -0400 | [diff] [blame] | 236 | } |
Robert Phillips | a4c93ac | 2017-05-18 11:40:04 -0400 | [diff] [blame] | 237 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 238 | GrOpFlushState flushState(gpu, fContext->priv().resourceProvider(), &fTokenTracker, |
Brian Salomon | 601ac80 | 2019-02-07 13:37:16 -0500 | [diff] [blame] | 239 | fCpuBufferCache); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 240 | |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 241 | GrOnFlushResourceProvider onFlushProvider(this); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 242 | // TODO: AFAICT the only reason fFlushState is on GrDrawingManager rather than on the |
| 243 | // stack here is to preserve the flush tokens. |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 244 | |
Chris Dalton | 1265894 | 2017-10-05 19:45:25 -0600 | [diff] [blame] | 245 | // Prepare any onFlush op lists (e.g. atlases). |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 246 | if (!fOnFlushCBObjects.empty()) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 247 | fDAG.gatherIDs(&fFlushingOpListIDs); |
| 248 | |
Chris Dalton | 1265894 | 2017-10-05 19:45:25 -0600 | [diff] [blame] | 249 | SkSTArray<4, sk_sp<GrRenderTargetContext>> renderTargetContexts; |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 250 | for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) { |
| 251 | onFlushCBObject->preFlush(&onFlushProvider, |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 252 | fFlushingOpListIDs.begin(), fFlushingOpListIDs.count(), |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 253 | &renderTargetContexts); |
Chris Dalton | 1265894 | 2017-10-05 19:45:25 -0600 | [diff] [blame] | 254 | for (const sk_sp<GrRenderTargetContext>& rtc : renderTargetContexts) { |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 255 | sk_sp<GrRenderTargetOpList> onFlushOpList = sk_ref_sp(rtc->getRTOpList()); |
Chris Dalton | 1265894 | 2017-10-05 19:45:25 -0600 | [diff] [blame] | 256 | if (!onFlushOpList) { |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 257 | continue; // Odd - but not a big deal |
| 258 | } |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 259 | #ifdef SK_DEBUG |
| 260 | // OnFlush callbacks are already invoked during flush, and are therefore expected to |
| 261 | // handle resource allocation & usage on their own. (No deferred or lazy proxies!) |
| 262 | onFlushOpList->visitProxies_debugOnly([](GrSurfaceProxy* p) { |
| 263 | SkASSERT(!p->asTextureProxy() || !p->asTextureProxy()->texPriv().isDeferred()); |
Greg Daniel | 65fa8ca | 2018-01-10 17:06:31 -0500 | [diff] [blame] | 264 | SkASSERT(GrSurfaceProxy::LazyState::kNot == p->lazyInstantiationState()); |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 265 | }); |
| 266 | #endif |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 267 | onFlushOpList->makeClosed(*fContext->priv().caps()); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 268 | onFlushOpList->prepare(&flushState); |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 269 | fOnFlushCBOpLists.push_back(std::move(onFlushOpList)); |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 270 | } |
| 271 | renderTargetContexts.reset(); |
| 272 | } |
| 273 | } |
| 274 | |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 275 | #if 0 |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 276 | // Enable this to print out verbose GrOp information |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 277 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 278 | SkDEBUGCODE(fOpLists[i]->dump();) |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 279 | } |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 280 | #endif |
| 281 | |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 282 | int startIndex, stopIndex; |
| 283 | bool flushed = false; |
| 284 | |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 285 | { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 286 | GrResourceAllocator alloc(fContext->priv().resourceProvider(), |
Brian Salomon | 967df20 | 2018-12-07 11:15:53 -0500 | [diff] [blame] | 287 | flushState.deinstantiateProxyTracker()); |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 288 | for (int i = 0; i < fDAG.numOpLists(); ++i) { |
| 289 | if (fDAG.opList(i)) { |
| 290 | fDAG.opList(i)->gatherProxyIntervals(&alloc); |
| 291 | } |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 292 | alloc.markEndOfOpList(i); |
Robert Phillips | f8e2502 | 2017-11-08 15:24:31 -0500 | [diff] [blame] | 293 | } |
Robert Phillips | d375dbf | 2017-09-14 12:45:25 -0400 | [diff] [blame] | 294 | |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 295 | GrResourceAllocator::AssignError error = GrResourceAllocator::AssignError::kNoError; |
Greg Daniel | d207345 | 2018-12-07 11:20:33 -0500 | [diff] [blame] | 296 | int numOpListsExecuted = 0; |
Brian Salomon | 577aa0f | 2018-11-30 13:32:23 -0500 | [diff] [blame] | 297 | while (alloc.assign(&startIndex, &stopIndex, &error)) { |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 298 | if (GrResourceAllocator::AssignError::kFailedProxyInstantiation == error) { |
| 299 | for (int i = startIndex; i < stopIndex; ++i) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 300 | if (fDAG.opList(i) && !fDAG.opList(i)->isFullyInstantiated()) { |
Robert Phillips | 01a9128 | 2018-07-26 08:03:04 -0400 | [diff] [blame] | 301 | // If the backing surface wasn't allocated drop the entire opList. |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 302 | fDAG.removeOpList(i); |
Robert Phillips | 01a9128 | 2018-07-26 08:03:04 -0400 | [diff] [blame] | 303 | } |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 304 | if (fDAG.opList(i)) { |
| 305 | fDAG.opList(i)->purgeOpsWithUninstantiatedProxies(); |
Robert Phillips | bbcb7f7 | 2018-05-31 11:16:19 -0400 | [diff] [blame] | 306 | } |
Greg Daniel | aa3dfbe | 2018-01-29 10:34:25 -0500 | [diff] [blame] | 307 | } |
| 308 | } |
Robert Phillips | 4150eea | 2018-02-07 17:08:21 -0500 | [diff] [blame] | 309 | |
Greg Daniel | d207345 | 2018-12-07 11:20:33 -0500 | [diff] [blame] | 310 | if (this->executeOpLists(startIndex, stopIndex, &flushState, &numOpListsExecuted)) { |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 311 | flushed = true; |
| 312 | } |
bsalomon | dc43898 | 2016-08-31 11:53:49 -0700 | [diff] [blame] | 313 | } |
Greg Daniel | c42b20b | 2017-10-04 10:34:49 -0400 | [diff] [blame] | 314 | } |
| 315 | |
Chris Dalton | 91ab155 | 2018-04-18 13:24:25 -0600 | [diff] [blame] | 316 | #ifdef SK_DEBUG |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 317 | for (int i = 0; i < fDAG.numOpLists(); ++i) { |
Chris Dalton | 91ab155 | 2018-04-18 13:24:25 -0600 | [diff] [blame] | 318 | // If there are any remaining opLists at this point, make sure they will not survive the |
| 319 | // flush. Otherwise we need to call endFlush() on them. |
| 320 | // http://skbug.com/7111 |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 321 | SkASSERT(!fDAG.opList(i) || fDAG.opList(i)->unique()); |
Chris Dalton | 91ab155 | 2018-04-18 13:24:25 -0600 | [diff] [blame] | 322 | } |
| 323 | #endif |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 324 | fDAG.reset(); |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 325 | |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 326 | #ifdef SK_DEBUG |
| 327 | // In non-DDL mode this checks that all the flushed ops have been freed from the memory pool. |
| 328 | // When we move to partial flushes this assert will no longer be valid. |
| 329 | // In DDL mode this check is somewhat superfluous since the memory for most of the ops/opLists |
| 330 | // will be stored in the DDL's GrOpMemoryPools. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 331 | GrOpMemoryPool* opMemoryPool = fContext->priv().opMemoryPool(); |
Robert Phillips | c994a93 | 2018-06-19 13:09:54 -0400 | [diff] [blame] | 332 | opMemoryPool->isEmpty(); |
| 333 | #endif |
| 334 | |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 335 | GrSemaphoresSubmitted result = gpu->finishFlush(numSemaphores, backendSemaphores); |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 336 | |
Brian Salomon | 967df20 | 2018-12-07 11:15:53 -0500 | [diff] [blame] | 337 | flushState.deinstantiateProxyTracker()->deinstantiateAllProxies(); |
Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 338 | |
Brian Salomon | 57d2beab | 2018-09-10 09:35:41 -0400 | [diff] [blame] | 339 | // Give the cache a chance to purge resources that become purgeable due to flushing. |
| 340 | if (flushed) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 341 | fContext->priv().getResourceCache()->purgeAsNeeded(); |
bsalomon | b77a907 | 2016-09-07 10:02:04 -0700 | [diff] [blame] | 342 | } |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 343 | for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) { |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 344 | onFlushCBObject->postFlush(fTokenTracker.nextTokenToFlush(), fFlushingOpListIDs.begin(), |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 345 | fFlushingOpListIDs.count()); |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 346 | } |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 347 | fFlushingOpListIDs.reset(); |
joshualitt | b8918c4 | 2015-12-18 09:59:46 -0800 | [diff] [blame] | 348 | fFlushing = false; |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 349 | |
| 350 | return result; |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Greg Daniel | d207345 | 2018-12-07 11:20:33 -0500 | [diff] [blame] | 353 | bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushState* flushState, |
| 354 | int* numOpListsExecuted) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 355 | SkASSERT(startIndex <= stopIndex && stopIndex <= fDAG.numOpLists()); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 356 | |
Robert Phillips | 2748391 | 2018-04-20 12:43:18 -0400 | [diff] [blame] | 357 | #if GR_FLUSH_TIME_OP_SPEW |
| 358 | SkDebugf("Flushing opLists: %d to %d out of [%d, %d]\n", |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 359 | startIndex, stopIndex, 0, fDAG.numOpLists()); |
Robert Phillips | 2748391 | 2018-04-20 12:43:18 -0400 | [diff] [blame] | 360 | for (int i = startIndex; i < stopIndex; ++i) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 361 | if (fDAG.opList(i)) { |
| 362 | fDAG.opList(i)->dump(true); |
Robert Phillips | 1734dd3 | 2018-08-21 13:52:09 -0400 | [diff] [blame] | 363 | } |
Robert Phillips | 2748391 | 2018-04-20 12:43:18 -0400 | [diff] [blame] | 364 | } |
| 365 | #endif |
| 366 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 367 | GrResourceProvider* resourceProvider = fContext->priv().resourceProvider(); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 368 | bool anyOpListsExecuted = false; |
| 369 | |
| 370 | for (int i = startIndex; i < stopIndex; ++i) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 371 | if (!fDAG.opList(i)) { |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 372 | continue; |
| 373 | } |
| 374 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 375 | GrOpList* opList = fDAG.opList(i); |
| 376 | |
Robert Phillips | 4150eea | 2018-02-07 17:08:21 -0500 | [diff] [blame] | 377 | if (resourceProvider->explicitlyAllocateGPUResources()) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 378 | if (!opList->isFullyInstantiated()) { |
Robert Phillips | 4150eea | 2018-02-07 17:08:21 -0500 | [diff] [blame] | 379 | // If the backing surface wasn't allocated drop the draw of the entire opList. |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 380 | fDAG.removeOpList(i); |
Robert Phillips | 4150eea | 2018-02-07 17:08:21 -0500 | [diff] [blame] | 381 | continue; |
| 382 | } |
| 383 | } else { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 384 | if (!opList->instantiate(resourceProvider)) { |
| 385 | fDAG.removeOpList(i); |
Robert Phillips | 4150eea | 2018-02-07 17:08:21 -0500 | [diff] [blame] | 386 | continue; |
| 387 | } |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 388 | } |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 389 | |
| 390 | // TODO: handle this instantiation via lazy surface proxies? |
| 391 | // Instantiate all deferred proxies (being built on worker threads) so we can upload them |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 392 | opList->instantiateDeferredProxies(fContext->priv().resourceProvider()); |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 393 | opList->prepare(flushState); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | // Upload all data to the GPU |
| 397 | flushState->preExecuteDraws(); |
| 398 | |
Greg Daniel | d207345 | 2018-12-07 11:20:33 -0500 | [diff] [blame] | 399 | // For Vulkan, if we have too many oplists to be flushed we end up allocating a lot of resources |
| 400 | // for each command buffer associated with the oplists. If this gets too large we can cause the |
| 401 | // devices to go OOM. In practice we usually only hit this case in our tests, but to be safe we |
| 402 | // put a cap on the number of oplists we will execute before flushing to the GPU to relieve some |
| 403 | // memory pressure. |
| 404 | static constexpr int kMaxOpListsBeforeFlush = 100; |
| 405 | |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 406 | // Execute the onFlush op lists first, if any. |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 407 | for (sk_sp<GrOpList>& onFlushOpList : fOnFlushCBOpLists) { |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 408 | if (!onFlushOpList->execute(flushState)) { |
| 409 | SkDebugf("WARNING: onFlushOpList failed to execute.\n"); |
| 410 | } |
| 411 | SkASSERT(onFlushOpList->unique()); |
| 412 | onFlushOpList = nullptr; |
Greg Daniel | d207345 | 2018-12-07 11:20:33 -0500 | [diff] [blame] | 413 | (*numOpListsExecuted)++; |
| 414 | if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) { |
| 415 | flushState->gpu()->finishFlush(0, nullptr); |
| 416 | *numOpListsExecuted = 0; |
| 417 | } |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 418 | } |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 419 | fOnFlushCBOpLists.reset(); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 420 | |
| 421 | // Execute the normal op lists. |
| 422 | for (int i = startIndex; i < stopIndex; ++i) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 423 | if (!fDAG.opList(i)) { |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 424 | continue; |
| 425 | } |
| 426 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 427 | if (fDAG.opList(i)->execute(flushState)) { |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 428 | anyOpListsExecuted = true; |
| 429 | } |
Greg Daniel | d207345 | 2018-12-07 11:20:33 -0500 | [diff] [blame] | 430 | (*numOpListsExecuted)++; |
| 431 | if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) { |
| 432 | flushState->gpu()->finishFlush(0, nullptr); |
| 433 | *numOpListsExecuted = 0; |
| 434 | } |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | SkASSERT(!flushState->commandBuffer()); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 438 | SkASSERT(fTokenTracker.nextDrawToken() == fTokenTracker.nextTokenToFlush()); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 439 | |
| 440 | // We reset the flush state before the OpLists so that the last resources to be freed are those |
| 441 | // that are written to in the OpLists. This helps to make sure the most recently used resources |
| 442 | // are the last to be purged by the resource cache. |
| 443 | flushState->reset(); |
| 444 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 445 | fDAG.removeOpLists(startIndex, stopIndex); |
Robert Phillips | eafd48a | 2017-11-16 07:52:08 -0500 | [diff] [blame] | 446 | |
| 447 | return anyOpListsExecuted; |
| 448 | } |
| 449 | |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 450 | GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO( |
| 451 | GrSurfaceProxy* proxy, int numSemaphores, GrBackendSemaphore backendSemaphores[]) { |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 452 | if (this->wasAbandoned()) { |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 453 | return GrSemaphoresSubmitted::kNo; |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 454 | } |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 455 | SkDEBUGCODE(this->validate()); |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 456 | SkASSERT(proxy); |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 457 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 458 | GrGpu* gpu = fContext->priv().getGpu(); |
Robert Phillips | 874b535 | 2018-03-16 08:48:24 -0400 | [diff] [blame] | 459 | if (!gpu) { |
| 460 | return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording |
| 461 | } |
| 462 | |
Kevin Lubick | 4284613 | 2018-01-05 10:11:11 -0500 | [diff] [blame] | 463 | GrSemaphoresSubmitted result = GrSemaphoresSubmitted::kNo; |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 464 | if (proxy->priv().hasPendingIO() || numSemaphores) { |
| 465 | result = this->flush(proxy, numSemaphores, backendSemaphores); |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 466 | } |
| 467 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 468 | if (!proxy->instantiate(fContext->priv().resourceProvider())) { |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 469 | return result; |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 470 | } |
| 471 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 472 | GrSurface* surface = proxy->peekSurface(); |
Brian Salomon | 930f939 | 2018-06-20 16:25:26 -0400 | [diff] [blame] | 473 | if (auto* rt = surface->asRenderTarget()) { |
| 474 | gpu->resolveRenderTarget(rt); |
| 475 | } |
| 476 | if (auto* tex = surface->asTexture()) { |
| 477 | if (tex->texturePriv().mipMapped() == GrMipMapped::kYes && |
| 478 | tex->texturePriv().mipMapsAreDirty()) { |
| 479 | gpu->regenerateMipMapLevels(tex); |
| 480 | } |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 481 | } |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 482 | |
| 483 | SkDEBUGCODE(this->validate()); |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 484 | return result; |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 485 | } |
| 486 | |
Chris Dalton | fe199b7 | 2017-05-05 11:26:15 -0400 | [diff] [blame] | 487 | void GrDrawingManager::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) { |
| 488 | fOnFlushCBObjects.push_back(onFlushCBObject); |
Robert Phillips | eb35f4d | 2017-03-21 07:56:47 -0400 | [diff] [blame] | 489 | } |
| 490 | |
Robert Phillips | dbaf317 | 2019-02-06 15:12:53 -0500 | [diff] [blame] | 491 | #if GR_TEST_UTILS |
| 492 | void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallbackObject* cb) { |
| 493 | int n = std::find(fOnFlushCBObjects.begin(), fOnFlushCBObjects.end(), cb) - |
| 494 | fOnFlushCBObjects.begin(); |
| 495 | SkASSERT(n < fOnFlushCBObjects.count()); |
| 496 | fOnFlushCBObjects.removeShuffle(n); |
| 497 | } |
| 498 | #endif |
| 499 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 500 | void GrDrawingManager::moveOpListsToDDL(SkDeferredDisplayList* ddl) { |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 501 | SkDEBUGCODE(this->validate()); |
| 502 | |
| 503 | // no opList should receive a new command after this |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 504 | fDAG.closeAll(fContext->priv().caps()); |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 505 | fActiveOpList = nullptr; |
Robert Phillips | 7a13705 | 2018-02-01 11:23:12 -0500 | [diff] [blame] | 506 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 507 | fDAG.swap(&ddl->fOpLists); |
Robert Phillips | 867ce8f | 2018-06-21 10:28:36 -0400 | [diff] [blame] | 508 | |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 509 | if (fPathRendererChain) { |
| 510 | if (auto ccpr = fPathRendererChain->getCoverageCountingPathRenderer()) { |
| 511 | ddl->fPendingPaths = ccpr->detachPendingPaths(); |
| 512 | } |
| 513 | } |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 514 | |
| 515 | SkDEBUGCODE(this->validate()); |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | void GrDrawingManager::copyOpListsFromDDL(const SkDeferredDisplayList* ddl, |
| 519 | GrRenderTargetProxy* newDest) { |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 520 | SkDEBUGCODE(this->validate()); |
| 521 | |
| 522 | if (fActiveOpList) { |
| 523 | // This is a temporary fix for the partial-MDB world. In that world we're not |
| 524 | // reordering so ops that (in the single opList world) would've just glommed onto the |
| 525 | // end of the single opList but referred to a far earlier RT need to appear in their |
| 526 | // own opList. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 527 | fActiveOpList->makeClosed(*fContext->priv().caps()); |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 528 | fActiveOpList = nullptr; |
| 529 | } |
| 530 | |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 531 | // Here we jam the proxy that backs the current replay SkSurface into the LazyProxyData. |
| 532 | // The lazy proxy that references it (in the copied opLists) will steal its GrTexture. |
| 533 | ddl->fLazyProxyData->fReplayDest = newDest; |
Robert Phillips | 774168e | 2018-05-31 12:43:27 -0400 | [diff] [blame] | 534 | |
| 535 | if (ddl->fPendingPaths.size()) { |
| 536 | GrCoverageCountingPathRenderer* ccpr = this->getCoverageCountingPathRenderer(); |
| 537 | |
| 538 | ccpr->mergePendingPaths(ddl->fPendingPaths); |
| 539 | } |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 540 | |
| 541 | fDAG.add(ddl->fOpLists); |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 542 | |
| 543 | SkDEBUGCODE(this->validate()); |
Robert Phillips | 6200036 | 2018-02-01 09:10:04 -0500 | [diff] [blame] | 544 | } |
| 545 | |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 546 | #ifdef SK_DEBUG |
| 547 | void GrDrawingManager::validate() const { |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 548 | if (fDAG.sortingOpLists() && fReduceOpListSplitting) { |
| 549 | SkASSERT(!fActiveOpList); |
| 550 | } else { |
| 551 | if (fActiveOpList) { |
| 552 | SkASSERT(!fDAG.empty()); |
| 553 | SkASSERT(!fActiveOpList->isClosed()); |
| 554 | SkASSERT(fActiveOpList == fDAG.back()); |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 555 | } |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 556 | |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 557 | for (int i = 0; i < fDAG.numOpLists(); ++i) { |
| 558 | if (fActiveOpList != fDAG.opList(i)) { |
| 559 | SkASSERT(fDAG.opList(i)->isClosed()); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | if (!fDAG.empty() && !fDAG.back()->isClosed()) { |
| 564 | SkASSERT(fActiveOpList == fDAG.back()); |
| 565 | } |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 566 | } |
| 567 | } |
| 568 | #endif |
| 569 | |
Robert Phillips | 941d144 | 2017-06-14 16:37:02 -0400 | [diff] [blame] | 570 | sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(GrRenderTargetProxy* rtp, |
| 571 | bool managedOpList) { |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 572 | SkDEBUGCODE(this->validate()); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 573 | SkASSERT(fContext); |
| 574 | |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 575 | if (fDAG.sortingOpLists() && fReduceOpListSplitting) { |
| 576 | // In this case we need to close all the opLists that rely on the current contents of |
| 577 | // 'rtp'. That is bc we're going to update the content of the proxy so they need to be |
| 578 | // split in case they use both the old and new content. (This is a bit of an overkill: |
| 579 | // they really only need to be split if they ever reference proxy's contents again but |
| 580 | // that is hard to predict/handle). |
| 581 | if (GrOpList* lastOpList = rtp->getLastOpList()) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 582 | lastOpList->closeThoseWhoDependOnMe(*fContext->priv().caps()); |
Robert Phillips | 46acf9d | 2018-10-09 09:31:40 -0400 | [diff] [blame] | 583 | } |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 584 | } else if (fActiveOpList) { |
| 585 | // This is a temporary fix for the partial-MDB world. In that world we're not |
| 586 | // reordering so ops that (in the single opList world) would've just glommed onto the |
| 587 | // end of the single opList but referred to a far earlier RT need to appear in their |
| 588 | // own opList. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 589 | fActiveOpList->makeClosed(*fContext->priv().caps()); |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 590 | fActiveOpList = nullptr; |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 591 | } |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 592 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 593 | auto resourceProvider = fContext->priv().resourceProvider(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 594 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 595 | sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList( |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 596 | resourceProvider, |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 597 | fContext->priv().refOpMemoryPool(), |
Robert Phillips | 3a9710b | 2018-03-27 17:51:55 -0400 | [diff] [blame] | 598 | rtp, |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 599 | fContext->priv().auditTrail())); |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 600 | SkASSERT(rtp->getLastOpList() == opList.get()); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 601 | |
Robert Phillips | 941d144 | 2017-06-14 16:37:02 -0400 | [diff] [blame] | 602 | if (managedOpList) { |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 603 | fDAG.add(opList); |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 604 | |
| 605 | if (!fDAG.sortingOpLists() || !fReduceOpListSplitting) { |
| 606 | fActiveOpList = opList.get(); |
| 607 | } |
Robert Phillips | 941d144 | 2017-06-14 16:37:02 -0400 | [diff] [blame] | 608 | } |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 609 | |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 610 | SkDEBUGCODE(this->validate()); |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 611 | return opList; |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 612 | } |
| 613 | |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 614 | sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(GrTextureProxy* textureProxy) { |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 615 | SkDEBUGCODE(this->validate()); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 616 | SkASSERT(fContext); |
| 617 | |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 618 | if (fDAG.sortingOpLists() && fReduceOpListSplitting) { |
| 619 | // In this case we need to close all the opLists that rely on the current contents of |
| 620 | // 'texture'. That is bc we're going to update the content of the proxy so they need to |
| 621 | // be split in case they use both the old and new content. (This is a bit of an |
| 622 | // overkill: they really only need to be split if they ever reference proxy's contents |
| 623 | // again but that is hard to predict/handle). |
| 624 | if (GrOpList* lastOpList = textureProxy->getLastOpList()) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 625 | lastOpList->closeThoseWhoDependOnMe(*fContext->priv().caps()); |
Robert Phillips | 46acf9d | 2018-10-09 09:31:40 -0400 | [diff] [blame] | 626 | } |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 627 | } else if (fActiveOpList) { |
| 628 | // This is a temporary fix for the partial-MDB world. In that world we're not |
| 629 | // reordering so ops that (in the single opList world) would've just glommed onto the |
| 630 | // end of the single opList but referred to a far earlier RT need to appear in their |
| 631 | // own opList. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 632 | fActiveOpList->makeClosed(*fContext->priv().caps()); |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 633 | fActiveOpList = nullptr; |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 634 | } |
| 635 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 636 | sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->priv().resourceProvider(), |
| 637 | fContext->priv().refOpMemoryPool(), |
Robert Phillips | 5efd5ea | 2017-05-30 13:47:32 -0400 | [diff] [blame] | 638 | textureProxy, |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 639 | fContext->priv().auditTrail())); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 640 | |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 641 | SkASSERT(textureProxy->getLastOpList() == opList.get()); |
Robert Phillips | 4a39504 | 2017-04-24 16:27:17 +0000 | [diff] [blame] | 642 | |
Robert Phillips | 22310d6 | 2018-09-05 11:07:21 -0400 | [diff] [blame] | 643 | fDAG.add(opList); |
Robert Phillips | b7a98ef | 2018-10-10 09:26:00 -0400 | [diff] [blame] | 644 | if (!fDAG.sortingOpLists() || !fReduceOpListSplitting) { |
| 645 | fActiveOpList = opList.get(); |
| 646 | } |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 647 | |
Robert Phillips | 38d64b0 | 2018-09-04 13:23:26 -0400 | [diff] [blame] | 648 | SkDEBUGCODE(this->validate()); |
Robert Phillips | 4a39504 | 2017-04-24 16:27:17 +0000 | [diff] [blame] | 649 | return opList; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 650 | } |
| 651 | |
Herb Derby | 26cbe51 | 2018-05-24 14:39:01 -0400 | [diff] [blame] | 652 | GrTextContext* GrDrawingManager::getTextContext() { |
| 653 | if (!fTextContext) { |
| 654 | fTextContext = GrTextContext::Make(fOptionsForTextContext); |
brianosman | 86e7626 | 2016-08-11 12:17:31 -0700 | [diff] [blame] | 655 | } |
| 656 | |
Herb Derby | 26cbe51 | 2018-05-24 14:39:01 -0400 | [diff] [blame] | 657 | return fTextContext.get(); |
brianosman | 86e7626 | 2016-08-11 12:17:31 -0700 | [diff] [blame] | 658 | } |
| 659 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 660 | /* |
| 661 | * This method finds a path renderer that can draw the specified path on |
| 662 | * the provided target. |
| 663 | * Due to its expense, the software path renderer has split out so it can |
| 664 | * can be individually allowed/disallowed via the "allowSW" boolean. |
| 665 | */ |
| 666 | GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
| 667 | bool allowSW, |
| 668 | GrPathRendererChain::DrawType drawType, |
| 669 | GrPathRenderer::StencilSupport* stencilSupport) { |
| 670 | |
| 671 | if (!fPathRendererChain) { |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 672 | fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain)); |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport); |
| 676 | if (!pr && allowSW) { |
Brian Salomon | e7df0bb | 2018-05-07 14:44:57 -0400 | [diff] [blame] | 677 | auto swPR = this->getSoftwarePathRenderer(); |
| 678 | if (GrPathRenderer::CanDrawPath::kNo != swPR->canDrawPath(args)) { |
| 679 | pr = swPR; |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 680 | } |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | return pr; |
| 684 | } |
| 685 | |
Brian Salomon | e7df0bb | 2018-05-07 14:44:57 -0400 | [diff] [blame] | 686 | GrPathRenderer* GrDrawingManager::getSoftwarePathRenderer() { |
| 687 | if (!fSoftwarePathRenderer) { |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 688 | fSoftwarePathRenderer.reset( |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 689 | new GrSoftwarePathRenderer(fContext->priv().proxyProvider(), |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 690 | fOptionsForPathRendererChain.fAllowPathMaskCaching)); |
Brian Salomon | e7df0bb | 2018-05-07 14:44:57 -0400 | [diff] [blame] | 691 | } |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 692 | return fSoftwarePathRenderer.get(); |
Brian Salomon | e7df0bb | 2018-05-07 14:44:57 -0400 | [diff] [blame] | 693 | } |
| 694 | |
Chris Dalton | fddb6c0 | 2017-11-04 15:22:22 -0600 | [diff] [blame] | 695 | GrCoverageCountingPathRenderer* GrDrawingManager::getCoverageCountingPathRenderer() { |
| 696 | if (!fPathRendererChain) { |
Ben Wagner | 9ec70c6 | 2018-07-12 13:30:47 -0400 | [diff] [blame] | 697 | fPathRendererChain.reset(new GrPathRendererChain(fContext, fOptionsForPathRendererChain)); |
Chris Dalton | fddb6c0 | 2017-11-04 15:22:22 -0600 | [diff] [blame] | 698 | } |
| 699 | return fPathRendererChain->getCoverageCountingPathRenderer(); |
| 700 | } |
| 701 | |
Brian Salomon | 653f42f | 2018-07-10 10:07:31 -0400 | [diff] [blame] | 702 | void GrDrawingManager::flushIfNecessary() { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 703 | GrResourceCache* resourceCache = fContext->priv().getResourceCache(); |
Brian Salomon | 653f42f | 2018-07-10 10:07:31 -0400 | [diff] [blame] | 704 | if (resourceCache && resourceCache->requestsFlush()) { |
Brian Salomon | 57d2beab | 2018-09-10 09:35:41 -0400 | [diff] [blame] | 705 | this->flush(nullptr, 0, nullptr); |
| 706 | resourceCache->purgeAsNeeded(); |
Brian Salomon | 653f42f | 2018-07-10 10:07:31 -0400 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 710 | sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext( |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 711 | sk_sp<GrSurfaceProxy> sProxy, |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 712 | sk_sp<SkColorSpace> colorSpace, |
Robert Phillips | 941d144 | 2017-06-14 16:37:02 -0400 | [diff] [blame] | 713 | const SkSurfaceProps* surfaceProps, |
| 714 | bool managedOpList) { |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 715 | if (this->wasAbandoned() || !sProxy->asRenderTargetProxy()) { |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 716 | return nullptr; |
| 717 | } |
| 718 | |
brianosman | 0e22eb8 | 2016-08-30 07:07:59 -0700 | [diff] [blame] | 719 | // SkSurface catches bad color space usage at creation. This check handles anything that slips |
Brian Salomon | 366093f | 2018-02-13 09:25:22 -0500 | [diff] [blame] | 720 | // by, including internal usage. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 721 | if (!SkSurface_Gpu::Valid(fContext->priv().caps(), sProxy->config(), colorSpace.get())) { |
brianosman | a9c3c6a | 2016-09-29 10:08:36 -0700 | [diff] [blame] | 722 | SkDEBUGFAIL("Invalid config and colorspace combination"); |
brianosman | 0e22eb8 | 2016-08-30 07:07:59 -0700 | [diff] [blame] | 723 | return nullptr; |
| 724 | } |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 725 | |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 726 | sk_sp<GrRenderTargetProxy> rtp(sk_ref_sp(sProxy->asRenderTargetProxy())); |
| 727 | |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 728 | return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext( |
| 729 | fContext, this, std::move(rtp), |
| 730 | std::move(colorSpace), |
| 731 | surfaceProps, |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 732 | fContext->priv().auditTrail(), |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 733 | fSingleOwner, managedOpList)); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 734 | } |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 735 | |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 736 | sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy, |
| 737 | sk_sp<SkColorSpace> colorSpace) { |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 738 | if (this->wasAbandoned() || !sProxy->asTextureProxy()) { |
| 739 | return nullptr; |
| 740 | } |
| 741 | |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 742 | // SkSurface catches bad color space usage at creation. This check handles anything that slips |
Brian Salomon | 366093f | 2018-02-13 09:25:22 -0500 | [diff] [blame] | 743 | // by, including internal usage. |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 744 | if (!SkSurface_Gpu::Valid(fContext->priv().caps(), sProxy->config(), colorSpace.get())) { |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 745 | SkDEBUGFAIL("Invalid config and colorspace combination"); |
| 746 | return nullptr; |
| 747 | } |
| 748 | |
Robert Phillips | 383c418 | 2018-02-07 12:47:44 -0500 | [diff] [blame] | 749 | // GrTextureRenderTargets should always be using a GrRenderTargetContext |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 750 | SkASSERT(!sProxy->asRenderTargetProxy()); |
| 751 | |
| 752 | sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy())); |
| 753 | |
| 754 | return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy), |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 755 | std::move(colorSpace), |
Robert Phillips | d684148 | 2019-02-08 10:29:20 -0500 | [diff] [blame] | 756 | fContext->priv().auditTrail(), |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 757 | fSingleOwner)); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 758 | } |