OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrContext.h" | 8 #include "GrContext.h" |
9 #include "GrContextOptions.h" | 9 #include "GrContextOptions.h" |
10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 fResourceProvider->abandon(); | 141 fResourceProvider->abandon(); |
142 | 142 |
143 // Need to abandon the drawing manager first so all the render targets | 143 // Need to abandon the drawing manager first so all the render targets |
144 // will be released/forgotten before they too are abandoned. | 144 // will be released/forgotten before they too are abandoned. |
145 fDrawingManager->abandon(); | 145 fDrawingManager->abandon(); |
146 | 146 |
147 // abandon first to so destructors | 147 // abandon first to so destructors |
148 // don't try to free the resources in the API. | 148 // don't try to free the resources in the API. |
149 fResourceCache->abandonAll(); | 149 fResourceCache->abandonAll(); |
150 | 150 |
151 fGpu->contextAbandoned(); | 151 fGpu->disconnect(GrGpu::DisconnectType::kAbandon); |
152 | 152 |
153 fBatchFontCache->freeAll(); | 153 fBatchFontCache->freeAll(); |
154 fLayerCache->freeAll(); | 154 fLayerCache->freeAll(); |
| 155 fTextBlobCache->freeAll(); |
| 156 } |
| 157 |
| 158 void GrContext::releaseResourcesAndAbandonContext() { |
| 159 ASSERT_SINGLE_OWNER |
| 160 |
| 161 fResourceProvider->abandon(); |
| 162 |
| 163 // Need to abandon the drawing manager first so all the render targets |
| 164 // will be released/forgotten before they too are abandoned. |
| 165 fDrawingManager->abandon(); |
| 166 |
| 167 // Release all resources in the backend 3D API. |
| 168 fResourceCache->releaseAll(); |
| 169 |
| 170 fGpu->disconnect(GrGpu::DisconnectType::kCleanup); |
| 171 |
| 172 fBatchFontCache->freeAll(); |
| 173 fLayerCache->freeAll(); |
155 fTextBlobCache->freeAll(); | 174 fTextBlobCache->freeAll(); |
156 } | 175 } |
157 | 176 |
158 void GrContext::resetContext(uint32_t state) { | 177 void GrContext::resetContext(uint32_t state) { |
159 ASSERT_SINGLE_OWNER | 178 ASSERT_SINGLE_OWNER |
160 fGpu->markContextDirty(state); | 179 fGpu->markContextDirty(state); |
161 } | 180 } |
162 | 181 |
163 void GrContext::freeGpuResources() { | 182 void GrContext::freeGpuResources() { |
164 ASSERT_SINGLE_OWNER | 183 ASSERT_SINGLE_OWNER |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 ASSERT_SINGLE_OWNER | 689 ASSERT_SINGLE_OWNER |
671 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 690 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
672 } | 691 } |
673 | 692 |
674 ////////////////////////////////////////////////////////////////////////////// | 693 ////////////////////////////////////////////////////////////////////////////// |
675 | 694 |
676 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 695 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
677 ASSERT_SINGLE_OWNER | 696 ASSERT_SINGLE_OWNER |
678 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 697 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
679 } | 698 } |
OLD | NEW |