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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 return texture_complete(); | 104 return texture_complete(); |
105 } else { | 105 } else { |
106 return texture_complete() && cube_complete(); | 106 return texture_complete() && cube_complete(); |
107 } | 107 } |
108 } else { | 108 } else { |
109 return true; | 109 return true; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 bool TextureManager::TextureInfo::MarkMipmapsGenerated( | 113 bool TextureManager::TextureInfo::MarkMipmapsGenerated( |
114 const FeatureInfo* feature_info) { | 114 const FeatureInfo* feature_info) { |
greggman
2011/12/02 18:33:24
add 'bool cleared'?
vangelis
2011/12/03 00:19:53
Done.
| |
115 if (!CanGenerateMipmaps(feature_info)) { | 115 if (!CanGenerateMipmaps(feature_info)) { |
116 return false; | 116 return false; |
117 } | 117 } |
118 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { | 118 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { |
119 const TextureInfo::LevelInfo& info1 = level_infos_[ii][0]; | 119 const TextureInfo::LevelInfo& info1 = level_infos_[ii][0]; |
120 GLsizei width = info1.width; | 120 GLsizei width = info1.width; |
121 GLsizei height = info1.height; | 121 GLsizei height = info1.height; |
122 GLsizei depth = info1.depth; | 122 GLsizei depth = info1.depth; |
123 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : | 123 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : |
124 FaceIndexToGLTarget(ii); | 124 FaceIndexToGLTarget(ii); |
125 int num_mips = ComputeMipMapCount(width, height, depth); | 125 int num_mips = ComputeMipMapCount(width, height, depth); |
126 for (int level = 1; level < num_mips; ++level) { | 126 for (int level = 1; level < num_mips; ++level) { |
127 width = std::max(1, width >> 1); | 127 width = std::max(1, width >> 1); |
128 height = std::max(1, height >> 1); | 128 height = std::max(1, height >> 1); |
129 depth = std::max(1, depth >> 1); | 129 depth = std::max(1, depth >> 1); |
130 SetLevelInfo(feature_info, | 130 SetLevelInfo(feature_info, |
131 target, | 131 target, |
132 level, | 132 level, |
133 info1.internal_format, | 133 info1.internal_format, |
134 width, | 134 width, |
135 height, | 135 height, |
136 depth, | 136 depth, |
137 info1.border, | 137 info1.border, |
138 info1.format, | 138 info1.format, |
139 info1.type, | 139 info1.type, |
140 true); | 140 true); |
greggman
2011/12/02 18:33:24
change this true to 'cleared'
vangelis
2011/12/03 00:19:53
Done.
| |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 return true; | 144 return true; |
145 } | 145 } |
146 | 146 |
147 void TextureManager::TextureInfo::SetTarget(GLenum target, GLint max_levels) { | 147 void TextureManager::TextureInfo::SetTarget(GLenum target, GLint max_levels) { |
148 DCHECK_EQ(0u, target_); // you can only set this once. | 148 DCHECK_EQ(0u, target_); // you can only set this once. |
149 target_ = target; | 149 target_ = target; |
150 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; | 150 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 break; | 361 break; |
362 case GL_TEXTURE_WRAP_T: | 362 case GL_TEXTURE_WRAP_T: |
363 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { | 363 if (!feature_info->validators()->texture_wrap_mode.IsValid(param)) { |
364 return false; | 364 return false; |
365 } | 365 } |
366 wrap_t_ = param; | 366 wrap_t_ = param; |
367 break; | 367 break; |
368 case GL_TEXTURE_MAX_ANISOTROPY_EXT: | 368 case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
369 // Nothing to do for this case at the moment. | 369 // Nothing to do for this case at the moment. |
370 break; | 370 break; |
371 case GL_TEXTURE_USAGE_ANGLE: | |
372 if (!feature_info->validators()->texture_usage.IsValid(param)) { | |
373 return false; | |
374 } | |
375 usage_ = param; | |
376 break; | |
371 default: | 377 default: |
372 NOTREACHED(); | 378 NOTREACHED(); |
373 return false; | 379 return false; |
374 } | 380 } |
375 Update(feature_info); | 381 Update(feature_info); |
376 UpdateCleared(); | 382 UpdateCleared(); |
377 return true; | 383 return true; |
378 } | 384 } |
379 | 385 |
380 void TextureManager::TextureInfo::Update(const FeatureInfo* feature_info) { | 386 void TextureManager::TextureInfo::Update(const FeatureInfo* feature_info) { |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 return true; | 870 return true; |
865 } | 871 } |
866 } | 872 } |
867 return false; | 873 return false; |
868 } | 874 } |
869 | 875 |
870 } // namespace gles2 | 876 } // namespace gles2 |
871 } // namespace gpu | 877 } // namespace gpu |
872 | 878 |
873 | 879 |
OLD | NEW |