| 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 "GrAtlasTextContext.h" | 8 #include "GrAtlasTextContext.h" |
| 9 #include "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
| 10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
| 11 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 12 #include "GrResourceProvider.h" | 12 #include "GrResourceProvider.h" |
| 13 #include "GrSoftwarePathRenderer.h" |
| 13 #include "GrStencilAndCoverTextContext.h" | 14 #include "GrStencilAndCoverTextContext.h" |
| 14 #include "SkTTopoSort.h" | 15 #include "SkTTopoSort.h" |
| 15 | 16 |
| 16 void GrDrawingManager::cleanup() { | 17 void GrDrawingManager::cleanup() { |
| 17 for (int i = 0; i < fDrawTargets.count(); ++i) { | 18 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 18 fDrawTargets[i]->unref(); | 19 fDrawTargets[i]->unref(); |
| 19 } | 20 } |
| 20 | 21 |
| 21 fDrawTargets.reset(); | 22 fDrawTargets.reset(); |
| 22 | 23 |
| 23 delete fNVPRTextContext; | 24 delete fNVPRTextContext; |
| 24 fNVPRTextContext = nullptr; | 25 fNVPRTextContext = nullptr; |
| 25 | 26 |
| 26 for (int i = 0; i < kNumPixelGeometries; ++i) { | 27 for (int i = 0; i < kNumPixelGeometries; ++i) { |
| 27 delete fTextContexts[i][0]; | 28 delete fTextContexts[i][0]; |
| 28 fTextContexts[i][0] = nullptr; | 29 fTextContexts[i][0] = nullptr; |
| 29 delete fTextContexts[i][1]; | 30 delete fTextContexts[i][1]; |
| 30 fTextContexts[i][1] = nullptr; | 31 fTextContexts[i][1] = nullptr; |
| 31 } | 32 } |
| 33 |
| 34 SkSafeSetNull(fPathRendererChain); |
| 35 SkSafeSetNull(fSoftwarePathRenderer); |
| 32 } | 36 } |
| 33 | 37 |
| 34 GrDrawingManager::~GrDrawingManager() { | 38 GrDrawingManager::~GrDrawingManager() { |
| 35 this->cleanup(); | 39 this->cleanup(); |
| 36 } | 40 } |
| 37 | 41 |
| 38 void GrDrawingManager::abandon() { | 42 void GrDrawingManager::abandon() { |
| 39 fAbandoned = true; | 43 fAbandoned = true; |
| 40 this->cleanup(); | 44 this->cleanup(); |
| 41 } | 45 } |
| 42 | 46 |
| 47 void GrDrawingManager::freeGpuResources() { |
| 48 // a path renderer may be holding onto resources |
| 49 SkSafeSetNull(fPathRendererChain); |
| 50 SkSafeSetNull(fSoftwarePathRenderer); |
| 51 } |
| 52 |
| 43 void GrDrawingManager::reset() { | 53 void GrDrawingManager::reset() { |
| 44 for (int i = 0; i < fDrawTargets.count(); ++i) { | 54 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 45 fDrawTargets[i]->reset(); | 55 fDrawTargets[i]->reset(); |
| 46 } | 56 } |
| 47 } | 57 } |
| 48 | 58 |
| 49 void GrDrawingManager::flush() { | 59 void GrDrawingManager::flush() { |
| 50 SkDEBUGCODE(bool result =) | 60 SkDEBUGCODE(bool result =) |
| 51 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(
&fDrawTargets); | 61 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(
&fDrawTargets); |
| 52 SkASSERT(result); | 62 SkASSERT(result); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 117 |
| 108 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr
ovider(), | 118 GrDrawTarget* dt = new GrDrawTarget(fContext->getGpu(), fContext->resourcePr
ovider(), |
| 109 fOptions); | 119 fOptions); |
| 110 | 120 |
| 111 *fDrawTargets.append() = dt; | 121 *fDrawTargets.append() = dt; |
| 112 | 122 |
| 113 // DrawingManager gets the creation ref - this ref is for the caller | 123 // DrawingManager gets the creation ref - this ref is for the caller |
| 114 return SkRef(dt); | 124 return SkRef(dt); |
| 115 } | 125 } |
| 116 | 126 |
| 117 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, | 127 /* |
| 128 * This method finds a path renderer that can draw the specified path on |
| 129 * the provided target. |
| 130 * Due to its expense, the software path renderer has split out so it can |
| 131 * can be individually allowed/disallowed via the "allowSW" boolean. |
| 132 */ |
| 133 GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
athArgs& args, |
| 134 bool allowSW, |
| 135 GrPathRendererChain::DrawType
drawType, |
| 136 GrPathRenderer::StencilSupport
* stencilSupport) { |
| 137 |
| 138 if (!fPathRendererChain) { |
| 139 fPathRendererChain = new GrPathRendererChain(fContext); |
| 140 } |
| 141 |
| 142 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, ste
ncilSupport); |
| 143 if (!pr && allowSW) { |
| 144 if (!fSoftwarePathRenderer) { |
| 145 fSoftwarePathRenderer = new GrSoftwarePathRenderer(fContext); |
| 146 } |
| 147 pr = fSoftwarePathRenderer; |
| 148 } |
| 149 |
| 150 return pr; |
| 151 } |
| 152 |
| 153 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
| 118 const SkSurfaceProps* surfaceProps)
{ | 154 const SkSurfaceProps* surfaceProps)
{ |
| 119 if (this->abandoned()) { | 155 if (this->abandoned()) { |
| 120 return nullptr; | 156 return nullptr; |
| 121 } | 157 } |
| 122 | 158 |
| 123 return new GrDrawContext(this, rt, surfaceProps); | 159 return new GrDrawContext(this, rt, surfaceProps); |
| 124 } | 160 } |
| OLD | NEW |