| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrGLShaderStringBuilder.h" | 8 #include "GrGLShaderStringBuilder.h" |
| 9 #include "gl/GrGLGpu.h" | 9 #include "gl/GrGLGpu.h" |
| 10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 if (!compiled) { | 65 if (!compiled) { |
| 66 GrGLint infoLen = GR_GL_INIT_ZERO; | 66 GrGLint infoLen = GR_GL_INIT_ZERO; |
| 67 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe
n)); | 67 GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLe
n)); |
| 68 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg
er | 68 SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugg
er |
| 69 if (infoLen > 0) { | 69 if (infoLen > 0) { |
| 70 // retrieve length even though we don't need it to workaround bu
g in Chromium cmd | 70 // retrieve length even though we don't need it to workaround bu
g in Chromium cmd |
| 71 // buffer param validation. | 71 // buffer param validation. |
| 72 GrGLsizei length = GR_GL_INIT_ZERO; | 72 GrGLsizei length = GR_GL_INIT_ZERO; |
| 73 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (
char*)log.get())); | 73 GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (
char*)log.get())); |
| 74 SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, co
unt, true).c_str()); | 74 SkDebugf("%s", GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengt
hs, count, true).c_str()); |
| 75 SkDebugf("\n%s", log.get()); | 75 SkDebugf("\n%s", log.get()); |
| 76 } | 76 } |
| 77 SkDEBUGFAIL("Shader compilation failed!"); | 77 SkDEBUGFAIL("Shader compilation failed!"); |
| 78 GR_GL_CALL(gli, DeleteShader(shaderId)); | 78 GR_GL_CALL(gli, DeleteShader(shaderId)); |
| 79 return 0; | 79 return 0; |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (c_PrintShaders) { | 83 if (c_PrintShaders) { |
| 84 SkDebugf(GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, count, tru
e).c_str()); | 84 SkDebugf("%s", GrGLSLPrettyPrint::PrettyPrintGLSL(strings, lengths, coun
t, true).c_str()); |
| 85 SkDebugf("\n"); | 85 SkDebugf("\n"); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Attach the shader, but defer deletion until after we have linked the prog
ram. | 88 // Attach the shader, but defer deletion until after we have linked the prog
ram. |
| 89 // This works around a bug in the Android emulator's GLES2 wrapper which | 89 // This works around a bug in the Android emulator's GLES2 wrapper which |
| 90 // will immediately delete the shader object and free its memory even though
it's | 90 // will immediately delete the shader object and free its memory even though
it's |
| 91 // attached to a program, which then causes glLinkProgram to fail. | 91 // attached to a program, which then causes glLinkProgram to fail. |
| 92 GR_GL_CALL(gli, AttachShader(programId, shaderId)); | 92 GR_GL_CALL(gli, AttachShader(programId, shaderId)); |
| 93 | 93 |
| 94 return shaderId; | 94 return shaderId; |
| 95 } | 95 } |
| OLD | NEW |