OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return texture_complete(); | 99 return texture_complete(); |
100 } else { | 100 } else { |
101 return texture_complete() && cube_complete(); | 101 return texture_complete() && cube_complete(); |
102 } | 102 } |
103 } else { | 103 } else { |
104 return true; | 104 return true; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 bool TextureManager::TextureInfo::MarkMipmapsGenerated( | 108 bool TextureManager::TextureInfo::MarkMipmapsGenerated( |
109 const FeatureInfo* feature_info, | 109 const FeatureInfo* feature_info) { |
110 bool cleared) { | |
111 if (!CanGenerateMipmaps(feature_info)) { | 110 if (!CanGenerateMipmaps(feature_info)) { |
112 return false; | 111 return false; |
113 } | 112 } |
114 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { | 113 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { |
115 const TextureInfo::LevelInfo& info1 = level_infos_[ii][0]; | 114 const TextureInfo::LevelInfo& info1 = level_infos_[ii][0]; |
116 GLsizei width = info1.width; | 115 GLsizei width = info1.width; |
117 GLsizei height = info1.height; | 116 GLsizei height = info1.height; |
118 GLsizei depth = info1.depth; | 117 GLsizei depth = info1.depth; |
119 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : | 118 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : |
120 FaceIndexToGLTarget(ii); | 119 FaceIndexToGLTarget(ii); |
121 int num_mips = ComputeMipMapCount(width, height, depth); | 120 int num_mips = ComputeMipMapCount(width, height, depth); |
122 for (int level = 1; level < num_mips; ++level) { | 121 for (int level = 1; level < num_mips; ++level) { |
123 width = std::max(1, width >> 1); | 122 width = std::max(1, width >> 1); |
124 height = std::max(1, height >> 1); | 123 height = std::max(1, height >> 1); |
125 depth = std::max(1, depth >> 1); | 124 depth = std::max(1, depth >> 1); |
126 SetLevelInfo(feature_info, | 125 SetLevelInfo(feature_info, |
127 target, | 126 target, |
128 level, | 127 level, |
129 info1.internal_format, | 128 info1.internal_format, |
130 width, | 129 width, |
131 height, | 130 height, |
132 depth, | 131 depth, |
133 info1.border, | 132 info1.border, |
134 info1.format, | 133 info1.format, |
135 info1.type, | 134 info1.type, |
136 cleared); | 135 true); |
137 } | 136 } |
138 } | 137 } |
139 | 138 |
140 return true; | 139 return true; |
141 } | 140 } |
142 | 141 |
143 void TextureManager::TextureInfo::SetTarget(GLenum target, GLint max_levels) { | 142 void TextureManager::TextureInfo::SetTarget(GLenum target, GLint max_levels) { |
144 DCHECK_EQ(0u, target_); // you can only set this once. | 143 DCHECK_EQ(0u, target_); // you can only set this once. |
145 target_ = target; | 144 target_ = target; |
146 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; | 145 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 516 } |
518 | 517 |
519 DCHECK_NE(0, num_uncleared_mips_); | 518 DCHECK_NE(0, num_uncleared_mips_); |
520 --num_uncleared_mips_; | 519 --num_uncleared_mips_; |
521 | 520 |
522 // NOTE: It seems kind of gross to call back into the decoder for this | 521 // NOTE: It seems kind of gross to call back into the decoder for this |
523 // but only the decoder knows all the state (like unpack_alignment_) that's | 522 // but only the decoder knows all the state (like unpack_alignment_) that's |
524 // needed to be able to call GL correctly. | 523 // needed to be able to call GL correctly. |
525 info.cleared = decoder->ClearLevel( | 524 info.cleared = decoder->ClearLevel( |
526 service_id_, target_, info.target, info.level, info.format, info.type, | 525 service_id_, target_, info.target, info.level, info.format, info.type, |
527 info.width, info.height); | 526 info.width, info.height, immutable_); |
528 if (!info.cleared) { | 527 if (!info.cleared) { |
529 ++num_uncleared_mips_; | 528 ++num_uncleared_mips_; |
530 } | 529 } |
531 return info.cleared; | 530 return info.cleared; |
532 } | 531 } |
533 | 532 |
534 TextureManager::TextureManager( | 533 TextureManager::TextureManager( |
535 GLint max_texture_size, | 534 GLint max_texture_size, |
536 GLint max_cube_map_texture_size) | 535 GLint max_cube_map_texture_size) |
537 : max_texture_size_(max_texture_size), | 536 : max_texture_size_(max_texture_size), |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 ++num_unrenderable_textures_; | 783 ++num_unrenderable_textures_; |
785 } | 784 } |
786 if (!info->SafeToRenderFrom()) { | 785 if (!info->SafeToRenderFrom()) { |
787 ++num_unsafe_textures_; | 786 ++num_unsafe_textures_; |
788 } | 787 } |
789 return result; | 788 return result; |
790 } | 789 } |
791 | 790 |
792 bool TextureManager::MarkMipmapsGenerated( | 791 bool TextureManager::MarkMipmapsGenerated( |
793 const FeatureInfo* feature_info, | 792 const FeatureInfo* feature_info, |
794 TextureManager::TextureInfo* info, | 793 TextureManager::TextureInfo* info) { |
795 bool cleared) { | |
796 DCHECK(info); | 794 DCHECK(info); |
797 if (!info->CanRender(feature_info)) { | 795 if (!info->CanRender(feature_info)) { |
798 DCHECK_NE(0, num_unrenderable_textures_); | 796 DCHECK_NE(0, num_unrenderable_textures_); |
799 --num_unrenderable_textures_; | 797 --num_unrenderable_textures_; |
800 } | 798 } |
801 if (!info->SafeToRenderFrom()) { | 799 if (!info->SafeToRenderFrom()) { |
802 DCHECK_NE(0, num_unsafe_textures_); | 800 DCHECK_NE(0, num_unsafe_textures_); |
803 --num_unsafe_textures_; | 801 --num_unsafe_textures_; |
804 } | 802 } |
805 num_uncleared_mips_ -= info->num_uncleared_mips(); | 803 num_uncleared_mips_ -= info->num_uncleared_mips(); |
806 DCHECK_GE(num_uncleared_mips_, 0); | 804 DCHECK_GE(num_uncleared_mips_, 0); |
807 bool result = info->MarkMipmapsGenerated(feature_info, cleared); | 805 bool result = info->MarkMipmapsGenerated(feature_info); |
808 num_uncleared_mips_ += info->num_uncleared_mips(); | 806 num_uncleared_mips_ += info->num_uncleared_mips(); |
809 if (!info->CanRender(feature_info)) { | 807 if (!info->CanRender(feature_info)) { |
810 ++num_unrenderable_textures_; | 808 ++num_unrenderable_textures_; |
811 } | 809 } |
812 if (!info->SafeToRenderFrom()) { | 810 if (!info->SafeToRenderFrom()) { |
813 ++num_unsafe_textures_; | 811 ++num_unsafe_textures_; |
814 } | 812 } |
815 return result; | 813 return result; |
816 } | 814 } |
817 | 815 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 GLsizei TextureManager::ComputeMipMapCount( | 871 GLsizei TextureManager::ComputeMipMapCount( |
874 GLsizei width, GLsizei height, GLsizei depth) { | 872 GLsizei width, GLsizei height, GLsizei depth) { |
875 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); | 873 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); |
876 } | 874 } |
877 | 875 |
878 | 876 |
879 } // namespace gles2 | 877 } // namespace gles2 |
880 } // namespace gpu | 878 } // namespace gpu |
881 | 879 |
882 | 880 |
OLD | NEW |