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

Side by Side Diff: src/gpu/gl/builders/GrGLShaderStringBuilder.cpp

Issue 943453002: Avoid wrong memory access due to double substitution and %% (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | tests/PathOpsExtendedTest.cpp » ('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 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
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 }
OLDNEW
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.cpp ('k') | tests/PathOpsExtendedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698