| 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/test_helper.h" | 5 #include "gpu/command_buffer/service/test_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || | 332 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || |
| 333 gl_info.is_es3) { | 333 gl_info.is_es3) { |
| 334 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) | 334 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) |
| 335 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) | 335 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) |
| 336 .RetiresOnSaturation(); | 336 .RetiresOnSaturation(); |
| 337 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { | 337 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { |
| 338 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES_IMG, _)) | 338 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES_IMG, _)) |
| 339 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) | 339 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) |
| 340 .RetiresOnSaturation(); | 340 .RetiresOnSaturation(); |
| 341 } | 341 } |
| 342 |
| 343 if (gl_info.IsAtLeastGL(3, 3) || |
| 344 (gl_info.IsAtLeastGL(3, 2) && |
| 345 strstr(extensions, "GL_ARB_blend_func_extended")) || |
| 346 (gl_info.is_es && strstr(extensions, "GL_EXT_blend_func_extended"))) { |
| 347 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT, _)) |
| 348 .WillOnce(SetArgumentPointee<1>(8)) |
| 349 .RetiresOnSaturation(); |
| 350 } |
| 351 |
| 342 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) | 352 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) |
| 343 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) | 353 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) |
| 344 .RetiresOnSaturation(); | 354 .RetiresOnSaturation(); |
| 345 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _)) | 355 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _)) |
| 346 .WillOnce(SetArgumentPointee<1>(kNumTextureUnits)) | 356 .WillOnce(SetArgumentPointee<1>(kNumTextureUnits)) |
| 347 .RetiresOnSaturation(); | 357 .RetiresOnSaturation(); |
| 348 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TEXTURE_SIZE, _)) | 358 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TEXTURE_SIZE, _)) |
| 349 .WillOnce(SetArgumentPointee<1>(kMaxTextureSize)) | 359 .WillOnce(SetArgumentPointee<1>(kMaxTextureSize)) |
| 350 .RetiresOnSaturation(); | 360 .RetiresOnSaturation(); |
| 351 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _)) | 361 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _)) |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 692 |
| 683 void TestHelper::SetupProgramSuccessExpectations( | 693 void TestHelper::SetupProgramSuccessExpectations( |
| 684 ::gfx::MockGLInterface* gl, | 694 ::gfx::MockGLInterface* gl, |
| 685 const FeatureInfo* feature_info, | 695 const FeatureInfo* feature_info, |
| 686 AttribInfo* attribs, | 696 AttribInfo* attribs, |
| 687 size_t num_attribs, | 697 size_t num_attribs, |
| 688 UniformInfo* uniforms, | 698 UniformInfo* uniforms, |
| 689 size_t num_uniforms, | 699 size_t num_uniforms, |
| 690 VaryingInfo* varyings, | 700 VaryingInfo* varyings, |
| 691 size_t num_varyings, | 701 size_t num_varyings, |
| 702 ProgramOutputInfo* program_outputs, |
| 703 size_t num_program_outputs, |
| 692 GLuint service_id) { | 704 GLuint service_id) { |
| 693 EXPECT_CALL(*gl, | 705 EXPECT_CALL(*gl, |
| 694 GetProgramiv(service_id, GL_LINK_STATUS, _)) | 706 GetProgramiv(service_id, GL_LINK_STATUS, _)) |
| 695 .WillOnce(SetArgumentPointee<2>(1)) | 707 .WillOnce(SetArgumentPointee<2>(1)) |
| 696 .RetiresOnSaturation(); | 708 .RetiresOnSaturation(); |
| 697 EXPECT_CALL(*gl, | 709 EXPECT_CALL(*gl, |
| 698 GetProgramiv(service_id, GL_INFO_LOG_LENGTH, _)) | 710 GetProgramiv(service_id, GL_INFO_LOG_LENGTH, _)) |
| 699 .WillOnce(SetArgumentPointee<2>(0)) | 711 .WillOnce(SetArgumentPointee<2>(0)) |
| 700 .RetiresOnSaturation(); | 712 .RetiresOnSaturation(); |
| 701 EXPECT_CALL(*gl, | 713 EXPECT_CALL(*gl, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 717 EXPECT_CALL(*gl, | 729 EXPECT_CALL(*gl, |
| 718 GetActiveAttrib(service_id, ii, | 730 GetActiveAttrib(service_id, ii, |
| 719 max_attrib_len, _, _, _, _)) | 731 max_attrib_len, _, _, _, _)) |
| 720 .WillOnce(DoAll( | 732 .WillOnce(DoAll( |
| 721 SetArgumentPointee<3>(strlen(info.name)), | 733 SetArgumentPointee<3>(strlen(info.name)), |
| 722 SetArgumentPointee<4>(info.size), | 734 SetArgumentPointee<4>(info.size), |
| 723 SetArgumentPointee<5>(info.type), | 735 SetArgumentPointee<5>(info.type), |
| 724 SetArrayArgument<6>(info.name, | 736 SetArrayArgument<6>(info.name, |
| 725 info.name + strlen(info.name) + 1))) | 737 info.name + strlen(info.name) + 1))) |
| 726 .RetiresOnSaturation(); | 738 .RetiresOnSaturation(); |
| 727 if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { | 739 if (!ProgramManager::HasBuiltInPrefix(info.name)) { |
| 728 EXPECT_CALL(*gl, GetAttribLocation(service_id, StrEq(info.name))) | 740 EXPECT_CALL(*gl, GetAttribLocation(service_id, StrEq(info.name))) |
| 729 .WillOnce(Return(info.location)) | 741 .WillOnce(Return(info.location)) |
| 730 .RetiresOnSaturation(); | 742 .RetiresOnSaturation(); |
| 731 } | 743 } |
| 732 } | 744 } |
| 733 EXPECT_CALL(*gl, | 745 EXPECT_CALL(*gl, |
| 734 GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _)) | 746 GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _)) |
| 735 .WillOnce(SetArgumentPointee<2>(num_uniforms)) | 747 .WillOnce(SetArgumentPointee<2>(num_uniforms)) |
| 736 .RetiresOnSaturation(); | 748 .RetiresOnSaturation(); |
| 737 | 749 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 .WillOnce(SetArgumentPointee<3>(int(max_varying_len))) | 814 .WillOnce(SetArgumentPointee<3>(int(max_varying_len))) |
| 803 .RetiresOnSaturation(); | 815 .RetiresOnSaturation(); |
| 804 for (size_t ii = 0; ii < num_varyings; ++ii) { | 816 for (size_t ii = 0; ii < num_varyings; ++ii) { |
| 805 VaryingInfo& info = varyings[ii]; | 817 VaryingInfo& info = varyings[ii]; |
| 806 EXPECT_CALL(*gl, GetProgramResourceName(service_id, GL_FRAGMENT_INPUT_NV, | 818 EXPECT_CALL(*gl, GetProgramResourceName(service_id, GL_FRAGMENT_INPUT_NV, |
| 807 ii, max_varying_len, _, _)) | 819 ii, max_varying_len, _, _)) |
| 808 .WillOnce(DoAll(SetArgumentPointee<4>(strlen(info.name)), | 820 .WillOnce(DoAll(SetArgumentPointee<4>(strlen(info.name)), |
| 809 SetArrayArgument<5>( | 821 SetArrayArgument<5>( |
| 810 info.name, info.name + strlen(info.name) + 1))) | 822 info.name, info.name + strlen(info.name) + 1))) |
| 811 .RetiresOnSaturation(); | 823 .RetiresOnSaturation(); |
| 812 if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) { | 824 if (ProgramManager::HasBuiltInPrefix(info.name)) { |
| 825 continue; |
| 826 } |
| 813 static const GLenum kPropsArray[] = {GL_LOCATION, GL_TYPE, | 827 static const GLenum kPropsArray[] = {GL_LOCATION, GL_TYPE, |
| 814 GL_ARRAY_SIZE}; | 828 GL_ARRAY_SIZE}; |
| 815 static const size_t kPropsSize = arraysize(kPropsArray); | 829 static const size_t kPropsSize = arraysize(kPropsArray); |
| 816 EXPECT_CALL( | 830 EXPECT_CALL( |
| 817 *gl, GetProgramResourceiv( | 831 *gl, GetProgramResourceiv( |
| 818 service_id, GL_FRAGMENT_INPUT_NV, ii, kPropsSize, | 832 service_id, GL_FRAGMENT_INPUT_NV, ii, kPropsSize, |
| 819 _ /*testing::ElementsAreArray(kPropsArray, kPropsSize)*/, | 833 _ /*testing::ElementsAreArray(kPropsArray, kPropsSize)*/, |
| 820 kPropsSize, _, _)) | 834 kPropsSize, _, _)) |
| 821 .WillOnce(testing::Invoke([info](GLuint, GLenum, GLuint, GLsizei, | 835 .WillOnce(testing::Invoke([info](GLuint, GLenum, GLuint, GLsizei, |
| 822 const GLenum*, GLsizei, | 836 const GLenum*, GLsizei, |
| 823 GLsizei* length, GLint* params) { | 837 GLsizei* length, GLint* params) { |
| 824 *length = kPropsSize; | 838 *length = kPropsSize; |
| 825 params[0] = info.real_location; | 839 params[0] = info.real_location; |
| 826 params[1] = info.type; | 840 params[1] = info.type; |
| 827 params[2] = info.size; | 841 params[2] = info.size; |
| 828 })) | 842 })) |
| 829 .RetiresOnSaturation(); | 843 .RetiresOnSaturation(); |
| 830 } | 844 } |
| 845 } |
| 846 if (feature_info->feature_flags().ext_blend_func_extended) { |
| 847 EXPECT_CALL(*gl, GetProgramInterfaceiv(service_id, GL_PROGRAM_OUTPUT, |
| 848 GL_ACTIVE_RESOURCES, _)) |
| 849 .WillOnce(SetArgumentPointee<3>(int(num_program_outputs))) |
| 850 .RetiresOnSaturation(); |
| 851 size_t max_program_output_len = 0; |
| 852 for (size_t ii = 0; ii < num_program_outputs; ++ii) { |
| 853 size_t len = strlen(program_outputs[ii].name) + 1; |
| 854 max_program_output_len = std::max(max_program_output_len, len); |
| 855 } |
| 856 EXPECT_CALL(*gl, GetProgramInterfaceiv(service_id, GL_PROGRAM_OUTPUT, |
| 857 GL_MAX_NAME_LENGTH, _)) |
| 858 .WillOnce(SetArgumentPointee<3>(int(max_program_output_len))) |
| 859 .RetiresOnSaturation(); |
| 860 for (size_t ii = 0; ii < num_program_outputs; ++ii) { |
| 861 ProgramOutputInfo& info = program_outputs[ii]; |
| 862 EXPECT_CALL(*gl, GetProgramResourceName(service_id, GL_PROGRAM_OUTPUT, ii, |
| 863 max_program_output_len, _, _)) |
| 864 .WillOnce(DoAll(SetArgumentPointee<4>(strlen(info.name)), |
| 865 SetArrayArgument<5>( |
| 866 info.name, info.name + strlen(info.name) + 1))) |
| 867 .RetiresOnSaturation(); |
| 868 if (ProgramManager::HasBuiltInPrefix(info.name)) { |
| 869 continue; |
| 870 } |
| 871 static const GLenum kPropsArray[] = {GL_LOCATION, GL_LOCATION_INDEX, |
| 872 GL_TYPE, GL_ARRAY_SIZE}; |
| 873 static const size_t kPropsSize = arraysize(kPropsArray); |
| 874 EXPECT_CALL(*gl, |
| 875 GetProgramResourceiv( |
| 876 service_id, GL_PROGRAM_OUTPUT, ii, kPropsSize, |
| 877 _ /*testing::ElementsAreArray(kPropsArray, kPropsSize)*/, |
| 878 kPropsSize, _, _)) |
| 879 .WillOnce(testing::Invoke([info](GLuint, GLenum, GLuint, GLsizei, |
| 880 const GLenum*, GLsizei, |
| 881 GLsizei* length, GLint* params) { |
| 882 *length = kPropsSize; |
| 883 params[0] = info.color_name; |
| 884 params[1] = info.index; |
| 885 params[2] = info.type; |
| 886 params[3] = info.size; |
| 887 })) |
| 888 .RetiresOnSaturation(); |
| 889 } |
| 890 } else if (feature_info->gl_version_info().IsES3Capable() && |
| 891 !feature_info->disable_shader_translator()) { |
| 892 for (size_t ii = 0; ii < num_program_outputs; ++ii) { |
| 893 ProgramOutputInfo& info = program_outputs[ii]; |
| 894 EXPECT_CALL(*gl, GetFragDataLocation(service_id, StrEq(info.name))) |
| 895 .WillOnce(Return(info.color_name)) |
| 896 .RetiresOnSaturation(); |
| 897 DCHECK(info.index == 0); |
| 898 // Test case must not use indices, or the context of the testcase has to |
| 899 // support |
| 900 // the dual source blending. |
| 831 } | 901 } |
| 832 } | 902 } |
| 833 } | 903 } |
| 834 | 904 |
| 835 void TestHelper::SetupShaderExpectations(::gfx::MockGLInterface* gl, | 905 void TestHelper::SetupShaderExpectations(::gfx::MockGLInterface* gl, |
| 836 const FeatureInfo* feature_info, | 906 const FeatureInfo* feature_info, |
| 837 AttribInfo* attribs, | 907 AttribInfo* attribs, |
| 838 size_t num_attribs, | 908 size_t num_attribs, |
| 839 UniformInfo* uniforms, | 909 UniformInfo* uniforms, |
| 840 size_t num_uniforms, | 910 size_t num_uniforms, |
| 841 GLuint service_id) { | 911 GLuint service_id) { |
| 842 InSequence s; | 912 InSequence s; |
| 843 | 913 |
| 844 EXPECT_CALL(*gl, LinkProgram(service_id)).Times(1).RetiresOnSaturation(); | 914 EXPECT_CALL(*gl, LinkProgram(service_id)).Times(1).RetiresOnSaturation(); |
| 845 | 915 |
| 846 SetupProgramSuccessExpectations(gl, feature_info, attribs, num_attribs, | 916 SetupProgramSuccessExpectations(gl, feature_info, attribs, num_attribs, |
| 847 uniforms, num_uniforms, nullptr, 0, | 917 uniforms, num_uniforms, nullptr, 0, nullptr, |
| 848 service_id); | 918 0, service_id); |
| 849 } | 919 } |
| 850 | 920 |
| 851 void TestHelper::SetupShaderExpectationsWithVaryings( | 921 void TestHelper::SetupShaderExpectationsWithVaryings( |
| 852 ::gfx::MockGLInterface* gl, | 922 ::gfx::MockGLInterface* gl, |
| 853 const FeatureInfo* feature_info, | 923 const FeatureInfo* feature_info, |
| 854 AttribInfo* attribs, | 924 AttribInfo* attribs, |
| 855 size_t num_attribs, | 925 size_t num_attribs, |
| 856 UniformInfo* uniforms, | 926 UniformInfo* uniforms, |
| 857 size_t num_uniforms, | 927 size_t num_uniforms, |
| 858 VaryingInfo* varyings, | 928 VaryingInfo* varyings, |
| 859 size_t num_varyings, | 929 size_t num_varyings, |
| 930 ProgramOutputInfo* program_outputs, |
| 931 size_t num_program_outputs, |
| 860 GLuint service_id) { | 932 GLuint service_id) { |
| 861 InSequence s; | 933 InSequence s; |
| 862 | 934 |
| 863 EXPECT_CALL(*gl, | 935 EXPECT_CALL(*gl, |
| 864 LinkProgram(service_id)) | 936 LinkProgram(service_id)) |
| 865 .Times(1) | 937 .Times(1) |
| 866 .RetiresOnSaturation(); | 938 .RetiresOnSaturation(); |
| 867 | 939 |
| 868 SetupProgramSuccessExpectations(gl, feature_info, attribs, num_attribs, | 940 SetupProgramSuccessExpectations( |
| 869 uniforms, num_uniforms, varyings, | 941 gl, feature_info, attribs, num_attribs, uniforms, num_uniforms, varyings, |
| 870 num_varyings, service_id); | 942 num_varyings, program_outputs, num_program_outputs, service_id); |
| 871 } | 943 } |
| 872 | 944 |
| 873 void TestHelper::DoBufferData( | 945 void TestHelper::DoBufferData( |
| 874 ::gfx::MockGLInterface* gl, MockErrorState* error_state, | 946 ::gfx::MockGLInterface* gl, MockErrorState* error_state, |
| 875 BufferManager* manager, Buffer* buffer, GLenum target, GLsizeiptr size, | 947 BufferManager* manager, Buffer* buffer, GLenum target, GLsizeiptr size, |
| 876 GLenum usage, const GLvoid* data, GLenum error) { | 948 GLenum usage, const GLvoid* data, GLenum error) { |
| 877 EXPECT_CALL(*error_state, CopyRealGLErrorsToWrapper(_, _, _)) | 949 EXPECT_CALL(*error_state, CopyRealGLErrorsToWrapper(_, _, _)) |
| 878 .Times(1) | 950 .Times(1) |
| 879 .RetiresOnSaturation(); | 951 .RetiresOnSaturation(); |
| 880 if (manager->IsUsageClientSideArray(usage)) { | 952 if (manager->IsUsageClientSideArray(usage)) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 910 } else { | 982 } else { |
| 911 EXPECT_CALL(*error_state, SetGLErrorInvalidParami(_, _, error, _, _, _)) | 983 EXPECT_CALL(*error_state, SetGLErrorInvalidParami(_, _, error, _, _, _)) |
| 912 .Times(1) | 984 .Times(1) |
| 913 .RetiresOnSaturation(); | 985 .RetiresOnSaturation(); |
| 914 } | 986 } |
| 915 manager->SetParameteri("", error_state, texture_ref, pname, value); | 987 manager->SetParameteri("", error_state, texture_ref, pname, value); |
| 916 } | 988 } |
| 917 | 989 |
| 918 // static | 990 // static |
| 919 void TestHelper::SetShaderStates( | 991 void TestHelper::SetShaderStates( |
| 920 ::gfx::MockGLInterface* gl, Shader* shader, | 992 ::gfx::MockGLInterface* gl, |
| 921 bool expected_valid, | 993 Shader* shader, |
| 922 const std::string* const expected_log_info, | 994 bool expected_valid, |
| 923 const std::string* const expected_translated_source, | 995 const std::string* const expected_log_info, |
| 924 const int* const expected_shader_version, | 996 const std::string* const expected_translated_source, |
| 925 const AttributeMap* const expected_attrib_map, | 997 const int* const expected_shader_version, |
| 926 const UniformMap* const expected_uniform_map, | 998 const AttributeMap* const expected_attrib_map, |
| 927 const VaryingMap* const expected_varying_map, | 999 const UniformMap* const expected_uniform_map, |
| 928 const NameMap* const expected_name_map) { | 1000 const VaryingMap* const expected_varying_map, |
| 1001 const OutputVariableList* const expected_output_variable_list, |
| 1002 const NameMap* const expected_name_map) { |
| 929 const std::string empty_log_info; | 1003 const std::string empty_log_info; |
| 930 const std::string* log_info = (expected_log_info && !expected_valid) ? | 1004 const std::string* log_info = (expected_log_info && !expected_valid) ? |
| 931 expected_log_info : &empty_log_info; | 1005 expected_log_info : &empty_log_info; |
| 932 const std::string empty_translated_source; | 1006 const std::string empty_translated_source; |
| 933 const std::string* translated_source = | 1007 const std::string* translated_source = |
| 934 (expected_translated_source && expected_valid) ? | 1008 (expected_translated_source && expected_valid) ? |
| 935 expected_translated_source : &empty_translated_source; | 1009 expected_translated_source : &empty_translated_source; |
| 936 int default_shader_version = 100; | 1010 int default_shader_version = 100; |
| 937 const int* shader_version = (expected_shader_version && expected_valid) ? | 1011 const int* shader_version = (expected_shader_version && expected_valid) ? |
| 938 expected_shader_version : &default_shader_version; | 1012 expected_shader_version : &default_shader_version; |
| 939 const AttributeMap empty_attrib_map; | 1013 const AttributeMap empty_attrib_map; |
| 940 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ? | 1014 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ? |
| 941 expected_attrib_map : &empty_attrib_map; | 1015 expected_attrib_map : &empty_attrib_map; |
| 942 const UniformMap empty_uniform_map; | 1016 const UniformMap empty_uniform_map; |
| 943 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ? | 1017 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ? |
| 944 expected_uniform_map : &empty_uniform_map; | 1018 expected_uniform_map : &empty_uniform_map; |
| 945 const VaryingMap empty_varying_map; | 1019 const VaryingMap empty_varying_map; |
| 946 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ? | 1020 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ? |
| 947 expected_varying_map : &empty_varying_map; | 1021 expected_varying_map : &empty_varying_map; |
| 1022 const OutputVariableList empty_output_variable_list; |
| 1023 const OutputVariableList* output_variable_list = |
| 1024 (expected_output_variable_list && expected_valid) |
| 1025 ? expected_output_variable_list |
| 1026 : &empty_output_variable_list; |
| 948 const NameMap empty_name_map; | 1027 const NameMap empty_name_map; |
| 949 const NameMap* name_map = (expected_name_map && expected_valid) ? | 1028 const NameMap* name_map = (expected_name_map && expected_valid) ? |
| 950 expected_name_map : &empty_name_map; | 1029 expected_name_map : &empty_name_map; |
| 951 | 1030 |
| 952 MockShaderTranslator* mock_translator = new MockShaderTranslator; | 1031 MockShaderTranslator* mock_translator = new MockShaderTranslator; |
| 953 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator); | 1032 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator); |
| 954 EXPECT_CALL(*mock_translator, Translate(_, | 1033 EXPECT_CALL(*mock_translator, Translate(_, |
| 955 NotNull(), // log_info | 1034 NotNull(), // log_info |
| 956 NotNull(), // translated_source | 1035 NotNull(), // translated_source |
| 957 NotNull(), // shader_version | 1036 NotNull(), // shader_version |
| 958 NotNull(), // attrib_map | 1037 NotNull(), // attrib_map |
| 959 NotNull(), // uniform_map | 1038 NotNull(), // uniform_map |
| 960 NotNull(), // varying_map | 1039 NotNull(), // varying_map |
| 1040 NotNull(), // output_variable_list |
| 961 NotNull())) // name_map | 1041 NotNull())) // name_map |
| 962 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info), | 1042 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info), |
| 963 SetArgumentPointee<2>(*translated_source), | 1043 SetArgumentPointee<2>(*translated_source), |
| 964 SetArgumentPointee<3>(*shader_version), | 1044 SetArgumentPointee<3>(*shader_version), |
| 965 SetArgumentPointee<4>(*attrib_map), | 1045 SetArgumentPointee<4>(*attrib_map), |
| 966 SetArgumentPointee<5>(*uniform_map), | 1046 SetArgumentPointee<5>(*uniform_map), |
| 967 SetArgumentPointee<6>(*varying_map), | 1047 SetArgumentPointee<6>(*varying_map), |
| 968 SetArgumentPointee<7>(*name_map), | 1048 SetArgumentPointee<7>(*output_variable_list), |
| 969 Return(expected_valid))) | 1049 SetArgumentPointee<8>(*name_map), Return(expected_valid))) |
| 970 .RetiresOnSaturation(); | 1050 .RetiresOnSaturation(); |
| 971 if (expected_valid) { | 1051 if (expected_valid) { |
| 972 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL)) | 1052 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL)) |
| 973 .Times(1) | 1053 .Times(1) |
| 974 .RetiresOnSaturation(); | 1054 .RetiresOnSaturation(); |
| 975 EXPECT_CALL(*gl, CompileShader(shader->service_id())) | 1055 EXPECT_CALL(*gl, CompileShader(shader->service_id())) |
| 976 .Times(1) | 1056 .Times(1) |
| 977 .RetiresOnSaturation(); | 1057 .RetiresOnSaturation(); |
| 978 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(), | 1058 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(), |
| 979 GL_COMPILE_STATUS, | 1059 GL_COMPILE_STATUS, |
| 980 NotNull())) // status | 1060 NotNull())) // status |
| 981 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) | 1061 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) |
| 982 .RetiresOnSaturation(); | 1062 .RetiresOnSaturation(); |
| 983 } | 1063 } |
| 984 shader->RequestCompile(translator, Shader::kGL); | 1064 shader->RequestCompile(translator, Shader::kGL); |
| 985 shader->DoCompile(); | 1065 shader->DoCompile(); |
| 986 } | 1066 } |
| 987 | 1067 |
| 988 // static | 1068 // static |
| 989 void TestHelper::SetShaderStates( | 1069 void TestHelper::SetShaderStates( |
| 990 ::gfx::MockGLInterface* gl, Shader* shader, bool valid) { | 1070 ::gfx::MockGLInterface* gl, Shader* shader, bool valid) { |
| 991 SetShaderStates(gl, shader, valid, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | 1071 SetShaderStates(gl, shader, valid, nullptr, nullptr, nullptr, nullptr, |
| 1072 nullptr, nullptr, nullptr, nullptr); |
| 992 } | 1073 } |
| 993 | 1074 |
| 994 // static | 1075 // static |
| 995 sh::Attribute TestHelper::ConstructAttribute( | 1076 sh::Attribute TestHelper::ConstructAttribute( |
| 996 GLenum type, GLint array_size, GLenum precision, | 1077 GLenum type, GLint array_size, GLenum precision, |
| 997 bool static_use, const std::string& name) { | 1078 bool static_use, const std::string& name) { |
| 998 return ConstructShaderVariable<sh::Attribute>( | 1079 return ConstructShaderVariable<sh::Attribute>( |
| 999 type, array_size, precision, static_use, name); | 1080 type, array_size, precision, static_use, name); |
| 1000 } | 1081 } |
| 1001 | 1082 |
| 1002 // static | 1083 // static |
| 1003 sh::Uniform TestHelper::ConstructUniform( | 1084 sh::Uniform TestHelper::ConstructUniform( |
| 1004 GLenum type, GLint array_size, GLenum precision, | 1085 GLenum type, GLint array_size, GLenum precision, |
| 1005 bool static_use, const std::string& name) { | 1086 bool static_use, const std::string& name) { |
| 1006 return ConstructShaderVariable<sh::Uniform>( | 1087 return ConstructShaderVariable<sh::Uniform>( |
| 1007 type, array_size, precision, static_use, name); | 1088 type, array_size, precision, static_use, name); |
| 1008 } | 1089 } |
| 1009 | 1090 |
| 1010 // static | 1091 // static |
| 1011 sh::Varying TestHelper::ConstructVarying( | 1092 sh::Varying TestHelper::ConstructVarying( |
| 1012 GLenum type, GLint array_size, GLenum precision, | 1093 GLenum type, GLint array_size, GLenum precision, |
| 1013 bool static_use, const std::string& name) { | 1094 bool static_use, const std::string& name) { |
| 1014 return ConstructShaderVariable<sh::Varying>( | 1095 return ConstructShaderVariable<sh::Varying>( |
| 1015 type, array_size, precision, static_use, name); | 1096 type, array_size, precision, static_use, name); |
| 1016 } | 1097 } |
| 1017 | 1098 |
| 1099 sh::OutputVariable TestHelper::ConstructOutputVariable( |
| 1100 GLenum type, |
| 1101 GLint array_size, |
| 1102 GLenum precision, |
| 1103 bool static_use, |
| 1104 const std::string& name) { |
| 1105 return ConstructShaderVariable<sh::OutputVariable>( |
| 1106 type, array_size, precision, static_use, name); |
| 1107 } |
| 1108 |
| 1018 ScopedGLImplementationSetter::ScopedGLImplementationSetter( | 1109 ScopedGLImplementationSetter::ScopedGLImplementationSetter( |
| 1019 gfx::GLImplementation implementation) | 1110 gfx::GLImplementation implementation) |
| 1020 : old_implementation_(gfx::GetGLImplementation()) { | 1111 : old_implementation_(gfx::GetGLImplementation()) { |
| 1021 gfx::SetGLImplementation(implementation); | 1112 gfx::SetGLImplementation(implementation); |
| 1022 } | 1113 } |
| 1023 | 1114 |
| 1024 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { | 1115 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { |
| 1025 gfx::SetGLImplementation(old_implementation_); | 1116 gfx::SetGLImplementation(old_implementation_); |
| 1026 } | 1117 } |
| 1027 | 1118 |
| 1028 } // namespace gles2 | 1119 } // namespace gles2 |
| 1029 } // namespace gpu | 1120 } // namespace gpu |
| 1030 | 1121 |
| OLD | NEW |