Modify GLSL version declaration to allow access to compat. features

R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/23526008

git-svn-id: http://skia.googlecode.com/svn/trunk/src@11033 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/gl/GrGLSL.cpp b/gpu/gl/GrGLSL.cpp
index 486390b..2959682 100644
--- a/gpu/gl/GrGLSL.cpp
+++ b/gpu/gl/GrGLSL.cpp
@@ -33,26 +33,30 @@
     }
 }
 
-const char* GrGetGLSLVersionDecl(GrGLBinding binding, GrGLSLGeneration gen) {
-    switch (gen) {
+const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
+    switch (info.glslGeneration()) {
         case k110_GrGLSLGeneration:
-            if (kES_GrGLBinding == binding) {
+            if (kES_GrGLBinding == info.binding()) {
                 // ES2s shader language is based on version 1.20 but is version
                 // 1.00 of the ES language.
                 return "#version 100\n";
             } else {
-                SkASSERT(kDesktop_GrGLBinding == binding);
+                SkASSERT(kDesktop_GrGLBinding == info.binding());
                 return "#version 110\n";
             }
         case k130_GrGLSLGeneration:
-            SkASSERT(kDesktop_GrGLBinding == binding);
+            SkASSERT(kDesktop_GrGLBinding == info.binding());
             return "#version 130\n";
         case k140_GrGLSLGeneration:
-            SkASSERT(kDesktop_GrGLBinding == binding);
+            SkASSERT(kDesktop_GrGLBinding == info.binding());
             return "#version 140\n";
         case k150_GrGLSLGeneration:
-            SkASSERT(kDesktop_GrGLBinding == binding);
-            return "#version 150\n";
+            SkASSERT(kDesktop_GrGLBinding == info.binding());
+            if (info.caps()->isCoreProfile()) {
+                return "#version 150\n";
+            } else {
+                return "#version 150 compatibility\n";
+            }
         default:
             GrCrash("Unknown GL version.");
             return ""; // suppress warning
diff --git a/gpu/gl/GrGLSL.h b/gpu/gl/GrGLSL.h
index e65c8d3..a54bd3b 100644
--- a/gpu/gl/GrGLSL.h
+++ b/gpu/gl/GrGLSL.h
@@ -12,6 +12,7 @@
 #include "GrColor.h"
 #include "GrTypesPriv.h"
 
+class GrGLContextInfo;
 class GrGLShaderVar;
 class SkString;
 
@@ -83,8 +84,7 @@
  * Returns a string to include at the beginning of a shader to declare the GLSL
  * version.
  */
-const char* GrGetGLSLVersionDecl(GrGLBinding binding,
-                                 GrGLSLGeneration v);
+const char* GrGetGLSLVersionDecl(const GrGLContextInfo&);
 
 /**
  * Depending on the GLSL version being emitted there may be an assumed output
diff --git a/gpu/gl/GrGLShaderBuilder.cpp b/gpu/gl/GrGLShaderBuilder.cpp
index 49d9591..9ac4645 100644
--- a/gpu/gl/GrGLShaderBuilder.cpp
+++ b/gpu/gl/GrGLShaderBuilder.cpp
@@ -589,7 +589,7 @@
 }
 
 void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
-    const char* version = GrGetGLSLVersionDecl(fCtxInfo.binding(), fCtxInfo.glslGeneration());
+    const char* version = GrGetGLSLVersionDecl(fCtxInfo);
 
     switch (type) {
         case kVertex_ShaderType: