Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #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" |
| 11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
| 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
| 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 16 #include "gpu/command_buffer/service/context_group.h" | 16 #include "gpu/command_buffer/service/context_group.h" |
| 17 #include "gpu/command_buffer/service/context_state.h" | |
| 17 #include "gpu/command_buffer/service/gl_surface_mock.h" | 18 #include "gpu/command_buffer/service/gl_surface_mock.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 19 #include "gpu/command_buffer/service/gpu_switches.h" | 20 #include "gpu/command_buffer/service/gpu_switches.h" |
| 20 #include "gpu/command_buffer/service/image_manager.h" | 21 #include "gpu/command_buffer/service/image_manager.h" |
| 21 #include "gpu/command_buffer/service/mailbox_manager.h" | 22 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 22 #include "gpu/command_buffer/service/mocks.h" | 23 #include "gpu/command_buffer/service/mocks.h" |
| 23 #include "gpu/command_buffer/service/program_manager.h" | 24 #include "gpu/command_buffer/service/program_manager.h" |
| 24 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" | 25 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" |
| 25 #include "gpu/command_buffer/service/stream_texture_mock.h" | 26 #include "gpu/command_buffer/service/stream_texture_mock.h" |
| 26 #include "gpu/command_buffer/service/test_helper.h" | 27 #include "gpu/command_buffer/service/test_helper.h" |
| (...skipping 8786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8813 DiscardFramebufferEXTImmediate& cmd = | 8814 DiscardFramebufferEXTImmediate& cmd = |
| 8814 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 8815 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
| 8815 cmd.Init(target, count, attachments); | 8816 cmd.Init(target, count, attachments); |
| 8816 | 8817 |
| 8817 // Should not result into a call into GL. | 8818 // Should not result into a call into GL. |
| 8818 EXPECT_EQ(error::kNoError, | 8819 EXPECT_EQ(error::kNoError, |
| 8819 ExecuteImmediateCmd(cmd, sizeof(attachments))); | 8820 ExecuteImmediateCmd(cmd, sizeof(attachments))); |
| 8820 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 8821 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 8821 } | 8822 } |
| 8822 | 8823 |
| 8824 TEST_F(GLES2DecoderManualInitTest, RestoreState) { | |
| 8825 InitDecoder( | |
| 8826 "", // extensions | |
| 8827 false, // has alpha | |
| 8828 false, // has depth | |
| 8829 false, // has stencil | |
| 8830 false, // request alpha | |
| 8831 false, // request depth | |
| 8832 false, // request stencil | |
| 8833 false); // bind generates resource | |
| 8834 SetupTexture(); | |
| 8835 | |
| 8836 InSequence sequence; | |
| 8837 // Expect to restore texture bindings for unit GL_TEXTURE0. | |
| 8838 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8839 .Times(1) | |
| 8840 .RetiresOnSaturation(); | |
| 8841 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
| 8842 .Times(1) | |
| 8843 .RetiresOnSaturation(); | |
| 8844 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, | |
| 8845 TestHelper::kServiceDefaultTextureCubemapId)) | |
| 8846 .Times(1) | |
| 8847 .RetiresOnSaturation(); | |
| 8848 | |
| 8849 // Expect to restore texture bindings for remaining units. | |
| 8850 for (unsigned i = 0; i < group().max_texture_units() - 1; ++i) { | |
| 8851 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1 + i)) | |
| 8852 .Times(1) | |
| 8853 .RetiresOnSaturation(); | |
| 8854 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, | |
| 8855 TestHelper::kServiceDefaultTexture2dId)) | |
| 8856 .Times(1) | |
| 8857 .RetiresOnSaturation(); | |
| 8858 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, | |
| 8859 TestHelper::kServiceDefaultTextureCubemapId)) | |
| 8860 .Times(1) | |
| 8861 .RetiresOnSaturation(); | |
| 8862 } | |
| 8863 | |
| 8864 // Expect to restore the active texture unit to GL_TEXTURE0. | |
| 8865 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8866 .Times(1) | |
| 8867 .RetiresOnSaturation(); | |
| 8868 | |
| 8869 GetDecoder()->RestoreAllTextureUnitBindings(NULL); | |
| 8870 } | |
| 8871 | |
| 8872 TEST_F(GLES2DecoderManualInitTest, RestoreStateWithPreviousState) { | |
|
Ken Russell (switch to Gerrit)
2014/01/08 02:56:28
Could you please add a couple more tests?
- Havi
| |
| 8873 InitDecoder( | |
| 8874 "", // extensions | |
| 8875 false, // has alpha | |
| 8876 false, // has depth | |
| 8877 false, // has stencil | |
| 8878 false, // request alpha | |
| 8879 false, // request depth | |
| 8880 false, // request stencil | |
| 8881 false); // bind generates resource | |
| 8882 SetupTexture(); | |
| 8883 | |
| 8884 // Construct a previous ContextState with all texture bindings | |
| 8885 // set to default textures. | |
| 8886 ContextState prev_state(NULL, NULL); | |
| 8887 prev_state.texture_units.resize(group().max_texture_units()); | |
| 8888 for (uint32 tt = 0; tt < prev_state.texture_units.size(); ++tt) { | |
| 8889 TextureRef* ref_cube_map = | |
| 8890 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | |
| 8891 prev_state.texture_units[tt].bound_texture_cube_map = ref_cube_map; | |
| 8892 TextureRef* ref_2d = | |
| 8893 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | |
| 8894 prev_state.texture_units[tt].bound_texture_2d = ref_2d; | |
| 8895 } | |
| 8896 prev_state.active_texture_unit = 0; | |
| 8897 | |
| 8898 InSequence sequence; | |
| 8899 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, | |
| 8900 // since the rest of the bindings haven't changed between the current | |
| 8901 // state and the |prev_state|. | |
| 8902 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8903 .Times(1) | |
| 8904 .RetiresOnSaturation(); | |
| 8905 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | |
| 8906 .Times(1) | |
| 8907 .RetiresOnSaturation(); | |
| 8908 | |
| 8909 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 8910 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | |
| 8911 .Times(1) | |
| 8912 .RetiresOnSaturation(); | |
| 8913 | |
| 8914 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 8915 } | |
| 8916 | |
| 8823 // TODO(gman): Complete this test. | 8917 // TODO(gman): Complete this test. |
| 8824 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | 8918 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
| 8825 // } | 8919 // } |
| 8826 | 8920 |
| 8827 // TODO(gman): BufferData | 8921 // TODO(gman): BufferData |
| 8828 | 8922 |
| 8829 // TODO(gman): BufferDataImmediate | 8923 // TODO(gman): BufferDataImmediate |
| 8830 | 8924 |
| 8831 // TODO(gman): BufferSubData | 8925 // TODO(gman): BufferSubData |
| 8832 | 8926 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 8849 // TODO(gman): TexImage2DImmediate | 8943 // TODO(gman): TexImage2DImmediate |
| 8850 | 8944 |
| 8851 // TODO(gman): TexSubImage2DImmediate | 8945 // TODO(gman): TexSubImage2DImmediate |
| 8852 | 8946 |
| 8853 // TODO(gman): UseProgram | 8947 // TODO(gman): UseProgram |
| 8854 | 8948 |
| 8855 // TODO(gman): SwapBuffers | 8949 // TODO(gman): SwapBuffers |
| 8856 | 8950 |
| 8857 } // namespace gles2 | 8951 } // namespace gles2 |
| 8858 } // namespace gpu | 8952 } // namespace gpu |
| OLD | NEW |