Added debug GL Interface. This interface tracks various GL objects in order to find leaks & invalid accesses.

Core Review: http://codereview.appspot.com/5846049/




git-svn-id: http://skia.googlecode.com/svn/trunk@3426 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 7732268..32aace3 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -20,6 +20,7 @@
 #include "SkImageEncoder.h"
 #include "gl/SkNativeGLContext.h"
 #include "gl/SkNullGLContext.h"
+#include "gl/SkDebugGLContext.h"
 #include "SkNWayCanvas.h"
 #include "SkPicture.h"
 #include "SkString.h"
@@ -208,6 +209,12 @@
         return true;
     }
 
+    void cleanup() {
+        fGLContext.reset(NULL);
+        fGrContext.reset(NULL);
+        fRenderTarget.reset(NULL);
+    }
+
     bool isValid() {
         return NULL != fGLContext.get();
     }
@@ -231,6 +238,7 @@
 
 static GLHelper gRealGLHelper;
 static GLHelper gNullGLHelper;
+static GLHelper gDebugGLHelper;
 
 static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
                              Backend backend, GLHelper* glHelper) {
@@ -512,8 +520,10 @@
     determine_gpu_context_size(defineDict, &contextWidth, &contextHeight);
     SkAutoTUnref<SkGLContext> realGLCtx(new SkNativeGLContext);
     SkAutoTUnref<SkGLContext> nullGLCtx(new SkNullGLContext);
+    SkAutoTUnref<SkGLContext> debugGLCtx(new SkDebugGLContext);
     gRealGLHelper.init(realGLCtx.get(), contextWidth, contextHeight);
     gNullGLHelper.init(nullGLCtx.get(), contextWidth, contextHeight);
+    gDebugGLHelper.init(debugGLCtx.get(), contextWidth, contextHeight);
 #endif
     BenchTimer timer = BenchTimer(gRealGLHelper.glContext());
 
@@ -617,5 +627,8 @@
         log_progress("\n");
     }
 
+    // need to clean up here rather than post-main to allow leak detection to work
+    gDebugGLHelper.cleanup();
+
     return 0;
 }