| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrDrawContext.h" | 8 #include "GrDrawContext.h" |
| 9 #include "GrDrawingManager.h" | 9 #include "GrDrawingManager.h" |
| 10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| 11 #include "GrInstancedRendering.h" |
| 11 #include "GrPathRenderingDrawContext.h" | 12 #include "GrPathRenderingDrawContext.h" |
| 12 #include "GrResourceProvider.h" | 13 #include "GrResourceProvider.h" |
| 13 #include "GrSoftwarePathRenderer.h" | 14 #include "GrSoftwarePathRenderer.h" |
| 14 #include "SkTTopoSort.h" | 15 #include "SkTTopoSort.h" |
| 15 | 16 |
| 16 #include "text/GrAtlasTextContext.h" | 17 #include "text/GrAtlasTextContext.h" |
| 17 #include "text/GrStencilAndCoverTextContext.h" | 18 #include "text/GrStencilAndCoverTextContext.h" |
| 18 | 19 |
| 19 void GrDrawingManager::cleanup() { | 20 void GrDrawingManager::cleanup() { |
| 20 for (int i = 0; i < fDrawTargets.count(); ++i) { | 21 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 fPathRendererChain = nullptr; | 34 fPathRendererChain = nullptr; |
| 34 SkSafeSetNull(fSoftwarePathRenderer); | 35 SkSafeSetNull(fSoftwarePathRenderer); |
| 35 } | 36 } |
| 36 | 37 |
| 37 GrDrawingManager::~GrDrawingManager() { | 38 GrDrawingManager::~GrDrawingManager() { |
| 38 this->cleanup(); | 39 this->cleanup(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void GrDrawingManager::abandon() { | 42 void GrDrawingManager::abandon() { |
| 42 fAbandoned = true; | 43 fAbandoned = true; |
| 44 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 45 if (GrInstancedRendering* ir = fDrawTargets[i]->instancedRendering()) { |
| 46 ir->resetGpuResources(GrInstancedRendering::ResetType::kAbandon); |
| 47 } |
| 48 } |
| 43 this->cleanup(); | 49 this->cleanup(); |
| 44 } | 50 } |
| 45 | 51 |
| 46 void GrDrawingManager::freeGpuResources() { | 52 void GrDrawingManager::freeGpuResources() { |
| 47 // a path renderer may be holding onto resources | 53 // a path renderer may be holding onto resources |
| 48 delete fPathRendererChain; | 54 delete fPathRendererChain; |
| 49 fPathRendererChain = nullptr; | 55 fPathRendererChain = nullptr; |
| 50 SkSafeSetNull(fSoftwarePathRenderer); | 56 SkSafeSetNull(fSoftwarePathRenderer); |
| 57 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 58 if (GrInstancedRendering* ir = fDrawTargets[i]->instancedRendering()) { |
| 59 ir->resetGpuResources(GrInstancedRendering::ResetType::kDestroy); |
| 60 } |
| 61 } |
| 51 } | 62 } |
| 52 | 63 |
| 53 void GrDrawingManager::reset() { | 64 void GrDrawingManager::reset() { |
| 54 for (int i = 0; i < fDrawTargets.count(); ++i) { | 65 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 55 fDrawTargets[i]->reset(); | 66 fDrawTargets[i]->reset(); |
| 56 } | 67 } |
| 57 fFlushState.reset(); | 68 fFlushState.reset(); |
| 58 } | 69 } |
| 59 | 70 |
| 60 void GrDrawingManager::flush() { | 71 void GrDrawingManager::flush() { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt
achment(rt); | 187 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt
achment(rt); |
| 177 if (sb) { | 188 if (sb) { |
| 178 return new GrPathRenderingDrawContext(fContext, this, rt, surfacePro
ps, | 189 return new GrPathRenderingDrawContext(fContext, this, rt, surfacePro
ps, |
| 179 fContext->getAuditTrail(), fSi
ngleOwner); | 190 fContext->getAuditTrail(), fSi
ngleOwner); |
| 180 } | 191 } |
| 181 } | 192 } |
| 182 | 193 |
| 183 return new GrDrawContext(fContext, this, rt, surfaceProps, fContext->getAudi
tTrail(), | 194 return new GrDrawContext(fContext, this, rt, surfaceProps, fContext->getAudi
tTrail(), |
| 184 fSingleOwner); | 195 fSingleOwner); |
| 185 } | 196 } |
| OLD | NEW |