Recommit r2510 now that mac build bot issue has been fixed.



git-svn-id: http://skia.googlecode.com/svn/trunk@2521 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrGLInterface.h b/include/gpu/GrGLInterface.h
index b3e0cf1..20b74ab 100644
--- a/include/gpu/GrGLInterface.h
+++ b/include/gpu/GrGLInterface.h
@@ -69,8 +69,17 @@
 
 const GrGLInterface* GrGLDefaultInterface();
 
+/**
+ * Creates a GrGLInterface for a "native" GL context (e.g. WGL on windows,
+ * GLX on linux, AGL on Mac). On platforms that have context-specific function
+ * pointers for GL extensions (e.g. windows) the returned interface is only 
+ * valid for the context that was current at creation.
+ */
 const GrGLInterface* GrGLCreateNativeInterface();
 
+/**
+ * Creates a GrGLInterface for an OSMesa context.
+ */
 const GrGLInterface* GrGLCreateMesaInterface();
 
 typedef unsigned int GrGLenum;
diff --git a/include/gpu/SkGLContext.h b/include/gpu/SkGLContext.h
index d36a9f9..f92a770 100644
--- a/include/gpu/SkGLContext.h
+++ b/include/gpu/SkGLContext.h
@@ -20,6 +20,9 @@
     SkGLContext();
     virtual ~SkGLContext();
 
+    /**
+     * Initializes the context and makes it current.
+     */
     bool init(const int width, const int height);
 
     int getFBOID() const { return fFBO; }
diff --git a/include/gpu/SkMesaGLContext.h b/include/gpu/SkMesaGLContext.h
index 4351f66..b7578f3 100644
--- a/include/gpu/SkMesaGLContext.h
+++ b/include/gpu/SkMesaGLContext.h
@@ -13,6 +13,9 @@
 #if SK_MESA
 
 class SkMesaGLContext : public SkGLContext {
+private:
+    typedef intptr_t Context;
+
 public:
     SkMesaGLContext();
 
@@ -20,16 +23,28 @@
 
     virtual void makeCurrent() const SK_OVERRIDE;
 
+    class AutoContextRestore {
+    public:
+        AutoContextRestore();
+        ~AutoContextRestore();
+
+    private:
+        Context fOldContext;
+        GLint   fOldWidth;
+        GLint   fOldHeight;
+        GLint   fOldFormat;
+        void*   fOldImage;
+    };
+
 protected:
     virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
     void destroyGLContext() SK_OVERRIDE;
 
 private:
-    typedef intptr_t Context;
     Context fContext;
     GrGLubyte *fImage;
 };
 
 #endif
 
-#endif
\ No newline at end of file
+#endif
diff --git a/include/gpu/SkNativeGLContext.h b/include/gpu/SkNativeGLContext.h
index 512e66a..f2037cf 100644
--- a/include/gpu/SkNativeGLContext.h
+++ b/include/gpu/SkNativeGLContext.h
@@ -28,6 +28,24 @@
 
     virtual void makeCurrent() const SK_OVERRIDE;
 
+    class AutoContextRestore {
+    public:
+        AutoContextRestore();
+        ~AutoContextRestore();
+
+    private:
+    #if defined(SK_BUILD_FOR_MAC)
+        AGLContext fOldAGLContext;
+    #elif defined(SK_BUILD_FOR_UNIX)
+        GLXContext fOldGLXContext;
+        Display* fOldDisplay;
+        GLXDrawable fOldDrawable;
+    #elif defined(SK_BUILD_FOR_WIN32)
+        HDC fOldHDC;
+        HGLRC fOldHGLRC;
+    #endif
+    };
+
 protected:
     virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
     void destroyGLContext() SK_OVERRIDE;