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

Side by Side Diff: gpu/command_buffer/tests/gl_test_utils.cc

Issue 12494005: Use client side arrays for GL_STREAM_DRAW attributes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/tests/gl_test_utils.h ('k') | gpu/gpu.gyp » ('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 (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 #include <string> 6 #include <string>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 -1.0f, -1.0f, 101 -1.0f, -1.0f,
102 1.0f, -1.0f, 102 1.0f, -1.0f,
103 }; 103 };
104 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); 104 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
105 glEnableVertexAttribArray(position_location); 105 glEnableVertexAttribArray(position_location);
106 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); 106 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
107 107
108 return vbo; 108 return vbo;
109 } 109 }
110 110
111 GLuint GLTestHelper::SetupColorsForUnitQuad(
112 GLint location, const GLfloat color[4], GLenum usage) {
113 GLuint vbo = 0;
114 glGenBuffers(1, &vbo);
115 glBindBuffer(GL_ARRAY_BUFFER, vbo);
116 GLfloat vertices[6 * 4];
117 for (int ii = 0; ii < 6; ++ii) {
118 for (int jj = 0; jj < 4; ++jj) {
119 vertices[ii * 4 + jj] = color[jj];
120 }
121 }
122 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, usage);
123 glEnableVertexAttribArray(location);
124 glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, 0, 0);
125
126 return vbo;
127 }
128
111 bool GLTestHelper::CheckPixels( 129 bool GLTestHelper::CheckPixels(
112 GLint x, GLint y, GLsizei width, GLsizei height, GLint tolerance, 130 GLint x, GLint y, GLsizei width, GLsizei height, GLint tolerance,
113 const uint8* color) { 131 const uint8* color) {
114 GLsizei size = width * height * 4; 132 GLsizei size = width * height * 4;
115 scoped_array<uint8> pixels(new uint8[size]); 133 scoped_array<uint8> pixels(new uint8[size]);
116 memset(pixels.get(), kCheckClearValue, size); 134 memset(pixels.get(), kCheckClearValue, size);
117 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); 135 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
118 bool same = true; 136 bool same = true;
119 for (GLint yy = 0; yy < height; ++yy) { 137 for (GLint yy = 0; yy < height; ++yy) {
120 for (GLint xx = 0; xx < width; ++xx) { 138 for (GLint xx = 0; xx < width; ++xx) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 fwrite(&bih, sizeof(bih), 1, fp); 233 fwrite(&bih, sizeof(bih), 1, fp);
216 fwrite(pixels, size, 1, fp); 234 fwrite(pixels, size, 1, fp);
217 fclose(fp); 235 fclose(fp);
218 return true; 236 return true;
219 } 237 }
220 238
221 int GLTestHelper::RunTests(int argc, char** argv) { 239 int GLTestHelper::RunTests(int argc, char** argv) {
222 testing::InitGoogleMock(&argc, argv); 240 testing::InitGoogleMock(&argc, argv);
223 return RUN_ALL_TESTS(); 241 return RUN_ALL_TESTS();
224 } 242 }
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_test_utils.h ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698