Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2318313004: emulate srgb format for generateMipmap (Closed)
Patch Set: addressed feedbacks Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 bool enable_srgb = 0;
6009 if (target == GL_TEXTURE_2D) {
6010 tex->GetLevelType(target, tex->base_level(), &type, &internal_format);
6011 enable_srgb =
6012 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB;
6013 }
6014 if (!enable_srgb || !feature_info_->feature_flags().desktop_srgb_support ||
6015 !workarounds().decode_encode_srgb_for_generatemipmap) {
6016 if (feature_info_->feature_flags().desktop_srgb_support) {
6017 state_.EnableDisableFramebufferSRGB(enable_srgb);
6018 }
6019 glGenerateMipmapEXT(target);
6020 } else {
6021 if (target == GL_TEXTURE_2D) {
6022 state_.EnableDisableFramebufferSRGB(true);
6023 if (!InitializeSRGBConverter("generateMipmap")) {
6024 return;
6025 }
6026 srgb_converter_->GenerateMipmap(this, tex, target);
6027 } else {
6028 // TODO(yizhou): If the target is GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY,
6029 // this change can not generate correct mipmap.
6030 glGenerateMipmapEXT(target);
6031 }
6032 }
6009 6033
6010 if (texture_zero_level_set) { 6034 if (texture_zero_level_set) {
6011 // This may have some unwanted side effects, but we expect command buffer 6035 // This may have some unwanted side effects, but we expect command buffer
6012 // validation to prevent you from doing anything weird with the texture 6036 // validation to prevent you from doing anything weird with the texture
6013 // after this, like calling texSubImage2D sucessfully. 6037 // after this, like calling texSubImage2D sucessfully.
6014 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr); 6038 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr);
6015 } 6039 }
6016 6040
6017 if (workarounds().set_texture_filter_before_generating_mipmap) { 6041 if (workarounds().set_texture_filter_before_generating_mipmap) {
6018 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, 6042 glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
(...skipping 12064 matching lines...) Expand 10 before | Expand all | Expand 10 after
18083 } 18107 }
18084 18108
18085 // Include the auto-generated part of this file. We split this because it means 18109 // Include the auto-generated part of this file. We split this because it means
18086 // we can easily edit the non-auto generated parts right here in this file 18110 // we can easily edit the non-auto generated parts right here in this file
18087 // instead of having to edit some template or the code generator. 18111 // instead of having to edit some template or the code generator.
18088 #include "base/macros.h" 18112 #include "base/macros.h"
18089 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18113 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18090 18114
18091 } // namespace gles2 18115 } // namespace gles2
18092 } // namespace gpu 18116 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698