OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/tools/compositor_model_bench/shaders.h" | 5 #include "gpu/tools/compositor_model_bench/shaders.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
10 | 11 |
11 #include "gpu/tools/compositor_model_bench/render_model_utils.h" | 12 #include "gpu/tools/compositor_model_bench/render_model_utils.h" |
12 #include "gpu/tools/compositor_model_bench/render_tree.h" | 13 #include "gpu/tools/compositor_model_bench/render_tree.h" |
13 | 14 |
14 using std::min; | 15 using std::min; |
15 | 16 |
16 static const int kPositionLocation = 0; | 17 static const int kPositionLocation = 0; |
17 static const int kTexCoordLocation = 1; | 18 static const int kTexCoordLocation = 1; |
18 | 19 |
19 static unsigned g_quad_vertices_vbo; | 20 static unsigned g_quad_vertices_vbo; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 231 } |
231 | 232 |
232 static void ReportAnyShaderCompilationErrors(GLuint shader, ShaderID id) { | 233 static void ReportAnyShaderCompilationErrors(GLuint shader, ShaderID id) { |
233 GLint status; | 234 GLint status; |
234 glGetShaderiv(shader, GL_COMPILE_STATUS, &status); | 235 glGetShaderiv(shader, GL_COMPILE_STATUS, &status); |
235 if (status) | 236 if (status) |
236 return; | 237 return; |
237 // Get the length of the log string | 238 // Get the length of the log string |
238 GLsizei length; | 239 GLsizei length; |
239 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); | 240 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); |
240 scoped_ptr<GLchar[]> log(new GLchar[length+1]); | 241 std::unique_ptr<GLchar[]> log(new GLchar[length + 1]); |
241 glGetShaderInfoLog(shader, length, NULL, log.get()); | 242 glGetShaderInfoLog(shader, length, NULL, log.get()); |
242 LOG(ERROR) << log.get() << " in shader " << ShaderNameFromID(id); | 243 LOG(ERROR) << log.get() << " in shader " << ShaderNameFromID(id); |
243 } | 244 } |
244 | 245 |
245 static int ActivateShader(ShaderID v, ShaderID f, float* layer_transform) { | 246 static int ActivateShader(ShaderID v, ShaderID f, float* layer_transform) { |
246 int program_index = GetProgramIdx(v, f); | 247 int program_index = GetProgramIdx(v, f); |
247 if (!g_program_objects[program_index]) { | 248 if (!g_program_objects[program_index]) { |
248 g_program_objects[program_index] = glCreateProgramObjectARB(); | 249 g_program_objects[program_index] = glCreateProgramObjectARB(); |
249 GLenum vs = glCreateShaderObjectARB(GL_VERTEX_SHADER); | 250 GLenum vs = glCreateShaderObjectARB(GL_VERTEX_SHADER); |
250 GLenum fs = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); | 251 GLenum fs = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 float center_y = (top+bottom)/2 - g_current_tile_layer_height/2; | 444 float center_y = (top+bottom)/2 - g_current_tile_layer_height/2; |
444 TranslateInPlace(mv_transform, center_x, center_y, 0.0); | 445 TranslateInPlace(mv_transform, center_x, center_y, 0.0); |
445 | 446 |
446 Project(mv_transform, proj_transform); | 447 Project(mv_transform, proj_transform); |
447 GLint mat = glGetUniformLocationARB(prog, "matrix"); | 448 GLint mat = glGetUniformLocationARB(prog, "matrix"); |
448 glUniformMatrix4fvARB(mat, 1, GL_TRUE, proj_transform); | 449 glUniformMatrix4fvARB(mat, 1, GL_TRUE, proj_transform); |
449 | 450 |
450 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 451 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
451 } | 452 } |
452 | 453 |
OLD | NEW |