Make GrGLInterface a per-GrContext refcounted object rather than a global

Review URL: http://codereview.appspot.com/4901046/



git-svn-id: http://skia.googlecode.com/svn/trunk@2140 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGLTexture.cpp b/gpu/src/GrGLTexture.cpp
index 1dc9c1c..be7a0f1 100644
--- a/gpu/src/GrGLTexture.cpp
+++ b/gpu/src/GrGLTexture.cpp
@@ -13,7 +13,9 @@
 
 #define GPUGL static_cast<GrGpuGL*>(getGpu())
 
-const GrGLenum* GrGLTexture::WrapMode2GLWrap() {
+#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
+
+const GrGLenum* GrGLTexture::WrapMode2GLWrap(GrGLBinding binding) {
     static const GrGLenum mirrorRepeatModes[] = {
         GR_GL_CLAMP_TO_EDGE,
         GR_GL_REPEAT,
@@ -26,7 +28,7 @@
         GR_GL_REPEAT
     };
 
-    if (GR_GL_SUPPORT_ES1 && !GR_GL_SUPPORT_ES2) {
+    if (kES1_GrGLBinding == binding) {
         return repeatModes;  // GL_MIRRORED_REPEAT not supported.
     } else {
         return mirrorRepeatModes;
@@ -41,7 +43,8 @@
     GrAssert(0 != textureDesc.fTextureID);
 
     fTexParams          = initialTexParams;
-    fTexIDObj           = new GrGLTexID(textureDesc.fTextureID,
+    fTexIDObj           = new GrGLTexID(GPUGL->glInterface(),
+                                        textureDesc.fTextureID,
                                         textureDesc.fOwnsID);
     fUploadFormat       = textureDesc.fUploadFormat;
     fUploadByteCount    = textureDesc.fUploadByteCount;
@@ -132,10 +135,10 @@
      */
     bool restoreGLRowLength = false;
     bool flipY = kBottomUp_Orientation == fOrientation;
-    if (GR_GL_SUPPORT_DESKTOP && !flipY) {
+    if (kDesktop_GrGLBinding == GPUGL->glBinding() && !flipY) {
         // can't use this for flipping, only non-neg values allowed. :(
         if (srcData && rowBytes) {
-            GR_GL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH,
+            GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH,
                               rowBytes / fUploadByteCount));
             restoreGLRowLength = true;
         }
@@ -166,14 +169,14 @@
     if (flipY) {
         y = this->height() - (y + height);
     }
-    GR_GL(BindTexture(GR_GL_TEXTURE_2D, fTexIDObj->id()));
-    GR_GL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, fUploadByteCount));
-    GR_GL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, x, y, width, height,
-                        fUploadFormat, fUploadType, srcData));
+    GL_CALL(BindTexture(GR_GL_TEXTURE_2D, fTexIDObj->id()));
+    GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, fUploadByteCount));
+    GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, x, y, width, height,
+                          fUploadFormat, fUploadType, srcData));
 
-    if (GR_GL_SUPPORT_DESKTOP) {
+    if (kDesktop_GrGLBinding == GPUGL->glBinding()) {
         if (restoreGLRowLength) {
-            GR_GL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
+            GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
         }
     }
 }