| 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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
| 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 bool TextureManager::TextureInfo::CanGenerateMipmaps( | 204 bool TextureManager::TextureInfo::CanGenerateMipmaps( |
| 205 const FeatureInfo* feature_info) const { | 205 const FeatureInfo* feature_info) const { |
| 206 if ((npot() && !feature_info->feature_flags().npot_ok) || | 206 if ((npot() && !feature_info->feature_flags().npot_ok) || |
| 207 level_infos_.empty() || | 207 level_infos_.empty() || |
| 208 target_ == GL_TEXTURE_EXTERNAL_OES || | 208 target_ == GL_TEXTURE_EXTERNAL_OES || |
| 209 target_ == GL_TEXTURE_RECTANGLE_ARB) { | 209 target_ == GL_TEXTURE_RECTANGLE_ARB) { |
| 210 return false; | 210 return false; |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Can't generate mips for depth or stencil textures. |
| 213 const TextureInfo::LevelInfo& first = level_infos_[0][0]; | 214 const TextureInfo::LevelInfo& first = level_infos_[0][0]; |
| 215 uint32 channels = GLES2Util::GetChannelsForFormat(first.format); |
| 216 if (channels & (GLES2Util::kDepth | GLES2Util::kStencil)) { |
| 217 return false; |
| 218 } |
| 219 |
| 214 // TODO(gman): Check internal_format, format and type. | 220 // TODO(gman): Check internal_format, format and type. |
| 215 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { | 221 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { |
| 216 const LevelInfo& info = level_infos_[ii][0]; | 222 const LevelInfo& info = level_infos_[ii][0]; |
| 217 if ((info.target == 0) || | 223 if ((info.target == 0) || |
| 218 (info.width != first.width) || | 224 (info.width != first.width) || |
| 219 (info.height != first.height) || | 225 (info.height != first.height) || |
| 220 (info.depth != 1) || | 226 (info.depth != 1) || |
| 221 (info.format != first.format) || | 227 (info.format != first.format) || |
| 222 (info.internal_format != first.internal_format) || | 228 (info.internal_format != first.internal_format) || |
| 223 (info.type != first.type) || | 229 (info.type != first.type) || |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 | 1048 |
| 1043 GLsizei TextureManager::ComputeMipMapCount( | 1049 GLsizei TextureManager::ComputeMipMapCount( |
| 1044 GLsizei width, GLsizei height, GLsizei depth) { | 1050 GLsizei width, GLsizei height, GLsizei depth) { |
| 1045 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); | 1051 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); |
| 1046 } | 1052 } |
| 1047 | 1053 |
| 1048 } // namespace gles2 | 1054 } // namespace gles2 |
| 1049 } // namespace gpu | 1055 } // namespace gpu |
| 1050 | 1056 |
| 1051 | 1057 |
| OLD | NEW |