Split GrGLContextInfo into GrGLContext & GrGLContextInfo

https://codereview.appspot.com/7436045/



git-svn-id: http://skia.googlecode.com/svn/trunk@7905 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index a511446..a3c8eba 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -34,9 +34,9 @@
 #endif
             return NULL;
         }
-        GrGLContextInfo ctxInfo(glInterface);
-        if (ctxInfo.isInitialized()) {
-            return SkNEW_ARGS(GrGpuGL, (ctxInfo, context));
+        GrGLContext ctx(glInterface);
+        if (ctx.isInitialized()) {
+            return SkNEW_ARGS(GrGpuGL, (ctx, context));
         }
     }
     return NULL;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 1276a65..d62a310 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -7,7 +7,7 @@
 
 
 #include "GrGLCaps.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "SkTSearch.h"
 
 GrGLCaps::GrGLCaps() {
@@ -73,14 +73,13 @@
     return *this;
 }
 
-void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
+void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
 
     this->reset();
     if (!ctxInfo.isInitialized()) {
         return;
     }
 
-    const GrGLInterface* gli = ctxInfo.interface();
     GrGLBinding binding = ctxInfo.binding();
     GrGLVersion version = ctxInfo.version();
 
@@ -178,7 +177,7 @@
         fUseNonVBOVertexAndIndexDynamicData = true;
     }
 
-    this->initFSAASupport(ctxInfo);
+    this->initFSAASupport(ctxInfo, gli);
     this->initStencilFormats(ctxInfo);
 }
 
@@ -227,7 +226,7 @@
 }
 }
 
-void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
+void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
 
     fMSFBOType = kNone_MSFBOType;
     if (kDesktop_GrGLBinding != ctxInfo.binding()) {
@@ -253,11 +252,11 @@
         if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) {
             fCoverageAAType = kNVDesktop_CoverageAAType;
             GrGLint count;
-            GR_GL_GetIntegerv(ctxInfo.interface(),
+            GR_GL_GetIntegerv(gli,
                               GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES,
                               &count);
             fMSAACoverageModes.setCount(count);
-            GR_GL_GetIntegerv(ctxInfo.interface(),
+            GR_GL_GetIntegerv(gli,
                               GR_GL_MULTISAMPLE_COVERAGE_MODES,
                               (int*)&fMSAACoverageModes[0]);
             // The NV driver seems to return the modes already sorted but the
@@ -269,9 +268,7 @@
         }
     }
     if (kNone_MSFBOType != fMSFBOType) {
-        GR_GL_GetIntegerv(ctxInfo.interface(),
-                          GR_GL_MAX_SAMPLES,
-                          &fMaxSampleCount);
+        GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
     }
 }
 
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 4143868..48ceb33 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -95,7 +95,7 @@
      * Initializes the GrGLCaps to the set of features supported in the current
      * OpenGL context accessible via ctxInfo.
      */
