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

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

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 | « ui/gl/gl_helper.h ('k') | ui/gl/gl_image_egl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "ui/gl/gl_helper.h" 5 #include "ui/gl/gl_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gl/scoped_binders.h" 10 #include "ui/gl/scoped_binders.h"
11 11
12 namespace gfx { 12 namespace gl {
13 13
14 // static 14 // static
15 GLuint GLHelper::CompileShader(GLenum type, const char* src) { 15 GLuint GLHelper::CompileShader(GLenum type, const char* src) {
16 GLuint shader = glCreateShader(type); 16 GLuint shader = glCreateShader(type);
17 // Load the shader source. 17 // Load the shader source.
18 glShaderSource(shader, 1, &src, nullptr); 18 glShaderSource(shader, 1, &src, nullptr);
19 // Compile the shader. 19 // Compile the shader.
20 glCompileShader(shader); 20 glCompileShader(shader);
21 return shader; 21 return shader;
22 } 22 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 glDeleteProgram(program); 66 glDeleteProgram(program);
67 program = 0; 67 program = 0;
68 } 68 }
69 return program; 69 return program;
70 } 70 }
71 71
72 // static 72 // static
73 GLuint GLHelper::SetupQuadVertexBuffer() { 73 GLuint GLHelper::SetupQuadVertexBuffer() {
74 GLuint vertex_buffer = 0; 74 GLuint vertex_buffer = 0;
75 glGenBuffersARB(1, &vertex_buffer); 75 glGenBuffersARB(1, &vertex_buffer);
76 gfx::ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer); 76 gl::ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer);
77 GLfloat data[] = {-1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f}; 77 GLfloat data[] = {-1.f, -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f};
78 glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW); 78 glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
79 return vertex_buffer; 79 return vertex_buffer;
80 } 80 }
81 81
82 // static 82 // static
83 void GLHelper::DrawQuad(GLuint vertex_buffer) { 83 void GLHelper::DrawQuad(GLuint vertex_buffer) {
84 gfx::ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer); 84 gl::ScopedBufferBinder buffer_binder(GL_ARRAY_BUFFER, vertex_buffer);
85 gfx::ScopedVertexAttribArray vertex_attrib_array(0, 2, GL_FLOAT, GL_FALSE, 85 gl::ScopedVertexAttribArray vertex_attrib_array(0, 2, GL_FLOAT, GL_FALSE,
86 sizeof(GLfloat) * 2, 0); 86 sizeof(GLfloat) * 2, 0);
87 gfx::ScopedCapability disable_blending(GL_BLEND, GL_FALSE); 87 gl::ScopedCapability disable_blending(GL_BLEND, GL_FALSE);
88 gfx::ScopedCapability disable_culling(GL_CULL_FACE, GL_FALSE); 88 gl::ScopedCapability disable_culling(GL_CULL_FACE, GL_FALSE);
89 gfx::ScopedCapability disable_dithering(GL_DITHER, GL_FALSE); 89 gl::ScopedCapability disable_dithering(GL_DITHER, GL_FALSE);
90 gfx::ScopedCapability disable_depth_test(GL_DEPTH_TEST, GL_FALSE); 90 gl::ScopedCapability disable_depth_test(GL_DEPTH_TEST, GL_FALSE);
91 gfx::ScopedCapability disable_scissor_test(GL_SCISSOR_TEST, GL_FALSE); 91 gl::ScopedCapability disable_scissor_test(GL_SCISSOR_TEST, GL_FALSE);
92 gfx::ScopedColorMask color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 92 gl::ScopedColorMask color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
93 93
94 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 94 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
95 } 95 }
96 96
97 } // namespace gfx 97 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_helper.h ('k') | ui/gl/gl_image_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698