OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <cmath> | 11 #include <cmath> |
12 | 12 |
no sievers
2016/04/05 19:02:41
#include <memory>
Mostyn Bramley-Moore
2016/04/05 21:35:32
Done.
| |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bit_cast.h" | 14 #include "base/bit_cast.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "gpu/command_buffer/tests/gl_manager.h" | 19 #include "gpu/command_buffer/tests/gl_manager.h" |
20 #include "gpu/command_buffer/tests/gl_test_utils.h" | 20 #include "gpu/command_buffer/tests/gl_test_utils.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 case GL_RGB: | 267 case GL_RGB: |
268 read_comp_count = 3; | 268 read_comp_count = 3; |
269 break; | 269 break; |
270 case GL_RGBA: | 270 case GL_RGBA: |
271 read_comp_count = 4; | 271 read_comp_count = 4; |
272 break; | 272 break; |
273 } | 273 } |
274 | 274 |
275 switch (read_type) { | 275 switch (read_type) { |
276 case GL_HALF_FLOAT_OES: { | 276 case GL_HALF_FLOAT_OES: { |
277 scoped_ptr<GLushort[]> buf( | 277 std::unique_ptr<GLushort[]> buf( |
278 new GLushort[kTextureSize * kTextureSize * read_comp_count]); | 278 new GLushort[kTextureSize * kTextureSize * read_comp_count]); |
279 glReadPixels( | 279 glReadPixels( |
280 0, 0, kTextureSize, kTextureSize, read_format, read_type, | 280 0, 0, kTextureSize, kTextureSize, read_format, read_type, |
281 buf.get()); | 281 buf.get()); |
282 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR)); | 282 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR)); |
283 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) { | 283 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) { |
284 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) { | 284 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) { |
285 EXPECT_LE( | 285 EXPECT_LE( |
286 std::abs(HalfToFloat32(buf[jj * read_comp_count + kk]) - | 286 std::abs(HalfToFloat32(buf[jj * read_comp_count + kk]) - |
287 kDrawColor[kk]), | 287 kDrawColor[kk]), |
288 std::abs(kDrawColor[kk] * kEpsilon)); | 288 std::abs(kDrawColor[kk] * kEpsilon)); |
289 } | 289 } |
290 } | 290 } |
291 break; | 291 break; |
292 } | 292 } |
293 case GL_FLOAT: { | 293 case GL_FLOAT: { |
294 scoped_ptr<GLfloat[]> buf( | 294 std::unique_ptr<GLfloat[]> buf( |
295 new GLfloat[kTextureSize * kTextureSize * read_comp_count]); | 295 new GLfloat[kTextureSize * kTextureSize * read_comp_count]); |
296 glReadPixels( | 296 glReadPixels( |
297 0, 0, kTextureSize, kTextureSize, read_format, read_type, | 297 0, 0, kTextureSize, kTextureSize, read_format, read_type, |
298 buf.get()); | 298 buf.get()); |
299 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR)); | 299 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR)); |
300 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) { | 300 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) { |
301 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) { | 301 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) { |
302 EXPECT_LE( | 302 EXPECT_LE( |
303 std::abs(buf[jj * read_comp_count + kk] - kDrawColor[kk]), | 303 std::abs(buf[jj * read_comp_count + kk] - kDrawColor[kk]), |
304 std::abs(kDrawColor[kk] * kEpsilon)); | 304 std::abs(kDrawColor[kk] * kEpsilon)); |
305 } | 305 } |
306 } | 306 } |
307 break; | 307 break; |
308 } | 308 } |
309 } | 309 } |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 glDeleteFramebuffers(1, &framebuffer); | 313 glDeleteFramebuffers(1, &framebuffer); |
314 glDeleteTextures(1, &texture_id); | 314 glDeleteTextures(1, &texture_id); |
315 } | 315 } |
316 | 316 |
317 glDeleteBuffers(1, &vertex_buffer); | 317 glDeleteBuffers(1, &vertex_buffer); |
318 glDeleteProgram(program); | 318 glDeleteProgram(program); |
319 } | 319 } |
320 | 320 |
321 } // namespace gpu | 321 } // namespace gpu |
OLD | NEW |