Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(965)

Side by Side Diff: src/gpu/gl/GrGLSL.cpp

Issue 254083002: Fail to create GrContext when we get a NULL for a GL/GLSL version string (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: check GrGLCaps::init return Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLUtil.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLSL.h" 8 #include "GrGLSL.h"
9 #include "GrGLShaderVar.h" 9 #include "GrGLShaderVar.h"
10 #include "SkString.h" 10 #include "SkString.h"
11 11
12 GrGLSLGeneration GrGetGLSLGeneration(const GrGLInterface* gl) { 12 bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
13 SkASSERT(NULL != generation);
13 GrGLSLVersion ver = GrGLGetGLSLVersion(gl); 14 GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
15 if (GR_GLSL_INVALID_VER == ver) {
16 return false;
17 }
14 switch (gl->fStandard) { 18 switch (gl->fStandard) {
15 case kGL_GrGLStandard: 19 case kGL_GrGLStandard:
16 SkASSERT(ver >= GR_GLSL_VER(1,10)); 20 SkASSERT(ver >= GR_GLSL_VER(1,10));
17 if (ver >= GR_GLSL_VER(1,50)) { 21 if (ver >= GR_GLSL_VER(1,50)) {
18 return k150_GrGLSLGeneration; 22 *generation = k150_GrGLSLGeneration;
19 } else if (ver >= GR_GLSL_VER(1,40)) { 23 } else if (ver >= GR_GLSL_VER(1,40)) {
20 return k140_GrGLSLGeneration; 24 *generation = k140_GrGLSLGeneration;
21 } else if (ver >= GR_GLSL_VER(1,30)) { 25 } else if (ver >= GR_GLSL_VER(1,30)) {
22 return k130_GrGLSLGeneration; 26 *generation = k130_GrGLSLGeneration;
23 } else { 27 } else {
24 return k110_GrGLSLGeneration; 28 *generation = k110_GrGLSLGeneration;
25 } 29 }
30 return true;
26 case kGLES_GrGLStandard: 31 case kGLES_GrGLStandard:
27 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL 32 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL
28 SkASSERT(ver >= GR_GL_VER(1,00)); 33 SkASSERT(ver >= GR_GL_VER(1,00));
29 return k110_GrGLSLGeneration; 34 *generation = k110_GrGLSLGeneration;
35 return true;
30 default: 36 default:
31 GrCrash("Unknown GL Standard"); 37 GrCrash("Unknown GL Standard");
32 return k110_GrGLSLGeneration; // suppress warning 38 return false;
33 } 39 }
34 } 40 }
35 41
36 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { 42 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
37 switch (info.glslGeneration()) { 43 switch (info.glslGeneration()) {
38 case k110_GrGLSLGeneration: 44 case k110_GrGLSLGeneration:
39 if (kGLES_GrGLStandard == info.standard()) { 45 if (kGLES_GrGLStandard == info.standard()) {
40 // ES2s shader language is based on version 1.20 but is version 46 // ES2s shader language is based on version 1.20 but is version
41 // 1.00 of the ES language. 47 // 1.00 of the ES language.
42 return "#version 100\n"; 48 return "#version 100\n";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 89 }
84 90
85 append_tabs(outAppend, tabCnt); 91 append_tabs(outAppend, tabCnt);
86 92
87 if (mulFactor.isZeros()) { 93 if (mulFactor.isZeros()) {
88 outAppend->appendf("%s = vec4(0);\n", vec4VarName); 94 outAppend->appendf("%s = vec4(0);\n", vec4VarName);
89 } else { 95 } else {
90 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); 96 outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str());
91 } 97 }
92 } 98 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698