-    void init(const GrGLContextInfo& ctxInfo);
+    void init(const GrGLContextInfo& ctxInfo, const GrGLInterface* interface);
 
     /**
      * Call to note that a color config has been verified as a valid color
@@ -267,7 +267,7 @@
         }
     };
 
-    void initFSAASupport(const GrGLContextInfo& ctxInfo);
+    void initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli);
     void initStencilFormats(const GrGLContextInfo& ctxInfo);
 
     // tracks configs that have been verified to pass the FBO completeness when
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
new file mode 100644
index 0000000..ba4196d
--- /dev/null
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLContext.h"
+
+////////////////////////////////////////////////////////////////////////////////
+GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) {
+    fBindingInUse = ctxInfo.fBindingInUse;
+    fGLVersion = ctxInfo.fGLVersion;
+    fGLSLGeneration = ctxInfo.fGLSLGeneration;
+    fVendor = ctxInfo.fVendor;
+    fExtensions = ctxInfo.fExtensions;
+    fGLCaps = ctxInfo.fGLCaps;
+    return *this;
+}
+    
+bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
+    this->reset();
+    // We haven't validated the GrGLInterface yet, so check for GetString
+    // function pointer
+    if (interface->fGetString) {
+        const GrGLubyte* verUByte;
+        GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
+        const char* ver = reinterpret_cast<const char*>(verUByte);
+        GrGLBinding binding = GrGLGetBindingInUseFromString(ver);
+
+        if (0 != binding && interface->validate(binding) && fExtensions.init(binding, interface)) {
+            fBindingInUse = binding;
+
+            fGLVersion = GrGLGetVersionFromString(ver);
+
+            fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface);
+
+            fVendor = GrGLGetVendor(interface);
+            fGLCaps.init(*this, interface);
+            return true;
+        }
+    }
+    return false;
+}
+
+bool GrGLContextInfo::isInitialized() const {
+    return kNone_GrGLBinding != fBindingInUse;    
+}
+
+void GrGLContextInfo::reset() {
+    fBindingInUse = kNone_GrGLBinding;
+    fGLVersion = GR_GL_VER(0, 0);
+    fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
+    fVendor = kOther_GrGLVendor;
+    fExtensions.reset();
+    fGLCaps.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+GrGLContext::GrGLContext(const GrGLInterface* interface) {
+    fInterface = NULL;
+    this->initialize(interface);
+}
+
+GrGLContext::GrGLContext(const GrGLContext& ctx) {
+    fInterface = NULL;
+    *this = ctx;
+}
+
+GrGLContext& GrGLContext::operator = (const GrGLContext& ctx) {
+    GrSafeAssign(fInterface, ctx.fInterface);
+    fInfo = ctx.fInfo;
+    return *this;
+}
+
+void GrGLContext::reset() {
+    GrSafeSetNull(fInterface);
+    fInfo.reset();
+}
+
+bool GrGLContext::initialize(const GrGLInterface* interface) {
+    if (fInfo.initialize(interface)) {
+        fInterface = interface;
+        interface->ref();
+        return true;
+    }
+    return false;
+}
diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h
new file mode 100644
index 0000000..05647cc
--- /dev/null
+++ b/src/gpu/gl/GrGLContext.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef GrGLContext_DEFINED
+#define GrGLContext_DEFINED
+
+#include "gl/GrGLExtensions.h"
+#include "gl/GrGLInterface.h"
+#include "GrGLCaps.h"
+#include "GrGLSL.h"
+#include "GrGLUtil.h"
+
+#include "SkString.h"
+
+/**
+ * Encapsulates information about an OpenGL context including the OpenGL 
+ * version, the GrGLBinding type of the context, and GLSL version.
+ */
+class GrGLContextInfo {
+public:
+    /**
+     * Default constructor
+     */
+    GrGLContextInfo() { this->reset(); }
+
+    /**
+     * Copies a GrGLContextInfo
+     */
+    GrGLContextInfo& operator= (const GrGLContextInfo& ctxInfo);
+    
+    /**
+     * Initializes a GrGLContextInfo from a GrGLInterface and the currently
+     * bound OpenGL context accessible by the GrGLInterface.
+     */
+    bool initialize(const GrGLInterface* interface);
+    bool isInitialized() const;
+
+    GrGLBinding binding() const { return fBindingInUse; }
+    GrGLVersion version() const { return fGLVersion; }
+    GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
+    GrGLVendor vendor() const { return fVendor; }
+    const GrGLCaps& caps() const { return fGLCaps; }
+    GrGLCaps& caps() { return fGLCaps; }
+
+    /**
+     * Checks for extension support using a cached copy of the GL_EXTENSIONS
+     * string.
+     */
+    bool hasExtension(const char* ext) const {
+        if (!this->isInitialized()) {
+            return false;
+        }
+        return fExtensions.has(ext);
+    }
+
+    /**
+     * Reset the information
+     */
+    void reset();
+
+private:
+
+    GrGLBinding          fBindingInUse;
+    GrGLVersion          fGLVersion;
+    GrGLSLGeneration     fGLSLGeneration;
+    GrGLVendor           fVendor;
+    GrGLExtensions       fExtensions;
+    GrGLCaps             fGLCaps;
+};
+
+/**
+ * Encapsulates the GrGLInterface used to make GL calls plus information
+ * about the context (via GrGLContextInfo).
+ */
+class GrGLContext {
+public:
+    /**
+     * Default constructor
+     */
+    GrGLContext() { this->reset(); }
+
+    /**
+     * Creates a GrGLContext from a GrGLInterface and the currently
+     * bound OpenGL context accessible by the GrGLInterface.
+     */
+    explicit GrGLContext(const GrGLInterface* interface);
+
+    /**
+     * Copies a GrGLContext
+     */
+    GrGLContext(const GrGLContext& ctx);
+
+    ~GrGLContext() { GrSafeUnref(fInterface); }
+
+    /**
+     * Copies a GrGLContext
+     */
+    GrGLContext& operator= (const GrGLContext& ctx);
+
+    /**
+     * Initializes a GrGLContext from a GrGLInterface and the currently
+     * bound OpenGL context accessible by the GrGLInterface.
+     */
+    bool initialize(const GrGLInterface* interface);
+    bool isInitialized() const { return fInfo.isInitialized(); }
+
+    const GrGLInterface* interface() const { return fInterface; }
+    const GrGLContextInfo& info() const { return fInfo; }
+    GrGLContextInfo& info() { return fInfo; }
+
+private:
+    void reset();
+
+    const GrGLInterface* fInterface;
+    GrGLContextInfo      fInfo;
+};
+
+#endif
diff --git a/src/gpu/gl/GrGLContextInfo.cpp b/src/gpu/gl/GrGLContextInfo.cpp
deleted file mode 100644
index 1522618..0000000
--- a/src/gpu/gl/GrGLContextInfo.cpp
+++ /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 "GrGLContextInfo.h"
-
-GrGLContextInfo::~GrGLContextInfo() {
-    GrSafeUnref(fInterface);
-}
-
-GrGLContextInfo::GrGLContextInfo() {
-    this->reset();
-}
-
-GrGLContextInfo::GrGLContextInfo(const GrGLInterface* interface) {
-    fInterface = NULL;
-    this->initialize(interface);
-}
-
-GrGLContextInfo::GrGLContextInfo(const GrGLContextInfo& ctx) {
-    fInterface = NULL;
-    *this = ctx;
-}
-
-GrGLContextInfo& GrGLContextInfo::operator = (const GrGLContextInfo& ctx) {
-    GrSafeAssign(fInterface, ctx.fInterface);
-    fBindingInUse = ctx.fBindingInUse;
-    fGLVersion = ctx.fGLVersion;
-    fGLSLGeneration = ctx.fGLSLGeneration;
-    fVendor = ctx.fVendor;
-    fExtensions = ctx.fExtensions;
-    fGLCaps = ctx.fGLCaps;
-    return *this;
-}
-
-void GrGLContextInfo::reset() {
-    GrSafeSetNull(fInterface);
-    fBindingInUse = kNone_GrGLBinding;
-    fGLVersion = GR_GL_VER(0, 0);
-    fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
-    fVendor = kOther_GrGLVendor;
-    fExtensions.reset();
-    fGLCaps.reset();
-}
-
-bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
-    this->reset();
-    // We haven't validated the GrGLInterface yet, so check for GetString
-    // function pointer
-    if (interface->fGetString) {
-        const GrGLubyte* verUByte;
-        GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
-        const char* ver = reinterpret_cast<const char*>(verUByte);
-        GrGLBinding binding = GrGLGetBindingInUseFromString(ver);
-
-        if (0 != binding && interface->validate(binding) && fExtensions.init(binding, interface)) {
-
-            fInterface = interface;
-            interface->ref();
-
-            fBindingInUse = binding;
-
-            fGLVersion = GrGLGetVersionFromString(ver);
-
-            fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse,
-                                                  this->interface());
-
-            fVendor = GrGLGetVendor(interface);
-            fGLCaps.init(*this);
-            return true;
-        }
-    }
-    return false;
-}
-
-bool GrGLContextInfo::isInitialized() const {
-    return kNone_GrGLBinding != fBindingInUse;
-}
diff --git a/src/gpu/gl/GrGLContextInfo.h b/src/gpu/gl/GrGLContextInfo.h
deleted file mode 100644
index bfadabe..0000000
--- a/src/gpu/gl/GrGLContextInfo.h
+++ /dev/null
@@ -1,89 +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.
- */
-
-
-#ifndef GrGLContextInfo_DEFINED
-#define GrGLContextInfo_DEFINED
-
-#include "gl/GrGLExtensions.h"
-#include "gl/GrGLInterface.h"
-#include "GrGLCaps.h"
-#include "GrGLSL.h"
-#include "GrGLUtil.h"
-
-#include "SkString.h"
-
-/**
- * Encapsulates information about an OpenGL context including the GrGLInterface
- * used to make GL calls, the OpenGL version, the GrGLBinding type of the
- * context, and GLSL version.
- */
-class GrGLContextInfo {
-public:
-
-    /**
-     * Default constructor, creates an uninitialized GrGLContextInfo
-     */
-    GrGLContextInfo();
-
-    /**
-     * Creates a GrGLContextInfo from a GrGLInterface and the currently
-     * bound OpenGL context accessible by the GrGLInterface.
-     */
-    explicit GrGLContextInfo(const GrGLInterface* interface);
-
-    /**
-     * Copies a GrGLContextInfo
-     */
-    GrGLContextInfo(const GrGLContextInfo& ctx);
-
-    ~GrGLContextInfo();
-
-    /**
-     * Copies a GrGLContextInfo
-     */
-    GrGLContextInfo& operator = (const GrGLContextInfo& ctx);
-
-    /**
-     * Initializes a GrGLContextInfo from a GrGLInterface and the currently
-     * bound OpenGL context accessible by the GrGLInterface.
-     */
-    bool initialize(const GrGLInterface* interface);
-    bool isInitialized() const;
-
-    const GrGLInterface* interface() const { return fInterface; }
-    GrGLBinding binding() const { return fBindingInUse; }
-    GrGLVersion version() const { return fGLVersion; }
-    GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
-    GrGLVendor vendor() const { return fVendor; }
-    const GrGLCaps& caps() const { return fGLCaps; }
-    GrGLCaps& caps() { return fGLCaps; }
-
-    /**
-     * Checks for extension support using a cached copy of the GL_EXTENSIONS
-     * string.
-     */
-    bool hasExtension(const char* ext) const {
-        if (!this->isInitialized()) {
-            return false;
-        }
-        return fExtensions.has(ext);
-    }
-
-private:
-    void reset();
-
-    const GrGLInterface* fInterface;
-    GrGLBinding          fBindingInUse;
-    GrGLVersion          fGLVersion;
-    GrGLSLGeneration     fGLSLGeneration;
-    GrGLVendor           fVendor;
-    GrGLExtensions       fExtensions;
-    GrGLCaps             fGLCaps;
-};
-
-#endif
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index eb49325..781e15f 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -20,8 +20,8 @@
 
 SK_DEFINE_INST_COUNT(GrGLProgram)
 
