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

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

Issue 2900403003: Set the texture base level before generating sRGB mipmaps. (Closed)
Patch Set: Fix sizes for mips Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); 471 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_);
472 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); 472 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
473 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 473 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
474 GL_NEAREST_MIPMAP_NEAREST); 474 GL_NEAREST_MIPMAP_NEAREST);
475 475
476 width = (width == 1) ? 1 : width >> 1; 476 width = (width == 1) ? 1 : width >> 1;
477 height = (height == 1) ? 1 : height >> 1; 477 height = (height == 1) ? 1 : height >> 1;
478 478
479 base::CheckedNumeric<GLint> level = base_level; 479 base::CheckedNumeric<GLint> level = base_level;
480 level += 1; 480 level += 1;
481 for (; level.IsValid() && level.ValueOrDie() <= max_mipmap_available_level; 481
482 ++level) { 482 if (!tex->IsImmutable()) {
483 glBindTexture(GL_TEXTURE_2D, tex->service_id());
484 GLsizei level_width = width;
485 GLsizei level_height = height;
486 for (base::CheckedNumeric<GLint> i = level;
487 i.IsValid() && i.ValueOrDie() <= max_mipmap_available_level; ++i) {
488 glTexImage2D(GL_TEXTURE_2D, i.ValueOrDie(), internal_format, level_width,
489 level_height, 0, format, type, nullptr);
490 level_width = (level_width == 1) ? 1 : level_width >> 1;
491 level_height = (level_height == 1) ? 1 : level_height >> 1;
492 }
493 }
494
495 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]);
496 for (base::CheckedNumeric<GLint> i = level;
497 i.IsValid() && i.ValueOrDie() <= max_mipmap_available_level; ++i) {
483 // copy mipmaps level by level from srgb_converter_textures_[1] to tex 498 // copy mipmaps level by level from srgb_converter_textures_[1] to tex
484 // generate mipmap for tex manually 499 // generate mipmap for tex manually
485 glBindTexture(GL_TEXTURE_2D, tex->service_id());
486 if (!tex->IsImmutable()) {
487 glTexImage2D(GL_TEXTURE_2D, level.ValueOrDie(), internal_format, width,
488 height, 0, format, type, nullptr);
489 }
490 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 500 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
491 GL_TEXTURE_2D, tex->service_id(), 501 GL_TEXTURE_2D, tex->service_id(), i.ValueOrDie());
492 level.ValueOrDie());
493 502
494 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); 503 DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
504 glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER));
505
495 glViewport(0, 0, width, height); 506 glViewport(0, 0, width, height);
496 glDrawArrays(GL_TRIANGLES, 0, 6); 507 glDrawArrays(GL_TRIANGLES, 0, 6);
497 width = (width == 1) ? 1 : width >> 1; 508 width = (width == 1) ? 1 : width >> 1;
498 height = (height == 1) ? 1 : height >> 1; 509 height = (height == 1) ? 1 : height >> 1;
499 } 510 }
500 511
501 // Restore state 512 // Restore state
502 decoder->RestoreAllAttributes(); 513 decoder->RestoreAllAttributes();
503 decoder->RestoreTextureUnitBindings(0); 514 decoder->RestoreTextureUnitBindings(0);
504 decoder->RestoreActiveTexture(); 515 decoder->RestoreActiveTexture();
505 decoder->RestoreProgramBindings(); 516 decoder->RestoreProgramBindings();
506 decoder->RestoreBufferBindings(); 517 decoder->RestoreBufferBindings();
507 decoder->RestoreFramebufferBindings(); 518 decoder->RestoreFramebufferBindings();
508 decoder->RestoreGlobalState(); 519 decoder->RestoreGlobalState();
509 decoder->RestoreTextureState(tex->service_id()); 520 decoder->RestoreTextureState(tex->service_id());
510 } 521 }
511 522
512 } // namespace gles2. 523 } // namespace gles2.
513 } // namespace gpu 524 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698