Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_srgb_converter.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_srgb_converter.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/service/texture_manager.h" | 7 #include "gpu/command_buffer/service/texture_manager.h" |
| 8 #include "ui/gl/gl_version_info.h" | 8 #include "ui/gl/gl_version_info.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 tex->GetLevelType(target, base_level, &type, &internal_format); | 417 tex->GetLevelType(target, base_level, &type, &internal_format); |
| 418 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); | 418 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); |
| 419 GLint mipmap_levels; | 419 GLint mipmap_levels; |
| 420 if (tex->IsImmutable()) { | 420 if (tex->IsImmutable()) { |
| 421 mipmap_levels = tex->GetImmutableLevels(); | 421 mipmap_levels = tex->GetImmutableLevels(); |
| 422 } else { | 422 } else { |
| 423 mipmap_levels = | 423 mipmap_levels = |
| 424 TextureManager::ComputeMipMapCount(target, width, height, depth); | 424 TextureManager::ComputeMipMapCount(target, width, height, depth); |
| 425 } | 425 } |
| 426 const GLint max_mipmap_available_levels = | 426 const GLint max_mipmap_available_levels = |
| 427 (base_level + mipmap_levels) > max_level ? max_level | 427 (base_level + mipmap_levels - 1) > max_level |
|
yunchao
2017/05/05 08:01:48
Please check that max_level, not max_level - 1?
yizhou.jiang
2017/05/08 08:28:56
The variable name is quite confusing, so I change
| |
| 428 : (base_level + mipmap_levels); | 428 ? max_level |
| 429 : (base_level + mipmap_levels - 1); | |
| 429 | 430 |
| 430 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); | 431 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); |
| 431 if (feature_info_->ext_color_buffer_float_available() && | 432 if (feature_info_->ext_color_buffer_float_available() && |
| 432 feature_info_->oes_texture_float_linear_available()) { | 433 feature_info_->oes_texture_float_linear_available()) { |
| 433 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, | 434 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, |
| 434 GL_FLOAT, nullptr); | 435 GL_FLOAT, nullptr); |
| 435 } else { | 436 } else { |
| 436 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, | 437 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, |
| 437 GL_UNSIGNED_BYTE, nullptr); | 438 GL_UNSIGNED_BYTE, nullptr); |
| 438 } | 439 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 466 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); | 467 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); |
| 467 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); | 468 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); |
| 468 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, | 469 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 469 GL_NEAREST_MIPMAP_NEAREST); | 470 GL_NEAREST_MIPMAP_NEAREST); |
| 470 | 471 |
| 471 width = (width == 1) ? 1 : width >> 1; | 472 width = (width == 1) ? 1 : width >> 1; |
| 472 height = (height == 1) ? 1 : height >> 1; | 473 height = (height == 1) ? 1 : height >> 1; |
| 473 | 474 |
| 474 // TODO(yizhou): An optimization. Attach 1 level at a time, once for every | 475 // TODO(yizhou): An optimization. Attach 1 level at a time, once for every |
| 475 // iteration of the loop. | 476 // iteration of the loop. |
| 476 for (GLint level = base_level + 1; level < max_mipmap_available_levels; | 477 for (GLint level = base_level + 1; level <= max_mipmap_available_levels; |
|
yunchao
2017/05/05 08:01:48
I think it is <=, instead of <.
yizhou.jiang
2017/05/08 08:28:56
Done.
| |
| 477 ++level) { | 478 ++level) { |
| 478 // copy mipmaps level by level from srgb_converter_textures_[1] to tex | 479 // copy mipmaps level by level from srgb_converter_textures_[1] to tex |
| 479 // generate mipmap for tex manually | 480 // generate mipmap for tex manually |
| 480 glBindTexture(GL_TEXTURE_2D, tex->service_id()); | 481 glBindTexture(GL_TEXTURE_2D, tex->service_id()); |
| 481 if (!tex->IsImmutable()) { | 482 if (!tex->IsImmutable()) { |
| 482 glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height, 0, | 483 glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height, 0, |
| 483 format, type, nullptr); | 484 format, type, nullptr); |
| 484 } | 485 } |
| 485 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 486 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 486 GL_TEXTURE_2D, tex->service_id(), level); | 487 GL_TEXTURE_2D, tex->service_id(), level); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 498 decoder->RestoreActiveTexture(); | 499 decoder->RestoreActiveTexture(); |
| 499 decoder->RestoreProgramBindings(); | 500 decoder->RestoreProgramBindings(); |
| 500 decoder->RestoreBufferBindings(); | 501 decoder->RestoreBufferBindings(); |
| 501 decoder->RestoreFramebufferBindings(); | 502 decoder->RestoreFramebufferBindings(); |
| 502 decoder->RestoreGlobalState(); | 503 decoder->RestoreGlobalState(); |
| 503 decoder->RestoreTextureState(tex->service_id()); | 504 decoder->RestoreTextureState(tex->service_id()); |
| 504 } | 505 } |
| 505 | 506 |
| 506 } // namespace gles2. | 507 } // namespace gles2. |
| 507 } // namespace gpu | 508 } // namespace gpu |
| OLD | NEW |