| OLD | NEW |
| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); | 700 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); |
| 701 void DeleteSamplersHelper(GLsizei n, const volatile GLuint* client_ids); | 701 void DeleteSamplersHelper(GLsizei n, const volatile GLuint* client_ids); |
| 702 bool GenTransformFeedbacksHelper(GLsizei n, const GLuint* client_ids); | 702 bool GenTransformFeedbacksHelper(GLsizei n, const GLuint* client_ids); |
| 703 void DeleteTransformFeedbacksHelper(GLsizei n, | 703 void DeleteTransformFeedbacksHelper(GLsizei n, |
| 704 const volatile GLuint* client_ids); | 704 const volatile GLuint* client_ids); |
| 705 void DeleteSyncHelper(GLuint sync); | 705 void DeleteSyncHelper(GLuint sync); |
| 706 | 706 |
| 707 // Workarounds | 707 // Workarounds |
| 708 void OnFboChanged() const; | 708 void OnFboChanged() const; |
| 709 void OnUseFramebuffer() const; | 709 void OnUseFramebuffer() const; |
| 710 void UpdateFramebufferSRGB(Framebuffer* framebuffer); |
| 710 | 711 |
| 711 error::ContextLostReason GetContextLostReasonFromResetStatus( | 712 error::ContextLostReason GetContextLostReasonFromResetStatus( |
| 712 GLenum reset_status) const; | 713 GLenum reset_status) const; |
| 713 | 714 |
| 714 // TODO(gman): Cache these pointers? | 715 // TODO(gman): Cache these pointers? |
| 715 BufferManager* buffer_manager() { | 716 BufferManager* buffer_manager() { |
| 716 return group_->buffer_manager(); | 717 return group_->buffer_manager(); |
| 717 } | 718 } |
| 718 | 719 |
| 719 RenderbufferManager* renderbuffer_manager() { | 720 RenderbufferManager* renderbuffer_manager() { |
| (...skipping 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3451 return false; | 3452 return false; |
| 3452 } | 3453 } |
| 3453 } | 3454 } |
| 3454 | 3455 |
| 3455 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); | 3456 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
| 3456 | 3457 |
| 3457 DoBindBuffer(GL_ARRAY_BUFFER, 0); | 3458 DoBindBuffer(GL_ARRAY_BUFFER, 0); |
| 3458 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 3459 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 3459 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 3460 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 3460 DoBindRenderbuffer(GL_RENDERBUFFER, 0); | 3461 DoBindRenderbuffer(GL_RENDERBUFFER, 0); |
| 3462 UpdateFramebufferSRGB(nullptr); |
| 3461 | 3463 |
| 3462 bool call_gl_clear = !surfaceless_ && !offscreen; | 3464 bool call_gl_clear = !surfaceless_ && !offscreen; |
| 3463 #if defined(OS_ANDROID) | 3465 #if defined(OS_ANDROID) |
| 3464 // Temporary workaround for Android WebView because this clear ignores the | 3466 // Temporary workaround for Android WebView because this clear ignores the |
| 3465 // clip and corrupts that external UI of the App. Not calling glClear is ok | 3467 // clip and corrupts that external UI of the App. Not calling glClear is ok |
| 3466 // because the system already clears the buffer before each draw. Proper | 3468 // because the system already clears the buffer before each draw. Proper |
| 3467 // fix might be setting the scissor clip properly before initialize. See | 3469 // fix might be setting the scissor clip properly before initialize. See |
| 3468 // crbug.com/259023 for details. | 3470 // crbug.com/259023 for details. |
| 3469 call_gl_clear = surface_->GetHandle(); | 3471 call_gl_clear = surface_->GetHandle(); |
| 3470 #endif | 3472 #endif |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4288 } | 4290 } |
| 4289 return true; | 4291 return true; |
| 4290 } | 4292 } |
| 4291 | 4293 |
| 4292 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) { | 4294 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) { |
| 4293 GLenum target = features().chromium_framebuffer_multisample ? | 4295 GLenum target = features().chromium_framebuffer_multisample ? |
| 4294 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 4296 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4295 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4297 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 4296 bool valid = CheckFramebufferValid( | 4298 bool valid = CheckFramebufferValid( |
| 4297 framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4299 framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 4298 if (valid && !features().chromium_framebuffer_multisample) | 4300 if (!valid) |
| 4301 return false; |
| 4302 |
| 4303 if (!features().chromium_framebuffer_multisample) |
| 4299 OnUseFramebuffer(); | 4304 OnUseFramebuffer(); |
| 4300 if (valid && feature_info_->feature_flags().desktop_srgb_support) { | 4305 |
| 4301 // If framebuffer contains sRGB images, then enable FRAMEBUFFER_SRGB. | 4306 UpdateFramebufferSRGB(framebuffer); |
| 4302 // Otherwise, disable FRAMEBUFFER_SRGB. Assume default fbo does not have | 4307 return true; |
| 4303 // sRGB image. | 4308 } |
| 4304 // In theory, we can just leave FRAMEBUFFER_SRGB on. However, many drivers | 4309 |
| 4305 // behave incorrectly when all images are linear encoding, they still apply | 4310 void GLES2DecoderImpl::UpdateFramebufferSRGB(Framebuffer* framebuffer) { |
| 4306 // the sRGB conversion, but when at least one image is sRGB, then they | 4311 // On desktop, enable FRAMEBUFFER_SRGB only if the framebuffer contains sRGB |
| 4307 // behave correctly. | 4312 // attachments. In theory, we can just leave FRAMEBUFFER_SRGB enabled, |
| 4313 // however, |
| 4314 // many drivers behave incorrectly when no attachments are sRGB. When at |
| 4315 // least one attachment is sRGB, then they behave correctly. |
| 4316 if (feature_info_->feature_flags().desktop_srgb_support) { |
| 4317 // Assume that the default fbo does not have an sRGB image. |
| 4308 bool enable_framebuffer_srgb = | 4318 bool enable_framebuffer_srgb = |
| 4309 framebuffer && framebuffer->HasSRGBAttachments(); | 4319 framebuffer && framebuffer->HasSRGBAttachments(); |
| 4310 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | 4320 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
| 4311 } | 4321 } |
| 4312 return valid; | |
| 4313 } | 4322 } |
| 4314 | 4323 |
| 4315 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( | 4324 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( |
| 4316 const char* func_name, GLenum gl_error) { | 4325 const char* func_name, GLenum gl_error) { |
| 4317 GLenum target = features().chromium_framebuffer_multisample ? | 4326 GLenum target = features().chromium_framebuffer_multisample ? |
| 4318 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 4327 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4319 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4328 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 4320 bool valid = CheckFramebufferValid( | 4329 bool valid = CheckFramebufferValid( |
| 4321 framebuffer, target, gl_error, func_name); | 4330 framebuffer, target, gl_error, func_name); |
| 4322 return valid; | 4331 return valid; |
| (...skipping 14549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18872 } | 18881 } |
| 18873 | 18882 |
| 18874 // Include the auto-generated part of this file. We split this because it means | 18883 // Include the auto-generated part of this file. We split this because it means |
| 18875 // we can easily edit the non-auto generated parts right here in this file | 18884 // we can easily edit the non-auto generated parts right here in this file |
| 18876 // instead of having to edit some template or the code generator. | 18885 // instead of having to edit some template or the code generator. |
| 18877 #include "base/macros.h" | 18886 #include "base/macros.h" |
| 18878 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18887 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18879 | 18888 |
| 18880 } // namespace gles2 | 18889 } // namespace gles2 |
| 18881 } // namespace gpu | 18890 } // namespace gpu |
| OLD | NEW |