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/program_manager.h" | 5 #include "gpu/command_buffer/service/program_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 ProgramCache* cache = manager_->program_cache_; | 494 ProgramCache* cache = manager_->program_cache_; |
495 if (cache) { | 495 if (cache) { |
496 ProgramCache::LinkedProgramStatus status = cache->GetLinkedProgramStatus( | 496 ProgramCache::LinkedProgramStatus status = cache->GetLinkedProgramStatus( |
497 *attached_shaders_[0]->deferred_compilation_source(), | 497 *attached_shaders_[0]->deferred_compilation_source(), |
498 *attached_shaders_[1]->deferred_compilation_source(), | 498 *attached_shaders_[1]->deferred_compilation_source(), |
499 &bind_attrib_location_map_); | 499 &bind_attrib_location_map_); |
500 | 500 |
501 if (status == ProgramCache::LINK_SUCCEEDED) { | 501 if (status == ProgramCache::LINK_SUCCEEDED) { |
502 ProgramCache::ProgramLoadResult success = cache->LoadLinkedProgram( | 502 ProgramCache::ProgramLoadResult success = cache->LoadLinkedProgram( |
503 service_id(), | 503 service_id(), |
504 attached_shaders_[0], | 504 attached_shaders_[0].get(), |
505 attached_shaders_[1], | 505 attached_shaders_[1].get(), |
506 &bind_attrib_location_map_); | 506 &bind_attrib_location_map_); |
507 link = success != ProgramCache::PROGRAM_LOAD_SUCCESS; | 507 link = success != ProgramCache::PROGRAM_LOAD_SUCCESS; |
508 UMA_HISTOGRAM_BOOLEAN("GPU.ProgramCache.LoadBinarySuccess", !link); | 508 UMA_HISTOGRAM_BOOLEAN("GPU.ProgramCache.LoadBinarySuccess", !link); |
509 } | 509 } |
510 | 510 |
511 if (link) { | 511 if (link) { |
512 // compile our shaders if they're pending | 512 // compile our shaders if they're pending |
513 const int kShaders = ProgramManager::ProgramInfo::kMaxAttachedShaders; | 513 const int kShaders = ProgramManager::ProgramInfo::kMaxAttachedShaders; |
514 for (int i = 0; i < kShaders; ++i) { | 514 for (int i = 0; i < kShaders; ++i) { |
515 ShaderManager::ShaderInfo* info = attached_shaders_[i].get(); | 515 ShaderManager::ShaderInfo* info = attached_shaders_[i].get(); |
516 if (info->compilation_status() == | 516 if (info->compilation_status() == |
517 ShaderManager::ShaderInfo::PENDING_DEFERRED_COMPILE) { | 517 ShaderManager::ShaderInfo::PENDING_DEFERRED_COMPILE) { |
518 ShaderTranslator* translator = ShaderIndexToTranslator( | 518 ShaderTranslator* translator = ShaderIndexToTranslator( |
519 i, | 519 i, |
520 vertex_translator, | 520 vertex_translator, |
521 fragment_translator); | 521 fragment_translator); |
522 manager_->ForceCompileShader(info->deferred_compilation_source(), | 522 manager_->ForceCompileShader(info->deferred_compilation_source(), |
523 attached_shaders_[i], | 523 attached_shaders_[i].get(), |
524 translator, | 524 translator, |
525 feature_info); | 525 feature_info); |
526 CHECK(info->IsValid()); | 526 CHECK(info->IsValid()); |
527 } | 527 } |
528 } | 528 } |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 if (link) { | 532 if (link) { |
533 before_time = TimeTicks::HighResNow(); | 533 before_time = TimeTicks::HighResNow(); |
534 if (cache && gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary) { | 534 if (cache && gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary) { |
535 glProgramParameteri(service_id(), | 535 glProgramParameteri(service_id(), |
536 PROGRAM_BINARY_RETRIEVABLE_HINT, | 536 PROGRAM_BINARY_RETRIEVABLE_HINT, |
537 GL_TRUE); | 537 GL_TRUE); |
538 } | 538 } |
539 glLinkProgram(service_id()); | 539 glLinkProgram(service_id()); |
540 } | 540 } |
541 | 541 |
542 GLint success = 0; | 542 GLint success = 0; |
543 glGetProgramiv(service_id(), GL_LINK_STATUS, &success); | 543 glGetProgramiv(service_id(), GL_LINK_STATUS, &success); |
544 if (success == GL_TRUE) { | 544 if (success == GL_TRUE) { |
545 Update(); | 545 Update(); |
546 if (link) { | 546 if (link) { |
547 if (cache) { | 547 if (cache) { |
548 cache->SaveLinkedProgram(service_id(), | 548 cache->SaveLinkedProgram(service_id(), |
549 attached_shaders_[0], | 549 attached_shaders_[0].get(), |
550 attached_shaders_[1], | 550 attached_shaders_[1].get(), |
551 &bind_attrib_location_map_); | 551 &bind_attrib_location_map_); |
552 } | 552 } |
553 UMA_HISTOGRAM_CUSTOM_COUNTS( | 553 UMA_HISTOGRAM_CUSTOM_COUNTS( |
554 "GPU.ProgramCache.BinaryCacheMissTime", | 554 "GPU.ProgramCache.BinaryCacheMissTime", |
555 (TimeTicks::HighResNow() - before_time).InMicroseconds(), | 555 (TimeTicks::HighResNow() - before_time).InMicroseconds(), |
556 0, | 556 0, |
557 TimeDelta::FromSeconds(10).InMicroseconds(), | 557 TimeDelta::FromSeconds(10).InMicroseconds(), |
558 50); | 558 50); |
559 } else { | 559 } else { |
560 UMA_HISTOGRAM_CUSTOM_COUNTS( | 560 UMA_HISTOGRAM_CUSTOM_COUNTS( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 DCHECK(size); | 688 DCHECK(size); |
689 DCHECK(type); | 689 DCHECK(type); |
690 const char* kArraySpec = "[0]"; | 690 const char* kArraySpec = "[0]"; |
691 for (int jj = 0; jj < 2; ++jj) { | 691 for (int jj = 0; jj < 2; ++jj) { |
692 std::string test_name(name + ((jj == 1) ? kArraySpec : "")); | 692 std::string test_name(name + ((jj == 1) ? kArraySpec : "")); |
693 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 693 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
694 ShaderManager::ShaderInfo* shader_info = attached_shaders_[ii].get(); | 694 ShaderManager::ShaderInfo* shader_info = attached_shaders_[ii].get(); |
695 if (shader_info) { | 695 if (shader_info) { |
696 const ShaderManager::ShaderInfo::VariableInfo* variable_info = | 696 const ShaderManager::ShaderInfo::VariableInfo* variable_info = |
697 use_uniforms ? shader_info->GetUniformInfo(test_name) : | 697 use_uniforms ? shader_info->GetUniformInfo(test_name) : |
698 shader_info->GetAttribInfo(test_name); | 698 shader_info->GetAttribInfo(test_name); |
699 // Note: There is an assuption here that if an attrib is defined in more | 699 // Note: There is an assuption here that if an attrib is defined in more |
700 // than 1 attached shader their types and sizes match. Should we check | 700 // than 1 attached shader their types and sizes match. Should we check |
701 // for that case? | 701 // for that case? |
702 if (variable_info) { | 702 if (variable_info) { |
703 *corrected_name = test_name; | 703 *corrected_name = test_name; |
704 *original_name = variable_info->name; | 704 *original_name = variable_info->name; |
705 *type = variable_info->type; | 705 *type = variable_info->type; |
706 *size = variable_info->size; | 706 *size = variable_info->size; |
707 return; | 707 return; |
708 } | 708 } |
709 } | 709 } |
710 } | 710 } |
711 } | 711 } |
712 *corrected_name = name; | 712 *corrected_name = name; |
713 *original_name = name; | 713 *original_name = name; |
714 } | 714 } |
715 | 715 |
716 bool ProgramManager::ProgramInfo::AddUniformInfo( | 716 bool ProgramManager::ProgramInfo::AddUniformInfo( |
717 GLsizei size, GLenum type, GLint location, GLint fake_base_location, | 717 GLsizei size, GLenum type, GLint location, GLint fake_base_location, |
718 const std::string& name, const std::string& original_name, | 718 const std::string& name, const std::string& original_name, |
719 size_t* next_available_index) { | 719 size_t* next_available_index) { |
720 DCHECK(next_available_index); | 720 DCHECK(next_available_index); |
721 const char* kArraySpec = "[0]"; | 721 const char* kArraySpec = "[0]"; |
722 size_t uniform_index = | 722 size_t uniform_index = |
723 fake_base_location >= 0 ? fake_base_location : *next_available_index; | 723 fake_base_location >= 0 ? fake_base_location : *next_available_index; |
724 if (uniform_infos_.size() < uniform_index + 1) { | 724 if (uniform_infos_.size() < uniform_index + 1) { |
725 uniform_infos_.resize(uniform_index + 1); | 725 uniform_infos_.resize(uniform_index + 1); |
726 } | 726 } |
727 | 727 |
728 // return if this location is already in use. | 728 // return if this location is already in use. |
729 if (uniform_infos_[uniform_index].IsValid()) { | 729 if (uniform_infos_[uniform_index].IsValid()) { |
(...skipping 27 matching lines...) Expand all Loading... |
757 } | 757 } |
758 } | 758 } |
759 for (GLsizei ii = 1; ii < info.size; ++ii) { | 759 for (GLsizei ii = 1; ii < info.size; ++ii) { |
760 std::string element_name(base_name + "[" + base::IntToString(ii) + "]"); | 760 std::string element_name(base_name + "[" + base::IntToString(ii) + "]"); |
761 info.element_locations[ii] = | 761 info.element_locations[ii] = |
762 glGetUniformLocation(service_id_, element_name.c_str()); | 762 glGetUniformLocation(service_id_, element_name.c_str()); |
763 } | 763 } |
764 } | 764 } |
765 | 765 |
766 info.is_array = | 766 info.is_array = |
767 (size > 1 || | 767 (size > 1 || |
768 (info.name.size() > 3 && | 768 (info.name.size() > 3 && |
769 info.name.rfind(kArraySpec) == info.name.size() - 3)); | 769 info.name.rfind(kArraySpec) == info.name.size() - 3)); |
770 | 770 |
771 if (info.IsSampler()) { | 771 if (info.IsSampler()) { |
772 sampler_indices_.push_back(info.fake_location_base); | 772 sampler_indices_.push_back(info.fake_location_base); |
773 } | 773 } |
774 max_uniform_name_length_ = | 774 max_uniform_name_length_ = |
775 std::max(max_uniform_name_length_, | 775 std::max(max_uniform_name_length_, |
776 static_cast<GLsizei>(info.name.size())); | 776 static_cast<GLsizei>(info.name.size())); |
777 | 777 |
778 while (*next_available_index < uniform_infos_.size() && | 778 while (*next_available_index < uniform_infos_.size() && |
779 uniform_infos_[*next_available_index].IsValid()) { | 779 uniform_infos_[*next_available_index].IsValid()) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 return true; | 821 return true; |
822 } | 822 } |
823 } | 823 } |
824 } | 824 } |
825 return true; | 825 return true; |
826 } | 826 } |
827 | 827 |
828 void ProgramManager::ProgramInfo::GetProgramiv(GLenum pname, GLint* params) { | 828 void ProgramManager::ProgramInfo::GetProgramiv(GLenum pname, GLint* params) { |
829 switch (pname) { | 829 switch (pname) { |
830 case GL_ACTIVE_ATTRIBUTES: | 830 case GL_ACTIVE_ATTRIBUTES: |
831 *params = attrib_infos_.size(); | 831 *params = attrib_infos_.size(); |
832 break; | 832 break; |
833 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: | 833 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
834 // Notice +1 to accomodate NULL terminator. | 834 // Notice +1 to accomodate NULL terminator. |
835 *params = max_attrib_name_length_ + 1; | 835 *params = max_attrib_name_length_ + 1; |
836 break; | 836 break; |
837 case GL_ACTIVE_UNIFORMS: | 837 case GL_ACTIVE_UNIFORMS: |
838 *params = num_uniforms_; | 838 *params = num_uniforms_; |
839 break; | 839 break; |
840 case GL_ACTIVE_UNIFORM_MAX_LENGTH: | 840 case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
841 // Notice +1 to accomodate NULL terminator. | 841 // Notice +1 to accomodate NULL terminator. |
842 *params = max_uniform_name_length_ + 1; | 842 *params = max_uniform_name_length_ + 1; |
843 break; | 843 break; |
844 case GL_LINK_STATUS: | 844 case GL_LINK_STATUS: |
845 *params = link_status_; | 845 *params = link_status_; |
846 break; | 846 break; |
847 case GL_INFO_LOG_LENGTH: | 847 case GL_INFO_LOG_LENGTH: |
848 // Notice +1 to accomodate NULL terminator. | 848 // Notice +1 to accomodate NULL terminator. |
849 *params = log_info_.get() ? (log_info_->size() + 1) : 0; | 849 *params = log_info_.get() ? (log_info_->size() + 1) : 0; |
850 break; | 850 break; |
851 case GL_DELETE_STATUS: | 851 case GL_DELETE_STATUS: |
852 *params = deleted_; | 852 *params = deleted_; |
853 break; | 853 break; |
854 case GL_VALIDATE_STATUS: | 854 case GL_VALIDATE_STATUS: |
855 if (!IsValid()) { | 855 if (!IsValid()) { |
856 *params = GL_FALSE; | 856 *params = GL_FALSE; |
857 } else { | 857 } else { |
| 858 glGetProgramiv(service_id_, pname, params); |
| 859 } |
| 860 break; |
| 861 default: |
858 glGetProgramiv(service_id_, pname, params); | 862 glGetProgramiv(service_id_, pname, params); |
859 } | 863 break; |
860 break; | |
861 default: | |
862 glGetProgramiv(service_id_, pname, params); | |
863 break; | |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 bool ProgramManager::ProgramInfo::AttachShader( | 867 bool ProgramManager::ProgramInfo::AttachShader( |
868 ShaderManager* shader_manager, | 868 ShaderManager* shader_manager, |
869 ShaderManager::ShaderInfo* info) { | 869 ShaderManager::ShaderInfo* info) { |
870 DCHECK(shader_manager); | 870 DCHECK(shader_manager); |
871 DCHECK(info); | 871 DCHECK(info); |
872 int index = ShaderTypeToIndex(info->shader_type()); | 872 int index = ShaderTypeToIndex(info->shader_type()); |
873 if (attached_shaders_[index] != NULL) { | 873 if (attached_shaders_[index].get() != NULL) { |
874 return false; | 874 return false; |
875 } | 875 } |
876 attached_shaders_[index] = ShaderManager::ShaderInfo::Ref(info); | 876 attached_shaders_[index] = ShaderManager::ShaderInfo::Ref(info); |
877 shader_manager->UseShader(info); | 877 shader_manager->UseShader(info); |
878 return true; | 878 return true; |
879 } | 879 } |
880 | 880 |
881 bool ProgramManager::ProgramInfo::DetachShader( | 881 bool ProgramManager::ProgramInfo::DetachShader( |
882 ShaderManager* shader_manager, | 882 ShaderManager* shader_manager, |
883 ShaderManager::ShaderInfo* info) { | 883 ShaderManager::ShaderInfo* info) { |
884 DCHECK(shader_manager); | 884 DCHECK(shader_manager); |
885 DCHECK(info); | 885 DCHECK(info); |
886 if (attached_shaders_[ShaderTypeToIndex(info->shader_type())].get() != info) { | 886 if (attached_shaders_[ShaderTypeToIndex(info->shader_type())].get() != info) { |
887 return false; | 887 return false; |
888 } | 888 } |
889 attached_shaders_[ShaderTypeToIndex(info->shader_type())] = NULL; | 889 attached_shaders_[ShaderTypeToIndex(info->shader_type())] = NULL; |
890 shader_manager->UnuseShader(info); | 890 shader_manager->UnuseShader(info); |
891 return true; | 891 return true; |
892 } | 892 } |
893 | 893 |
894 void ProgramManager::ProgramInfo::DetachShaders(ShaderManager* shader_manager) { | 894 void ProgramManager::ProgramInfo::DetachShaders(ShaderManager* shader_manager) { |
895 DCHECK(shader_manager); | 895 DCHECK(shader_manager); |
896 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 896 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
897 if (attached_shaders_[ii]) { | 897 if (attached_shaders_[ii].get()) { |
898 DetachShader(shader_manager, attached_shaders_[ii]); | 898 DetachShader(shader_manager, attached_shaders_[ii].get()); |
899 } | 899 } |
900 } | 900 } |
901 } | 901 } |
902 | 902 |
903 bool ProgramManager::ProgramInfo::CanLink() const { | 903 bool ProgramManager::ProgramInfo::CanLink() const { |
904 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 904 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
905 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) { | 905 if (!attached_shaders_[ii].get() || !attached_shaders_[ii]->IsValid()) { |
906 return false; | 906 return false; |
907 } | 907 } |
908 } | 908 } |
909 return true; | 909 return true; |
910 } | 910 } |
911 | 911 |
912 bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const { | 912 bool ProgramManager::ProgramInfo::DetectAttribLocationBindingConflicts() const { |
913 std::set<GLint> location_binding_used; | 913 std::set<GLint> location_binding_used; |
914 for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); | 914 for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); |
915 it != bind_attrib_location_map_.end(); ++it) { | 915 it != bind_attrib_location_map_.end(); ++it) { |
916 // Find out if an attribute is declared in this program's shaders. | 916 // Find out if an attribute is declared in this program's shaders. |
917 bool active = false; | 917 bool active = false; |
918 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 918 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
919 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) | 919 if (!attached_shaders_[ii].get() || !attached_shaders_[ii]->IsValid()) |
920 continue; | 920 continue; |
921 if (attached_shaders_[ii]->GetAttribInfo(it->first)) { | 921 if (attached_shaders_[ii]->GetAttribInfo(it->first)) { |
922 active = true; | 922 active = true; |
923 break; | 923 break; |
924 } | 924 } |
925 } | 925 } |
926 if (active) { | 926 if (active) { |
927 std::pair<std::set<GLint>::iterator, bool> result = | 927 std::pair<std::set<GLint>::iterator, bool> result = |
928 location_binding_used.insert(it->second); | 928 location_binding_used.insert(it->second); |
929 if (!result.second) | 929 if (!result.second) |
930 return true; | 930 return true; |
931 } | 931 } |
932 } | 932 } |
933 return false; | 933 return false; |
934 } | 934 } |
935 | 935 |
936 static uint32 ComputeOffset(const void* start, const void* position) { | 936 static uint32 ComputeOffset(const void* start, const void* position) { |
937 return static_cast<const uint8*>(position) - | 937 return static_cast<const uint8*>(position) - |
938 static_cast<const uint8*>(start); | 938 static_cast<const uint8*>(start); |
939 } | 939 } |
940 | 940 |
941 void ProgramManager::ProgramInfo::GetProgramInfo( | 941 void ProgramManager::ProgramInfo::GetProgramInfo( |
942 ProgramManager* manager, CommonDecoder::Bucket* bucket) const { | 942 ProgramManager* manager, CommonDecoder::Bucket* bucket) const { |
943 // NOTE: It seems to me the math in here does not need check for overflow | 943 // NOTE: It seems to me the math in here does not need check for overflow |
944 // because the data being calucated from has various small limits. The max | 944 // because the data being calucated from has various small limits. The max |
945 // number of attribs + uniforms is somewhere well under 1024. The maximum size | 945 // number of attribs + uniforms is somewhere well under 1024. The maximum size |
946 // of an identifier is 256 characters. | 946 // of an identifier is 256 characters. |
947 uint32 num_locations = 0; | 947 uint32 num_locations = 0; |
948 uint32 total_string_size = 0; | 948 uint32 total_string_size = 0; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 glDeleteProgram(service_id()); | 1025 glDeleteProgram(service_id()); |
1026 } | 1026 } |
1027 manager_->StopTracking(this); | 1027 manager_->StopTracking(this); |
1028 manager_ = NULL; | 1028 manager_ = NULL; |
1029 } | 1029 } |
1030 } | 1030 } |
1031 | 1031 |
1032 | 1032 |
1033 ProgramManager::ProgramManager(ProgramCache* program_cache) | 1033 ProgramManager::ProgramManager(ProgramCache* program_cache) |
1034 : program_info_count_(0), | 1034 : program_info_count_(0), |
1035 have_context_(true), | 1035 have_context_(true), |
1036 disable_workarounds_( | 1036 disable_workarounds_( |
1037 CommandLine::ForCurrentProcess()->HasSwitch( | 1037 CommandLine::ForCurrentProcess()->HasSwitch( |
1038 switches::kDisableGpuDriverBugWorkarounds)), | 1038 switches::kDisableGpuDriverBugWorkarounds)), |
1039 program_cache_(program_cache) { } | 1039 program_cache_(program_cache) { } |
1040 | 1040 |
1041 ProgramManager::~ProgramManager() { | 1041 ProgramManager::~ProgramManager() { |
1042 DCHECK(program_infos_.empty()); | 1042 DCHECK(program_infos_.empty()); |
1043 } | 1043 } |
1044 | 1044 |
1045 void ProgramManager::Destroy(bool have_context) { | 1045 void ProgramManager::Destroy(bool have_context) { |
1046 have_context_ = have_context; | 1046 have_context_ = have_context; |
1047 program_infos_.clear(); | 1047 program_infos_.clear(); |
1048 } | 1048 } |
1049 | 1049 |
1050 void ProgramManager::StartTracking(ProgramManager::ProgramInfo* /* program */) { | 1050 void ProgramManager::StartTracking(ProgramManager::ProgramInfo* /* program */) { |
1051 ++program_info_count_; | 1051 ++program_info_count_; |
1052 } | 1052 } |
1053 | 1053 |
1054 void ProgramManager::StopTracking(ProgramManager::ProgramInfo* /* program */) { | 1054 void ProgramManager::StopTracking(ProgramManager::ProgramInfo* /* program */) { |
1055 --program_info_count_; | 1055 --program_info_count_; |
1056 } | 1056 } |
1057 | 1057 |
1058 ProgramManager::ProgramInfo* ProgramManager::CreateProgramInfo( | 1058 ProgramManager::ProgramInfo* ProgramManager::CreateProgramInfo( |
1059 GLuint client_id, GLuint service_id) { | 1059 GLuint client_id, GLuint service_id) { |
1060 std::pair<ProgramInfoMap::iterator, bool> result = | 1060 std::pair<ProgramInfoMap::iterator, bool> result = |
1061 program_infos_.insert( | 1061 program_infos_.insert( |
1062 std::make_pair(client_id, | 1062 std::make_pair(client_id, |
1063 ProgramInfo::Ref(new ProgramInfo(this, service_id)))); | 1063 ProgramInfo::Ref(new ProgramInfo(this, service_id)))); |
1064 DCHECK(result.second); | 1064 DCHECK(result.second); |
1065 return result.first->second; | 1065 return result.first->second.get(); |
1066 } | 1066 } |
1067 | 1067 |
1068 ProgramManager::ProgramInfo* ProgramManager::GetProgramInfo(GLuint client_id) { | 1068 ProgramManager::ProgramInfo* ProgramManager::GetProgramInfo(GLuint client_id) { |
1069 ProgramInfoMap::iterator it = program_infos_.find(client_id); | 1069 ProgramInfoMap::iterator it = program_infos_.find(client_id); |
1070 return it != program_infos_.end() ? it->second : NULL; | 1070 return .get() |
| 1071 return it != program_infos_.end() ? it->second : NULL; |
1071 } | 1072 } |
1072 | 1073 |
1073 bool ProgramManager::GetClientId(GLuint service_id, GLuint* client_id) const { | 1074 bool ProgramManager::GetClientId(GLuint service_id, GLuint* client_id) const { |
1074 // This doesn't need to be fast. It's only used during slow queries. | 1075 // This doesn't need to be fast. It's only used during slow queries. |
1075 for (ProgramInfoMap::const_iterator it = program_infos_.begin(); | 1076 for (ProgramInfoMap::const_iterator it = program_infos_.begin(); |
1076 it != program_infos_.end(); ++it) { | 1077 it != program_infos_.end(); ++it) { |
1077 if (it->second->service_id() == service_id) { | 1078 if (it->second->service_id() == service_id) { |
1078 *client_id = it->first; | 1079 *client_id = it->first; |
1079 return true; | 1080 return true; |
1080 } | 1081 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 info->ClearUniforms(&zero_); | 1148 info->ClearUniforms(&zero_); |
1148 } | 1149 } |
1149 } | 1150 } |
1150 | 1151 |
1151 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { | 1152 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { |
1152 return index + element * 0x10000; | 1153 return index + element * 0x10000; |
1153 } | 1154 } |
1154 | 1155 |
1155 } // namespace gles2 | 1156 } // namespace gles2 |
1156 } // namespace gpu | 1157 } // namespace gpu |
OLD | NEW |