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 "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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 AddExpectationsForSimulatedAttrib0WithError( | 732 AddExpectationsForSimulatedAttrib0WithError( |
733 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); | 733 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); |
734 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0).RetiresOnSaturation(); | 734 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0).RetiresOnSaturation(); |
735 DrawArrays cmd; | 735 DrawArrays cmd; |
736 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); | 736 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); |
737 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 737 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
738 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 738 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
739 EXPECT_FALSE(GetDecoder()->WasContextLost()); | 739 EXPECT_FALSE(GetDecoder()->WasContextLost()); |
740 } | 740 } |
741 | 741 |
742 // Test that we lose context. | |
743 TEST_P(GLES2DecoderManualInitTest, LoseContextWhenOOM) { | |
744 InitState init; | |
745 init.has_alpha = true; | |
746 init.has_depth = true; | |
747 init.request_alpha = true; | |
748 init.request_depth = true; | |
749 init.bind_generates_resource = true; | |
750 init.lose_context_when_out_of_memory = true; | |
751 InitDecoder(init); | |
752 SetupDefaultProgram(); | |
753 | |
754 const GLsizei kFakeLargeCount = 0x1234; | |
755 SetupTexture(); | |
756 AddExpectationsForSimulatedAttrib0WithError( | |
757 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); | |
758 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0).RetiresOnSaturation(); | |
759 // Other contexts in the group should be lost also. | |
760 EXPECT_CALL(*mock_decoder_, LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB)) | |
761 .Times(1) | |
762 .RetiresOnSaturation(); | |
763 DrawArrays cmd; | |
764 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); | |
765 // This context should be lost. | |
766 EXPECT_EQ(error::kLostContext, ExecuteCmd(cmd)); | |
767 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | |
768 EXPECT_TRUE(decoder_->WasContextLost()); | |
769 } | |
770 | |
771 TEST_P(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { | 742 TEST_P(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { |
772 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 743 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
773 // This is an NPOT texture. As the default filtering requires mips | 744 // This is an NPOT texture. As the default filtering requires mips |
774 // this should trigger replacing with black textures before rendering. | 745 // this should trigger replacing with black textures before rendering. |
775 DoTexImage2D(GL_TEXTURE_2D, | 746 DoTexImage2D(GL_TEXTURE_2D, |
776 0, | 747 0, |
777 GL_RGBA, | 748 GL_RGBA, |
778 3, | 749 3, |
779 1, | 750 1, |
780 0, | 751 0, |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 .Times(1) | 2352 .Times(1) |
2382 .RetiresOnSaturation(); | 2353 .RetiresOnSaturation(); |
2383 DrawArrays cmd; | 2354 DrawArrays cmd; |
2384 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 2355 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
2385 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2356 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2386 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2357 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2387 } | 2358 } |
2388 | 2359 |
2389 } // namespace gles2 | 2360 } // namespace gles2 |
2390 } // namespace gpu | 2361 } // namespace gpu |
OLD | NEW |