Checkpoint towards core profile support.

1) Stop calling glDisable for removed state

2) Use new GLSL names for texture sampling functions.
Review URL: https://codereview.chromium.org/12330181

git-svn-id: http://skia.googlecode.com/svn/trunk@7908 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index d62a310..9058b35 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -38,6 +38,7 @@
     fTwoFormatLimit = false;
     fFragCoordsConventionSupport = false;
     fUseNonVBOVertexAndIndexDynamicData = false;
+    fIsCoreProfile = false;
 }
 
 GrGLCaps::GrGLCaps(const GrGLCaps& caps) {
@@ -69,6 +70,7 @@
     fTwoFormatLimit = caps.fTwoFormatLimit;
     fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
     fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData;
+    fIsCoreProfile = caps.fIsCoreProfile;
 
     return *this;
 }
@@ -176,6 +178,12 @@
         (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor())) {
         fUseNonVBOVertexAndIndexDynamicData = true;
     }
+    
+    if (kDesktop_GrGLBinding == binding && version >= GR_GL_VER(3, 2)) {
+        GrGLint profileMask;
+        GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
+        fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
+    }
 
     this->initFSAASupport(ctxInfo, gli);
     this->initStencilFormats(ctxInfo);
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 48ceb33..35b4dfc 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -228,6 +228,8 @@
     bool readPixelsSupported(const GrGLInterface* intf,
                              GrGLenum format,
                              GrGLenum type) const;
+    
+    bool isCoreProfile() const { return fIsCoreProfile; }
 
 private:
     /**
@@ -303,6 +305,7 @@
     bool fTwoFormatLimit : 1;
     bool fFragCoordsConventionSupport : 1;
     bool fUseNonVBOVertexAndIndexDynamicData : 1;
+    bool fIsCoreProfile : 1;
 };
 
 #endif
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index aa3505c..c4339b8 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -24,12 +24,12 @@
 
 namespace {
 
-inline const char* sample_function_name(GrSLType type) {
+inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen) {
     if (kVec2f_GrSLType == type) {
-        return "texture2D";
+        return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D";
     } else {
         GrAssert(kVec3f_GrSLType == type);
-        return "texture2DProj";
+        return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj";
     }
 }
 
@@ -109,7 +109,7 @@
     GrAssert(NULL != coordName);
 
     out->appendf("%s(%s, %s)",
-                 sample_function_name(varyingType),
+                 sample_function_name(varyingType, fCtxInfo.glslGeneration()),
                  this->getUniformCStr(sampler.fSamplerUniform),
                  coordName);
     append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps());
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 8ea7e5c..42e83b0 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -414,15 +414,17 @@
 
     if (kDesktop_GrGLBinding == this->glBinding()) {
         // Desktop-only state that we never change
-        GL_CALL(Disable(GR_GL_POINT_SMOOTH));
-        GL_CALL(Disable(GR_GL_LINE_SMOOTH));
-        GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
-        GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
-        GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
+        if (!this->glCaps().isCoreProfile()) {
+            GL_CALL(Disable(GR_GL_POINT_SMOOTH));
+            GL_CALL(Disable(GR_GL_LINE_SMOOTH));
+            GL_CALL(Disable(GR_GL_POLYGON_SMOOTH));
+            GL_CALL(Disable(GR_GL_POLYGON_STIPPLE));
+            GL_CALL(Disable(GR_GL_COLOR_LOGIC_OP));
+            GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
+        }
         if (this->glCaps().imagingSupport()) {
             GL_CALL(Disable(GR_GL_COLOR_TABLE));
         }
-        GL_CALL(Disable(GR_GL_INDEX_LOGIC_OP));
         GL_CALL(Disable(GR_GL_POLYGON_OFFSET_FILL));
         // Since ES doesn't support glPointSize at all we always use the VS to
         // set the point size