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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 12892005: Implement client side PBOs for glReadPixel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lots of cleanup, made sure callbacks come back in right order 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
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 // Tests for GLES2Implementation. 5 // Tests for GLES2Implementation.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 expected.set_token.Init(GetNextToken()); 1413 expected.set_token.Init(GetNextToken());
1414 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); 1414 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]);
1415 1415
1416 EXPECT_CALL(*command_buffer(), OnFlush()) 1416 EXPECT_CALL(*command_buffer(), OnFlush())
1417 .Times(1) 1417 .Times(1)
1418 .RetiresOnSaturation(); 1418 .RetiresOnSaturation();
1419 1419
1420 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); 1420 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
1421 } 1421 }
1422 1422
1423 TEST_F(GLES2ImplementationTest, ReadPixelsWithPBO) {
1424 struct Cmds {
1425 cmds::ReadPixels read;
1426 cmd::SetToken set_token;
1427 };
1428 const GLint kBytesPerPixel = 4;
1429 const GLint kWidth = 2;
1430 const GLint kHeight = 2;
1431 const GLenum kFormat = 0;
1432 const GLenum kType = 0;
1433
1434 ExpectedMemoryInfo mem1 =
1435 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel);
1436 ExpectedMemoryInfo result1 =
1437 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result));
1438
1439 Cmds expected;
1440 expected.read.Init(
1441 0, 0, kWidth, kHeight, kFormat, kType,
1442 mem1.id, mem1.offset, result1.id, result1.offset);
1443 expected.set_token.Init(GetNextToken());
1444 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]);
1445
1446 GLuint b;
1447 gl_->GenBuffers(1, &b);
1448 gl_->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, b);
1449 gl_->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1450 kWidth * kHeight * kBytesPerPixel,
1451 NULL,
1452 0 /* GL_STREAM_READ */ );
1453 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, 0);
1454 EXPECT_TRUE(gl_->MapBufferCHROMIUM(
1455 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1456 GL_READ_ONLY));
1457 gl_->UnmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
1458 gl_->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1459 gl_->DeleteBuffers(1, &b);
greggman 2013/03/20 00:42:17 Ideally you want to check that gl_->ReadPixels ins
1460 }
1461
1423 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { 1462 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) {
1424 struct Cmds { 1463 struct Cmds {
1425 cmds::BufferSubData buf; 1464 cmds::BufferSubData buf;
1426 cmd::SetToken set_token; 1465 cmd::SetToken set_token;
1427 }; 1466 };
1428 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; 1467 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER;
1429 const GLintptr kOffset = 15; 1468 const GLintptr kOffset = 15;
1430 const GLsizeiptr kSize = 16; 1469 const GLsizeiptr kSize = 16;
1431 1470
1432 ExpectedMemoryInfo mem1 = GetExpectedMemory(kSize); 1471 ExpectedMemoryInfo mem1 = GetExpectedMemory(kSize);
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 ClearCommands(); 2841 ClearCommands();
2803 gl_->Enable(GL_BLEND); 2842 gl_->Enable(GL_BLEND);
2804 EXPECT_TRUE(NoCommandsWritten()); 2843 EXPECT_TRUE(NoCommandsWritten());
2805 } 2844 }
2806 2845
2807 2846
2808 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 2847 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
2809 2848
2810 } // namespace gles2 2849 } // namespace gles2
2811 } // namespace gpu 2850 } // namespace gpu
2812
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698