Added tracking of frame buffer objects to debug GL interface

http://codereview.appspot.com/5866043/




git-svn-id: http://skia.googlecode.com/svn/trunk@3455 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGLShaders.cpp b/src/gpu/gl/GrGpuGLShaders.cpp
index db7e3a7..cb156f7 100644
--- a/src/gpu/gl/GrGpuGLShaders.cpp
+++ b/src/gpu/gl/GrGpuGLShaders.cpp
@@ -125,6 +125,7 @@
 void GrGpuGLShaders::abandonResources(){
     INHERITED::abandonResources();
     fProgramCache->abandon();
+    fHWProgramID = 0;
 }
 
 void GrGpuGLShaders::DeleteProgram(const GrGLInterface* gl,
@@ -326,6 +327,13 @@
 }
 
 GrGpuGLShaders::~GrGpuGLShaders() {
+
+    if (fProgramData && 0 != fHWProgramID) {
+        // detach the current program so there is no confusion on OpenGL's part
+        // that we want it to be deleted
+        SkASSERT(fHWProgramID == fProgramData->fProgramID);
+        GL_CALL(UseProgram(0));
+    }
     delete fProgramCache;
 }