| 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 "content/renderer/gpu/compositor_output_surface.h" | 5 #include "content/renderer/gpu/compositor_output_surface.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 OnSwapAck(output_surface_id, *layout_test_previous_frame_ack_); | 129 OnSwapAck(output_surface_id, *layout_test_previous_frame_ack_); |
| 130 | 130 |
| 131 layout_test_previous_frame_ack_->gl_frame_data = gl_frame_data.Pass(); | 131 layout_test_previous_frame_ack_->gl_frame_data = gl_frame_data.Pass(); |
| 132 layout_test_previous_frame_ack_->last_software_frame_id = | 132 layout_test_previous_frame_ack_->last_software_frame_id = |
| 133 software_frame_data ? software_frame_data->id : 0; | 133 software_frame_data ? software_frame_data->id : 0; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 136 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| 137 if (layout_test_mode_ && use_swap_compositor_frame_message_) { | 137 DCHECK(use_swap_compositor_frame_message_); |
| 138 if (layout_test_mode_) { |
| 138 // This code path is here to support layout tests that are currently | 139 // This code path is here to support layout tests that are currently |
| 139 // doing a readback in the renderer instead of the browser. So they | 140 // doing a readback in the renderer instead of the browser. So they |
| 140 // are using deprecated code paths in the renderer and don't need to | 141 // are using deprecated code paths in the renderer and don't need to |
| 141 // actually swap anything to the browser. We shortcut the swap to the | 142 // actually swap anything to the browser. We shortcut the swap to the |
| 142 // browser here and just ack directly within the renderer process. | 143 // browser here and just ack directly within the renderer process. |
| 143 // Once crbug.com/311404 is fixed, this can be removed. | 144 // Once crbug.com/311404 is fixed, this can be removed. |
| 144 | 145 |
| 145 // This would indicate that crbug.com/311404 is being fixed, and this | 146 // This would indicate that crbug.com/311404 is being fixed, and this |
| 146 // block needs to be removed. | 147 // block needs to be removed. |
| 147 DCHECK(!frame->delegated_frame_data); | 148 DCHECK(!frame->delegated_frame_data); |
| 148 | 149 |
| 149 base::Closure closure = | 150 base::Closure closure = |
| 150 base::Bind(&CompositorOutputSurface::ShortcutSwapAck, | 151 base::Bind(&CompositorOutputSurface::ShortcutSwapAck, |
| 151 weak_ptrs_.GetWeakPtr(), | 152 weak_ptrs_.GetWeakPtr(), |
| 152 output_surface_id_, | 153 output_surface_id_, |
| 153 base::Passed(&frame->gl_frame_data), | 154 base::Passed(&frame->gl_frame_data), |
| 154 base::Passed(&frame->software_frame_data)); | 155 base::Passed(&frame->software_frame_data)); |
| 155 | 156 |
| 156 if (context_provider()) { | 157 if (context_provider()) { |
| 157 gpu::gles2::GLES2Interface* context = context_provider()->ContextGL(); | 158 gpu::gles2::GLES2Interface* context = context_provider()->ContextGL(); |
| 158 context->Flush(); | 159 context->Flush(); |
| 159 uint32 sync_point = context->InsertSyncPointCHROMIUM(); | 160 uint32 sync_point = context->InsertSyncPointCHROMIUM(); |
| 160 context_provider()->ContextSupport()->SignalSyncPoint(sync_point, | 161 context_provider()->ContextSupport()->SignalSyncPoint(sync_point, |
| 161 closure); | 162 closure); |
| 162 } else { | 163 } else { |
| 163 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); | 164 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); |
| 164 } | 165 } |
| 165 client_->DidSwapBuffers(); | 166 client_->DidSwapBuffers(); |
| 166 return; | 167 return; |
| 167 } | 168 } else { |
| 168 | |
| 169 if (use_swap_compositor_frame_message_) { | |
| 170 { | 169 { |
| 171 ScopedVector<IPC::Message> messages; | 170 ScopedVector<IPC::Message> messages; |
| 172 std::vector<IPC::Message> messages_to_deliver_with_frame; | 171 std::vector<IPC::Message> messages_to_deliver_with_frame; |
| 173 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = | 172 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = |
| 174 frame_swap_message_queue_->AcquireSendMessageScope(); | 173 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 175 frame_swap_message_queue_->DrainMessages(&messages); | 174 frame_swap_message_queue_->DrainMessages(&messages); |
| 176 FrameSwapMessageQueue::TransferMessages(messages, | 175 FrameSwapMessageQueue::TransferMessages(messages, |
| 177 &messages_to_deliver_with_frame); | 176 &messages_to_deliver_with_frame); |
| 178 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, | 177 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, |
| 179 output_surface_id_, | 178 output_surface_id_, |
| 180 *frame, | 179 *frame, |
| 181 messages_to_deliver_with_frame)); | 180 messages_to_deliver_with_frame)); |
| 182 // ~send_message_scope. | 181 // ~send_message_scope. |
| 183 } | 182 } |
| 184 client_->DidSwapBuffers(); | 183 client_->DidSwapBuffers(); |
| 185 return; | |
| 186 } | 184 } |
| 187 | |
| 188 if (frame->gl_frame_data) { | |
| 189 ContextProviderCommandBuffer* provider_command_buffer = | |
| 190 static_cast<ContextProviderCommandBuffer*>(context_provider()); | |
| 191 CommandBufferProxyImpl* command_buffer_proxy = | |
| 192 provider_command_buffer->GetCommandBufferProxy(); | |
| 193 DCHECK(command_buffer_proxy); | |
| 194 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); | |
| 195 } | |
| 196 | |
| 197 OutputSurface::SwapBuffers(frame); | |
| 198 } | 185 } |
| 199 | 186 |
| 200 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 187 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 201 DCHECK(CalledOnValidThread()); | 188 DCHECK(CalledOnValidThread()); |
| 202 if (!HasClient()) | 189 if (!HasClient()) |
| 203 return; | 190 return; |
| 204 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 191 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 205 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 192 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 206 OnUpdateVSyncParametersFromBrowser); | 193 OnUpdateVSyncParametersFromBrowser); |
| 207 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 194 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // If this is the last surface to stop preferring smoothness, | 277 // If this is the last surface to stop preferring smoothness, |
| 291 // Reset the main thread's priority to the default. | 278 // Reset the main thread's priority to the default. |
| 292 if (prefers_smoothness_ == true && | 279 if (prefers_smoothness_ == true && |
| 293 --g_prefer_smoothness_count == 0) { | 280 --g_prefer_smoothness_count == 0) { |
| 294 SetThreadPriorityToDefault(main_thread_handle_); | 281 SetThreadPriorityToDefault(main_thread_handle_); |
| 295 } | 282 } |
| 296 prefers_smoothness_ = prefers_smoothness; | 283 prefers_smoothness_ = prefers_smoothness; |
| 297 } | 284 } |
| 298 | 285 |
| 299 } // namespace content | 286 } // namespace content |
| OLD | NEW |