| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 fTextureCache = NULL; | 160 fTextureCache = NULL; |
| 161 delete fFontCache; | 161 delete fFontCache; |
| 162 delete fDrawBuffer; | 162 delete fDrawBuffer; |
| 163 delete fDrawBufferVBAllocPool; | 163 delete fDrawBufferVBAllocPool; |
| 164 delete fDrawBufferIBAllocPool; | 164 delete fDrawBufferIBAllocPool; |
| 165 | 165 |
| 166 fAARectRenderer->unref(); | 166 fAARectRenderer->unref(); |
| 167 fOvalRenderer->unref(); | 167 fOvalRenderer->unref(); |
| 168 | 168 |
| 169 fGpu->unref(); | 169 fGpu->unref(); |
| 170 GrSafeUnref(fPathRendererChain); | 170 SkSafeUnref(fPathRendererChain); |
| 171 GrSafeUnref(fSoftwarePathRenderer); | 171 SkSafeUnref(fSoftwarePathRenderer); |
| 172 fDrawState->unref(); | 172 fDrawState->unref(); |
| 173 | 173 |
| 174 --THREAD_INSTANCE_COUNT; | 174 --THREAD_INSTANCE_COUNT; |
| 175 } | 175 } |
| 176 | 176 |
| 177 void GrContext::contextLost() { | 177 void GrContext::contextLost() { |
| 178 this->contextDestroyed(); | 178 this->contextDestroyed(); |
| 179 this->setupDrawBuffer(); | 179 this->setupDrawBuffer(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void GrContext::contextDestroyed() { | 182 void GrContext::contextDestroyed() { |
| 183 // abandon first to so destructors | 183 // abandon first to so destructors |
| 184 // don't try to free the resources in the API. | 184 // don't try to free the resources in the API. |
| 185 fGpu->abandonResources(); | 185 fGpu->abandonResources(); |
| 186 | 186 |
| 187 // a path renderer may be holding onto resources that | 187 // a path renderer may be holding onto resources that |
| 188 // are now unusable | 188 // are now unusable |
| 189 GrSafeSetNull(fPathRendererChain); | 189 SkSafeSetNull(fPathRendererChain); |
| 190 GrSafeSetNull(fSoftwarePathRenderer); | 190 SkSafeSetNull(fSoftwarePathRenderer); |
| 191 | 191 |
| 192 delete fDrawBuffer; | 192 delete fDrawBuffer; |
| 193 fDrawBuffer = NULL; | 193 fDrawBuffer = NULL; |
| 194 | 194 |
| 195 delete fDrawBufferVBAllocPool; | 195 delete fDrawBufferVBAllocPool; |
| 196 fDrawBufferVBAllocPool = NULL; | 196 fDrawBufferVBAllocPool = NULL; |
| 197 | 197 |
| 198 delete fDrawBufferIBAllocPool; | 198 delete fDrawBufferIBAllocPool; |
| 199 fDrawBufferIBAllocPool = NULL; | 199 fDrawBufferIBAllocPool = NULL; |
| 200 | 200 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 214 this->flush(); | 214 this->flush(); |
| 215 | 215 |
| 216 fGpu->purgeResources(); | 216 fGpu->purgeResources(); |
| 217 | 217 |
| 218 fAARectRenderer->reset(); | 218 fAARectRenderer->reset(); |
| 219 fOvalRenderer->reset(); | 219 fOvalRenderer->reset(); |
| 220 | 220 |
| 221 fTextureCache->purgeAllUnlocked(); | 221 fTextureCache->purgeAllUnlocked(); |
| 222 fFontCache->freeAll(); | 222 fFontCache->freeAll(); |
| 223 // a path renderer may be holding onto resources | 223 // a path renderer may be holding onto resources |
| 224 GrSafeSetNull(fPathRendererChain); | 224 SkSafeSetNull(fPathRendererChain); |
| 225 GrSafeSetNull(fSoftwarePathRenderer); | 225 SkSafeSetNull(fSoftwarePathRenderer); |
| 226 } | 226 } |
| 227 | 227 |
| 228 size_t GrContext::getGpuTextureCacheBytes() const { | 228 size_t GrContext::getGpuTextureCacheBytes() const { |
| 229 return fTextureCache->getCachedResourceBytes(); | 229 return fTextureCache->getCachedResourceBytes(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 //////////////////////////////////////////////////////////////////////////////// | 232 //////////////////////////////////////////////////////////////////////////////// |
| 233 | 233 |
| 234 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, | 234 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, |
| 235 const GrCacheID& cacheID, | 235 const GrCacheID& cacheID, |
| (...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 return NULL; | 1743 return NULL; |
| 1744 } | 1744 } |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 /////////////////////////////////////////////////////////////////////////////// | 1747 /////////////////////////////////////////////////////////////////////////////// |
| 1748 #if GR_CACHE_STATS | 1748 #if GR_CACHE_STATS |
| 1749 void GrContext::printCacheStats() const { | 1749 void GrContext::printCacheStats() const { |
| 1750 fTextureCache->printStats(); | 1750 fTextureCache->printStats(); |
| 1751 } | 1751 } |
| 1752 #endif | 1752 #endif |
| OLD | NEW |