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

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

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | gpu/command_buffer/tests/gl_test_utils.cc » ('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 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 #include <memory>
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/bit_cast.h" 15 #include "base/bit_cast.h"
15 #include "base/location.h" 16 #include "base/location.h"
16 #include "base/run_loop.h" 17 #include "base/run_loop.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
19 #include "gpu/command_buffer/tests/gl_manager.h" 20 #include "gpu/command_buffer/tests/gl_manager.h"
20 #include "gpu/command_buffer/tests/gl_test_utils.h" 21 #include "gpu/command_buffer/tests/gl_test_utils.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 case GL_RGB: 268 case GL_RGB:
268 read_comp_count = 3; 269 read_comp_count = 3;
269 break; 270 break;
270 case GL_RGBA: 271 case GL_RGBA:
271 read_comp_count = 4; 272 read_comp_count = 4;
272 break; 273 break;
273 } 274 }
274 275
275 switch (read_type) { 276 switch (read_type) {
276 case GL_HALF_FLOAT_OES: { 277 case GL_HALF_FLOAT_OES: {
277 scoped_ptr<GLushort[]> buf( 278 std::unique_ptr<GLushort[]> buf(
278 new GLushort[kTextureSize * kTextureSize * read_comp_count]); 279 new GLushort[kTextureSize * kTextureSize * read_comp_count]);
279 glReadPixels( 280 glReadPixels(
280 0, 0, kTextureSize, kTextureSize, read_format, read_type, 281 0, 0, kTextureSize, kTextureSize, read_format, read_type,
281 buf.get()); 282 buf.get());
282 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR)); 283 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR));
283 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) { 284 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) {
284 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) { 285 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) {
285 EXPECT_LE( 286 EXPECT_LE(
286 std::abs(HalfToFloat32(buf[jj * read_comp_count + kk]) - 287 std::abs(HalfToFloat32(buf[jj * read_comp_count + kk]) -
287 kDrawColor[kk]), 288 kDrawColor[kk]),
288 std::abs(kDrawColor[kk] * kEpsilon)); 289 std::abs(kDrawColor[kk] * kEpsilon));
289 } 290 }
290 } 291 }
291 break; 292 break;
292 } 293 }
293 case GL_FLOAT: { 294 case GL_FLOAT: {
294 scoped_ptr<GLfloat[]> buf( 295 std::unique_ptr<GLfloat[]> buf(
295 new GLfloat[kTextureSize * kTextureSize * read_comp_count]); 296 new GLfloat[kTextureSize * kTextureSize * read_comp_count]);
296 glReadPixels( 297 glReadPixels(
297 0, 0, kTextureSize, kTextureSize, read_format, read_type, 298 0, 0, kTextureSize, kTextureSize, read_format, read_type,
298 buf.get()); 299 buf.get());
299 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR)); 300 EXPECT_EQ(glGetError(), GLenum(GL_NO_ERROR));
300 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) { 301 for (uint32_t jj = 0; jj < kTextureSize * kTextureSize; ++jj) {
301 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) { 302 for (uint32_t kk = 0; kk < test_formats[ii].comp_count; ++kk) {
302 EXPECT_LE( 303 EXPECT_LE(
303 std::abs(buf[jj * read_comp_count + kk] - kDrawColor[kk]), 304 std::abs(buf[jj * read_comp_count + kk] - kDrawColor[kk]),
304 std::abs(kDrawColor[kk] * kEpsilon)); 305 std::abs(kDrawColor[kk] * kEpsilon));
305 } 306 }
306 } 307 }
307 break; 308 break;
308 } 309 }
309 } 310 }
310 } 311 }
311 } 312 }
312 313
313 glDeleteFramebuffers(1, &framebuffer); 314 glDeleteFramebuffers(1, &framebuffer);
314 glDeleteTextures(1, &texture_id); 315 glDeleteTextures(1, &texture_id);
315 } 316 }
316 317
317 glDeleteBuffers(1, &vertex_buffer); 318 glDeleteBuffers(1, &vertex_buffer);
318 glDeleteProgram(program); 319 glDeleteProgram(program);
319 } 320 }
320 321
321 } // namespace gpu 322 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.cc ('k') | gpu/command_buffer/tests/gl_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698