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

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

Issue 10984009: Allow immutable textures into mailboxes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/texture_manager.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/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 #include "base/bits.h" 6 #include "base/bits.h"
7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
8 #include "gpu/command_buffer/service/feature_info.h" 8 #include "gpu/command_buffer/service/feature_info.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
10 #include "gpu/command_buffer/service/mailbox_manager.h" 10 #include "gpu/command_buffer/service/mailbox_manager.h"
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 ++num_unsafe_textures_; 854 ++num_unsafe_textures_;
855 } 855 }
856 } 856 }
857 857
858 TextureDefinition* TextureManager::Save(TextureInfo* info) { 858 TextureDefinition* TextureManager::Save(TextureInfo* info) {
859 DCHECK(info->owned_); 859 DCHECK(info->owned_);
860 860
861 if (info->IsAttachedToFramebuffer()) 861 if (info->IsAttachedToFramebuffer())
862 return NULL; 862 return NULL;
863 863
864 if (info->IsImmutable())
865 return NULL;
866
867 TextureDefinition::LevelInfos level_infos(info->level_infos_.size()); 864 TextureDefinition::LevelInfos level_infos(info->level_infos_.size());
868 for (size_t face = 0; face < level_infos.size(); ++face) { 865 for (size_t face = 0; face < level_infos.size(); ++face) {
869 GLenum target = info->target() == GL_TEXTURE_2D ? 866 GLenum target = info->target() == GL_TEXTURE_2D ?
870 GL_TEXTURE_2D : FaceIndexToGLTarget(face); 867 GL_TEXTURE_2D : FaceIndexToGLTarget(face);
871 for (size_t level = 0; level < info->level_infos_[face].size(); ++level) { 868 for (size_t level = 0; level < info->level_infos_[face].size(); ++level) {
872 const TextureInfo::LevelInfo& level_info = 869 const TextureInfo::LevelInfo& level_info =
873 info->level_infos_[face][level]; 870 info->level_infos_[face][level];
874 level_infos[face].push_back( 871 level_infos[face].push_back(
875 TextureDefinition::LevelInfo(target, 872 TextureDefinition::LevelInfo(target,
876 level_info.internal_format, 873 level_info.internal_format,
(...skipping 17 matching lines...) Expand all
894 GL_UNSIGNED_BYTE, 891 GL_UNSIGNED_BYTE,
895 true); 892 true);
896 } 893 }
897 } 894 }
898 895
899 GLuint old_service_id = info->service_id(); 896 GLuint old_service_id = info->service_id();
900 897
901 GLuint new_service_id = 0; 898 GLuint new_service_id = 0;
902 glGenTextures(1, &new_service_id); 899 glGenTextures(1, &new_service_id);
903 info->SetServiceId(new_service_id); 900 info->SetServiceId(new_service_id);
901 info->SetImmutable(false);
904 902
905 return new TextureDefinition(info->target(), 903 return new TextureDefinition(info->target(),
906 old_service_id, 904 old_service_id,
905 info->IsImmutable(),
apatrick_chromium 2012/09/24 23:00:51 Need to call IsImmutable before SetImmutable.
piman 2012/09/24 23:03:37 Doh, thanks, done.
907 level_infos); 906 level_infos);
908 } 907 }
909 908
910 bool TextureManager::Restore(TextureInfo* info, 909 bool TextureManager::Restore(TextureInfo* info,
911 TextureDefinition* definition) { 910 TextureDefinition* definition) {
912 DCHECK(info->owned_); 911 DCHECK(info->owned_);
913 912
914 scoped_ptr<TextureDefinition> scoped_definition(definition); 913 scoped_ptr<TextureDefinition> scoped_definition(definition);
915 914
916 if (info->IsAttachedToFramebuffer()) 915 if (info->IsAttachedToFramebuffer())
917 return false; 916 return false;
918 917
919 if (info->IsImmutable())
920 return false;
921
922 if (info->target() != definition->target()) 918 if (info->target() != definition->target())
923 return false; 919 return false;
924 920
925 if (info->level_infos_.size() != definition->level_infos().size()) 921 if (info->level_infos_.size() != definition->level_infos().size())
926 return false; 922 return false;
927 923
928 if (info->level_infos_[0].size() != definition->level_infos()[0].size()) 924 if (info->level_infos_[0].size() != definition->level_infos()[0].size())
929 return false; 925 return false;
930 926
931 for (size_t face = 0; face < info->level_infos_.size(); ++face) { 927 for (size_t face = 0; face < info->level_infos_.size(); ++face) {
(...skipping 12 matching lines...) Expand all
944 level_info.border, 940 level_info.border,
945 level_info.format, 941 level_info.format,
946 level_info.type, 942 level_info.type,
947 level_info.cleared); 943 level_info.cleared);
948 } 944 }
949 } 945 }
950 946
951 GLuint old_service_id = info->service_id(); 947 GLuint old_service_id = info->service_id();
952 glDeleteTextures(1, &old_service_id); 948 glDeleteTextures(1, &old_service_id);
953 info->SetServiceId(definition->ReleaseServiceId()); 949 info->SetServiceId(definition->ReleaseServiceId());
950 info->SetImmutable(definition->immutable());
954 951
955 return true; 952 return true;
956 } 953 }
957 954
958 bool TextureManager::SetParameter( 955 bool TextureManager::SetParameter(
959 TextureManager::TextureInfo* info, GLenum pname, GLint param) { 956 TextureManager::TextureInfo* info, GLenum pname, GLint param) {
960 DCHECK(info); 957 DCHECK(info);
961 if (!info->CanRender(feature_info_)) { 958 if (!info->CanRender(feature_info_)) {
962 DCHECK_NE(0, num_unrenderable_textures_); 959 DCHECK_NE(0, num_unrenderable_textures_);
963 --num_unrenderable_textures_; 960 --num_unrenderable_textures_;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 return false; 1064 return false;
1068 } 1065 }
1069 1066
1070 GLsizei TextureManager::ComputeMipMapCount( 1067 GLsizei TextureManager::ComputeMipMapCount(
1071 GLsizei width, GLsizei height, GLsizei depth) { 1068 GLsizei width, GLsizei height, GLsizei depth) {
1072 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); 1069 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth));
1073 } 1070 }
1074 1071
1075 } // namespace gles2 1072 } // namespace gles2
1076 } // namespace gpu 1073 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698