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/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 5987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5998 target == GL_TEXTURE_2D) { | 5998 target == GL_TEXTURE_2D) { |
5999 if (base_level != 0 && | 5999 if (base_level != 0 && |
6000 !tex->GetLevelType(target, 0, &type, &internal_format) && | 6000 !tex->GetLevelType(target, 0, &type, &internal_format) && |
6001 tex->GetLevelType(target, tex->base_level(), &type, &internal_format)) { | 6001 tex->GetLevelType(target, tex->base_level(), &type, &internal_format)) { |
6002 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); | 6002 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); |
6003 glTexImage2D(target, 0, internal_format, 1, 1, 0, format, type, nullptr); | 6003 glTexImage2D(target, 0, internal_format, 1, 1, 0, format, type, nullptr); |
6004 texture_zero_level_set = true; | 6004 texture_zero_level_set = true; |
6005 } | 6005 } |
6006 } | 6006 } |
6007 | 6007 |
6008 glGenerateMipmapEXT(target); | 6008 tex->GetLevelType(target, 0, &type, &internal_format); |
| 6009 bool enable_srgb = |
| 6010 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; |
| 6011 if (!enable_srgb || !feature_info_->feature_flags().desktop_srgb_support || |
| 6012 gl_version_info().IsAtLeastGL(4, 4)) { |
| 6013 if (gl_version_info().IsAtLeastGL(4, 4)) { |
| 6014 state_.EnableDisableFramebufferSRGB(enable_srgb); |
| 6015 } |
| 6016 glGenerateMipmapEXT(target); |
| 6017 } else { |
| 6018 if (target == GL_TEXTURE_2D) { |
| 6019 state_.EnableDisableFramebufferSRGB(true); |
| 6020 if (!InitializeSRGBConverter("generateMipmap")) { |
| 6021 return; |
| 6022 } |
| 6023 srgb_converter_->SRGBGenerateMipmap(this, tex, target); |
| 6024 } else { |
| 6025 // TODO(yizhou): If the target is GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY, |
| 6026 // this change can not generate correct mipmap. |
| 6027 glGenerateMipmapEXT(target); |
| 6028 } |
| 6029 } |
6009 | 6030 |
6010 if (texture_zero_level_set) { | 6031 if (texture_zero_level_set) { |
6011 // This may have some unwanted side effects, but we expect command buffer | 6032 // This may have some unwanted side effects, but we expect command buffer |
6012 // validation to prevent you from doing anything weird with the texture | 6033 // validation to prevent you from doing anything weird with the texture |
6013 // after this, like calling texSubImage2D sucessfully. | 6034 // after this, like calling texSubImage2D sucessfully. |
6014 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr); | 6035 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr); |
6015 } | 6036 } |
6016 | 6037 |
6017 if (workarounds().set_texture_filter_before_generating_mipmap) { | 6038 if (workarounds().set_texture_filter_before_generating_mipmap) { |
6018 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, | 6039 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, |
(...skipping 12056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18075 } | 18096 } |
18076 | 18097 |
18077 // Include the auto-generated part of this file. We split this because it means | 18098 // Include the auto-generated part of this file. We split this because it means |
18078 // we can easily edit the non-auto generated parts right here in this file | 18099 // we can easily edit the non-auto generated parts right here in this file |
18079 // instead of having to edit some template or the code generator. | 18100 // instead of having to edit some template or the code generator. |
18080 #include "base/macros.h" | 18101 #include "base/macros.h" |
18081 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18102 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18082 | 18103 |
18083 } // namespace gles2 | 18104 } // namespace gles2 |
18084 } // namespace gpu | 18105 } // namespace gpu |
OLD | NEW |