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

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

Issue 2550203003: Add command buffer support for EXT_sRGB_write_control (Closed)
Patch Set: Created 4 years 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 4290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 return false; 4301 return false;
4302 4302
4303 if (!features().chromium_framebuffer_multisample) 4303 if (!features().chromium_framebuffer_multisample)
4304 OnUseFramebuffer(); 4304 OnUseFramebuffer();
4305 4305
4306 UpdateFramebufferSRGB(framebuffer); 4306 UpdateFramebufferSRGB(framebuffer);
4307 return true; 4307 return true;
4308 } 4308 }
4309 4309
4310 void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) { 4310 void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) {
4311 // Manually set the value of FRAMEBUFFER_SRGB based on the state that was set
4312 // by the client.
4313 bool needs_enable_disable_framebuffer_srgb = false;
4314 bool enable_framebuffer_srgb = true;
4315 if (feature_info_->feature_flags().ext_srgb_write_control) {
4316 needs_enable_disable_framebuffer_srgb = true;
4317 enable_framebuffer_srgb &= state_.GetEnabled(GL_FRAMEBUFFER_SRGB);
4318 }
4311 // On desktop, enable FRAMEBUFFER_SRGB only if the framebuffer contains sRGB 4319 // On desktop, enable FRAMEBUFFER_SRGB only if the framebuffer contains sRGB
4312 // attachments. In theory, we can just leave FRAMEBUFFER_SRGB enabled, 4320 // attachments. In theory, we can just leave FRAMEBUFFER_SRGB enabled,
4313 // however, 4321 // however,
4314 // many drivers behave incorrectly when no attachments are sRGB. When at 4322 // many drivers behave incorrectly when no attachments are sRGB. When at
4315 // least one attachment is sRGB, then they behave correctly. 4323 // least one attachment is sRGB, then they behave correctly.
4316 if (feature_info_->feature_flags().desktop_srgb_support) { 4324 if (feature_info_->feature_flags().desktop_srgb_support) {
4325 needs_enable_disable_framebuffer_srgb = true;
4317 // Assume that the default fbo does not have an sRGB image. 4326 // Assume that the default fbo does not have an sRGB image.
4318 bool enable_framebuffer_srgb = 4327 enable_framebuffer_srgb &= framebuffer && framebuffer->HasSRGBAttachments();
4319 framebuffer && framebuffer->HasSRGBAttachments(); 4328 }
4329 if (needs_enable_disable_framebuffer_srgb)
4320 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); 4330 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
4321 }
4322 } 4331 }
4323 4332
4324 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( 4333 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
4325 const char* func_name, GLenum gl_error) { 4334 const char* func_name, GLenum gl_error) {
4326 GLenum target = features().chromium_framebuffer_multisample ? 4335 GLenum target = features().chromium_framebuffer_multisample ?
4327 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; 4336 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4328 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); 4337 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
4329 bool valid = CheckFramebufferValid( 4338 bool valid = CheckFramebufferValid(
4330 framebuffer, target, gl_error, func_name); 4339 framebuffer, target, gl_error, func_name);
4331 return valid; 4340 return valid;
(...skipping 3094 matching lines...) Expand 10 before | Expand all | Expand 10 after
7426 } 7435 }
7427 7436
7428 void GLES2DecoderImpl::DoDisable(GLenum cap) { 7437 void GLES2DecoderImpl::DoDisable(GLenum cap) {
7429 if (SetCapabilityState(cap, false)) { 7438 if (SetCapabilityState(cap, false)) {
7430 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && 7439 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX &&
7431 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { 7440 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) {
7432 // Enable and Disable PRIMITIVE_RESTART only before and after 7441 // Enable and Disable PRIMITIVE_RESTART only before and after
7433 // DrawElements* for old desktop GL. 7442 // DrawElements* for old desktop GL.
7434 return; 7443 return;
7435 } 7444 }
7445 if (cap == GL_FRAMEBUFFER_SRGB) {
7446 // Enable and Disable GL_FRAMEBUFFER_SRGB is done manually in
7447 // CheckBoundDrawFramebufferValid.
7448 return;
7449 }
7436 glDisable(cap); 7450 glDisable(cap);
7437 } 7451 }
7438 } 7452 }
7439 7453
7440 void GLES2DecoderImpl::DoEnable(GLenum cap) { 7454 void GLES2DecoderImpl::DoEnable(GLenum cap) {
7441 if (SetCapabilityState(cap, true)) { 7455 if (SetCapabilityState(cap, true)) {
7442 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && 7456 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX &&
7443 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { 7457 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) {
7444 // Enable and Disable PRIMITIVE_RESTART only before and after 7458 // Enable and Disable PRIMITIVE_RESTART only before and after
7445 // DrawElements* for old desktop GL. 7459 // DrawElements* for old desktop GL.
7446 return; 7460 return;
7447 } 7461 }
7462 if (cap == GL_FRAMEBUFFER_SRGB) {
7463 // Enable and Disable GL_FRAMEBUFFER_SRGB is done manually in
7464 // CheckBoundDrawFramebufferValid.
7465 return;
7466 }
7448 glEnable(cap); 7467 glEnable(cap);
7449 } 7468 }
7450 } 7469 }
7451 7470
7452 void GLES2DecoderImpl::DoDepthRangef(GLclampf znear, GLclampf zfar) { 7471 void GLES2DecoderImpl::DoDepthRangef(GLclampf znear, GLclampf zfar) {
7453 state_.z_near = std::min(1.0f, std::max(0.0f, znear)); 7472 state_.z_near = std::min(1.0f, std::max(0.0f, znear));
7454 state_.z_far = std::min(1.0f, std::max(0.0f, zfar)); 7473 state_.z_far = std::min(1.0f, std::max(0.0f, zfar));
7455 glDepthRange(znear, zfar); 7474 glDepthRange(znear, zfar);
7456 } 7475 }
7457 7476
(...skipping 11457 matching lines...) Expand 10 before | Expand all | Expand 10 after
18915 } 18934 }
18916 18935
18917 // Include the auto-generated part of this file. We split this because it means 18936 // Include the auto-generated part of this file. We split this because it means
18918 // we can easily edit the non-auto generated parts right here in this file 18937 // we can easily edit the non-auto generated parts right here in this file
18919 // instead of having to edit some template or the code generator. 18938 // instead of having to edit some template or the code generator.
18920 #include "base/macros.h" 18939 #include "base/macros.h"
18921 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18940 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18922 18941
18923 } // namespace gles2 18942 } // namespace gles2
18924 } // namespace gpu 18943 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698