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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
7 | 9 |
8 #include "gpu/command_buffer/tests/gl_manager.h" | 10 #include "gpu/command_buffer/tests/gl_manager.h" |
9 #include "gpu/command_buffer/tests/gl_test_utils.h" | 11 #include "gpu/command_buffer/tests/gl_test_utils.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 #define SHADER(Src) #Src | 15 #define SHADER(Src) #Src |
14 | 16 |
15 namespace gpu { | 17 namespace gpu { |
16 | 18 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // Render with the depth texture. | 176 // Render with the depth texture. |
175 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 177 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
176 glBindTexture(GL_TEXTURE_2D, depth_texture); | 178 glBindTexture(GL_TEXTURE_2D, depth_texture); |
177 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 179 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
178 glDrawArrays(GL_TRIANGLES, 0, 6); | 180 glDrawArrays(GL_TRIANGLES, 0, 6); |
179 | 181 |
180 if (!GLTestHelper::CheckGLError("no errors after texture draw", __LINE__)) { | 182 if (!GLTestHelper::CheckGLError("no errors after texture draw", __LINE__)) { |
181 continue; | 183 continue; |
182 } | 184 } |
183 | 185 |
184 uint8 actual_pixels[kResolution * kResolution * 4] = { 0, }; | 186 uint8_t actual_pixels[kResolution * kResolution * 4] = { |
| 187 0, |
| 188 }; |
185 glReadPixels( | 189 glReadPixels( |
186 0, 0, kResolution, kResolution, GL_RGBA, GL_UNSIGNED_BYTE, | 190 0, 0, kResolution, kResolution, GL_RGBA, GL_UNSIGNED_BYTE, |
187 actual_pixels); | 191 actual_pixels); |
188 | 192 |
189 if (!GLTestHelper::CheckGLError("no errors after readpixels", __LINE__)) { | 193 if (!GLTestHelper::CheckGLError("no errors after readpixels", __LINE__)) { |
190 continue; | 194 continue; |
191 } | 195 } |
192 | 196 |
193 // Check that each pixel's red value is less than the previous pixel in | 197 // Check that each pixel's red value is less than the previous pixel in |
194 // either direction. Basically verify we have a gradient. No assumption is | 198 // either direction. Basically verify we have a gradient. No assumption is |
195 // made about the other channels green, blue and alpha since, according to | 199 // made about the other channels green, blue and alpha since, according to |
196 // the GL_CHROMIUM_depth_texture spec, they have undefined values for | 200 // the GL_CHROMIUM_depth_texture spec, they have undefined values for |
197 // depth textures. | 201 // depth textures. |
198 int bad_count = 0; // used to not spam the log with too many messages. | 202 int bad_count = 0; // used to not spam the log with too many messages. |
199 for (GLint yy = 0; bad_count < 16 && yy < kResolution; ++yy) { | 203 for (GLint yy = 0; bad_count < 16 && yy < kResolution; ++yy) { |
200 for (GLint xx = 0; bad_count < 16 && xx < kResolution; ++xx) { | 204 for (GLint xx = 0; bad_count < 16 && xx < kResolution; ++xx) { |
201 const uint8* actual = &actual_pixels[(yy * kResolution + xx) * 4]; | 205 const uint8_t* actual = &actual_pixels[(yy * kResolution + xx) * 4]; |
202 const uint8* left = actual - 4; | 206 const uint8_t* left = actual - 4; |
203 const uint8* down = actual - kResolution * 4; | 207 const uint8_t* down = actual - kResolution * 4; |
204 | 208 |
205 // NOTE: Qualcomm on Nexus 4 the right most column has the same | 209 // NOTE: Qualcomm on Nexus 4 the right most column has the same |
206 // values as the next to right most column. (bad interpolator?) | 210 // values as the next to right most column. (bad interpolator?) |
207 if (xx > 0 && xx < kResolution - 1) { | 211 if (xx > 0 && xx < kResolution - 1) { |
208 EXPECT_GT(actual[0], left[0]) | 212 EXPECT_GT(actual[0], left[0]) |
209 << "pixel at " << xx << ", " << yy | 213 << "pixel at " << xx << ", " << yy |
210 << " actual[0] =" << static_cast<unsigned>(actual[0]) | 214 << " actual[0] =" << static_cast<unsigned>(actual[0]) |
211 << " left[0] =" << static_cast<unsigned>(left[0]) | 215 << " left[0] =" << static_cast<unsigned>(left[0]) |
212 << " actual =" << reinterpret_cast<const void*>(actual) | 216 << " actual =" << reinterpret_cast<const void*>(actual) |
213 << " left =" << reinterpret_cast<const void*>(left); | 217 << " left =" << reinterpret_cast<const void*>(left); |
(...skipping 14 matching lines...) Expand all Loading... |
228 | 232 |
229 GLTestHelper::CheckGLError("no errors after everything", __LINE__); | 233 GLTestHelper::CheckGLError("no errors after everything", __LINE__); |
230 } | 234 } |
231 } | 235 } |
232 | 236 |
233 } // namespace gpu | 237 } // namespace gpu |
234 | 238 |
235 | 239 |
236 | 240 |
237 | 241 |
OLD | NEW |