Revert of Make the Sk GL context class an abstract base class (patchset #4 id:60001 of https://codereview.chromium.org/630843002/)

Reason for revert:
nanobech failing on Android

Original issue's description:
> Make the Sk GL context class an abstract base class
>
> Make the Sk GL context class, SkGLNativeContext, an abstract base class. Before,
> it depended on ifdefs to implement the platform dependent polymorphism.  Move
> the logic to subclasses of the various platform implementations.
>
> This a step to enable Skia embedders to compile dm and bench_pictures. The
> concrete goal is to support running these test apps with Chromium command buffer.
>
> With this change, Chromium can implement its own version of SkGLNativeContext
> that uses command buffer, and host the implementation in its own repository.
>
> Implements the above by renaming the SkGLContextHelper to SkGLContext and
> removing the unneeded SkGLNativeContext. Also removes
> SkGLNativeContext::AutoRestoreContext functionality, it appeared to be unused:
> no use in Skia code, and no tests.
>
> BUG=skia:2992
>
> Committed: https://skia.googlesource.com/skia/+/a90ed4e83897b45d6331ee4c54e1edd4054de9a8

TBR=kkinnunen@nvidia.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2992

Review URL: https://codereview.chromium.org/639793002
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 65cef89..21aeef4 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -84,7 +84,7 @@
 }
 #define HUMANIZE(ms) humanize(ms).c_str()
 
