Chromium Code Reviews| 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/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 Loading... | |
| 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, |
| 877 level_info.width, | 874 level_info.width, |
| 878 level_info.height, | 875 level_info.height, |
| 879 level_info.depth, | 876 level_info.depth, |
| 880 level_info.border, | 877 level_info.border, |
| 881 level_info.format, | 878 level_info.format, |
| 882 level_info.type, | 879 level_info.type, |
| 883 level_info.cleared)); | 880 level_info.cleared)); |
| 884 | 881 |
| 885 SetLevelInfo(info, | 882 SetLevelInfo(info, |
|
apatrick_chromium
2012/09/24 22:55:16
Should a immutable texture object that has been pr
piman
2012/09/24 22:59:50
That seems reasonable. done.
| |
| 886 target, | 883 target, |
| 887 level, | 884 level, |
| 888 GL_RGBA, | 885 GL_RGBA, |
| 889 0, | 886 0, |
| 890 0, | 887 0, |
| 891 0, | 888 0, |
| 892 0, | 889 0, |
| 893 GL_RGBA, | 890 GL_RGBA, |
| 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); |
| 904 | 901 |
| 905 return new TextureDefinition(info->target(), | 902 return new TextureDefinition(info->target(), |
| 906 old_service_id, | 903 old_service_id, |
| 904 info->IsImmutable(), | |
| 907 level_infos); | 905 level_infos); |
| 908 } | 906 } |
| 909 | 907 |
| 910 bool TextureManager::Restore(TextureInfo* info, | 908 bool TextureManager::Restore(TextureInfo* info, |
| 911 TextureDefinition* definition) { | 909 TextureDefinition* definition) { |
| 912 DCHECK(info->owned_); | 910 DCHECK(info->owned_); |
| 913 | 911 |
| 914 scoped_ptr<TextureDefinition> scoped_definition(definition); | 912 scoped_ptr<TextureDefinition> scoped_definition(definition); |
| 915 | 913 |
| 916 if (info->IsAttachedToFramebuffer()) | 914 if (info->IsAttachedToFramebuffer()) |
| 917 return false; | 915 return false; |
| 918 | 916 |
| 919 if (info->IsImmutable()) | 917 //if (info->IsImmutable()) |
|
apatrick_chromium
2012/09/24 22:55:16
This can be deleted.
piman
2012/09/24 22:59:50
Of course! Done.
| |
| 920 return false; | 918 // return false; |
| 921 | 919 |
| 922 if (info->target() != definition->target()) | 920 if (info->target() != definition->target()) |
| 923 return false; | 921 return false; |
| 924 | 922 |
| 925 if (info->level_infos_.size() != definition->level_infos().size()) | 923 if (info->level_infos_.size() != definition->level_infos().size()) |
| 926 return false; | 924 return false; |
| 927 | 925 |
| 928 if (info->level_infos_[0].size() != definition->level_infos()[0].size()) | 926 if (info->level_infos_[0].size() != definition->level_infos()[0].size()) |
| 929 return false; | 927 return false; |
| 930 | 928 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 944 level_info.border, | 942 level_info.border, |
| 945 level_info.format, | 943 level_info.format, |
| 946 level_info.type, | 944 level_info.type, |
| 947 level_info.cleared); | 945 level_info.cleared); |
| 948 } | 946 } |
| 949 } | 947 } |
| 950 | 948 |
| 951 GLuint old_service_id = info->service_id(); | 949 GLuint old_service_id = info->service_id(); |
| 952 glDeleteTextures(1, &old_service_id); | 950 glDeleteTextures(1, &old_service_id); |
| 953 info->SetServiceId(definition->ReleaseServiceId()); | 951 info->SetServiceId(definition->ReleaseServiceId()); |
| 952 info->SetImmutable(definition->immutable()); | |
| 954 | 953 |
| 955 return true; | 954 return true; |
| 956 } | 955 } |
| 957 | 956 |
| 958 bool TextureManager::SetParameter( | 957 bool TextureManager::SetParameter( |
| 959 TextureManager::TextureInfo* info, GLenum pname, GLint param) { | 958 TextureManager::TextureInfo* info, GLenum pname, GLint param) { |
| 960 DCHECK(info); | 959 DCHECK(info); |
| 961 if (!info->CanRender(feature_info_)) { | 960 if (!info->CanRender(feature_info_)) { |
| 962 DCHECK_NE(0, num_unrenderable_textures_); | 961 DCHECK_NE(0, num_unrenderable_textures_); |
| 963 --num_unrenderable_textures_; | 962 --num_unrenderable_textures_; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 return false; | 1066 return false; |
| 1068 } | 1067 } |
| 1069 | 1068 |
| 1070 GLsizei TextureManager::ComputeMipMapCount( | 1069 GLsizei TextureManager::ComputeMipMapCount( |
| 1071 GLsizei width, GLsizei height, GLsizei depth) { | 1070 GLsizei width, GLsizei height, GLsizei depth) { |
| 1072 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); | 1071 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); |
| 1073 } | 1072 } |
| 1074 | 1073 |
| 1075 } // namespace gles2 | 1074 } // namespace gles2 |
| 1076 } // namespace gpu | 1075 } // namespace gpu |
| OLD | NEW |