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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc

Issue 1320093002: Command Buffer: read pixels into pixel pack buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unittests Created 5 years 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
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 "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 result_shm_id, 653 result_shm_id,
654 result_shm_offset, 654 result_shm_offset,
655 false); 655 false);
656 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 656 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
657 for (GLint yy = 0; yy < kHeight; ++yy) { 657 for (GLint yy = 0; yy < kHeight; ++yy) {
658 EXPECT_TRUE(emu.CompareRowSegment( 658 EXPECT_TRUE(emu.CompareRowSegment(
659 0, yy, kWidth, emu.ComputePackAlignmentAddress(0, yy, kWidth, dest))); 659 0, yy, kWidth, emu.ComputePackAlignmentAddress(0, yy, kWidth, dest)));
660 } 660 }
661 } 661 }
662 662
663 TEST_P(GLES3DecoderTest, ReadPixels2PixelPackBufferNoBufferBound) {
664 const GLsizei kWidth = 5;
665 const GLsizei kHeight = 3;
666 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0);
667
668 ReadPixels cmd;
669 cmd.Init(0,
670 0,
671 kWidth,
672 kHeight,
673 GL_RGBA,
674 GL_UNSIGNED_BYTE,
675 0,
676 0,
677 0,
678 0,
679 false);
680 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
681 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
682 }
683
684 TEST_P(GLES3DecoderTest, ReadPixels2BufferBound) {
685 const GLsizei kWidth = 5;
686 const GLsizei kHeight = 3;
687 const GLint kBytesPerPixel = 4;
688 GLint size = kWidth * kHeight * kBytesPerPixel;
689 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0);
690 typedef ReadPixels::Result Result;
691 Result* result = GetSharedMemoryAs<Result*>();
692 uint32 result_shm_id = kSharedMemoryId;
693 uint32 result_shm_offset = kSharedMemoryOffset;
694 uint32 pixels_shm_id = kSharedMemoryId;
695 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result);
696
697 DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId);
698 DoBufferData(GL_PIXEL_PACK_BUFFER, size);
699
700 ReadPixels cmd;
701 cmd.Init(0,
702 0,
703 kWidth,
704 kHeight,
705 GL_RGBA,
706 GL_UNSIGNED_BYTE,
707 pixels_shm_id,
708 pixels_shm_offset,
709 result_shm_id,
710 result_shm_offset,
711 false);
712 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
713 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
714 }
715
716 TEST_P(GLES3DecoderTest, ReadPixels2PixelPackBuffer) {
717 const GLsizei kWidth = 5;
718 const GLsizei kHeight = 3;
719 const GLint kBytesPerPixel = 4;
720 GLint size = kWidth * kHeight * kBytesPerPixel;
721
722 DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId);
723 DoBufferData(GL_PIXEL_PACK_BUFFER, size);
724
725 EXPECT_CALL(*gl_, GetError())
726 .WillOnce(Return(GL_NO_ERROR))
727 .WillOnce(Return(GL_NO_ERROR))
728 .RetiresOnSaturation();
729 EXPECT_CALL(*gl_,
730 ReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, _));
731 ReadPixels cmd;
732 cmd.Init(0,
733 0,
734 kWidth,
735 kHeight,
736 GL_RGBA,
737 GL_UNSIGNED_BYTE,
738 0,
739 0,
740 0,
741 0,
742 false);
743 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
744 EXPECT_EQ(GL_NO_ERROR, GetGLError());
745 }
746
663 TEST_P(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) { 747 TEST_P(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) {
664 const GLsizei kWidth = 3; 748 const GLsizei kWidth = 3;
665 const GLsizei kHeight = 3; 749 const GLsizei kHeight = 3;
666 const GLint kBytesPerPixel = 4; 750 const GLint kBytesPerPixel = 4;
667 const GLint kPackAlignment = 4; 751 const GLint kPackAlignment = 4;
668 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = { 752 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = {
669 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255, 753 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255,
670 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255, 754 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255,
671 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255, 755 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255,
672 }; 756 };
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 EXPECT_EQ(1, result->GetNumResults()); 3001 EXPECT_EQ(1, result->GetNumResults());
2918 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3002 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2919 } 3003 }
2920 3004
2921 // TODO(gman): PixelStorei 3005 // TODO(gman): PixelStorei
2922 3006
2923 // TODO(gman): SwapBuffers 3007 // TODO(gman): SwapBuffers
2924 3008
2925 } // namespace gles2 3009 } // namespace gles2
2926 } // namespace gpu 3010 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698