Adding functionality for purgin graphics resource handles
This will allow a fix to WebKit for preventing a crash when the graphics
context is destroyed before the GrContext
BUG=http://code.google.com/p/chromium/issues/detail?id=85309
git-svn-id: http://skia.googlecode.com/svn/trunk@1551 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index 8baa855..4ebf225 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -74,6 +74,11 @@
}
void GrContext::contextLost() {
+ contextDestroyed();
+ this->setupDrawBuffer();
+}
+
+void GrContext::contextDestroyed() {
// abandon first to so destructors
// don't try to free the resources in the API.
fGpu->abandonResources();
@@ -93,8 +98,6 @@
fTextureCache->removeAll();
fFontCache->freeAll();
fGpu->markContextDirty();
-
- this->setupDrawBuffer();
}
void GrContext::resetContext() {
@@ -1245,8 +1248,10 @@
void GrContext::flushDrawBuffer() {
#if BATCH_RECT_TO_RECT || DEFER_TEXT_RENDERING
- fDrawBuffer->playback(fGpu);
- fDrawBuffer->reset();
+ if (fDrawBuffer) {
+ fDrawBuffer->playback(fGpu);
+ fDrawBuffer->reset();
+ }
#endif
}