-#define GL_CALL(X) GR_GL_CALL(fContextInfo.interface(), X)
-#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContextInfo.interface(), R, X)
+#define GL_CALL(X) GR_GL_CALL(fContext.interface(), X)
+#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X)
 
 SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, "Print the source code for all shaders generated.");
 
@@ -229,7 +229,7 @@
 #endif
 }
 
-GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
+GrGLProgram* GrGLProgram::Create(const GrGLContext& gl,
                                  const Desc& desc,
                                  const GrEffectStage* stages[]) {
     GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages));
@@ -240,10 +240,10 @@
     return program;
 }
 
-GrGLProgram::GrGLProgram(const GrGLContextInfo& gl,
+GrGLProgram::GrGLProgram(const GrGLContext& gl,
                          const Desc& desc,
                          const GrEffectStage* stages[])
-: fContextInfo(gl)
+: fContext(gl)
 , fUniformManager(gl) {
     fDesc = desc;
     fVShaderID = 0;
@@ -438,7 +438,7 @@
             builder->fFSCode.appendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
             builder->fFSCode.append("\t\tedgeAlpha = clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);\n"
                                     "\t}\n");
-            if (kES2_GrGLBinding == fContextInfo.binding()) {
+            if (kES2_GrGLBinding == fContext.info().binding()) {
                 builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
             }
             break;
@@ -451,7 +451,7 @@
             builder->fFSCode.appendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
             builder->fFSCode.append("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
             builder->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
-            if (kES2_GrGLBinding == fContextInfo.binding()) {
+            if (kES2_GrGLBinding == fContext.info().binding()) {
                 builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
             }
             break;
@@ -548,7 +548,7 @@
 void GrGLProgram::genGeometryShader(GrGLShaderBuilder* segments) const {
 #if GR_GL_EXPERIMENTAL_GS
     if (fDesc.fExperimentalGS) {
-        GrAssert(fContextInfo.glslGeneration() >= k150_GrGLSLGeneration);
+        GrAssert(fContext.info().glslGeneration() >= k150_GrGLSLGeneration);
         segments->fGSHeader.append("layout(triangles) in;\n"
                                    "layout(triangle_strip, max_vertices = 6) out;\n");
         segments->fGSCode.append("\tfor (int i = 0; i < 3; ++i) {\n"
@@ -597,7 +597,7 @@
 }
 
 // Compiles a GL shader, returns shader ID or 0 if failed params have same meaning as glShaderSource
-GrGLuint compile_shader(const GrGLContextInfo& gl,
+GrGLuint compile_shader(const GrGLContext& gl,
                         GrGLenum type,
                         int stringCnt,
                         const char** strings,
@@ -638,7 +638,7 @@
 }
 
 // helper version of above for when shader is already flattened into a single SkString
-GrGLuint compile_shader(const GrGLContextInfo& gl, GrGLenum type, const SkString& shader) {
+GrGLuint compile_shader(const GrGLContext& gl, GrGLenum type, const SkString& shader) {
     const GrGLchar* str = shader.c_str();
     int length = shader.size();
     return compile_shader(gl, type, 1, &str, &length);
@@ -657,7 +657,7 @@
         GrPrintf("\n");
     }
 
-    if (!(fVShaderID = compile_shader(fContextInfo, GR_GL_VERTEX_SHADER, shader))) {
+    if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader))) {
         return false;
     }
 
@@ -667,7 +667,7 @@
             GrPrintf(shader.c_str());
             GrPrintf("\n");
         }
-        if (!(fGShaderID = compile_shader(fContextInfo, GR_GL_GEOMETRY_SHADER, shader))) {
+        if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, shader))) {
             return false;
         }
     } else {
@@ -679,7 +679,7 @@
         GrPrintf(shader.c_str());
         GrPrintf("\n");
     }
-    if (!(fFShaderID = compile_shader(fContextInfo, GR_GL_FRAGMENT_SHADER, shader))) {
+    if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) {
         return false;
     }
 
@@ -689,7 +689,7 @@
 bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
     GrAssert(0 == fProgramID);
 
-    GrGLShaderBuilder builder(fContextInfo, fUniformManager);
+    GrGLShaderBuilder builder(fContext.info(), fUniformManager);
     const GrAttribBindings& attribBindings = fDesc.fAttribBindings;
 
 #if GR_GL_EXPERIMENTAL_GS
@@ -738,11 +738,11 @@
     // the dual source output has no canonical var name, have to
     // declare an output, which is incompatible with gl_FragColor/gl_FragData.
     bool dualSourceOutputWritten = false;
-    builder.fHeader.append(GrGetGLSLVersionDecl(fContextInfo.binding(),
-                                                fContextInfo.glslGeneration()));
+    builder.fHeader.append(GrGetGLSLVersionDecl(fContext.info().binding(),
+                                                fContext.info().glslGeneration()));
 
     GrGLShaderVar colorOutput;
-    bool isColorDeclared = GrGLSLSetupFSColorOuput(fContextInfo.glslGeneration(),
+    bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneration(),
                                                    declared_color_output_name(),
                                                    &colorOutput);
     if (isColorDeclared) {
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index ea39fa8..cde918b 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -11,7 +11,7 @@
 
 #include "GrDrawState.h"
 #include "GrGLEffect.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "GrGLSL.h"
 #include "GrGLTexture.h"
 #include "GrGLUniformManager.h"
@@ -55,7 +55,7 @@
                           const GrGpuGL* gpu,
                           Desc* outDesc);
 
-    static GrGLProgram* Create(const GrGLContextInfo& gl,
+    static GrGLProgram* Create(const GrGLContext& gl,
                                const Desc& desc,
                                const GrEffectStage* stages[]);
 
@@ -206,7 +206,7 @@
     static const AttribLayout kAttribLayouts[kGrVertexAttribTypeCount];
 
 private:
-    GrGLProgram(const GrGLContextInfo& gl,
+    GrGLProgram(const GrGLContext& gl,
                 const Desc& desc,
                 const GrEffectStage* stages[]);
 
@@ -290,7 +290,7 @@
     GrGLEffect*                 fEffects[GrDrawState::kNumStages];
 
     Desc                        fDesc;
-    const GrGLContextInfo&      fContextInfo;
+    const GrGLContext&          fContext;
 
     GrGLUniformManager          fUniformManager;
     UniformHandles              fUniformHandles;
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index 1618fe5..aa3505c 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -81,7 +81,8 @@
 // varying by stage, if we use 1D textures for gradients!
 //const int GrGLShaderBuilder::fCoordDims = 2;
 
-GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformManager& uniformManager)
+GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, 
+                                     GrGLUniformManager& uniformManager)
     : fUniforms(kVarsPerBlock)
     , fVSAttrs(kVarsPerBlock)
     , fVSOutputs(kVarsPerBlock)
@@ -90,7 +91,7 @@
     , fFSInputs(kVarsPerBlock)
     , fFSOutputs(kMaxFSOutputs)
     , fUsesGS(false)
-    , fContext(ctx)
+    , fCtxInfo(ctxInfo)
     , fUniformManager(uniformManager)
     , fCurrentStageIdx(kNonStageIdx)
     , fSetupFragPosition(false)
@@ -111,7 +112,7 @@
                  sample_function_name(varyingType),
                  this->getUniformCStr(sampler.fSamplerUniform),
                  coordName);
-    append_swizzle(out, *sampler.textureAccess(), fContext.caps());
+    append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps());
 }
 
 void GrGLShaderBuilder::appendTextureLookupAndModulate(
@@ -261,7 +262,7 @@
 
 const char* GrGLShaderBuilder::fragmentPosition() {
 #if 1
-    if (fContext.caps().fragCoordConventionsSupport()) {
+    if (fCtxInfo.caps().fragCoordConventionsSupport()) {
         if (!fSetupFragPosition) {
             fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n");
             fFSInputs.push_back().set(kVec4f_GrSLType,
@@ -327,7 +328,7 @@
     fFSFunctions.append(*outName);
     fFSFunctions.append("(");
     for (int i = 0; i < argCnt; ++i) {
-        args[i].appendDecl(fContext, &fFSFunctions);
+        args[i].appendDecl(fCtxInfo, &fFSFunctions);
         if (i < argCnt - 1) {
             fFSFunctions.append(", ");
         }
@@ -365,7 +366,7 @@
 
 void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
     for (int i = 0; i < vars.count(); ++i) {
-        vars[i].appendDecl(fContext, out);
+        vars[i].appendDecl(fCtxInfo, out);
         out->append(";\n");
     }
 }
@@ -373,7 +374,7 @@
 void GrGLShaderBuilder::appendUniformDecls(ShaderType stype, SkString* out) const {
     for (int i = 0; i < fUniforms.count(); ++i) {
         if (fUniforms[i].fVisibility & stype) {
-            fUniforms[i].fVariable.appendDecl(fContext, out);
+            fUniforms[i].fVariable.appendDecl(fCtxInfo, out);
             out->append(";\n");
         }
     }
@@ -406,13 +407,13 @@
         case kFragment_ShaderType:
             *shaderStr = fHeader;
             append_default_precision_qualifier(kDefaultFragmentPrecision,
-                                               fContext.binding(),
+                                               fCtxInfo.binding(),
                                                shaderStr);
             shaderStr->append(fFSHeader);
             this->appendUniformDecls(kFragment_ShaderType, shaderStr);
             this->appendDecls(fFSInputs, shaderStr);
             // We shouldn't have declared outputs on 1.10
-            GrAssert(k110_GrGLSLGeneration != fContext.glslGeneration() || fFSOutputs.empty());
+            GrAssert(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOutputs.empty());
             this->appendDecls(fFSOutputs, shaderStr);
             shaderStr->append(fFSFunctions);
             shaderStr->append("void main() {\n");
diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h
index 87136cd..d50fbce 100644
--- a/src/gpu/gl/GrGLShaderBuilder.h
+++ b/src/gpu/gl/GrGLShaderBuilder.h
@@ -217,7 +217,7 @@
         kNonStageIdx = -1,
     };
 
-    const GrGLContextInfo&              fContext;
+    const GrGLContextInfo&              fCtxInfo;
     GrGLUniformManager&                 fUniformManager;
     int                                 fCurrentStageIdx;
     SkString                            fFSFunctions;
diff --git a/src/gpu/gl/GrGLShaderVar.h b/src/gpu/gl/GrGLShaderVar.h
index 89fa087..ecf0b47 100644
--- a/src/gpu/gl/GrGLShaderVar.h
+++ b/src/gpu/gl/GrGLShaderVar.h
@@ -8,7 +8,7 @@
 #ifndef GrGLShaderVar_DEFINED
 #define GrGLShaderVar_DEFINED
 
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "GrGLSL.h"
 #include "SkString.h"
 
@@ -252,7 +252,7 @@
     /**
      * Write a declaration of this variable to out.
      */
-    void appendDecl(const GrGLContextInfo& gl, SkString* out) const {
+    void appendDecl(const GrGLContextInfo& ctxInfo, SkString* out) const {
         if (kUpperLeft_Origin == fOrigin) {
             // this is the only place where we specify a layout modifier. If we use other layout
             // modifiers in the future then they should be placed in a list.
@@ -260,10 +260,10 @@
         }
         if (this->getTypeModifier() != kNone_TypeModifier) {
            out->append(TypeModifierString(this->getTypeModifier(),
-                                          gl.glslGeneration()));
+                                          ctxInfo.glslGeneration()));
            out->append(" ");
         }
-        out->append(PrecisionString(fPrecision, gl.binding()));
+        out->append(PrecisionString(fPrecision, ctxInfo.binding()));
         GrSLType effectiveType = this->getType();
         if (this->isArray()) {
             if (this->isUnsizedArray()) {
diff --git a/src/gpu/gl/GrGLUniformManager.h b/src/gpu/gl/GrGLUniformManager.h
index 8f435d3..ee693a6 100644
--- a/src/gpu/gl/GrGLUniformManager.h
+++ b/src/gpu/gl/GrGLUniformManager.h
@@ -14,7 +14,7 @@
 
 #include "SkTArray.h"
 
-class GrGLContextInfo;
+class GrGLContext;
 class SkMatrix;
 
 /** Manages a program's uniforms.
@@ -25,7 +25,7 @@
     typedef int UniformHandle;
     static const UniformHandle kInvalidUniformHandle = 0;
 
-    GrGLUniformManager(const GrGLContextInfo& context) : fContext(context) {}
+    GrGLUniformManager(const GrGLContext& context) : fContext(context) {}
 
     UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray);
 
@@ -78,7 +78,7 @@
     };
 
     SkTArray<Uniform, true> fUniforms;
-    const GrGLContextInfo&  fContext;
+    const GrGLContext&  fContext;
 };
 
 #endif
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 92bac03..8ea7e5c 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -147,17 +147,17 @@
     return status == GR_GL_FRAMEBUFFER_COMPLETE;
 }
 
-GrGpuGL::GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context)
+GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
     : GrGpu(context)
-    , fGLContextInfo(ctxInfo) {
+    , fGLContext(ctx) {
 
-    GrAssert(ctxInfo.isInitialized());
+    GrAssert(ctx.isInitialized());
 
     fillInConfigRenderableTable();
 
     fPrintedCaps = false;
 
-    GrGLClearErr(fGLContextInfo.interface());
+    GrGLClearErr(fGLContext.interface());
 
     if (gPrintStartupSpew) {
         const GrGLubyte* ext;
@@ -178,7 +178,7 @@
 
     this->initCaps();
 
-    fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContextInfo()));
+    fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext()));
 
     fHWGeometryState.setMaxAttribArrays(this->glCaps().maxVertexAttributes());
 
@@ -827,34 +827,34 @@
 }
 
 namespace {
-bool renderbuffer_storage_msaa(GrGLContextInfo& ctxInfo,
+bool renderbuffer_storage_msaa(GrGLContext& ctx,
                                int sampleCount,
                                GrGLenum format,
                                int width, int height) {
-    CLEAR_ERROR_BEFORE_ALLOC(ctxInfo.interface());
-    GrAssert(GrGLCaps::kNone_MSFBOType != ctxInfo.caps().msFBOType());
+    CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
+    GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps().msFBOType());
     bool created = false;
     if (GrGLCaps::kNVDesktop_CoverageAAType ==
-        ctxInfo.caps().coverageAAType()) {
+        ctx.info().caps().coverageAAType()) {
         const GrGLCaps::MSAACoverageMode& mode =
-            ctxInfo.caps().getMSAACoverageMode(sampleCount);
-        GL_ALLOC_CALL(ctxInfo.interface(),
+            ctx.info().caps().getMSAACoverageMode(sampleCount);
+        GL_ALLOC_CALL(ctx.interface(),
                       RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER,
                                                         mode.fCoverageSampleCnt,
                                                         mode.fColorSampleCnt,
                                                         format,
                                                         width, height));
-        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
+        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
     }
     if (!created) {
         // glRBMS will fail if requested samples is > max samples.
-        sampleCount = GrMin(sampleCount, ctxInfo.caps().maxSampleCount());
-        GL_ALLOC_CALL(ctxInfo.interface(),
+        sampleCount = GrMin(sampleCount, ctx.info().caps().maxSampleCount());
+        GL_ALLOC_CALL(ctx.interface(),
                       RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
                                                      sampleCount,
                                                      format,
                                                      width, height));
-        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
+        created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
     }
     return created;
 }
@@ -904,7 +904,7 @@
         GrAssert(desc->fSampleCnt > 0);
         GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER,
                                desc->fMSColorRenderbufferID));
-        if (!renderbuffer_storage_msaa(fGLContextInfo,
+        if (!renderbuffer_storage_msaa(fGLContext,
                                        desc->fSampleCnt,
                                        msColorFormat,
                                        width, height)) {
@@ -920,7 +920,7 @@
             if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
                 goto FAILED;
             }
-            fGLContextInfo.caps().markConfigAsValidColorAttachment(
+            fGLContext.info().caps().markConfigAsValidColorAttachment(
                                                                 desc->fConfig);
         }
     }
@@ -935,7 +935,7 @@
         if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
             goto FAILED;
         }
-        fGLContextInfo.caps().markConfigAsValidColorAttachment(desc->fConfig);
+        fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fConfig);
     }
 
     return true;
@@ -1131,7 +1131,7 @@
         // version on a GL that doesn't have an MSAA extension.
         bool created;
         if (samples > 0) {
-            created = renderbuffer_storage_msaa(fGLContextInfo,
+            created = renderbuffer_storage_msaa(fGLContext,
                                                 samples,
                                                 sFmt.fInternalFormat,
                                                 width, height);
@@ -1220,7 +1220,7 @@
                 }
                 return false;
             } else {
-                fGLContextInfo.caps().markColorConfigAndStencilFormatAsVerified(
+                fGLContext.info().caps().markColorConfigAndStencilFormatAsVerified(
                     rt->config(),
                     glsb->format());
             }
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index b47865c..a859d18 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -13,7 +13,7 @@
 #include "GrBinHashKey.h"
 #include "GrDrawState.h"
 #include "GrGpu.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
 #include "GrGLIndexBuffer.h"
 #include "GrGLIRect.h"
 #include "GrGLProgram.h"
@@ -24,17 +24,13 @@
 
 class GrGpuGL : public GrGpu {
 public:
-    GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context);
+    GrGpuGL(const GrGLContext& ctx, GrContext* context);
     virtual ~GrGpuGL();
 
-    const GrGLInterface* glInterface() const {
-        return fGLContextInfo.interface();
-    }
-    GrGLBinding glBinding() const { return fGLContextInfo.binding(); }
-    GrGLVersion glVersion() const { return fGLContextInfo.version(); }
-    GrGLSLGeneration glslGeneration() const {
-        return fGLContextInfo.glslGeneration();
-    }
+    const GrGLInterface* glInterface() const { return fGLContext.interface(); }
+    GrGLBinding glBinding() const { return fGLContext.info().binding(); }
+    GrGLVersion glVersion() const { return fGLContext.info().version(); }
+    GrGLSLGeneration glslGeneration() const { return fGLContext.info().glslGeneration(); }
 
     // Used by GrGLProgram to bind necessary textures for GrGLEffects.
     void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture);
@@ -55,7 +51,7 @@
 
     virtual void abandonResources() SK_OVERRIDE;
 
-    const GrGLCaps& glCaps() const { return fGLContextInfo.caps(); }
+    const GrGLCaps& glCaps() const { return fGLContext.info().caps(); }
 
     // Callbacks to update state tracking when related GL objects are bound or deleted
     void notifyVertexBufferBind(GrGLuint id);
@@ -137,17 +133,15 @@
     // have been accounted for).
     void flushBlend(bool isLines, GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff);
 
-    bool hasExtension(const char* ext) const {
-        return fGLContextInfo.hasExtension(ext);
-    }
+    bool hasExtension(const char* ext) const { return fGLContext.info().hasExtension(ext); }
 
-    const GrGLContextInfo& glContextInfo() const { return fGLContextInfo; }
+    const GrGLContext& glContext() const { return fGLContext; }
 
     static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
 
     class ProgramCache : public ::GrNoncopyable {
     public:
-        ProgramCache(const GrGLContextInfo& gl);
+        ProgramCache(const GrGLContext& gl);
 
         void abandon();
         GrGLProgram* getProgram(const GrGLProgram::Desc& desc, const GrEffectStage* stages[]);
@@ -188,7 +182,7 @@
         Entry                       fEntries[kMaxEntries];
         int                         fCount;
         unsigned int                fCurrLRUStamp;
-        const GrGLContextInfo&      fGL;
+        const GrGLContext&          fGL;
     };
 
     // sets the matrix for path stenciling (uses the GL fixed pipe matrices)
@@ -236,7 +230,7 @@
 
     void fillInConfigRenderableTable();
 
-    GrGLContextInfo fGLContextInfo;
+    GrGLContext fGLContext;
 
     // GL program-related state
     ProgramCache*               fProgramCache;
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 8526100..e5a7183 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -16,7 +16,7 @@
 #define SKIP_CACHE_CHECK    true
 #define GR_UINT32_MAX   static_cast<uint32_t>(-1)
 
-GrGpuGL::ProgramCache::ProgramCache(const GrGLContextInfo& gl)
+GrGpuGL::ProgramCache::ProgramCache(const GrGLContext& gl)
     : fCount(0)
     , fCurrLRUStamp(0)
     , fGL(gl) {
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 6076845..9dcc8ec 100644
--- a/src/gpu/gl/SkGLContext.cpp
+++ b/src/gpu/gl/SkGLContextHelper.cpp
@@ -1,23 +1,23 @@
 
 /*
- * Copyright 2011 Google Inc.
+ * Copyright 2013 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 "gl/SkGLContextHelper.h"
 #include "GrGLUtil.h"
 
-SK_DEFINE_INST_COUNT(SkGLContext)
+SK_DEFINE_INST_COUNT(SkGLContextHelper)
 
-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
@@ -29,7 +29,7 @@
     SkSafeUnref(fGL);
 }
 
-bool SkGLContext::init(int width, int height) {
+bool SkGLContextHelper::init(int width, int height) {
     if (fGL) {
         fGL->unref();
         this->destroyGLContext();
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index ab3501c..21a3d1b 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -738,7 +738,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