| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_buffer/tests/gl_test_utils.h" | 5 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (!vertex_shader || !fragment_shader) { | 154 if (!vertex_shader || !fragment_shader) { |
| 155 return 0; | 155 return 0; |
| 156 } | 156 } |
| 157 return SetupProgram(vertex_shader, fragment_shader); | 157 return SetupProgram(vertex_shader, fragment_shader); |
| 158 } | 158 } |
| 159 | 159 |
| 160 GLuint GLTestHelper::SetupUnitQuad(GLint position_location) { | 160 GLuint GLTestHelper::SetupUnitQuad(GLint position_location) { |
| 161 GLuint vbo = 0; | 161 GLuint vbo = 0; |
| 162 glGenBuffers(1, &vbo); | 162 glGenBuffers(1, &vbo); |
| 163 glBindBuffer(GL_ARRAY_BUFFER, vbo); | 163 glBindBuffer(GL_ARRAY_BUFFER, vbo); |
| 164 static const float vertices[] = { | 164 static float vertices[] = { |
| 165 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, | 165 1.0f, 1.0f, |
| 166 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, | 166 -1.0f, 1.0f, |
| 167 -1.0f, -1.0f, |
| 168 1.0f, 1.0f, |
| 169 -1.0f, -1.0f, |
| 170 1.0f, -1.0f, |
| 167 }; | 171 }; |
| 168 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); | 172 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); |
| 169 glEnableVertexAttribArray(position_location); | 173 glEnableVertexAttribArray(position_location); |
| 170 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); | 174 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); |
| 171 | 175 |
| 172 return vbo; | 176 return vbo; |
| 173 } | 177 } |
| 174 | 178 |
| 175 std::vector<GLuint> GLTestHelper::SetupIndexedUnitQuad( | |
| 176 GLint position_location) { | |
| 177 GLuint array_buffer = SetupUnitQuad(position_location); | |
| 178 static const uint8_t indices[] = {0, 1, 2, 3, 4, 5}; | |
| 179 GLuint index_buffer = 0; | |
| 180 glGenBuffers(1, &index_buffer); | |
| 181 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer); | |
| 182 glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6, indices, GL_STATIC_DRAW); | |
| 183 std::vector<GLuint> buffers(2); | |
| 184 buffers[0] = array_buffer; | |
| 185 buffers[1] = index_buffer; | |
| 186 return buffers; | |
| 187 } | |
| 188 | |
| 189 GLuint GLTestHelper::SetupColorsForUnitQuad( | 179 GLuint GLTestHelper::SetupColorsForUnitQuad( |
| 190 GLint location, const GLfloat color[4], GLenum usage) { | 180 GLint location, const GLfloat color[4], GLenum usage) { |
| 191 GLuint vbo = 0; | 181 GLuint vbo = 0; |
| 192 glGenBuffers(1, &vbo); | 182 glGenBuffers(1, &vbo); |
| 193 glBindBuffer(GL_ARRAY_BUFFER, vbo); | 183 glBindBuffer(GL_ARRAY_BUFFER, vbo); |
| 194 GLfloat vertices[6 * 4]; | 184 GLfloat vertices[6 * 4]; |
| 195 for (int ii = 0; ii < 6; ++ii) { | 185 for (int ii = 0; ii < 6; ++ii) { |
| 196 for (int jj = 0; jj < 4; ++jj) { | 186 for (int jj = 0; jj < 4; ++jj) { |
| 197 vertices[ii * 4 + jj] = color[jj]; | 187 vertices[ii * 4 + jj] = color[jj]; |
| 198 } | 188 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ASSERT_NE(sampler_location, -1); | 336 ASSERT_NE(sampler_location, -1); |
| 347 | 337 |
| 348 GLuint vertex_buffer = GLTestHelper::SetupUnitQuad(sampler_location); | 338 GLuint vertex_buffer = GLTestHelper::SetupUnitQuad(sampler_location); |
| 349 glDrawArrays(GL_TRIANGLES, 0, 6); | 339 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 350 | 340 |
| 351 glDeleteShader(vertex_shader); | 341 glDeleteShader(vertex_shader); |
| 352 glDeleteShader(fragment_shader); | 342 glDeleteShader(fragment_shader); |
| 353 glDeleteProgram(program); | 343 glDeleteProgram(program); |
| 354 glDeleteBuffers(1, &vertex_buffer); | 344 glDeleteBuffers(1, &vertex_buffer); |
| 355 } | 345 } |
| OLD | NEW |