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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 GLsizei height; | 353 GLsizei height; |
354 GLsizei depth; | 354 GLsizei depth; |
355 GLenum type = 0; | 355 GLenum type = 0; |
356 GLenum internal_format = 0; | 356 GLenum internal_format = 0; |
357 GLsizei base_level = tex->base_level(); | 357 GLsizei base_level = tex->base_level(); |
358 tex->GetLevelSize(target, base_level, &width, &height, &depth); | 358 tex->GetLevelSize(target, base_level, &width, &height, &depth); |
359 tex->GetLevelType(target, base_level, &type, &internal_format); | 359 tex->GetLevelType(target, base_level, &type, &internal_format); |
360 const GLint mipmap_levels = | 360 const GLint mipmap_levels = |
361 TextureManager::ComputeMipMapCount(target, width, height, depth); | 361 TextureManager::ComputeMipMapCount(target, width, height, depth); |
362 | 362 |
363 // bind srgb_decoder_textures_[1] to draw framebuffer | |
364 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); | 363 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); |
365 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, | 364 if (feature_info_->ext_color_buffer_float_available()) { |
Zhenyao Mo
2016/10/20 16:54:04
Sorry I forgot to mention this in earlier review,
yizhou.jiang
2016/10/21 03:25:26
Done.
| |
366 GL_UNSIGNED_BYTE, nullptr); | 365 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, |
366 GL_UNSIGNED_BYTE, nullptr); | |
367 } else { | |
368 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, | |
369 GL_UNSIGNED_BYTE, nullptr); | |
370 } | |
367 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_decoder_fbo_); | 371 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_decoder_fbo_); |
368 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 372 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
369 GL_TEXTURE_2D, srgb_converter_textures_[1], 0); | 373 GL_TEXTURE_2D, srgb_converter_textures_[1], 0); |
370 | 374 |
371 // bind texture with srgb format and render with srgb_converter_program_ | 375 // bind texture with srgb format and render with srgb_converter_program_ |
372 glUseProgram(srgb_converter_program_); | 376 glUseProgram(srgb_converter_program_); |
373 glViewport(0, 0, width, height); | 377 glViewport(0, 0, width, height); |
374 glDisable(GL_SCISSOR_TEST); | 378 glDisable(GL_SCISSOR_TEST); |
375 glDisable(GL_DEPTH_TEST); | 379 glDisable(GL_DEPTH_TEST); |
376 glDisable(GL_STENCIL_TEST); | 380 glDisable(GL_STENCIL_TEST); |
377 glDisable(GL_CULL_FACE); | 381 glDisable(GL_CULL_FACE); |
378 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 382 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
379 glDepthMask(GL_FALSE); | 383 glDepthMask(GL_FALSE); |
380 glDisable(GL_BLEND); | 384 glDisable(GL_BLEND); |
381 glDisable(GL_DITHER); | 385 glDisable(GL_DITHER); |
382 | 386 |
383 glBindVertexArrayOES(srgb_converter_vao_); | 387 glBindVertexArrayOES(srgb_converter_vao_); |
384 glActiveTexture(GL_TEXTURE0); | 388 glActiveTexture(GL_TEXTURE0); |
385 glBindTexture(GL_TEXTURE_2D, tex->service_id()); | 389 glBindTexture(GL_TEXTURE_2D, tex->service_id()); |
386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 390 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
387 | 391 |
388 glDrawArrays(GL_TRIANGLES, 0, 6); | 392 glDrawArrays(GL_TRIANGLES, 0, 6); |
389 | 393 |
390 // generateMipmap for srgb_decoder_textures_[1] | |
391 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); | 394 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); |
392 glGenerateMipmapEXT(GL_TEXTURE_2D); | 395 glGenerateMipmapEXT(GL_TEXTURE_2D); |
393 | 396 |
394 // bind tex with rgba format and render with srgb_converter_program_ | 397 // bind tex with rgba format and render with srgb_converter_program_ |
395 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); | 398 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, srgb_encoder_fbo_); |
396 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); | 399 glBindTexture(GL_TEXTURE_2D, srgb_converter_textures_[1]); |
397 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, | 400 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
398 GL_NEAREST_MIPMAP_NEAREST); | 401 GL_NEAREST_MIPMAP_NEAREST); |
399 width >>= 1; | 402 width >>= 1; |
400 height >>= 1; | 403 height >>= 1; |
(...skipping 23 matching lines...) Expand all Loading... | |
424 decoder->RestoreActiveTexture(); | 427 decoder->RestoreActiveTexture(); |
425 decoder->RestoreProgramBindings(); | 428 decoder->RestoreProgramBindings(); |
426 decoder->RestoreBufferBindings(); | 429 decoder->RestoreBufferBindings(); |
427 decoder->RestoreFramebufferBindings(); | 430 decoder->RestoreFramebufferBindings(); |
428 decoder->RestoreGlobalState(); | 431 decoder->RestoreGlobalState(); |
429 decoder->RestoreTextureState(tex->service_id()); | 432 decoder->RestoreTextureState(tex->service_id()); |
430 } | 433 } |
431 | 434 |
432 } // namespace gles2. | 435 } // namespace gles2. |
433 } // namespace gpu | 436 } // namespace gpu |
OLD | NEW |