Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Unified Diff: src/gpu/GrContext.cpp

Issue 481443002: Add GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix leaks Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698