-static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContext* gl) {
+static double time(int loops, Benchmark* bench, SkCanvas* canvas, SkGLContextHelper* gl) {
     if (canvas) {
         canvas->clear(SK_ColorWHITE);
     }
@@ -203,7 +203,7 @@
 }
 
 #if SK_SUPPORT_GPU
-static int gpu_bench(SkGLContext* gl,
+static int gpu_bench(SkGLContextHelper* gl,
                      Benchmark* bench,
                      SkCanvas* canvas,
                      double* samples) {
@@ -274,7 +274,7 @@
     const Config config;
     SkAutoTDelete<SkSurface> surface;
 #if SK_SUPPORT_GPU
-    SkGLContext* gl;
+    SkGLContextHelper* gl;
 #endif
 };
 
@@ -389,7 +389,7 @@
 }
 
 #if SK_SUPPORT_GPU
-static void fill_gpu_options(ResultsWriter* log, SkGLContext* ctx) {
+static void fill_gpu_options(ResultsWriter* log, SkGLContextHelper* ctx) {
     const GrGLubyte* version;
     SK_GL_RET(*ctx, version, GetString(GR_GL_VERSION));
     log->configOption("GL_VERSION", (const char*)(version));
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index a853cf5..eb520b5 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -279,7 +279,7 @@
       '<(skia_include_path)/gpu/SkGrPixelRef.h',
       '<(skia_include_path)/gpu/SkGrTexturePixelRef.h',
 
-      '<(skia_include_path)/gpu/gl/SkGLContext.h',
+      '<(skia_include_path)/gpu/gl/SkGLContextHelper.h',
 
       '<(skia_src_path)/gpu/SkGpuDevice.cpp',
       '<(skia_src_path)/gpu/SkGpuDevice.h',
@@ -290,7 +290,7 @@
       '<(skia_src_path)/image/SkImage_Gpu.cpp',
       '<(skia_src_path)/image/SkSurface_Gpu.cpp',
 
-      '<(skia_src_path)/gpu/gl/SkGLContext.cpp'
+      '<(skia_src_path)/gpu/gl/SkGLContextHelper.cpp'
     ],
     'skgpu_native_gl_sources': [
       '<(skia_src_path)/gpu/gl/GrGLDefaultInterface_native.cpp',
@@ -302,12 +302,13 @@
       '<(skia_src_path)/gpu/gl/android/GrGLCreateNativeInterface_android.cpp',
 
       # Sk files
-      '<(skia_src_path)/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp',
-      '<(skia_src_path)/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp',
-      '<(skia_src_path)/gpu/gl/win/SkCreatePlatformGLContext_win.cpp',
-      '<(skia_src_path)/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp',
-      '<(skia_src_path)/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp',
-      '<(skia_src_path)/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm',
+      '<(skia_include_path)/gpu/gl/SkNativeGLContext.h',
+      '<(skia_src_path)/gpu/gl/mac/SkNativeGLContext_mac.cpp',
+      '<(skia_src_path)/gpu/gl/nacl/SkNativeGLContext_nacl.cpp',
+      '<(skia_src_path)/gpu/gl/win/SkNativeGLContext_win.cpp',
+      '<(skia_src_path)/gpu/gl/glx/SkNativeGLContext_glx.cpp',
+      '<(skia_src_path)/gpu/gl/egl/SkNativeGLContext_egl.cpp',
+      '<(skia_src_path)/gpu/gl/iOS/SkNativeGLContext_iOS.mm',
     ],
     'skgpu_mesa_gl_sources': [
       '<(skia_src_path)/gpu/gl/mesa/GrGLCreateMesaInterface.cpp',
diff --git a/gyp/public_headers.gypi b/gyp/public_headers.gypi
index 4ee02d5..6e61b4e 100644
--- a/gyp/public_headers.gypi
+++ b/gyp/public_headers.gypi
@@ -183,8 +183,9 @@
       'gpu/gl/GrGLInterface.h',
       'gpu/gl/SkANGLEGLContext.h',
       'gpu/gl/SkDebugGLContext.h',
+      'gpu/gl/SkGLContextHelper.h',
       'gpu/gl/SkMesaGLContext.h',
-      'gpu/gl/SkGLContext.h',
+      'gpu/gl/SkNativeGLContext.h',
       'gpu/gl/SkNullGLContext.h',
       'images/SkForceLinking.h',
       'images/SkMovie.h',
diff --git a/include/gpu/GrContextFactory.h b/include/gpu/GrContextFactory.h
index eff1f58..d78120c 100644
--- a/include/gpu/GrContextFactory.h
+++ b/include/gpu/GrContextFactory.h
@@ -15,7 +15,7 @@
 #if SK_MESA
     #include "gl/SkMesaGLContext.h"
 #endif
-#include "gl/SkGLContext.h"
+#include "gl/SkNativeGLContext.h"
 #include "gl/SkNullGLContext.h"
 
 #include "GrContext.h"
@@ -130,12 +130,12 @@
                 return fContexts[i].fGrContext;
             }
         }
-        SkAutoTUnref<SkGLContext> glCtx;
+        SkAutoTUnref<SkGLContextHelper> glCtx;
         SkAutoTUnref<GrContext> grCtx;
         switch (type) {
             case kNVPR_GLContextType: // fallthru
             case kNative_GLContextType:
-                glCtx.reset(SkCreatePlatformGLContext());
+                glCtx.reset(SkNEW(SkNativeGLContext));
                 break;
 #ifdef SK_ANGLE
             case kANGLE_GLContextType:
@@ -192,7 +192,7 @@
 
     // Returns the GLContext of the given type. If it has not been created yet,
     // NULL is returned instead.
-    SkGLContext* getGLContext(GLContextType type) {
+    SkGLContextHelper* getGLContext(GLContextType type) {
         for (int i = 0; i < fContexts.count(); ++i) {
             if (fContexts[i].fType == type) {
                 return fContexts[i].fGLContext;
@@ -207,7 +207,7 @@
 private:
     struct GPUContext {
         GLContextType             fType;
-        SkGLContext*              fGLContext;
+        SkGLContextHelper*        fGLContext;
         GrContext*                fGrContext;
     };
     SkTArray<GPUContext, true>    fContexts;
diff --git a/include/gpu/gl/SkANGLEGLContext.h b/include/gpu/gl/SkANGLEGLContext.h
index 18cdbdb..c5f62ff 100644
--- a/include/gpu/gl/SkANGLEGLContext.h
+++ b/include/gpu/gl/SkANGLEGLContext.h
@@ -10,12 +10,12 @@
 
 #if SK_ANGLE
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
 #include <GLES2/gl2.h>
 #include <EGL/egl.h>
 
-class SkANGLEGLContext : public SkGLContext {
+class SkANGLEGLContext : public SkGLContextHelper {
 public:
     SkANGLEGLContext();
 
@@ -24,6 +24,17 @@
     virtual void makeCurrent() const SK_OVERRIDE;
     virtual void swapBuffers() const SK_OVERRIDE;
 
+    class AutoContextRestore {
+    public:
+        AutoContextRestore();
+        ~AutoContextRestore();
+
+    private:
+        EGLContext fOldEGLContext;
+        EGLDisplay fOldDisplay;
+        EGLSurface fOldSurface;
+    };
+
 protected:
     virtual const GrGLInterface* createGLContext(
         GrGLStandard forcedGpuAPI) SK_OVERRIDE;
diff --git a/include/gpu/gl/SkDebugGLContext.h b/include/gpu/gl/SkDebugGLContext.h
index 7926663..7db9579 100644
--- a/include/gpu/gl/SkDebugGLContext.h
+++ b/include/gpu/gl/SkDebugGLContext.h
@@ -8,9 +8,9 @@
 #ifndef SkDebugGLContext_DEFINED
 #define SkDebugGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
-class SkDebugGLContext : public SkGLContext {
+class SkDebugGLContext : public SkGLContextHelper {
 
 public:
     SkDebugGLContext() {}
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContextHelper.h
similarity index 84%
rename from include/gpu/gl/SkGLContext.h
rename to include/gpu/gl/SkGLContextHelper.h
index 83c9146..c4d9bdf 100644
--- a/include/gpu/gl/SkGLContext.h
+++ b/include/gpu/gl/SkGLContextHelper.h
@@ -5,8 +5,8 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#ifndef SkGLContext_DEFINED
-#define SkGLContext_DEFINED
+#ifndef SkGLContextHelper_DEFINED
+#define SkGLContextHelper_DEFINED
 
 #include "GrGLInterface.h"
 
@@ -15,12 +15,12 @@
  * Provides a GrGLInterface struct of function pointers for the context.
  */
 
-class SK_API SkGLContext : public SkRefCnt {
+class SK_API SkGLContextHelper : public SkRefCnt {
 public:
-    SK_DECLARE_INST_COUNT(SkGLContext)
+    SK_DECLARE_INST_COUNT(SkGLContextHelper)
 
-    SkGLContext();
-    virtual ~SkGLContext();
+    SkGLContextHelper();
+    virtual ~SkGLContextHelper();
 
     /**
      * Initializes the context and makes it current.
@@ -81,14 +81,6 @@
     typedef SkRefCnt INHERITED;
 };
 
-/** Creates platform-dependent GL context object
- * Note: If Skia embedder needs a custom GL context that sets up the GL
- * interface, this function should be implemented by the embedder.
- * Otherwise, the default implementation for the platform should be compiled in
- * the library.
- */
-SK_API SkGLContext* SkCreatePlatformGLContext();
-
 /**
  * Helper macros for using the GL context through the GrGLInterface. Example:
  * SK_GL(glCtx, GenTextures(1, &texID));
diff --git a/include/gpu/gl/SkMesaGLContext.h b/include/gpu/gl/SkMesaGLContext.h
index ef00171..28349dd 100644
--- a/include/gpu/gl/SkMesaGLContext.h
+++ b/include/gpu/gl/SkMesaGLContext.h
@@ -8,11 +8,11 @@
 #ifndef SkMesaGLContext_DEFINED
 #define SkMesaGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
 #if SK_MESA
 
-class SkMesaGLContext : public SkGLContext {
+class SkMesaGLContext : public SkGLContextHelper {
 private:
     typedef intptr_t Context;
 
@@ -24,6 +24,19 @@
     virtual void makeCurrent() const SK_OVERRIDE;
     virtual void swapBuffers() const SK_OVERRIDE;
 
+    class AutoContextRestore {
+    public:
+        AutoContextRestore();
+        ~AutoContextRestore();
+
+    private:
+        Context fOldContext;
+        GrGLint fOldWidth;
+        GrGLint fOldHeight;
+        GrGLint fOldFormat;
+        void*   fOldImage;
+    };
+
 protected:
     virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
     virtual void destroyGLContext() SK_OVERRIDE;
diff --git a/include/gpu/gl/SkNativeGLContext.h b/include/gpu/gl/SkNativeGLContext.h
new file mode 100644
index 0000000..93b5b41
--- /dev/null
+++ b/include/gpu/gl/SkNativeGLContext.h
@@ -0,0 +1,111 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkNativeGLContext_DEFINED
+#define SkNativeGLContext_DEFINED
+
+#include "SkGLContextHelper.h"
+
+/* This struct is taken from a mesa demo.  Please update as required */
+static const struct { int major, minor; } gl_versions[] = {
+   {1, 0},
+   {1, 1},
+   {1, 2},
+   {1, 3},
+   {1, 4},
+   {1, 5},
+   {2, 0},
+   {2, 1},
+   {3, 0},
+   {3, 1},
+   {3, 2},
+   {3, 3},
+   {4, 0},
+   {4, 1},
+   {4, 2},
+   {4, 3},
+   {4, 4},
+   {0, 0} /* end of list */
+};
+#define NUM_GL_VERSIONS SK_ARRAY_COUNT(gl_versions)
+
+#if defined(SK_BUILD_FOR_MAC)
+    #include <OpenGL/OpenGL.h>
+#elif SK_EGL
+    #include <GLES2/gl2.h>
+    #include <EGL/egl.h>
+#elif defined(SK_BUILD_FOR_UNIX)
+    #include <X11/Xlib.h>
+    #include <GL/glx.h>
+#elif defined(SK_BUILD_FOR_WIN32)
+    #include <windows.h>
+    #include <GL/GL.h>
+    #include "SkWGL.h"
+#endif
+
+class SkNativeGLContext : public SkGLContextHelper {
+public:
+    SkNativeGLContext();
+
+    virtual ~SkNativeGLContext();
+
+    virtual void makeCurrent() const SK_OVERRIDE;
+    virtual void swapBuffers() const SK_OVERRIDE;
+
+    class AutoContextRestore {
+    public:
+        AutoContextRestore();
+        ~AutoContextRestore();
+
+    private:
+    #if defined(SK_BUILD_FOR_MAC)
+        CGLContextObj fOldCGLContext;
+    #elif SK_EGL
+        EGLContext fOldEGLContext;
+        EGLDisplay fOldDisplay;
+        EGLSurface fOldSurface;
+    #elif defined(SK_BUILD_FOR_UNIX)
+        GLXContext fOldGLXContext;
+        Display* fOldDisplay;
+        GLXDrawable fOldDrawable;
+    #elif defined(SK_BUILD_FOR_WIN32)
+        HDC fOldHDC;
+        HGLRC fOldHGLRC;
+
+    #elif defined(SK_BUILD_FOR_IOS)
+        void* fEAGLContext;
+    #endif
+    };
+
+protected:
+    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
+    virtual void destroyGLContext() SK_OVERRIDE;
+
+private:
+#if defined(SK_BUILD_FOR_MAC)
+    CGLContextObj fContext;
+#elif SK_EGL
+    EGLContext fContext;
+    EGLDisplay fDisplay;
+    EGLSurface fSurface;
+#elif defined(SK_BUILD_FOR_UNIX)
+    GLXContext fContext;
+    Display* fDisplay;
+    Pixmap fPixmap;
+    GLXPixmap fGlxPixmap;
+#elif defined(SK_BUILD_FOR_WIN32)
+    HWND fWindow;
+    HDC fDeviceContext;
+    HGLRC fGlRenderContext;
+    static ATOM gWC;
+    SkWGLPbufferContext* fPbufferContext;
+#elif defined(SK_BUILD_FOR_IOS)
+    void* fEAGLContext;
+#endif
+};
+
+#endif
diff --git a/include/gpu/gl/SkNullGLContext.h b/include/gpu/gl/SkNullGLContext.h
index 16621fc..6c2a1d7 100644
--- a/include/gpu/gl/SkNullGLContext.h
+++ b/include/gpu/gl/SkNullGLContext.h
@@ -8,9 +8,9 @@
 #ifndef SkNullGLContext_DEFINED
 #define SkNullGLContext_DEFINED
 
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
 
-class SK_API SkNullGLContext : public SkGLContext {
+class SK_API SkNullGLContext : public SkGLContextHelper {
 
 public:
     SkNullGLContext() {};
diff --git a/src/gpu/gl/SkGLContext.cpp b/src/gpu/gl/SkGLContextHelper.cpp
similarity index 95%
rename from src/gpu/gl/SkGLContext.cpp
rename to src/gpu/gl/SkGLContextHelper.cpp
index 92f65cd..03b70c3 100644
--- a/src/gpu/gl/SkGLContext.cpp
+++ b/src/gpu/gl/SkGLContextHelper.cpp
@@ -5,17 +5,17 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include "gl/SkGLContext.h"
+#include "gl/SkGLContextHelper.h"
 #include "GrGLUtil.h"
 
-SkGLContext::SkGLContext()
+SkGLContextHelper::SkGLContextHelper()
     : fFBO(0)
     , fColorBufferID(0)
     , fDepthStencilBufferID(0)
     , fGL(NULL) {
 }
 
-SkGLContext::~SkGLContext() {
+SkGLContextHelper::~SkGLContextHelper() {
 
     if (fGL) {
         // TODO: determine why DeleteFramebuffers is generating a GL error in tests
@@ -27,7 +27,7 @@
     SkSafeUnref(fGL);
 }
 
-bool SkGLContext::init(GrGLStandard forcedGpuAPI, int width,
+bool SkGLContextHelper::init(GrGLStandard forcedGpuAPI, int width,
                              int height) {
     if (fGL) {
         fGL->unref();
@@ -135,7 +135,7 @@
     return false;
 }
 
-void SkGLContext::testAbandon() {
+void SkGLContextHelper::testAbandon() {
     if (fGL) {
         fGL->abandon();
     }
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp
index 4914ba5..81fcceb 100644
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp
+++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp
@@ -8,6 +8,21 @@
 
 #include "gl/SkANGLEGLContext.h"
 
+SkANGLEGLContext::AutoContextRestore::AutoContextRestore() {
+    fOldEGLContext = eglGetCurrentContext();
+    fOldDisplay = eglGetCurrentDisplay();
+    fOldSurface = eglGetCurrentSurface(EGL_DRAW);
+
+}
+
+SkANGLEGLContext::AutoContextRestore::~AutoContextRestore() {
+    if (fOldDisplay) {
+        eglMakeCurrent(fOldDisplay, fOldSurface, fOldSurface, fOldEGLContext);
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
 SkANGLEGLContext::SkANGLEGLContext()
     : fContext(EGL_NO_CONTEXT)
     , fDisplay(EGL_NO_DISPLAY)
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index 287a43f..4bd8f99 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -819,7 +819,7 @@
     //      The solution to this is probably to alter SkDebugGlContext's
     //      "makeCurrent" method to make a call like "makeCurrent(this)" to
     //      the debug GL interface (assuming that the application will create
-    //      multiple SkGLContext's) to let it switch between the active
+    //      multiple SkGLContextHelper's) to let it switch between the active
     //      context. Everything in the GrDebugGL object would then need to be
     //      moved to a GrContextObj and the GrDebugGL object would just switch
     //      between them. Note that this approach would also require that
diff --git a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp b/src/gpu/gl/egl/SkNativeGLContext_egl.cpp
similarity index 83%
rename from src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
rename to src/gpu/gl/egl/SkNativeGLContext_egl.cpp
index dac2d11..d4d7219 100644
--- a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
+++ b/src/gpu/gl/egl/SkNativeGLContext_egl.cpp
@@ -5,42 +5,34 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include "gl/SkGLContext.h"
+#include "gl/SkNativeGLContext.h"
 
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
+SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+    fOldEGLContext = eglGetCurrentContext();
+    fOldDisplay = eglGetCurrentDisplay();
+    fOldSurface = eglGetCurrentSurface(EGL_DRAW);
 
-namespace {
+}
 
-class EGLGLContext : public SkGLContext  {
-public:
-    EGLGLContext();
+SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+    if (fOldDisplay) {
+        eglMakeCurrent(fOldDisplay, fOldSurface, fOldSurface, fOldEGLContext);
+    }
+}
 
-    virtual ~EGLGLContext();
+///////////////////////////////////////////////////////////////////////////////
 
-    virtual void makeCurrent() const SK_OVERRIDE;
-    virtual void swapBuffers() const SK_OVERRIDE;
-protected:
-    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
-    virtual void destroyGLContext() SK_OVERRIDE;
-
-private:
-    EGLContext fContext;
-    EGLDisplay fDisplay;
-    EGLSurface fSurface;
-};
-
-EGLGLContext::EGLGLContext()
+SkNativeGLContext::SkNativeGLContext()
     : fContext(EGL_NO_CONTEXT)
     , fDisplay(EGL_NO_DISPLAY)
     , fSurface(EGL_NO_SURFACE) {
 }
 
-EGLGLContext::~EGLGLContext() {
+SkNativeGLContext::~SkNativeGLContext() {
     this->destroyGLContext();
 }
 
-void EGLGLContext::destroyGLContext() {
+void SkNativeGLContext::destroyGLContext() {
     if (fDisplay) {
         eglMakeCurrent(fDisplay, 0, 0, 0);
 
@@ -59,7 +51,7 @@
     }
 }
 
-const GrGLInterface* EGLGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
     static const EGLint kEGLContextAttribsForOpenGL[] = {
         EGL_NONE
     };
@@ -177,21 +169,14 @@
     return interface;
 }
 
-void EGLGLContext::makeCurrent() const {
+void SkNativeGLContext::makeCurrent() const {
     if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
         SkDebugf("Could not set the context.\n");
     }
 }
 
-void EGLGLContext::swapBuffers() const {
+void SkNativeGLContext::swapBuffers() const {
     if (!eglSwapBuffers(fDisplay, fSurface)) {
         SkDebugf("Could not complete eglSwapBuffers.\n");
     }
 }
-
-} // anonymous namespace
-
-SkGLContext* CreatePlatformGLContext() {
-    return SkNEW(EGLGLContext);
-}
-
diff --git a/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp b/src/gpu/gl/glx/SkNativeGLContext_glx.cpp
similarity index 87%
rename from src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp
rename to src/gpu/gl/glx/SkNativeGLContext_glx.cpp
index 794cdb6..bd130b5 100644
--- a/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp
+++ b/src/gpu/gl/glx/SkNativeGLContext_glx.cpp
@@ -5,38 +5,25 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include "gl/SkGLContext.h"
+#include "gl/SkNativeGLContext.h"
 
-#include <X11/Xlib.h>
-#include <GL/glx.h>
 #include <GL/glu.h>
 
-namespace {
-
 /* Note: Skia requires glx 1.3 or newer */
 
-/* This struct is taken from a mesa demo.  Please update as required */
-static const struct { int major, minor; } gl_versions[] = {
-   {1, 0},
-   {1, 1},
-   {1, 2},
-   {1, 3},
-   {1, 4},
-   {1, 5},
-   {2, 0},
-   {2, 1},
-   {3, 0},
-   {3, 1},
-   {3, 2},
-   {3, 3},
-   {4, 0},
-   {4, 1},
-   {4, 2},
-   {4, 3},
-   {4, 4},
-   {0, 0} /* end of list */
-};
-#define NUM_GL_VERSIONS SK_ARRAY_COUNT(gl_versions)
+SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+    fOldGLXContext = glXGetCurrentContext();
+    fOldDisplay = glXGetCurrentDisplay();
+    fOldDrawable = glXGetCurrentDrawable();
+}
+
+SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+    if (fOldDisplay) {
+        glXMakeCurrent(fOldDisplay, fOldDrawable, fOldGLXContext);
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
 
 static bool ctxErrorOccurred = false;
 static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
@@ -44,37 +31,18 @@
     return 0;
 }
 
-class GLXGLContext : public SkGLContext {
-public:
-    GLXGLContext();
-
-    virtual ~GLXGLContext();
-
-    virtual void makeCurrent() const SK_OVERRIDE;
-    virtual void swapBuffers() const SK_OVERRIDE;
-protected:
-    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
-    virtual void destroyGLContext() SK_OVERRIDE;
-
-private:
-    GLXContext fContext;
-    Display* fDisplay;
-    Pixmap fPixmap;
-    GLXPixmap fGlxPixmap;
-};
-
-GLXGLContext::GLXGLContext()
+SkNativeGLContext::SkNativeGLContext()
     : fContext(NULL)
     , fDisplay(NULL)
     , fPixmap(0)
     , fGlxPixmap(0) {
 }
 
-GLXGLContext::~GLXGLContext() {
+SkNativeGLContext::~SkNativeGLContext() {
     this->destroyGLContext();
 }
 
-void GLXGLContext::destroyGLContext() {
+void SkNativeGLContext::destroyGLContext() {
     if (fDisplay) {
         glXMakeCurrent(fDisplay, 0, 0);
 
@@ -98,7 +66,7 @@
     }
 }
 
-const GrGLInterface* GLXGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
     fDisplay = XOpenDisplay(0);
 
     if (!fDisplay) {
@@ -309,18 +277,12 @@
     return interface;
 }
 
-void GLXGLContext::makeCurrent() const {
+void SkNativeGLContext::makeCurrent() const {
     if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) {
         SkDebugf("Could not set the context.\n");
     }
 }
 
-void GLXGLContext::swapBuffers() const {
+void SkNativeGLContext::swapBuffers() const {
     glXSwapBuffers(fDisplay, fGlxPixmap);
 }
-
-} // anonymous namespace
-
-SkGLContext* SkCreatePlatformGLContext() {
-    return SkNEW(GLXGLContext);
-}
diff --git a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm b/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
deleted file mode 100644
index ce44dd3..0000000
--- a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/SkGLContext.h"
-#import <OpenGLES/EAGL.h>
-
-#define EAGLCTX ((EAGLContext*)(fEAGLContext))
-
-namespace {
-
-class IOSNativeGLContext : public SkNativeGLContext {
-public:
-    IOSNativeGLContext();
-
-    virtual ~IOSNativeGLContext();
-
-    virtual void makeCurrent() const SK_OVERRIDE;
-    virtual void swapBuffers() const SK_OVERRIDE;
-protected:
-    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
-    virtual void destroyGLContext() SK_OVERRIDE;
-
-private:
-    void* fEAGLContext;
-};
-
-IOSNativeGLContext::IOSNativeGLContext()
-    : fEAGLContext(NULL) {
-}
-
-IOSNativeGLContext::~IOSNativeGLContext() {
-    this->destroyGLContext();
-}
-
-void IOSNativeGLContext::destroyGLContext() {
-    if (fEAGLContext) {
-        if ([EAGLContext currentContext] == EAGLCTX) {
-            [EAGLContext setCurrentContext:nil];
-        }
-        [EAGLCTX release];
-        fEAGLContext = NULL;
-    }
-}
-
-const GrGLInterface* IOSNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
-    if (kGL_GrGLStandard == forcedGpuAPI) {
-        return NULL;
-    }
-
-    fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
-    [EAGLContext setCurrentContext:EAGLCTX];
-    
-    const GrGLInterface* interface = GrGLCreateNativeInterface();
-    if (!interface) {
-        SkDebugf("Failed to create gl interface");
-        this->destroyGLContext();
-        return NULL;
-    }
-    return interface;
-}
-
-void IOSNativeGLContext::makeCurrent() const {
-    if (![EAGLContext setCurrentContext:EAGLCTX]) {
-        SkDebugf("Could not set the context.\n");
-    }
-}
-
-void IOSNativeGLContext::swapBuffers() const { }
-
-} // anonymous namespace
-
-
-SkNativeGLContext* SkCreatePlatformGLContext() {
-    return SkNEW(IOSNativeGLContext);
-}
-
diff --git a/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
new file mode 100644
index 0000000..1bdaf70
--- /dev/null
+++ b/src/gpu/gl/iOS/SkNativeGLContext_iOS.mm
@@ -0,0 +1,71 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gl/SkNativeGLContext.h"
+#import <OpenGLES/EAGL.h>
+
+#define EAGLCTX ((EAGLContext*)(fEAGLContext))
+
+SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+    fEAGLContext = [EAGLContext currentContext];
+    if (EAGLCTX) {
+        [EAGLCTX retain];
+    }
+}
+
+SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+    if (EAGLCTX) {
+        [EAGLContext setCurrentContext:EAGLCTX];
+        [EAGLCTX release];
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+SkNativeGLContext::SkNativeGLContext()
+    : fEAGLContext(NULL) {
+}
+
+SkNativeGLContext::~SkNativeGLContext() {
+    this->destroyGLContext();
+}
+
+void SkNativeGLContext::destroyGLContext() {
+    if (fEAGLContext) {
+        if ([EAGLContext currentContext] == EAGLCTX) {
+            [EAGLContext setCurrentContext:nil];
+        }
+        [EAGLCTX release];
+        fEAGLContext = NULL;
+    }
+}
+
+const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+    if (kGL_GrGLStandard == forcedGpuAPI) {
+        return NULL;
+    }
+
+    fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
+    [EAGLContext setCurrentContext:EAGLCTX];
+    
+    const GrGLInterface* interface = GrGLCreateNativeInterface();
+    if (!interface) {
+        SkDebugf("Failed to create gl interface");
+        this->destroyGLContext();
+        return NULL;
+    }
+    return interface;
+}
+
+void SkNativeGLContext::makeCurrent() const {
+    if (![EAGLContext setCurrentContext:EAGLCTX]) {
+        SkDebugf("Could not set the context.\n");
+    }
+}
+
+void SkNativeGLContext::swapBuffers() const { }
diff --git a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp
similarity index 63%
rename from src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp
rename to src/gpu/gl/mac/SkNativeGLContext_mac.cpp
index 35ec276..f63471c 100644
--- a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp
+++ b/src/gpu/gl/mac/SkNativeGLContext_mac.cpp
@@ -5,43 +5,34 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include "gl/SkGLContext.h"
+#include "gl/SkNativeGLContext.h"
 #include "AvailabilityMacros.h"
 
-#include <OpenGL/OpenGL.h>
+SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+    fOldCGLContext = CGLGetCurrentContext();
+}
 
-namespace {
-class MacGLContext : public SkGLContext {
-public:
-    MacGLContext();
+SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+    CGLSetCurrentContext(fOldCGLContext);
+}
 
-    virtual ~MacGLContext();
+///////////////////////////////////////////////////////////////////////////////
 
-    virtual void makeCurrent() const SK_OVERRIDE;
-    virtual void swapBuffers() const SK_OVERRIDE;
-protected:
-    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
-    virtual void destroyGLContext() SK_OVERRIDE;
-
-private:
-    CGLContextObj fContext;
-};
-
-MacGLContext::MacGLContext()
+SkNativeGLContext::SkNativeGLContext()
     : fContext(NULL) {
 }
 
-MacGLContext::~MacGLContext() {
+SkNativeGLContext::~SkNativeGLContext() {
     this->destroyGLContext();
 }
 
-void MacGLContext::destroyGLContext() {
+void SkNativeGLContext::destroyGLContext() {
     if (fContext) {
         CGLReleaseContext(fContext);
     }
 }
 
-const GrGLInterface* MacGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
     SkASSERT(NULL == fContext);
     if (kGLES_GrGLStandard == forcedGpuAPI) {
         return NULL;
@@ -84,16 +75,10 @@
     return interface;
 }
 
-void MacGLContext::makeCurrent() const {
+void SkNativeGLContext::makeCurrent() const {
     CGLSetCurrentContext(fContext);
 }
 
-void MacGLContext::swapBuffers() const {
+void SkNativeGLContext::swapBuffers() const {
     CGLFlushDrawable(fContext);
 }
-
-} // anonymous namespace
-
-SkGLContext* SkCreatePlatformGLContext() {
-    return SkNEW(MacGLContext);
-}
diff --git a/src/gpu/gl/mesa/SkMesaGLContext.cpp b/src/gpu/gl/mesa/SkMesaGLContext.cpp
index 8c339c7..31402c5 100644
--- a/src/gpu/gl/mesa/SkMesaGLContext.cpp
+++ b/src/gpu/gl/mesa/SkMesaGLContext.cpp
@@ -11,6 +11,24 @@
 #include "gl/SkMesaGLContext.h"
 #include "gl/GrGLDefines.h"
 
+SkMesaGLContext::AutoContextRestore::AutoContextRestore() {
+    fOldContext = (Context)OSMesaGetCurrentContext();
+    if (fOldContext) {
+        OSMesaGetColorBuffer((OSMesaContext)fOldContext,
+                              &fOldWidth, &fOldHeight,
+                              &fOldFormat, &fOldImage);
+    }
+}
+
+SkMesaGLContext::AutoContextRestore::~AutoContextRestore() {
+    if (fOldContext) {
+        OSMesaMakeCurrent((OSMesaContext)fOldContext, fOldImage,
+                          fOldFormat, fOldWidth, fOldHeight);
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
 SkMesaGLContext::SkMesaGLContext()
     : fContext(static_cast<Context>(NULL))
     , fImage(NULL) {
diff --git a/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp b/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp
deleted file mode 100644
index 5e4b2e4..0000000
--- a/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "gl/SkGLContext.h"
-
-#include <GLES2/gl2.h>
-#include <EGL/egl.h>
-
-namespace {
-class NACLGLContext : public SkGLContext  {
-public:
-    SkGLContextEGL();
-
-    virtual ~NACLGLContext();
-
-    virtual void makeCurrent() const SK_OVERRIDE;
-    virtual void swapBuffers() const SK_OVERRIDE;
-protected:
-    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
-    virtual void destroyGLContext() SK_OVERRIDE;
-
-private:
-    EGLContext fContext;
-    EGLDisplay fDisplay;
-    EGLSurface fSurface;
-};
-
-NACLGLContext::NACLGLContext()
-    : fContext(NULL)
-    , fDisplay(NULL)
-{
-}
-
-NACLGLContext::~NACLGLContext() {
-    this->destroyGLContext();
-}
-
-void NACLGLContext::destroyGLContext() {
-}
-
-const GrGLInterface* NACLGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
-    return NULL;
-}
-
-void NACLGLContext::makeCurrent() const {
-}
-
-void NACLGLContext::swapBuffers() const {
-}
-
-} // anonymous namespace
-
-NACLGLContext* SkCreatePlatformGLContext() {
-    return SkNEW(NACLGLContext);
-}
-
diff --git a/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp b/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp
new file mode 100644
index 0000000..334be1d
--- /dev/null
+++ b/src/gpu/gl/nacl/SkNativeGLContext_nacl.cpp
@@ -0,0 +1,37 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "gl/SkNativeGLContext.h"
+
+SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+}
+
+SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+}
+
+SkNativeGLContext::SkNativeGLContext()
+    : fContext(NULL)
+    , fDisplay(NULL)
+{
+}
+
+SkNativeGLContext::~SkNativeGLContext() {
+    this->destroyGLContext();
+}
+
+void SkNativeGLContext::destroyGLContext() {
+}
+
+const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+    return NULL;
+}
+
+void SkNativeGLContext::makeCurrent() const {
+}
+
+void SkNativeGLContext::swapBuffers() const {
+}
diff --git a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp b/src/gpu/gl/win/SkNativeGLContext_win.cpp
similarity index 79%
rename from src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
rename to src/gpu/gl/win/SkNativeGLContext_win.cpp
index d362556..ab66ba4 100644
--- a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
+++ b/src/gpu/gl/win/SkNativeGLContext_win.cpp
@@ -6,51 +6,36 @@
  * found in the LICENSE file.
  */
 
-#include "gl/SkGLContext.h"
-
-#include <windows.h>
-#include <GL/GL.h>
-#include "SkWGL.h"
+#include "gl/SkNativeGLContext.h"
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
-namespace {
+SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
+    fOldHGLRC = wglGetCurrentContext();
+    fOldHDC = wglGetCurrentDC();
+}
 
-class WinGLContext : public SkGLContext {
-public:
-    WinGLContext();
+SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
+    wglMakeCurrent(fOldHDC, fOldHGLRC);
+}
 
-    virtual ~WinGLContext();
+///////////////////////////////////////////////////////////////////////////////
 
-    virtual void makeCurrent() const SK_OVERRIDE;
-    virtual void swapBuffers() const SK_OVERRIDE;
-protected:
-    virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
-    virtual void destroyGLContext() SK_OVERRIDE;
+ATOM SkNativeGLContext::gWC = 0;
 
-private:
-    HWND fWindow;
-    HDC fDeviceContext;
-    HGLRC fGlRenderContext;
-    static ATOM gWC;
-    SkWGLPbufferContext* fPbufferContext;
-};
-
-ATOM WinGLContext::gWC = 0;
-
-WinGLContext::WinGLContext()
+SkNativeGLContext::SkNativeGLContext()
     : fWindow(NULL)
     , fDeviceContext(NULL)
     , fGlRenderContext(0)
     , fPbufferContext(NULL) {
 }
 
-WinGLContext::~WinGLContext() {
+SkNativeGLContext::~SkNativeGLContext() {
     this->destroyGLContext();
 }
 
-void WinGLContext::destroyGLContext() {
+void SkNativeGLContext::destroyGLContext() {
     SkSafeSetNull(fPbufferContext);
     if (fGlRenderContext) {
         wglDeleteContext(fGlRenderContext);
@@ -66,7 +51,7 @@
     }
 }
 
-const GrGLInterface* WinGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
+const GrGLInterface* SkNativeGLContext::createGLContext(GrGLStandard forcedGpuAPI) {
     HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
 
     if (!gWC) {
@@ -149,7 +134,7 @@
     return interface;
 }
 
-void WinGLContext::makeCurrent() const {
+void SkNativeGLContext::makeCurrent() const {
     HDC dc;
     HGLRC glrc;
 
@@ -166,7 +151,7 @@
     }
 }
 
-void WinGLContext::swapBuffers() const {
+void SkNativeGLContext::swapBuffers() const {
     HDC dc;
 
     if (NULL == fPbufferContext) {
@@ -178,10 +163,3 @@
         SkDebugf("Could not complete SwapBuffers.\n");
     }
 }
-
-} // anonymous namespace
-
-SkGLContext* SkCreatePlatformGLContext() {
-    return SkNEW(WinGLContext);
-}
-
diff --git a/tests/GLInterfaceValidationTest.cpp b/tests/GLInterfaceValidationTest.cpp
index 83f9e2e..797ba72 100755
--- a/tests/GLInterfaceValidationTest.cpp
+++ b/tests/GLInterfaceValidationTest.cpp
@@ -17,20 +17,20 @@
         GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
         // this forces the factory to make the context if it hasn't yet
         factory->get(glCtxType);
-        SkGLContext* glCtx = factory->getGLContext(glCtxType);
+        SkGLContextHelper* glCtxHelper = factory->getGLContext(glCtxType);
 
         // We're supposed to fail the NVPR context type when we the native context that does not
         // support the NVPR extension.
         if (GrContextFactory::kNVPR_GLContextType == glCtxType &&
             factory->getGLContext(GrContextFactory::kNative_GLContextType) &&
             !factory->getGLContext(GrContextFactory::kNative_GLContextType)->hasExtension("GL_NV_path_rendering")) {
-            REPORTER_ASSERT(reporter, NULL == glCtx);
+            REPORTER_ASSERT(reporter, NULL == glCtxHelper);
             continue;
         }
 
-        REPORTER_ASSERT(reporter, glCtx);
-        if (glCtx) {
-            const GrGLInterface* interface = glCtx->gl();
+        REPORTER_ASSERT(reporter, glCtxHelper);
+        if (glCtxHelper) {
+            const GrGLInterface* interface = glCtxHelper->gl();
             REPORTER_ASSERT(reporter, interface->validate());
         }
     }
diff --git a/tests/Test.cpp b/tests/Test.cpp
index c458f89..d0147e1 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -15,7 +15,7 @@
 
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
-#include "gl/SkGLContext.h"
+#include "gl/SkNativeGLContext.h"
 #else
 class GrContext;
 #endif
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index ca44985..705849d 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -228,7 +228,7 @@
 
 void PictureRenderer::resetState(bool callFinish) {
 #if SK_SUPPORT_GPU
-    SkGLContext* glContext = this->getGLContext();
+    SkGLContextHelper* glContext = this->getGLContext();
     if (NULL == glContext) {
         SkASSERT(kBitmap_DeviceType == fDeviceType);
         return;
@@ -248,7 +248,7 @@
     pool->dumpPool();
 
 #if SK_SUPPORT_GPU
-    SkGLContext* glContext = this->getGLContext();
+    SkGLContextHelper* glContext = this->getGLContext();
     if (NULL == glContext) {
         SkASSERT(kBitmap_DeviceType == fDeviceType);
         return;
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index 8465af2..04ac20f 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -30,7 +30,7 @@
 
 class SkBitmap;
 class SkCanvas;
-class SkGLContext;
+class SkGLContextHelper;
 class SkThread;
 
 namespace sk_tools {
@@ -369,7 +369,7 @@
         }
     }
 
-    SkGLContext* getGLContext() {
+    SkGLContextHelper* getGLContext() {
         GrContextFactory::GLContextType glContextType
                 = GrContextFactory::kNull_GLContextType;
         switch(fDeviceType) {
diff --git a/tools/timer/GpuTimer.cpp b/tools/timer/GpuTimer.cpp
index 0fdd999..aac10a3 100644
--- a/tools/timer/GpuTimer.cpp
+++ b/tools/timer/GpuTimer.cpp
@@ -6,10 +6,10 @@
  * found in the LICENSE file.
  */
 #include "GpuTimer.h"
-#include "gl/SkGLContext.h"
+#include "gl/SkGLContextHelper.h"
 #include "gl/GrGLUtil.h"
 
-GpuTimer::GpuTimer(const SkGLContext* glctx) : fContext(glctx) {
+GpuTimer::GpuTimer(const SkGLContextHelper* glctx) : fContext(glctx) {
     if (fContext) {
         fContext->ref();
         fContext->makeCurrent();
diff --git a/tools/timer/GpuTimer.h b/tools/timer/GpuTimer.h
index da1fdab..2100312 100644
--- a/tools/timer/GpuTimer.h
+++ b/tools/timer/GpuTimer.h
@@ -7,18 +7,18 @@
 #ifndef GpuTimer_DEFINED
 #define GpuTimer_DEFINED
 
-class SkGLContext;
+class SkGLContextHelper;
 
 class GpuTimer {
 public:
-    GpuTimer(const SkGLContext*);
+    GpuTimer(const SkGLContextHelper*);
     ~GpuTimer();
     void start();
     double end();
 private:
     unsigned fQuery;
     int fStarted;
-    const SkGLContext* fContext;
+    const SkGLContextHelper* fContext;
     bool fSupported;
 };
 
diff --git a/tools/timer/Timer.cpp b/tools/timer/Timer.cpp
index a9f04afe..4f3fc85 100644
--- a/tools/timer/Timer.cpp
+++ b/tools/timer/Timer.cpp
@@ -6,7 +6,7 @@
  */
 #include "Timer.h"
 
-Timer::Timer(SkGLContext* gl)
+Timer::Timer(SkGLContextHelper* gl)
         : fCpu(-1.0)
         , fWall(-1.0)
         , fTruncatedCpu(-1.0)
diff --git a/tools/timer/Timer.h b/tools/timer/Timer.h
index 81d1ca5..15c93f5 100644
--- a/tools/timer/Timer.h
+++ b/tools/timer/Timer.h
@@ -21,7 +21,7 @@
     #include "GpuTimer.h"
 #endif
 
-class SkGLContext;
+class SkGLContextHelper;
 
 /**
  * SysTimers and GpuTimers are implemented orthogonally.
@@ -34,7 +34,7 @@
  */
 class Timer {
 public:
-    explicit Timer(SkGLContext* gl = NULL);
+    explicit Timer(SkGLContextHelper* gl = NULL);
 
     void start();
     void truncatedEnd();