Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2527 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 2527 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 2528 glClearStencil(0); | 2528 glClearStencil(0); |
| 2529 glStencilMaskSeparate(GL_FRONT, -1); | 2529 glStencilMaskSeparate(GL_FRONT, -1); |
| 2530 glStencilMaskSeparate(GL_BACK, -1); | 2530 glStencilMaskSeparate(GL_BACK, -1); |
| 2531 glClearDepth(0); | 2531 glClearDepth(0); |
| 2532 glDepthMask(GL_TRUE); | 2532 glDepthMask(GL_TRUE); |
| 2533 glDisable(GL_SCISSOR_TEST); | 2533 glDisable(GL_SCISSOR_TEST); |
| 2534 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | 2534 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 2535 RestoreClearState(); | 2535 RestoreClearState(); |
| 2536 } | 2536 } |
| 2537 | |
| 2538 // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, | |
| 2539 // crbug.com/94103. TODO(kbr): figure out reproduction so Apple will | |
| 2540 // fix this. | |
| 2541 if (needs_mac_nvidia_driver_workaround_) { | |
| 2542 offscreen_saved_frame_buffer_->Create(); | |
| 2543 glFinish(); | |
| 2544 } | |
| 2545 | |
| 2546 // Allocate the offscreen saved color texture. | |
| 2547 DCHECK(offscreen_saved_color_format_); | |
| 2548 offscreen_saved_color_texture_->AllocateStorage( | |
| 2549 offscreen_size_, offscreen_saved_color_format_); | |
| 2550 | |
| 2551 offscreen_saved_frame_buffer_->AttachRenderTexture( | |
| 2552 offscreen_saved_color_texture_.get()); | |
| 2553 if (offscreen_saved_frame_buffer_->CheckStatus() != | |
| 2554 GL_FRAMEBUFFER_COMPLETE) { | |
| 2555 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | |
| 2556 << "because offscreen saved FBO was incomplete."; | |
| 2557 return false; | |
| 2558 } | |
| 2559 | |
| 2560 // Destroy the offscreen resolved framebuffers. | |
| 2561 if (offscreen_resolved_frame_buffer_.get()) | |
| 2562 offscreen_resolved_frame_buffer_->Destroy(); | |
| 2563 if (offscreen_resolved_color_texture_.get()) | |
| 2564 offscreen_resolved_color_texture_->Destroy(); | |
| 2565 offscreen_resolved_color_texture_.reset(); | |
| 2566 offscreen_resolved_frame_buffer_.reset(); | |
| 2567 | |
| 2568 // Clear the offscreen color texture. | |
| 2569 { | |
| 2570 ScopedFrameBufferBinder binder(this, offscreen_saved_frame_buffer_->id()); | |
| 2571 glClearColor(0, 0, 0, 0); | |
| 2572 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | |
| 2573 glDisable(GL_SCISSOR_TEST); | |
| 2574 glClear(GL_COLOR_BUFFER_BIT); | |
| 2575 RestoreClearState(); | |
| 2576 } | |
| 2577 | |
| 2578 UpdateParentTextureInfo(); | |
| 2579 | |
| 2580 return true; | 2537 return true; |
| 2581 } | 2538 } |
| 2582 | 2539 |
| 2583 error::Error GLES2DecoderImpl::HandleResizeCHROMIUM( | 2540 error::Error GLES2DecoderImpl::HandleResizeCHROMIUM( |
| 2584 uint32 immediate_data_size, const gles2::ResizeCHROMIUM& c) { | 2541 uint32 immediate_data_size, const gles2::ResizeCHROMIUM& c) { |
| 2585 GLuint width = static_cast<GLuint>(c.width); | 2542 GLuint width = static_cast<GLuint>(c.width); |
| 2586 GLuint height = static_cast<GLuint>(c.height); | 2543 GLuint height = static_cast<GLuint>(c.height); |
| 2587 TRACE_EVENT2("gpu", "glResizeChromium", "width", width, "height", height); | 2544 TRACE_EVENT2("gpu", "glResizeChromium", "width", width, "height", height); |
| 2588 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI) | 2545 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOUCH_UI) |
| 2589 // Make sure that we are done drawing to the back buffer before resizing. | 2546 // Make sure that we are done drawing to the back buffer before resizing. |
| (...skipping 3985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6575 error::Error GLES2DecoderImpl::HandleSwapBuffers( | 6532 error::Error GLES2DecoderImpl::HandleSwapBuffers( |
| 6576 uint32 immediate_data_size, const gles2::SwapBuffers& c) { | 6533 uint32 immediate_data_size, const gles2::SwapBuffers& c) { |
| 6577 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 6534 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
| 6578 int this_frame_number = frame_number_++; | 6535 int this_frame_number = frame_number_++; |
| 6579 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", | 6536 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", |
| 6580 "offscreen", is_offscreen, | 6537 "offscreen", is_offscreen, |
| 6581 "frame", this_frame_number); | 6538 "frame", this_frame_number); |
| 6582 // If offscreen then don't actually SwapBuffers to the display. Just copy | 6539 // If offscreen then don't actually SwapBuffers to the display. Just copy |
| 6583 // the rendered frame to another frame buffer. | 6540 // the rendered frame to another frame buffer. |
| 6584 if (is_offscreen) { | 6541 if (is_offscreen) { |
| 6542 if (offscreen_size_ != offscreen_saved_color_texture_->size()) { | |
| 6543 // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, | |
| 6544 // crbug.com/94163. TODO(kbr): figure out reproduction so Apple will | |
| 6545 // fix this. | |
| 6546 if (needs_mac_nvidia_driver_workaround_) { | |
| 6547 offscreen_saved_frame_buffer_->Create(); | |
| 6548 glFinish(); | |
| 6549 } | |
| 6550 | |
| 6551 // Allocate the offscreen saved color texture. | |
| 6552 DCHECK(offscreen_saved_color_format_); | |
| 6553 offscreen_saved_color_texture_->AllocateStorage( | |
| 6554 offscreen_size_, offscreen_saved_color_format_); | |
| 6555 | |
| 6556 offscreen_saved_frame_buffer_->AttachRenderTexture( | |
| 6557 offscreen_saved_color_texture_.get()); | |
| 6558 if (offscreen_saved_frame_buffer_->CheckStatus() != | |
| 6559 GL_FRAMEBUFFER_COMPLETE) { | |
| 6560 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | |
| 6561 << "because offscreen saved FBO was incomplete."; | |
| 6562 return error::kLostContext; | |
| 6563 } | |
| 6564 | |
| 6565 // Destroy the offscreen resolved framebuffers. | |
| 6566 if (offscreen_resolved_frame_buffer_.get()) | |
| 6567 offscreen_resolved_frame_buffer_->Destroy(); | |
| 6568 if (offscreen_resolved_color_texture_.get()) | |
| 6569 offscreen_resolved_color_texture_->Destroy(); | |
| 6570 offscreen_resolved_color_texture_.reset(); | |
| 6571 offscreen_resolved_frame_buffer_.reset(); | |
| 6572 | |
| 6573 // Clear the offscreen color texture. | |
| 6574 // TODO(piman): Is this still necessary? | |
|
Ken Russell (switch to Gerrit)
2011/08/30 22:47:13
I'm quite sure it is -- if the offscreen color tex
| |
| 6575 { | |
| 6576 ScopedFrameBufferBinder binder(this, | |
| 6577 offscreen_saved_frame_buffer_->id()); | |
| 6578 glClearColor(0, 0, 0, 0); | |
| 6579 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | |
| 6580 glDisable(GL_SCISSOR_TEST); | |
| 6581 glClear(GL_COLOR_BUFFER_BIT); | |
| 6582 RestoreClearState(); | |
| 6583 } | |
| 6584 | |
| 6585 UpdateParentTextureInfo(); | |
| 6586 } | |
| 6587 | |
| 6585 ScopedGLErrorSuppressor suppressor(this); | 6588 ScopedGLErrorSuppressor suppressor(this); |
| 6586 | 6589 |
| 6587 if (IsOffscreenBufferMultisampled()) { | 6590 if (IsOffscreenBufferMultisampled()) { |
| 6588 // For multisampled buffers, bind the resolved frame buffer so that | 6591 // For multisampled buffers, bind the resolved frame buffer so that |
| 6589 // callbacks can call ReadPixels or CopyTexImage2D. | 6592 // callbacks can call ReadPixels or CopyTexImage2D. |
| 6590 ScopedResolvedFrameBufferBinder binder(this, true, false); | 6593 ScopedResolvedFrameBufferBinder binder(this, true, false); |
| 6591 #if defined(OS_MACOSX) | 6594 #if defined(OS_MACOSX) |
| 6592 if (swap_buffers_callback_.get()) { | 6595 if (swap_buffers_callback_.get()) { |
| 6593 swap_buffers_callback_->Run(); | 6596 swap_buffers_callback_->Run(); |
| 6594 } | 6597 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6842 return false; | 6845 return false; |
| 6843 } | 6846 } |
| 6844 | 6847 |
| 6845 // Include the auto-generated part of this file. We split this because it means | 6848 // Include the auto-generated part of this file. We split this because it means |
| 6846 // we can easily edit the non-auto generated parts right here in this file | 6849 // we can easily edit the non-auto generated parts right here in this file |
| 6847 // instead of having to edit some template or the code generator. | 6850 // instead of having to edit some template or the code generator. |
| 6848 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6851 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 6849 | 6852 |
| 6850 } // namespace gles2 | 6853 } // namespace gles2 |
| 6851 } // namespace gpu | 6854 } // namespace gpu |
| OLD | NEW |