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

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

Issue 1540553003: Revert of Command Buffer: read pixels into pixel pack buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | no next file » | 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 "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::kInvalidArguments, ExecuteCmd(cmd));
681 EXPECT_EQ(GL_NO_ERROR, GetGLError());
682 }
683
684 TEST_P(GLES3DecoderTest, ReadPixelsBufferBound) {
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 uint32 result_shm_id = kSharedMemoryId;
691 uint32 result_shm_offset = kSharedMemoryOffset;
692 uint32 pixels_shm_id = kSharedMemoryId;
693 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(ReadPixels::Result);
694
695 DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId);
696 DoBufferData(GL_PIXEL_PACK_BUFFER, size);
697
698 ReadPixels cmd;
699 cmd.Init(0,
700 0,
701 kWidth,
702 kHeight,
703 GL_RGBA,
704 GL_UNSIGNED_BYTE,
705 pixels_shm_id,
706 pixels_shm_offset,
707 result_shm_id,
708 result_shm_offset,
709 false);
710 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd));
711 EXPECT_EQ(GL_NO_ERROR, GetGLError());
712 }
713
714 TEST_P(GLES3DecoderTest, ReadPixels2PixelPackBuffer) {
715 const GLsizei kWidth = 5;
716 const GLsizei kHeight = 3;
717 const GLint kBytesPerPixel = 4;
718 GLint size = kWidth * kHeight * kBytesPerPixel;
719
720 DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId);
721 DoBufferData(GL_PIXEL_PACK_BUFFER, size);
722
723 EXPECT_CALL(*gl_, GetError())
724 .WillOnce(Return(GL_NO_ERROR))
725 .RetiresOnSaturation();
726 EXPECT_CALL(*gl_,
727 ReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, _));
728 ReadPixels cmd;
729 cmd.Init(0,
730 0,
731 kWidth,
732 kHeight,
733 GL_RGBA,
734 GL_UNSIGNED_BYTE,
735 0,
736 0,
737 0,
738 0,
739 false);
740 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
741 EXPECT_EQ(GL_NO_ERROR, GetGLError());
742 }
743
744 TEST_P(GLES3DecoderTest, ReadPixelsPixelPackBufferMapped) {
745 const GLsizei kWidth = 5;
746 const GLsizei kHeight = 3;
747 const GLint kBytesPerPixel = 4;
748 GLint size = kWidth * kHeight * kBytesPerPixel;
749
750 DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId);
751
752 uint32_t result_shm_id = kSharedMemoryId;
753 uint32_t result_shm_offset = kSharedMemoryOffset;
754 uint32_t data_shm_id = kSharedMemoryId;
755 // uint32_t is Result for both MapBufferRange and UnmapBuffer commands.
756 uint32_t data_shm_offset = kSharedMemoryOffset + sizeof(uint32_t);
757 EXPECT_CALL(*gl_,
758 MapBufferRange(GL_PIXEL_PACK_BUFFER, 0, size, GL_MAP_READ_BIT))
759 .RetiresOnSaturation();
760 MapBufferRange map_buffer_range;
761 map_buffer_range.Init(GL_PIXEL_PACK_BUFFER, 0, size, GL_MAP_READ_BIT,
762 data_shm_id, data_shm_offset,
763 result_shm_id, result_shm_offset);
764 EXPECT_EQ(error::kNoError, ExecuteCmd(map_buffer_range));
765 EXPECT_EQ(GL_NO_ERROR, GetGLError());
766
767 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0);
768 ReadPixels cmd;
769 cmd.Init(0,
770 0,
771 kWidth,
772 kHeight,
773 GL_RGBA,
774 GL_UNSIGNED_BYTE,
775 0,
776 0,
777 0,
778 0,
779 false);
780 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
781 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
782 }
783
784 TEST_P(GLES3DecoderTest, ReadPixelsPixelPackBufferIsNotLargeEnough) {
785 const GLsizei kWidth = 5;
786 const GLsizei kHeight = 3;
787 const GLint kBytesPerPixel = 4;
788 GLint size = kWidth * kHeight * kBytesPerPixel;
789
790 DoBindBuffer(GL_PIXEL_PACK_BUFFER, client_buffer_id_, kServiceBufferId);
791
792 DoBufferData(GL_PIXEL_PACK_BUFFER, size - 4);
793 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0);
794
795 ReadPixels cmd;
796 cmd.Init(0,
797 0,
798 kWidth,
799 kHeight,
800 GL_RGBA,
801 GL_UNSIGNED_BYTE,
802 0,
803 0,
804 0,
805 0,
806 false);
807 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
808 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
809 }
810
811 TEST_P(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) { 663 TEST_P(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) {
812 const GLsizei kWidth = 3; 664 const GLsizei kWidth = 3;
813 const GLsizei kHeight = 3; 665 const GLsizei kHeight = 3;
814 const GLint kBytesPerPixel = 4; 666 const GLint kBytesPerPixel = 4;
815 const GLint kPackAlignment = 4; 667 const GLint kPackAlignment = 4;
816 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = { 668 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = {
817 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255, 669 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255,
818 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255, 670 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255,
819 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255, 671 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255,
820 }; 672 };
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 EXPECT_EQ(1, result->GetNumResults()); 2917 EXPECT_EQ(1, result->GetNumResults());
3066 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2918 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3067 } 2919 }
3068 2920
3069 // TODO(gman): PixelStorei 2921 // TODO(gman): PixelStorei
3070 2922
3071 // TODO(gman): SwapBuffers 2923 // TODO(gman): SwapBuffers
3072 2924
3073 } // namespace gles2 2925 } // namespace gles2
3074 } // namespace gpu 2926 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698