Fix test app to ensure that we destroy our GPU resources.

The problem arises on devices like the Nexus 10 where we allow the
destruction of resources using the destructor of a static variable.
However, we have no guarentee that the GPU driver has not already
cleaned up it's resources prior to our static destructor.

Review URL: https://codereview.appspot.com/6851124

git-svn-id: http://skia.googlecode.com/svn/trunk@6599 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 07107bc..bebb351 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -83,15 +83,24 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
+#if SK_SUPPORT_GPU
+    static SkAutoTUnref<SkNativeGLContext> gGLContext;
+    static SkAutoTUnref<GrContext> gGrContext;
+#endif
+
+void GpuTest::DestroyContext() {
+#if SK_SUPPORT_GPU
+    // preserve this order, we want gGrContext destroyed after gEGLContext
+    gGLContext.reset(NULL);
+    gGrContext.reset(NULL);
+#endif
+}
+
 
 GrContext* GpuTest::GetContext() {
 #if SK_SUPPORT_GPU
-    // preserve this order, we want gGrContext destroyed after gEGLContext
-    static SkTLazy<SkNativeGLContext> gGLContext;
-    static SkAutoTUnref<GrContext> gGrContext;
-
     if (NULL == gGrContext.get()) {
-        gGLContext.init();
+        gGLContext.reset(new SkNativeGLContext());
         if (gGLContext.get()->init(800, 600)) {
             GrBackendContext ctx = reinterpret_cast<GrBackendContext>(gGLContext.get()->gl());
             gGrContext.reset(GrContext::Create(kOpenGL_GrBackend, ctx));