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" |
11 #include "GrDrawContext.h" | 11 #include "GrDrawContext.h" |
12 #include "GrLayerCache.h" | |
13 #include "GrResourceCache.h" | 12 #include "GrResourceCache.h" |
14 #include "GrResourceProvider.h" | 13 #include "GrResourceProvider.h" |
15 #include "GrSoftwarePathRenderer.h" | 14 #include "GrSoftwarePathRenderer.h" |
16 #include "GrSurfacePriv.h" | 15 #include "GrSurfacePriv.h" |
17 | 16 |
18 #include "SkConfig8888.h" | 17 #include "SkConfig8888.h" |
19 #include "SkGrPriv.h" | 18 #include "SkGrPriv.h" |
20 | 19 |
21 #include "batches/GrCopySurfaceBatch.h" | 20 #include "batches/GrCopySurfaceBatch.h" |
22 #include "effects/GrConfigConversionEffect.h" | 21 #include "effects/GrConfigConversionEffect.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 80 } |
82 | 81 |
83 void GrContext::initCommon(const GrContextOptions& options) { | 82 void GrContext::initCommon(const GrContextOptions& options) { |
84 ASSERT_SINGLE_OWNER | 83 ASSERT_SINGLE_OWNER |
85 | 84 |
86 fCaps = SkRef(fGpu->caps()); | 85 fCaps = SkRef(fGpu->caps()); |
87 fResourceCache = new GrResourceCache(fCaps); | 86 fResourceCache = new GrResourceCache(fCaps); |
88 fResourceCache->setOverBudgetCallback(OverBudgetCB, this); | 87 fResourceCache->setOverBudgetCallback(OverBudgetCB, this); |
89 fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwn
er); | 88 fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwn
er); |
90 | 89 |
91 fLayerCache.reset(new GrLayerCache(this)); | |
92 | |
93 fDidTestPMConversions = false; | 90 fDidTestPMConversions = false; |
94 | 91 |
95 GrDrawTarget::Options dtOptions; | 92 GrDrawTarget::Options dtOptions; |
96 dtOptions.fClipBatchToBounds = options.fClipBatchToBounds; | 93 dtOptions.fClipBatchToBounds = options.fClipBatchToBounds; |
97 dtOptions.fDrawBatchBounds = options.fDrawBatchBounds; | 94 dtOptions.fDrawBatchBounds = options.fDrawBatchBounds; |
98 dtOptions.fMaxBatchLookback = options.fMaxBatchLookback; | 95 dtOptions.fMaxBatchLookback = options.fMaxBatchLookback; |
99 dtOptions.fMaxBatchLookahead = options.fMaxBatchLookahead; | 96 dtOptions.fMaxBatchLookahead = options.fMaxBatchLookahead; |
100 fDrawingManager.reset(new GrDrawingManager(this, dtOptions, &fSingleOwner)); | 97 fDrawingManager.reset(new GrDrawingManager(this, dtOptions, &fSingleOwner)); |
101 | 98 |
102 // GrBatchFontCache will eventually replace GrFontCache | 99 // GrBatchFontCache will eventually replace GrFontCache |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // will be released/forgotten before they too are abandoned. | 142 // will be released/forgotten before they too are abandoned. |
146 fDrawingManager->abandon(); | 143 fDrawingManager->abandon(); |
147 | 144 |
148 // abandon first to so destructors | 145 // abandon first to so destructors |
149 // don't try to free the resources in the API. | 146 // don't try to free the resources in the API. |
150 fResourceCache->abandonAll(); | 147 fResourceCache->abandonAll(); |
151 | 148 |
152 fGpu->disconnect(GrGpu::DisconnectType::kAbandon); | 149 fGpu->disconnect(GrGpu::DisconnectType::kAbandon); |
153 | 150 |
154 fBatchFontCache->freeAll(); | 151 fBatchFontCache->freeAll(); |
155 fLayerCache->freeAll(); | |
156 fTextBlobCache->freeAll(); | 152 fTextBlobCache->freeAll(); |
157 } | 153 } |
158 | 154 |
159 void GrContext::releaseResourcesAndAbandonContext() { | 155 void GrContext::releaseResourcesAndAbandonContext() { |
160 ASSERT_SINGLE_OWNER | 156 ASSERT_SINGLE_OWNER |
161 | 157 |
162 fResourceProvider->abandon(); | 158 fResourceProvider->abandon(); |
163 | 159 |
164 // Need to abandon the drawing manager first so all the render targets | 160 // Need to abandon the drawing manager first so all the render targets |
165 // will be released/forgotten before they too are abandoned. | 161 // will be released/forgotten before they too are abandoned. |
166 fDrawingManager->abandon(); | 162 fDrawingManager->abandon(); |
167 | 163 |
168 // Release all resources in the backend 3D API. | 164 // Release all resources in the backend 3D API. |
169 fResourceCache->releaseAll(); | 165 fResourceCache->releaseAll(); |
170 | 166 |
171 fGpu->disconnect(GrGpu::DisconnectType::kCleanup); | 167 fGpu->disconnect(GrGpu::DisconnectType::kCleanup); |
172 | 168 |
173 fBatchFontCache->freeAll(); | 169 fBatchFontCache->freeAll(); |
174 fLayerCache->freeAll(); | |
175 fTextBlobCache->freeAll(); | 170 fTextBlobCache->freeAll(); |
176 } | 171 } |
177 | 172 |
178 void GrContext::resetContext(uint32_t state) { | 173 void GrContext::resetContext(uint32_t state) { |
179 ASSERT_SINGLE_OWNER | 174 ASSERT_SINGLE_OWNER |
180 fGpu->markContextDirty(state); | 175 fGpu->markContextDirty(state); |
181 } | 176 } |
182 | 177 |
183 void GrContext::freeGpuResources() { | 178 void GrContext::freeGpuResources() { |
184 ASSERT_SINGLE_OWNER | 179 ASSERT_SINGLE_OWNER |
185 | 180 |
186 this->flush(); | 181 this->flush(); |
187 | 182 |
188 fBatchFontCache->freeAll(); | 183 fBatchFontCache->freeAll(); |
189 fLayerCache->freeAll(); | |
190 | 184 |
191 fDrawingManager->freeGpuResources(); | 185 fDrawingManager->freeGpuResources(); |
192 | 186 |
193 fResourceCache->purgeAllUnlocked(); | 187 fResourceCache->purgeAllUnlocked(); |
194 } | 188 } |
195 | 189 |
196 void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes)
const { | 190 void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes)
const { |
197 ASSERT_SINGLE_OWNER | 191 ASSERT_SINGLE_OWNER |
198 | 192 |
199 if (resourceCount) { | 193 if (resourceCount) { |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 ASSERT_SINGLE_OWNER | 758 ASSERT_SINGLE_OWNER |
765 fResourceCache->setLimits(maxTextures, maxTextureBytes); | 759 fResourceCache->setLimits(maxTextures, maxTextureBytes); |
766 } | 760 } |
767 | 761 |
768 ////////////////////////////////////////////////////////////////////////////// | 762 ////////////////////////////////////////////////////////////////////////////// |
769 | 763 |
770 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { | 764 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |
771 ASSERT_SINGLE_OWNER | 765 ASSERT_SINGLE_OWNER |
772 fResourceCache->dumpMemoryStatistics(traceMemoryDump); | 766 fResourceCache->dumpMemoryStatistics(traceMemoryDump); |
773 } | 767 } |
OLD | NEW |