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
}
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index 50be67f..0a933b5 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -130,6 +130,11 @@
}
};
+void GrGpuGLShaders::abandonResources(){
+ INHERITED::abandonResources();
+ fProgramCache->abandon();
+}
+
void GrGpuGLShaders::DeleteProgram(GrGLProgram::CachedData* programData) {
GR_GL(DeleteShader(programData->fVShaderID));
GR_GL(DeleteShader(programData->fFShaderID));
diff --git a/gpu/src/GrGpuGLShaders.h b/gpu/src/GrGpuGLShaders.h
index 9392d1c..557a4e3 100644
--- a/gpu/src/GrGpuGLShaders.h
+++ b/gpu/src/GrGpuGLShaders.h
@@ -31,6 +31,8 @@
virtual void resetContext();
+ virtual void abandonResources();
+
protected:
// overrides from GrGpu
virtual bool flushGraphicsState(GrPrimitiveType type);