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" |
bsalomon | b77a907 | 2016-09-07 10:02:04 -0700 | [diff] [blame] | 9 | |
| 10 | #include "GrContext.h" |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 11 | #include "GrRenderTargetContext.h" |
| 12 | #include "GrPathRenderingRenderTargetContext.h" |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 13 | #include "GrRenderTargetProxy.h" |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 14 | #include "GrResourceProvider.h" |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 15 | #include "GrSoftwarePathRenderer.h" |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 16 | #include "GrSurfacePriv.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 17 | #include "GrTextureContext.h" |
| 18 | #include "GrTextureOpList.h" |
brianosman | 0e22eb8 | 2016-08-30 07:07:59 -0700 | [diff] [blame] | 19 | #include "SkSurface_Gpu.h" |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 20 | #include "SkTTopoSort.h" |
| 21 | |
joshualitt | e804292 | 2015-12-11 06:11:21 -0800 | [diff] [blame] | 22 | #include "text/GrAtlasTextContext.h" |
| 23 | #include "text/GrStencilAndCoverTextContext.h" |
robertphillips | 498d7ac | 2015-10-30 10:11:30 -0700 | [diff] [blame] | 24 | |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 25 | void GrDrawingManager::cleanup() { |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 26 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 27 | fOpLists[i]->makeClosed(); // no opList should receive a new command after this |
| 28 | fOpLists[i]->clearTarget(); |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 29 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 30 | // We shouldn't need to do this, but it turns out some clients still hold onto opLists |
joshualitt | 20ccd40 | 2016-01-05 08:56:56 -0800 | [diff] [blame] | 31 | // after a cleanup |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 32 | fOpLists[i]->reset(); |
| 33 | fOpLists[i]->unref(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 36 | fOpLists.reset(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 37 | |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 38 | delete fPathRendererChain; |
| 39 | fPathRendererChain = nullptr; |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 40 | SkSafeSetNull(fSoftwarePathRenderer); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | GrDrawingManager::~GrDrawingManager() { |
| 44 | this->cleanup(); |
| 45 | } |
| 46 | |
| 47 | void GrDrawingManager::abandon() { |
| 48 | fAbandoned = true; |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 49 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 50 | fOpLists[i]->abandonGpuResources(); |
csmartdalton | a7f2964 | 2016-07-07 08:49:11 -0700 | [diff] [blame] | 51 | } |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 52 | this->cleanup(); |
| 53 | } |
| 54 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 55 | void GrDrawingManager::freeGpuResources() { |
| 56 | // a path renderer may be holding onto resources |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 57 | delete fPathRendererChain; |
| 58 | fPathRendererChain = nullptr; |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 59 | SkSafeSetNull(fSoftwarePathRenderer); |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 60 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 61 | fOpLists[i]->freeGpuResources(); |
csmartdalton | a7f2964 | 2016-07-07 08:49:11 -0700 | [diff] [blame] | 62 | } |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 63 | } |
| 64 | |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 65 | void GrDrawingManager::reset() { |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 66 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 67 | fOpLists[i]->reset(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 68 | } |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 69 | fFlushState.reset(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 70 | } |
| 71 | |
bsalomon | b77a907 | 2016-09-07 10:02:04 -0700 | [diff] [blame] | 72 | void GrDrawingManager::internalFlush(GrResourceCache::FlushType type) { |
robertphillips | 7761d61 | 2016-05-16 09:14:53 -0700 | [diff] [blame] | 73 | if (fFlushing || this->wasAbandoned()) { |
bsalomon | b77a907 | 2016-09-07 10:02:04 -0700 | [diff] [blame] | 74 | return; |
joshualitt | b8918c4 | 2015-12-18 09:59:46 -0800 | [diff] [blame] | 75 | } |
| 76 | fFlushing = true; |
bsalomon | dc43898 | 2016-08-31 11:53:49 -0700 | [diff] [blame] | 77 | bool flushed = false; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 78 | SkDEBUGCODE(bool result =) |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 79 | SkTTopoSort<GrOpList, GrOpList::TopoSortTraits>(&fOpLists); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 80 | SkASSERT(result); |
| 81 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 82 | for (int i = 0; i < fOpLists.count(); ++i) { |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 83 | fOpLists[i]->prepareOps(&fFlushState); |
robertphillips | 27fe1f8 | 2016-06-29 13:43:22 -0700 | [diff] [blame] | 84 | } |
| 85 | |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 86 | #if 0 |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame^] | 87 | // Enable this to print out verbose GrOp information |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 88 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 89 | SkDEBUGCODE(fOpLists[i]->dump();) |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 90 | } |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 91 | #endif |
| 92 | |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 93 | // Upload all data to the GPU |
| 94 | fFlushState.preIssueDraws(); |
| 95 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 96 | for (int i = 0; i < fOpLists.count(); ++i) { |
Brian Salomon | 1e41f4a | 2016-12-07 15:05:04 -0500 | [diff] [blame] | 97 | if (fOpLists[i]->executeOps(&fFlushState)) { |
bsalomon | dc43898 | 2016-08-31 11:53:49 -0700 | [diff] [blame] | 98 | flushed = true; |
| 99 | } |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 100 | } |
| 101 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 102 | SkASSERT(fFlushState.nextDrawToken() == fFlushState.nextTokenToFlush()); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 103 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 104 | for (int i = 0; i < fOpLists.count(); ++i) { |
| 105 | fOpLists[i]->reset(); |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 106 | #ifdef ENABLE_MDB |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 107 | fOpLists[i]->unref(); |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 108 | #endif |
| 109 | } |
| 110 | |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 111 | #ifndef ENABLE_MDB |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 112 | // When MDB is disabled we keep reusing the same GrOpList |
| 113 | if (fOpLists.count()) { |
| 114 | SkASSERT(fOpLists.count() == 1); |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 115 | // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnmarked check |
| 116 | // won't bark |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 117 | fOpLists[0]->resetFlag(GrOpList::kWasOutput_Flag); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 118 | } |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 119 | #else |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 120 | fOpLists.reset(); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 121 | #endif |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 122 | |
robertphillips | a13e202 | 2015-11-11 12:01:09 -0800 | [diff] [blame] | 123 | fFlushState.reset(); |
robertphillips | ee843b2 | 2016-10-04 05:30:20 -0700 | [diff] [blame] | 124 | // We always have to notify the cache when it requested a flush so it can reset its state. |
| 125 | if (flushed || type == GrResourceCache::FlushType::kCacheRequested) { |
bsalomon | b77a907 | 2016-09-07 10:02:04 -0700 | [diff] [blame] | 126 | fContext->getResourceCache()->notifyFlushOccurred(type); |
| 127 | } |
joshualitt | b8918c4 | 2015-12-18 09:59:46 -0800 | [diff] [blame] | 128 | fFlushing = false; |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 129 | } |
| 130 | |
bsalomon | 6a2b194 | 2016-09-08 11:28:59 -0700 | [diff] [blame] | 131 | void GrDrawingManager::prepareSurfaceForExternalIO(GrSurface* surface) { |
| 132 | if (this->wasAbandoned()) { |
| 133 | return; |
| 134 | } |
| 135 | SkASSERT(surface); |
| 136 | SkASSERT(surface->getContext() == fContext); |
| 137 | |
| 138 | if (surface->surfacePriv().hasPendingIO()) { |
| 139 | this->flush(); |
| 140 | } |
| 141 | |
| 142 | GrRenderTarget* rt = surface->asRenderTarget(); |
| 143 | if (fContext->getGpu() && rt) { |
| 144 | fContext->getGpu()->resolveRenderTarget(rt); |
| 145 | } |
| 146 | } |
| 147 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 148 | GrRenderTargetOpList* GrDrawingManager::newOpList(GrRenderTargetProxy* rtp) { |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 149 | SkASSERT(fContext); |
| 150 | |
| 151 | #ifndef ENABLE_MDB |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 152 | // When MDB is disabled we always just return the single GrOpList |
| 153 | if (fOpLists.count()) { |
| 154 | SkASSERT(fOpLists.count() == 1); |
| 155 | // In the non-MDB-world the same GrOpList gets reused for multiple render targets. |
robertphillips | 0dfa62c | 2015-11-16 06:23:31 -0800 | [diff] [blame] | 156 | // Update this pointer so all the asserts are happy |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 157 | rtp->setLastOpList(fOpLists[0]); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 158 | // DrawingManager gets the creation ref - this ref is for the caller |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 159 | |
| 160 | // TODO: although this is true right now it isn't cool |
| 161 | return SkRef((GrRenderTargetOpList*) fOpLists[0]); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 162 | } |
| 163 | #endif |
| 164 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 165 | GrRenderTargetOpList* opList = new GrRenderTargetOpList(rtp, |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 166 | fContext->getGpu(), |
| 167 | fContext->resourceProvider(), |
| 168 | fContext->getAuditTrail(), |
| 169 | fOptionsForOpLists); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 170 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 171 | *fOpLists.append() = opList; |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 172 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 173 | // DrawingManager gets the creation ref - this ref is for the caller |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 174 | return SkRef(opList); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 177 | GrTextureOpList* GrDrawingManager::newOpList(GrTextureProxy* textureProxy) { |
| 178 | SkASSERT(fContext); |
| 179 | |
| 180 | GrTextureOpList* opList = new GrTextureOpList(textureProxy, fContext->getGpu(), |
| 181 | fContext->getAuditTrail()); |
| 182 | |
| 183 | #ifndef ENABLE_MDB |
| 184 | // When MDB is disabled we still create a new GrOpList, but don't store or ref it - we rely |
| 185 | // on the caller to immediately execute and free it. |
| 186 | return opList; |
| 187 | #else |
| 188 | *fOpLists.append() = opList; |
| 189 | |
| 190 | // Drawing manager gets the creation ref - this ref is for the caller |
| 191 | return SkRef(opList); |
| 192 | #endif |
| 193 | } |
| 194 | |
brianosman | 86e7626 | 2016-08-11 12:17:31 -0700 | [diff] [blame] | 195 | GrAtlasTextContext* GrDrawingManager::getAtlasTextContext() { |
| 196 | if (!fAtlasTextContext) { |
| 197 | fAtlasTextContext.reset(GrAtlasTextContext::Create()); |
| 198 | } |
| 199 | |
| 200 | return fAtlasTextContext.get(); |
| 201 | } |
| 202 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 203 | /* |
| 204 | * This method finds a path renderer that can draw the specified path on |
| 205 | * the provided target. |
| 206 | * Due to its expense, the software path renderer has split out so it can |
| 207 | * can be individually allowed/disallowed via the "allowSW" boolean. |
| 208 | */ |
| 209 | GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
| 210 | bool allowSW, |
| 211 | GrPathRendererChain::DrawType drawType, |
| 212 | GrPathRenderer::StencilSupport* stencilSupport) { |
| 213 | |
| 214 | if (!fPathRendererChain) { |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 215 | fPathRendererChain = new GrPathRendererChain(fContext, fOptionsForPathRendererChain); |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport); |
| 219 | if (!pr && allowSW) { |
| 220 | if (!fSoftwarePathRenderer) { |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 221 | fSoftwarePathRenderer = |
| 222 | new GrSoftwarePathRenderer(fContext->textureProvider(), |
| 223 | fOptionsForPathRendererChain.fAllowPathMaskCaching); |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 224 | } |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 225 | if (fSoftwarePathRenderer->canDrawPath(args)) { |
| 226 | pr = fSoftwarePathRenderer; |
| 227 | } |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | return pr; |
| 231 | } |
| 232 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 233 | sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext( |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 234 | sk_sp<GrSurfaceProxy> sProxy, |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 235 | sk_sp<SkColorSpace> colorSpace, |
| 236 | const SkSurfaceProps* surfaceProps) { |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 237 | if (this->wasAbandoned() || !sProxy->asRenderTargetProxy()) { |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 238 | return nullptr; |
| 239 | } |
| 240 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 241 | sk_sp<GrRenderTargetProxy> rtp(sk_ref_sp(sProxy->asRenderTargetProxy())); |
| 242 | |
brianosman | 0e22eb8 | 2016-08-30 07:07:59 -0700 | [diff] [blame] | 243 | // SkSurface catches bad color space usage at creation. This check handles anything that slips |
| 244 | // by, including internal usage. We allow a null color space here, for read/write pixels and |
| 245 | // other special code paths. If a color space is provided, though, enforce all other rules. |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 246 | if (colorSpace && !SkSurface_Gpu::Valid(fContext, rtp->config(), colorSpace.get())) { |
brianosman | a9c3c6a | 2016-09-29 10:08:36 -0700 | [diff] [blame] | 247 | SkDEBUGFAIL("Invalid config and colorspace combination"); |
brianosman | 0e22eb8 | 2016-08-30 07:07:59 -0700 | [diff] [blame] | 248 | return nullptr; |
| 249 | } |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 250 | |
| 251 | bool useDIF = false; |
| 252 | if (surfaceProps) { |
| 253 | useDIF = surfaceProps->isUseDeviceIndependentFonts(); |
| 254 | } |
| 255 | |
| 256 | if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 257 | rtp->isStencilBufferMultisampled()) { |
| 258 | // TODO: defer stencil buffer attachment for PathRenderingDrawContext |
| 259 | sk_sp<GrRenderTarget> rt(sk_ref_sp(rtp->instantiate(fContext->textureProvider()))); |
Robert Phillips | e60ad62 | 2016-11-17 10:22:48 -0500 | [diff] [blame] | 260 | if (!rt) { |
| 261 | return nullptr; |
| 262 | } |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 263 | GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAttachment(rt.get()); |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 264 | if (sb) { |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 265 | return sk_sp<GrRenderTargetContext>(new GrPathRenderingRenderTargetContext( |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 266 | fContext, this, std::move(rtp), |
brianosman | dfe4f2e | 2016-07-21 13:28:36 -0700 | [diff] [blame] | 267 | std::move(colorSpace), surfaceProps, |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 268 | fContext->getAuditTrail(), fSingleOwner)); |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 272 | return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext, this, std::move(rtp), |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 273 | std::move(colorSpace), |
| 274 | surfaceProps, |
| 275 | fContext->getAuditTrail(), |
| 276 | fSingleOwner)); |
robertphillips | 3dc6ae5 | 2015-10-20 09:54:32 -0700 | [diff] [blame] | 277 | } |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 278 | |
| 279 | sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy) { |
| 280 | if (this->wasAbandoned() || !sProxy->asTextureProxy()) { |
| 281 | return nullptr; |
| 282 | } |
| 283 | |
| 284 | // GrTextureRenderTargets should always be using GrRenderTargetContext |
| 285 | SkASSERT(!sProxy->asRenderTargetProxy()); |
| 286 | |
| 287 | sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy())); |
| 288 | |
| 289 | return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy), |
| 290 | fContext->getAuditTrail(), fSingleOwner)); |
| 291 | } |