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

Side by Side Diff: gpu/tools/compositor_model_bench/shaders.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo part of clang-format Created 4 years, 8 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
OLDNEW
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 10
no sievers 2016/04/05 19:02:42 #include <memory>
Mostyn Bramley-Moore 2016/04/05 21:35:33 Done.
11 #include "gpu/tools/compositor_model_bench/render_model_utils.h" 11 #include "gpu/tools/compositor_model_bench/render_model_utils.h"
12 #include "gpu/tools/compositor_model_bench/render_tree.h" 12 #include "gpu/tools/compositor_model_bench/render_tree.h"
13 13
14 using std::min; 14 using std::min;
15 15
16 static const int kPositionLocation = 0; 16 static const int kPositionLocation = 0;
17 static const int kTexCoordLocation = 1; 17 static const int kTexCoordLocation = 1;
18 18
19 static unsigned g_quad_vertices_vbo; 19 static unsigned g_quad_vertices_vbo;
20 static unsigned g_quad_elements_vbo; 20 static unsigned g_quad_elements_vbo;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 231
232 static void ReportAnyShaderCompilationErrors(GLuint shader, ShaderID id) { 232 static void ReportAnyShaderCompilationErrors(GLuint shader, ShaderID id) {
233 GLint status; 233 GLint status;
234 glGetShaderiv(shader, GL_COMPILE_STATUS, &status); 234 glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
235 if (status) 235 if (status)
236 return; 236 return;
237 // Get the length of the log string 237 // Get the length of the log string
238 GLsizei length; 238 GLsizei length;
239 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); 239 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
240 scoped_ptr<GLchar[]> log(new GLchar[length+1]); 240 std::unique_ptr<GLchar[]> log(new GLchar[length + 1]);
241 glGetShaderInfoLog(shader, length, NULL, log.get()); 241 glGetShaderInfoLog(shader, length, NULL, log.get());
242 LOG(ERROR) << log.get() << " in shader " << ShaderNameFromID(id); 242 LOG(ERROR) << log.get() << " in shader " << ShaderNameFromID(id);
243 } 243 }
244 244
245 static int ActivateShader(ShaderID v, ShaderID f, float* layer_transform) { 245 static int ActivateShader(ShaderID v, ShaderID f, float* layer_transform) {
246 int program_index = GetProgramIdx(v, f); 246 int program_index = GetProgramIdx(v, f);
247 if (!g_program_objects[program_index]) { 247 if (!g_program_objects[program_index]) {
248 g_program_objects[program_index] = glCreateProgramObjectARB(); 248 g_program_objects[program_index] = glCreateProgramObjectARB();
249 GLenum vs = glCreateShaderObjectARB(GL_VERTEX_SHADER); 249 GLenum vs = glCreateShaderObjectARB(GL_VERTEX_SHADER);
250 GLenum fs = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); 250 GLenum fs = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 float center_y = (top+bottom)/2 - g_current_tile_layer_height/2; 443 float center_y = (top+bottom)/2 - g_current_tile_layer_height/2;
444 TranslateInPlace(mv_transform, center_x, center_y, 0.0); 444 TranslateInPlace(mv_transform, center_x, center_y, 0.0);
445 445
446 Project(mv_transform, proj_transform); 446 Project(mv_transform, proj_transform);
447 GLint mat = glGetUniformLocationARB(prog, "matrix"); 447 GLint mat = glGetUniformLocationARB(prog, "matrix");
448 glUniformMatrix4fvARB(mat, 1, GL_TRUE, proj_transform); 448 glUniformMatrix4fvARB(mat, 1, GL_TRUE, proj_transform);
449 449
450 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 450 glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
451 } 451 }
452 452
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698