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 "GrSoftwarePathRenderer.h" |
14 #include "GrStencilAndCoverTextContext.h" | 14 #include "GrStencilAndCoverTextContext.h" |
15 #include "SkTTopoSort.h" | 15 #include "SkTTopoSort.h" |
16 | 16 |
| 17 //#define ENABLE_MDB 1 |
17 | 18 |
18 void GrDrawingManager::cleanup() { | 19 void GrDrawingManager::cleanup() { |
19 for (int i = 0; i < fDrawTargets.count(); ++i) { | 20 for (int i = 0; i < fDrawTargets.count(); ++i) { |
20 fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new co
mmand after this | |
21 fDrawTargets[i]->clearRT(); | |
22 | |
23 fDrawTargets[i]->unref(); | 21 fDrawTargets[i]->unref(); |
24 } | 22 } |
25 | 23 |
26 fDrawTargets.reset(); | 24 fDrawTargets.reset(); |
27 | 25 |
28 delete fNVPRTextContext; | 26 delete fNVPRTextContext; |
29 fNVPRTextContext = nullptr; | 27 fNVPRTextContext = nullptr; |
30 | 28 |
31 for (int i = 0; i < kNumPixelGeometries; ++i) { | 29 for (int i = 0; i < kNumPixelGeometries; ++i) { |
32 delete fTextContexts[i][0]; | 30 delete fTextContexts[i][0]; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 78 |
81 // Upload all data to the GPU | 79 // Upload all data to the GPU |
82 fFlushState.preIssueDraws(); | 80 fFlushState.preIssueDraws(); |
83 | 81 |
84 for (int i = 0; i < fDrawTargets.count(); ++i) { | 82 for (int i = 0; i < fDrawTargets.count(); ++i) { |
85 fDrawTargets[i]->drawBatches(&fFlushState); | 83 fDrawTargets[i]->drawBatches(&fFlushState); |
86 } | 84 } |
87 | 85 |
88 SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken()); | 86 SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken()); |
89 | 87 |
90 for (int i = 0; i < fDrawTargets.count(); ++i) { | |
91 fDrawTargets[i]->reset(); | |
92 #ifdef ENABLE_MDB | |
93 fDrawTargets[i]->unref(); | |
94 #endif | |
95 } | |
96 | |
97 #ifndef ENABLE_MDB | 88 #ifndef ENABLE_MDB |
98 // When MDB is disabled we keep reusing the same drawTarget | 89 // When MDB is disabled we keep reusing the same drawTarget |
99 if (fDrawTargets.count()) { | 90 if (fDrawTargets.count()) { |
100 SkASSERT(fDrawTargets.count() == 1); | 91 SkASSERT(fDrawTargets.count() == 1); |
101 // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnm
arked check | |
102 // won't bark | |
103 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); | 92 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
104 } | 93 } |
105 #else | |
106 fDrawTargets.reset(); | |
107 #endif | 94 #endif |
108 | 95 |
| 96 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 97 fDrawTargets[i]->reset(); |
| 98 } |
109 fFlushState.reset(); | 99 fFlushState.reset(); |
110 } | 100 } |
111 | 101 |
112 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, | 102 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, |
113 GrRenderTarget* rt) { | 103 GrRenderTarget* rt) { |
114 if (this->abandoned()) { | 104 if (this->abandoned()) { |
115 return nullptr; | 105 return nullptr; |
116 } | 106 } |
117 | 107 |
118 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); | 108 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); |
(...skipping 18 matching lines...) Expand all Loading... |
137 return fTextContexts[props.pixelGeometry()][useDIF]; | 127 return fTextContexts[props.pixelGeometry()][useDIF]; |
138 } | 128 } |
139 | 129 |
140 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { | 130 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
141 SkASSERT(fContext); | 131 SkASSERT(fContext); |
142 | 132 |
143 #ifndef ENABLE_MDB | 133 #ifndef ENABLE_MDB |
144 // When MDB is disabled we always just return the single drawTarget | 134 // When MDB is disabled we always just return the single drawTarget |
145 if (fDrawTargets.count()) { | 135 if (fDrawTargets.count()) { |
146 SkASSERT(fDrawTargets.count() == 1); | 136 SkASSERT(fDrawTargets.count() == 1); |
147 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. | |
148 // Update this pointer so all the asserts are happy | |
149 rt->setLastDrawTarget(fDrawTargets[0]); | |
150 // DrawingManager gets the creation ref - this ref is for the caller | 137 // DrawingManager gets the creation ref - this ref is for the caller |
151 return SkRef(fDrawTargets[0]); | 138 return SkRef(fDrawTargets[0]); |
152 } | 139 } |
153 #endif | 140 #endif |
154 | 141 |
155 GrDrawTarget* dt = new GrDrawTarget(rt, fContext->getGpu(), fContext->resour
ceProvider()); | 142 GrDrawTarget* dt = new GrDrawTarget(rt, fContext->getGpu(), fContext->resour
ceProvider()); |
156 | 143 |
157 *fDrawTargets.append() = dt; | 144 *fDrawTargets.append() = dt; |
158 | 145 |
159 // DrawingManager gets the creation ref - this ref is for the caller | 146 // DrawingManager gets the creation ref - this ref is for the caller |
(...skipping 27 matching lines...) Expand all Loading... |
187 } | 174 } |
188 | 175 |
189 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, | 176 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
190 const SkSurfaceProps* surfaceProps)
{ | 177 const SkSurfaceProps* surfaceProps)
{ |
191 if (this->abandoned()) { | 178 if (this->abandoned()) { |
192 return nullptr; | 179 return nullptr; |
193 } | 180 } |
194 | 181 |
195 return new GrDrawContext(this, rt, surfaceProps); | 182 return new GrDrawContext(this, rt, surfaceProps); |
196 } | 183 } |
OLD | NEW |