| 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 #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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 }; | 98 }; |
| 99 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); | 99 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); |
| 100 glEnableVertexAttribArray(position_location); | 100 glEnableVertexAttribArray(position_location); |
| 101 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); | 101 glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, 0); |
| 102 | 102 |
| 103 return vbo; | 103 return vbo; |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool GLTestHelper::CheckPixels( | 106 bool GLTestHelper::CheckPixels( |
| 107 GLint x, GLint y, GLsizei width, GLsizei height, GLint tolerance, | 107 GLint x, GLint y, GLsizei width, GLsizei height, GLint tolerance, |
| 108 uint8* color) { | 108 const uint8* color) { |
| 109 GLsizei size = width * height * 4; | 109 GLsizei size = width * height * 4; |
| 110 scoped_array<uint8> pixels(new uint8[size]); | 110 scoped_array<uint8> pixels(new uint8[size]); |
| 111 memset(pixels.get(), 123, size); | 111 memset(pixels.get(), 123, size); |
| 112 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); | 112 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); |
| 113 bool same = true; | 113 bool same = true; |
| 114 for (GLint yy = 0; yy < height; ++yy) { | 114 for (GLint yy = 0; yy < height; ++yy) { |
| 115 for (GLint xx = 0; xx < width; ++xx) { | 115 for (GLint xx = 0; xx < width; ++xx) { |
| 116 int offset = yy * width + xx * 4; | 116 int offset = yy * width + xx * 4; |
| 117 for (int jj = 0; jj < 4; ++jj) { | 117 for (int jj = 0; jj < 4; ++jj) { |
| 118 uint8 actual = pixels[offset + jj]; | 118 uint8 actual = pixels[offset + jj]; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 fwrite(&bih, sizeof(bih), 1, fp); | 210 fwrite(&bih, sizeof(bih), 1, fp); |
| 211 fwrite(pixels, size, 1, fp); | 211 fwrite(pixels, size, 1, fp); |
| 212 fclose(fp); | 212 fclose(fp); |
| 213 return true; | 213 return true; |
| 214 } | 214 } |
| 215 | 215 |
| 216 int GLTestHelper::RunTests(int argc, char** argv) { | 216 int GLTestHelper::RunTests(int argc, char** argv) { |
| 217 testing::InitGoogleMock(&argc, argv); | 217 testing::InitGoogleMock(&argc, argv); |
| 218 return RUN_ALL_TESTS(); | 218 return RUN_ALL_TESTS(); |
| 219 } | 219 } |
| OLD | NEW |