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

Side by Side Diff: ui/gl/gl_helper.cc

Issue 1419733005: gpu: Add YCbCr 420v extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean-ups. Created 5 years, 1 month 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gl/gl_helper.h"
6
7 #include <fstream>
reveman 2015/10/27 19:31:54 fstream? what is this for?
Daniele Castagna 2015/10/29 20:09:04 Leftover since I had a function to save the output
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
reveman 2015/10/27 19:31:54 why this include? not seeing any use of scoped_ptr
Daniele Castagna 2015/10/29 20:09:04 Leftover.
11 #include "ui/gfx/geometry/size.h"
reveman 2015/10/27 19:31:54 this doesn't seem to be used either but it looks l
Daniele Castagna 2015/10/29 20:09:04 Removed size.h and added base/logging.h
12
13 namespace gfx {
14
15 // static
16 GLuint GLHelper::CompileShader(GLenum type, const char* src) {
17 GLuint shader = glCreateShader(type);
18 // Load the shader source.
19 glShaderSource(shader, 1, &src, nullptr);
20 // Compile the shader.
21 glCompileShader(shader);
22 return shader;
23 }
24
25 // static
26 GLuint GLHelper::LoadShader(GLenum type, const char* src) {
27 GLuint shader = CompileShader(type, src);
28
29 // Check the compile status.
30 GLint value = 0;
31 glGetShaderiv(shader, GL_COMPILE_STATUS, &value);
32 if (!value) {
33 char buffer[1024];
34 GLsizei length = 0;
35 glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer);
36 std::string log(buffer, length);
37 DCHECK_EQ(1, value) << "Error compiling shader: " << log;
38 glDeleteShader(shader);
39 shader = 0;
40 }
41 return shader;
42 }
43
44 // static
45 GLuint GLHelper::LinkProgram(GLuint vertex_shader, GLuint fragment_shader) {
46 // Create the program object.
47 GLuint program = glCreateProgram();
48 glAttachShader(program, vertex_shader);
49 glAttachShader(program, fragment_shader);
50 // Link the program.
51 glLinkProgram(program);
52 return program;
53 }
54
55 // static
56 GLuint GLHelper::SetupProgram(GLuint vertex_shader, GLuint fragment_shader) {
57 GLuint program = LinkProgram(vertex_shader, fragment_shader);
58 // Check the link status.
59 GLint linked = 0;
60 glGetProgramiv(program, GL_LINK_STATUS, &linked);
61 if (!linked) {
62 char buffer[1024];
63 GLsizei length = 0;
64 glGetProgramInfoLog(program, sizeof(buffer), &length, buffer);
65 std::string log(buffer, length);
66 DCHECK_EQ(1, linked) << "Error linking program: " << log;
67 glDeleteProgram(program);
68 program = 0;
69 }
70 return program;
71 }
72
73 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698