• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "GrGLContext.h"
9 #include "GrGLUtil.h"
10 #include "SkString.h"
11 #include "../private/GrGLSL.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,20)) {
23                 *generation = k420_GrGLSLGeneration;
24             } else if (ver >= GR_GLSL_VER(4,00)) {
25                 *generation = k400_GrGLSLGeneration;
26             } else if (ver >= GR_GLSL_VER(3,30)) {
27                 *generation = k330_GrGLSLGeneration;
28             } else if (ver >= GR_GLSL_VER(1,50)) {
29                 *generation = k150_GrGLSLGeneration;
30             } else if (ver >= GR_GLSL_VER(1,40)) {
31                 *generation = k140_GrGLSLGeneration;
32             } else if (ver >= GR_GLSL_VER(1,30)) {
33                 *generation = k130_GrGLSLGeneration;
34             } else {
35                 *generation = k110_GrGLSLGeneration;
36             }
37             return true;
38         case kGLES_GrGLStandard:
39             SkASSERT(ver >= GR_GL_VER(1,00));
40             if (ver >= GR_GLSL_VER(3,20)) {
41                 *generation = k320es_GrGLSLGeneration;
42             } else if (ver >= GR_GLSL_VER(3,10)) {
43                 *generation = k310es_GrGLSLGeneration;
44             } else if (ver >= GR_GLSL_VER(3,00)) {
45                 *generation = k330_GrGLSLGeneration;
46             } else {
47                 *generation = k110_GrGLSLGeneration;
48             }
49             return true;
50         default:
51             SK_ABORT("Unknown GL Standard");
52             return false;
53     }
54 }
55