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

Unified Diff: src/gpu/GrTexture.cpp

Issue 422323002: Some fixes around GrContext::abandonContext: (Closed) Base URL: https://skia.googlesource.com/skia.git@abandon
Patch Set: Address comments Created 6 years, 5 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/GrContext.cpp ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTexture.cpp
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 63069a452bd6bfd17cd50548b957864765b5c260..594444743614ad17331b1f9d9a754b8dbba511e0 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -102,12 +102,27 @@ void GrTexture::writePixels(int left, int top, int width, int height,
pixelOpsFlags);
}
+void GrTexture::abandonReleaseCommon() {
+ // In debug builds the resource cache tracks removed/exclusive textures and has an unref'ed ptr.
+ // After abandon() or release() the resource cache will be unreachable (getContext() == NULL).
+ // So we readd the texture to the cache here so that it is removed from the exclusive list and
+ // there is no longer an unref'ed ptr to the texture in the cache.
+ if (this->impl()->isSetFlag((GrTextureFlags)GrTextureImpl::kReturnToCache_FlagBit)) {
+ SkASSERT(!this->wasDestroyed());
+ this->ref(); // restores the ref the resource cache gave up when it marked this exclusive.
+ this->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
+ this->getContext()->addExistingTextureToCache(this);
+ }
+}
+
void GrTexture::onRelease() {
+ this->abandonReleaseCommon();
SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit));
INHERITED::onRelease();
}
void GrTexture::onAbandon() {
+ this->abandonReleaseCommon();
if (NULL != fRenderTarget.get()) {
fRenderTarget->abandon();
}
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/gl/GrGpuGL_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698