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

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: Actually enable/disable capabilities. Typo. Created 5 years 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 | « ui/gl/gl_helper.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string>
8
9 #include "base/logging.h"
10
11 namespace gfx {
12
13 // static
14 GLuint GLHelper::CompileShader(GLenum type, const char* src) {
15 GLuint shader = glCreateShader(type);
16 // Load the shader source.
17 glShaderSource(shader, 1, &src, nullptr);
18 // Compile the shader.
19 glCompileShader(shader);
20 return shader;
21 }
22
23 // static
24 GLuint GLHelper::LoadShader(GLenum type, const char* src) {
25 GLuint shader = CompileShader(type, src);
26
27 // Check the compile status.
28 GLint value = 0;
29 glGetShaderiv(shader, GL_COMPILE_STATUS, &value);
30 if (!value) {
31 char buffer[1024];
32 GLsizei length = 0;
33 glGetShaderInfoLog(shader, sizeof(buffer), &length, buffer);
34 std::string log(buffer, length);
35 DCHECK_EQ(1, value) << "Error compiling shader: " << log;
36 glDeleteShader(shader);
37 shader = 0;
38 }
39 return shader;
40 }
41
42 // static
43 GLuint GLHelper::LinkProgram(GLuint vertex_shader, GLuint fragment_shader) {
44 // Create the program object.
45 GLuint program = glCreateProgram();
46 glAttachShader(program, vertex_shader);
47 glAttachShader(program, fragment_shader);
48 // Link the program.
49 glLinkProgram(program);
50 return program;
51 }
52
53 // static
54 GLuint GLHelper::SetupProgram(GLuint vertex_shader, GLuint fragment_shader) {
55 GLuint program = LinkProgram(vertex_shader, fragment_shader);
56 // Check the link status.
57 GLint linked = 0;
58 glGetProgramiv(program, GL_LINK_STATUS, &linked);
59 if (!linked) {
60 char buffer[1024];
61 GLsizei length = 0;
62 glGetProgramInfoLog(program, sizeof(buffer), &length, buffer);
63 std::string log(buffer, length);
64 DCHECK_EQ(1, linked) << "Error linking program: " << log;
65 glDeleteProgram(program);
66 program = 0;
67 }
68 return program;
69 }
70
71 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_helper.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698