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/gpu_scheduler.h" | 5 #include "gpu/command_buffer/service/gpu_scheduler.h" |
6 #include "ui/gfx/gl/gl_context.h" | 6 #include "ui/gfx/gl/gl_context.h" |
7 #include "ui/gfx/gl/gl_share_group.h" | 7 #include "ui/gfx/gl/gl_share_group.h" |
8 #include "ui/gfx/gl/gl_surface.h" | 8 #include "ui/gfx/gl/gl_surface.h" |
9 | 9 |
10 using ::base::SharedMemory; | 10 using ::base::SharedMemory; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // will attempt to finish all GL commands, it will busy-wait on the GPU | 113 // will attempt to finish all GL commands, it will busy-wait on the GPU |
114 // process until the command queue is empty. If a paint is pending, the GPU | 114 // process until the command queue is empty. If a paint is pending, the GPU |
115 // process won't process any GL commands until the browser sends a paint ack, | 115 // process won't process any GL commands until the browser sends a paint ack, |
116 // but since the browser window is already closed, it will never arrive. | 116 // but since the browser window is already closed, it will never arrive. |
117 // To break this infinite loop, the browser tells the GPU process that the | 117 // To break this infinite loop, the browser tells the GPU process that the |
118 // surface became invalid, which causes the GPU process to not wait for paint | 118 // surface became invalid, which causes the GPU process to not wait for paint |
119 // acks. | 119 // acks. |
120 surface_.reset(); | 120 surface_.reset(); |
121 } | 121 } |
122 | 122 |
| 123 void GpuScheduler::SetSwapBuffersCallback( |
| 124 Callback0::Type* callback) { |
| 125 wrapped_swap_buffers_callback_.reset(callback); |
| 126 decoder_->SetSwapBuffersCallback( |
| 127 NewCallback(this, |
| 128 &GpuScheduler::WillSwapBuffers)); |
| 129 } |
| 130 |
123 void GpuScheduler::WillSwapBuffers() { | 131 void GpuScheduler::WillSwapBuffers() { |
124 DCHECK(decoder_.get()); | 132 DCHECK(decoder_.get()); |
125 DCHECK(decoder_->GetGLContext()); | 133 DCHECK(decoder_->GetGLContext()); |
126 DCHECK(decoder_->GetGLContext()->IsCurrent(decoder_->GetGLSurface())); | 134 DCHECK(decoder_->GetGLContext()->IsCurrent(decoder_->GetGLSurface())); |
127 | 135 |
128 ++swap_buffers_count_; | 136 ++swap_buffers_count_; |
129 | 137 |
130 if (surface_.get()) { | 138 if (surface_.get()) { |
131 surface_->SwapBuffers(); | 139 surface_->SwapBuffers(); |
132 } | 140 } |
133 | 141 |
134 if (wrapped_swap_buffers_callback_.get()) { | 142 if (wrapped_swap_buffers_callback_.get()) { |
135 wrapped_swap_buffers_callback_->Run(); | 143 wrapped_swap_buffers_callback_->Run(); |
136 } | 144 } |
137 } | 145 } |
138 | 146 |
139 } // namespace gpu | 147 } // namespace gpu |
OLD | NEW |