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

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

Issue 619723008: Switch to use ANGLE's new APIs to query shader variables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win build fix Created 6 years, 2 months 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/test_helper.h ('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 (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 16 matching lines...) Expand all
27 using ::testing::NotNull; 27 using ::testing::NotNull;
28 using ::testing::Return; 28 using ::testing::Return;
29 using ::testing::SetArrayArgument; 29 using ::testing::SetArrayArgument;
30 using ::testing::SetArgumentPointee; 30 using ::testing::SetArgumentPointee;
31 using ::testing::StrEq; 31 using ::testing::StrEq;
32 using ::testing::StrictMock; 32 using ::testing::StrictMock;
33 33
34 namespace gpu { 34 namespace gpu {
35 namespace gles2 { 35 namespace gles2 {
36 36
37 namespace {
38
39 template<typename T>
40 T ConstructShaderVariable(
41 GLenum type, GLint array_size, GLenum precision,
42 bool static_use, const std::string& name) {
43 T var;
44 var.type = type;
45 var.arraySize = array_size;
46 var.precision = precision;
47 var.staticUse = static_use;
48 var.name = name;
49 var.mappedName = name; // No name hashing.
50 return var;
51 }
52
53 } // namespace anonymous
54
37 // GCC requires these declarations, but MSVC requires they not be present 55 // GCC requires these declarations, but MSVC requires they not be present
38 #ifndef COMPILER_MSVC 56 #ifndef COMPILER_MSVC
39 const GLuint TestHelper::kServiceBlackTexture2dId; 57 const GLuint TestHelper::kServiceBlackTexture2dId;
40 const GLuint TestHelper::kServiceDefaultTexture2dId; 58 const GLuint TestHelper::kServiceDefaultTexture2dId;
41 const GLuint TestHelper::kServiceBlackTextureCubemapId; 59 const GLuint TestHelper::kServiceBlackTextureCubemapId;
42 const GLuint TestHelper::kServiceDefaultTextureCubemapId; 60 const GLuint TestHelper::kServiceDefaultTextureCubemapId;
43 const GLuint TestHelper::kServiceBlackExternalTextureId; 61 const GLuint TestHelper::kServiceBlackExternalTextureId;
44 const GLuint TestHelper::kServiceDefaultExternalTextureId; 62 const GLuint TestHelper::kServiceDefaultExternalTextureId;
45 const GLuint TestHelper::kServiceBlackRectangleTextureId; 63 const GLuint TestHelper::kServiceBlackRectangleTextureId;
46 const GLuint TestHelper::kServiceDefaultRectangleTextureId; 64 const GLuint TestHelper::kServiceDefaultRectangleTextureId;
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 659 }
642 manager->SetParameteri("", error_state, texture_ref, pname, value); 660 manager->SetParameteri("", error_state, texture_ref, pname, value);
643 } 661 }
644 662
645 // static 663 // static
646 void TestHelper::SetShaderStates( 664 void TestHelper::SetShaderStates(
647 ::gfx::MockGLInterface* gl, Shader* shader, 665 ::gfx::MockGLInterface* gl, Shader* shader,
648 bool expected_valid, 666 bool expected_valid,
649 const std::string* const expected_log_info, 667 const std::string* const expected_log_info,
650 const std::string* const expected_translated_source, 668 const std::string* const expected_translated_source,
651 const ShaderTranslatorInterface::VariableMap* const expected_attrib_map, 669 const AttributeMap* const expected_attrib_map,
652 const ShaderTranslatorInterface::VariableMap* const expected_uniform_map, 670 const UniformMap* const expected_uniform_map,
653 const ShaderTranslatorInterface::VariableMap* const expected_varying_map, 671 const VaryingMap* const expected_varying_map,
654 const ShaderTranslatorInterface::NameMap* const expected_name_map) { 672 const NameMap* const expected_name_map) {
655 const std::string empty_log_info; 673 const std::string empty_log_info;
656 const std::string* log_info = (expected_log_info && !expected_valid) ? 674 const std::string* log_info = (expected_log_info && !expected_valid) ?
657 expected_log_info : &empty_log_info; 675 expected_log_info : &empty_log_info;
658 const std::string empty_translated_source; 676 const std::string empty_translated_source;
659 const std::string* translated_source = 677 const std::string* translated_source =
660 (expected_translated_source && expected_valid) ? 678 (expected_translated_source && expected_valid) ?
661 expected_translated_source : &empty_translated_source; 679 expected_translated_source : &empty_translated_source;
662 const ShaderTranslatorInterface::VariableMap empty_attrib_map; 680 const AttributeMap empty_attrib_map;
663 const ShaderTranslatorInterface::VariableMap* attrib_map = 681 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ?
664 (expected_attrib_map && expected_valid) ? 682 expected_attrib_map : &empty_attrib_map;
665 expected_attrib_map : &empty_attrib_map; 683 const UniformMap empty_uniform_map;
666 const ShaderTranslatorInterface::VariableMap empty_uniform_map; 684 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ?
667 const ShaderTranslatorInterface::VariableMap* uniform_map = 685 expected_uniform_map : &empty_uniform_map;
668 (expected_uniform_map && expected_valid) ? 686 const VaryingMap empty_varying_map;
669 expected_uniform_map : &empty_uniform_map; 687 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ?
670 const ShaderTranslatorInterface::VariableMap empty_varying_map; 688 expected_varying_map : &empty_varying_map;
671 const ShaderTranslatorInterface::VariableMap* varying_map = 689 const NameMap empty_name_map;
672 (expected_varying_map && expected_valid) ? 690 const NameMap* name_map = (expected_name_map && expected_valid) ?
673 expected_varying_map : &empty_varying_map; 691 expected_name_map : &empty_name_map;
674 const ShaderTranslatorInterface::NameMap empty_name_map;
675 const ShaderTranslatorInterface::NameMap* name_map =
676 (expected_name_map && expected_valid) ?
677 expected_name_map : &empty_name_map;
678 692
679 MockShaderTranslator translator; 693 MockShaderTranslator translator;
680 EXPECT_CALL(translator, Translate(_, 694 EXPECT_CALL(translator, Translate(_,
681 NotNull(), // log_info 695 NotNull(), // log_info
682 NotNull(), // translated_source 696 NotNull(), // translated_source
683 NotNull(), // attrib_map 697 NotNull(), // attrib_map
684 NotNull(), // uniform_map 698 NotNull(), // uniform_map
685 NotNull(), // varying_map 699 NotNull(), // varying_map
686 NotNull())) // name_map 700 NotNull())) // name_map
687 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info), 701 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info),
(...skipping 19 matching lines...) Expand all
707 } 721 }
708 shader->DoCompile(&translator, Shader::kGL); 722 shader->DoCompile(&translator, Shader::kGL);
709 } 723 }
710 724
711 // static 725 // static
712 void TestHelper::SetShaderStates( 726 void TestHelper::SetShaderStates(
713 ::gfx::MockGLInterface* gl, Shader* shader, bool valid) { 727 ::gfx::MockGLInterface* gl, Shader* shader, bool valid) {
714 SetShaderStates(gl, shader, valid, NULL, NULL, NULL, NULL, NULL, NULL); 728 SetShaderStates(gl, shader, valid, NULL, NULL, NULL, NULL, NULL, NULL);
715 } 729 }
716 730
731 // static
732 sh::Attribute TestHelper::ConstructAttribute(
733 GLenum type, GLint array_size, GLenum precision,
734 bool static_use, const std::string& name) {
735 return ConstructShaderVariable<sh::Attribute>(
736 type, array_size, precision, static_use, name);
737 }
738
739 // static
740 sh::Uniform TestHelper::ConstructUniform(
741 GLenum type, GLint array_size, GLenum precision,
742 bool static_use, const std::string& name) {
743 return ConstructShaderVariable<sh::Uniform>(
744 type, array_size, precision, static_use, name);
745 }
746
747 // static
748 sh::Varying TestHelper::ConstructVarying(
749 GLenum type, GLint array_size, GLenum precision,
750 bool static_use, const std::string& name) {
751 return ConstructShaderVariable<sh::Varying>(
752 type, array_size, precision, static_use, name);
753 }
754
717 ScopedGLImplementationSetter::ScopedGLImplementationSetter( 755 ScopedGLImplementationSetter::ScopedGLImplementationSetter(
718 gfx::GLImplementation implementation) 756 gfx::GLImplementation implementation)
719 : old_implementation_(gfx::GetGLImplementation()) { 757 : old_implementation_(gfx::GetGLImplementation()) {
720 gfx::SetGLImplementation(implementation); 758 gfx::SetGLImplementation(implementation);
721 } 759 }
722 760
723 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { 761 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() {
724 gfx::SetGLImplementation(old_implementation_); 762 gfx::SetGLImplementation(old_implementation_);
725 } 763 }
726 764
727 } // namespace gles2 765 } // namespace gles2
728 } // namespace gpu 766 } // namespace gpu
729 767
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/test_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698