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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 EXPECT_CALL(*gl, GetAttribLocation(service_id, StrEq(info.name))) | 728 EXPECT_CALL(*gl, GetAttribLocation(service_id, StrEq(info.name))) |
729 .WillOnce(Return(info.location)) | 729 .WillOnce(Return(info.location)) |
730 .RetiresOnSaturation(); | 730 .RetiresOnSaturation(); |
731 } | 731 } |
732 } | 732 } |
733 EXPECT_CALL(*gl, | 733 EXPECT_CALL(*gl, |
734 GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _)) | 734 GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _)) |
735 .WillOnce(SetArgumentPointee<2>(num_uniforms)) | 735 .WillOnce(SetArgumentPointee<2>(num_uniforms)) |
736 .RetiresOnSaturation(); | 736 .RetiresOnSaturation(); |
737 | 737 |
738 size_t max_uniform_len = 0; | 738 if (num_uniforms > 0) { |
739 for (size_t ii = 0; ii < num_uniforms; ++ii) { | 739 size_t max_uniform_len = 0; |
740 size_t len = strlen(uniforms[ii].name) + 1; | 740 for (size_t ii = 0; ii < num_uniforms; ++ii) { |
741 max_uniform_len = std::max(max_uniform_len, len); | 741 size_t len = strlen(uniforms[ii].name) + 1; |
742 } | 742 max_uniform_len = std::max(max_uniform_len, len); |
743 EXPECT_CALL(*gl, | 743 } |
744 GetProgramiv(service_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, _)) | 744 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, _)) |
745 .WillOnce(SetArgumentPointee<2>(max_uniform_len)) | 745 .WillOnce(SetArgumentPointee<2>(max_uniform_len)) |
746 .RetiresOnSaturation(); | |
747 for (size_t ii = 0; ii < num_uniforms; ++ii) { | |
748 const UniformInfo& info = uniforms[ii]; | |
749 EXPECT_CALL(*gl, | |
750 GetActiveUniform(service_id, ii, | |
751 max_uniform_len, _, _, _, _)) | |
752 .WillOnce(DoAll( | |
753 SetArgumentPointee<3>(strlen(info.name)), | |
754 SetArgumentPointee<4>(info.size), | |
755 SetArgumentPointee<5>(info.type), | |
756 SetArrayArgument<6>(info.name, | |
757 info.name + strlen(info.name) + 1))) | |
758 .RetiresOnSaturation(); | 746 .RetiresOnSaturation(); |
759 } | |
760 | |
761 for (int pass = 0; pass < 2; ++pass) { | |
762 for (size_t ii = 0; ii < num_uniforms; ++ii) { | 747 for (size_t ii = 0; ii < num_uniforms; ++ii) { |
763 const UniformInfo& info = uniforms[ii]; | 748 const UniformInfo& info = uniforms[ii]; |
764 if (pass == 0 && info.real_location != -1) { | 749 EXPECT_CALL(*gl, |
| 750 GetActiveUniform(service_id, ii, max_uniform_len, _, _, _, _)) |
| 751 .WillOnce(DoAll(SetArgumentPointee<3>(strlen(info.name)), |
| 752 SetArgumentPointee<4>(info.size), |
| 753 SetArgumentPointee<5>(info.type), |
| 754 SetArrayArgument<6>( |
| 755 info.name, info.name + strlen(info.name) + 1))) |
| 756 .RetiresOnSaturation(); |
| 757 |
| 758 if (info.real_location != -1) { |
765 EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name))) | 759 EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name))) |
766 .WillOnce(Return(info.real_location)) | 760 .WillOnce(Return(info.real_location)) |
767 .RetiresOnSaturation(); | 761 .RetiresOnSaturation(); |
768 } | 762 } |
769 if ((pass == 0 && info.desired_location >= 0) || | 763 if (info.size > 1) { |
770 (pass == 1 && info.desired_location < 0)) { | 764 std::string base_name = info.name; |
771 if (info.size > 1) { | 765 size_t array_pos = base_name.rfind("[0]"); |
772 std::string base_name = info.name; | 766 if (base_name.size() > 3 && array_pos == base_name.size() - 3) { |
773 size_t array_pos = base_name.rfind("[0]"); | 767 base_name = base_name.substr(0, base_name.size() - 3); |
774 if (base_name.size() > 3 && array_pos == base_name.size() - 3) { | 768 } |
775 base_name = base_name.substr(0, base_name.size() - 3); | 769 for (GLsizei jj = 1; jj < info.size; ++jj) { |
776 } | 770 std::string element_name(std::string(base_name) + "[" + |
777 for (GLsizei jj = 1; jj < info.size; ++jj) { | 771 base::IntToString(jj) + "]"); |
778 std::string element_name( | 772 EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(element_name))) |
779 std::string(base_name) + "[" + base::IntToString(jj) + "]"); | 773 .WillOnce(Return(info.real_location + jj * 2)) |
780 EXPECT_CALL(*gl, GetUniformLocation( | 774 .RetiresOnSaturation(); |
781 service_id, StrEq(element_name))) | |
782 .WillOnce(Return(info.real_location + jj * 2)) | |
783 .RetiresOnSaturation(); | |
784 } | |
785 } | 775 } |
786 } | 776 } |
787 } | 777 } |
788 } | 778 } |
789 | 779 |
790 if (feature_info->feature_flags().chromium_path_rendering) { | 780 if (feature_info->feature_flags().chromium_path_rendering) { |
791 EXPECT_CALL(*gl, GetProgramInterfaceiv(service_id, GL_FRAGMENT_INPUT_NV, | 781 EXPECT_CALL(*gl, GetProgramInterfaceiv(service_id, GL_FRAGMENT_INPUT_NV, |
792 GL_ACTIVE_RESOURCES, _)) | 782 GL_ACTIVE_RESOURCES, _)) |
793 .WillOnce(SetArgumentPointee<3>(int(num_varyings))) | 783 .WillOnce(SetArgumentPointee<3>(int(num_varyings))) |
794 .RetiresOnSaturation(); | 784 .RetiresOnSaturation(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 gfx::SetGLImplementation(implementation); | 1009 gfx::SetGLImplementation(implementation); |
1020 } | 1010 } |
1021 | 1011 |
1022 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { | 1012 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { |
1023 gfx::SetGLImplementation(old_implementation_); | 1013 gfx::SetGLImplementation(old_implementation_); |
1024 } | 1014 } |
1025 | 1015 |
1026 } // namespace gles2 | 1016 } // namespace gles2 |
1027 } // namespace gpu | 1017 } // namespace gpu |
1028 | 1018 |
OLD | NEW |