| Index: src/gpu/GrContext.cpp
|
| diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
|
| index 091c4a899e401595fe26c4fa7f5053391d02e2cd..b420df2bc806c0b06fcb7aeff9f18ff5e61e0c1c 100755
|
| --- a/src/gpu/GrContext.cpp
|
| +++ b/src/gpu/GrContext.cpp
|
| @@ -25,6 +25,7 @@
|
| #include "GrPathRenderer.h"
|
| #include "GrPathUtils.h"
|
| #include "GrResourceCache.h"
|
| +#include "GrResourceCache2.h"
|
| #include "GrSoftwarePathRenderer.h"
|
| #include "GrStencilBuffer.h"
|
| #include "GrStencilAndCoverTextContext.h"
|
| @@ -108,6 +109,7 @@ GrContext::GrContext(const Options& opts) : fOptions(opts) {
|
| fPathRendererChain = NULL;
|
| fSoftwarePathRenderer = NULL;
|
| fResourceCache = NULL;
|
| + fResourceCache2 = NULL;
|
| fFontCache = NULL;
|
| fDrawBuffer = NULL;
|
| fDrawBufferVBAllocPool = NULL;
|
| @@ -133,6 +135,7 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
|
| fResourceCache = SkNEW_ARGS(GrResourceCache, (MAX_RESOURCE_CACHE_COUNT,
|
| MAX_RESOURCE_CACHE_BYTES));
|
| fResourceCache->setOverbudgetCallback(OverbudgetCB, this);
|
| + fResourceCache2 = SkNEW(GrResourceCache2);
|
|
|
| fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
|
|
|
| @@ -161,10 +164,8 @@ GrContext::~GrContext() {
|
| (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
|
| }
|
|
|
| - // Since the gpu can hold scratch textures, give it a chance to let go
|
| - // of them before freeing the texture cache
|
| - fGpu->purgeResources();
|
| -
|
| + delete fResourceCache2;
|
| + fResourceCache2 = NULL;
|
| delete fResourceCache;
|
| fResourceCache = NULL;
|
| delete fFontCache;
|
| @@ -184,7 +185,9 @@ GrContext::~GrContext() {
|
| void GrContext::abandonContext() {
|
| // abandon first to so destructors
|
| // don't try to free the resources in the API.
|
| - fGpu->abandonResources();
|
| + fResourceCache2->abandonAll();
|
| +
|
| + fGpu->contextAbandonded();
|
|
|
| // a path renderer may be holding onto resources that
|
| // are now unusable
|
| @@ -207,7 +210,6 @@ void GrContext::abandonContext() {
|
|
|
| fFontCache->freeAll();
|
| fLayerCache->freeAll();
|
| - fGpu->markContextDirty();
|
| }
|
|
|
| void GrContext::resetContext(uint32_t state) {
|
| @@ -218,6 +220,9 @@ void GrContext::freeGpuResources() {
|
| this->flush();
|
|
|
| fGpu->purgeResources();
|
| + if (NULL != fDrawBuffer) {
|
| + fDrawBuffer->purgeResources();
|
| + }
|
|
|
| fAARectRenderer->reset();
|
| fOvalRenderer->reset();
|
| @@ -540,6 +545,15 @@ void GrContext::addExistingTextureToCache(GrTexture* texture) {
|
| }
|
|
|
| void GrContext::unlockScratchTexture(GrTexture* texture) {
|
| + if (texture->wasDestroyed()) {
|
| + if (texture->getCacheEntry()->key().isScratch()) {
|
| + // This texture was detached from the cache but the cache still had a ref to it but
|
| + // not a pointer to it.
|
| + texture->unref();
|
| + }
|
| + return;
|
| + }
|
| +
|
| ASSERT_OWNED_RESOURCE(texture);
|
| SkASSERT(NULL != texture->getCacheEntry());
|
|
|
|
|