Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1083)

Side by Side Diff: src/gpu/GrDrawingManager.cpp

Issue 1407883004: Remove GrPipelineBuilder from getPathRenderer call (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Hide GrContext::drawingManager entry point Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrDrawingManager.h ('k') | src/gpu/GrPathRenderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawingManager.h ('k') | src/gpu/GrPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698