1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrGLGLSL.h"
9 #include "GrGLContext.h"
10 #include "GrGLUtil.h"
11 #include "SkString.h"
12
GrGLGetGLSLGeneration(const GrGLInterface * gl,GrGLSLGeneration * generation)13 bool GrGLGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
14 SkASSERT(generation);
15 GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
16 if (GR_GLSL_INVALID_VER == ver) {
17 return false;
18 }
19 switch (gl->fStandard) {
20 case kGL_GrGLStandard:
21 SkASSERT(ver >= GR_GLSL_VER(1,10));
22 if (ver >= GR_GLSL_VER(4,00)) {
23 *generation = k400_GrGLSLGeneration;
24 } else if (ver >= GR_GLSL_VER(3,30)) {
25 *generation = k330_GrGLSLGeneration;
26 } else if (ver >= GR_GLSL_VER(1,50)) {
27 *generation = k150_GrGLSLGeneration;
28 } else if (ver >= GR_GLSL_VER(1,40)) {
29 *generation = k140_GrGLSLGeneration;
30 } else if (ver >= GR_GLSL_VER(1,30)) {
31 *generation = k130_GrGLSLGeneration;
32 } else {
33 *generation = k110_GrGLSLGeneration;
34 }
35 return true;
36 case kGLES_GrGLStandard:
37 SkASSERT(ver >= GR_GL_VER(1,00));
38 if (ver >= GR_GLSL_VER(3,20)) {
39 *generation = k320es_GrGLSLGeneration;
40 } else if (ver >= GR_GLSL_VER(3,10)) {
41 *generation = k310es_GrGLSLGeneration;
42 } else if (ver >= GR_GLSL_VER(3,00)) {
43 *generation = k330_GrGLSLGeneration;
44 } else {
45 *generation = k110_GrGLSLGeneration;
46 }
47 return true;
48 default:
49 SkFAIL("Unknown GL Standard");
50 return false;
51 }
52 }
53
54