| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "cc/output/compositor_frame.h" | 14 #include "cc/output/compositor_frame.h" |
| 15 #include "cc/output/compositor_frame_ack.h" | |
| 16 #include "cc/output/managed_memory_policy.h" | 15 #include "cc/output/managed_memory_policy.h" |
| 17 #include "cc/output/output_surface_client.h" | 16 #include "cc/output/output_surface_client.h" |
| 18 #include "content/common/gpu/client/context_provider_command_buffer.h" | 17 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 19 #include "content/common/view_messages.h" | 18 #include "content/common/view_messages.h" |
| 20 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 21 #include "content/renderer/gpu/frame_swap_message_queue.h" | 20 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 22 #include "content/renderer/render_thread_impl.h" | 21 #include "content/renderer/render_thread_impl.h" |
| 23 #include "gpu/command_buffer/client/context_support.h" | 22 #include "gpu/command_buffer/client/context_support.h" |
| 24 #include "gpu/command_buffer/client/gles2_interface.h" | 23 #include "gpu/command_buffer/client/gles2_interface.h" |
| 25 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 24 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return 0; | 130 return 0; |
| 132 } | 131 } |
| 133 | 132 |
| 134 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 133 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 135 DCHECK(client_thread_checker_.CalledOnValidThread()); | 134 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| 136 if (!HasClient()) | 135 if (!HasClient()) |
| 137 return; | 136 return; |
| 138 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 137 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 139 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 138 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 140 OnUpdateVSyncParametersFromBrowser); | 139 OnUpdateVSyncParametersFromBrowser); |
| 141 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 140 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, |
| 142 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); | 141 OnReclaimCompositorResources); |
| 143 IPC_END_MESSAGE_MAP() | 142 IPC_END_MESSAGE_MAP() |
| 144 } | 143 } |
| 145 | 144 |
| 146 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( | 145 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( |
| 147 base::TimeTicks timebase, | 146 base::TimeTicks timebase, |
| 148 base::TimeDelta interval) { | 147 base::TimeDelta interval) { |
| 149 DCHECK(client_thread_checker_.CalledOnValidThread()); | 148 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| 150 TRACE_EVENT2("cc", | 149 TRACE_EVENT2("cc", |
| 151 "CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser", | 150 "CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser", |
| 152 "timebase", (timebase - base::TimeTicks()).InSecondsF(), | 151 "timebase", (timebase - base::TimeTicks()).InSecondsF(), |
| 153 "interval", interval.InSecondsF()); | 152 "interval", interval.InSecondsF()); |
| 154 client_->CommitVSyncParameters(timebase, interval); | 153 client_->CommitVSyncParameters(timebase, interval); |
| 155 } | 154 } |
| 156 | 155 |
| 157 void CompositorOutputSurface::OnSwapAck(uint32_t output_surface_id, | 156 void CompositorOutputSurface::OnReclaimCompositorResources( |
| 158 const cc::CompositorFrameAck& ack) { | 157 uint32_t output_surface_id, |
| 158 bool is_swap_ack, |
| 159 const cc::ReturnedResourceArray& resources) { |
| 159 // Ignore message if it's a stale one coming from a different output surface | 160 // Ignore message if it's a stale one coming from a different output surface |
| 160 // (e.g. after a lost context). | 161 // (e.g. after a lost context). |
| 161 if (output_surface_id != output_surface_id_) | 162 if (output_surface_id != output_surface_id_) |
| 162 return; | 163 return; |
| 163 ReclaimResources(&ack); | 164 ReclaimResources(resources); |
| 164 client_->DidSwapBuffersComplete(); | 165 if (is_swap_ack) |
| 165 } | 166 client_->DidSwapBuffersComplete(); |
| 166 | |
| 167 void CompositorOutputSurface::OnReclaimResources( | |
| 168 uint32_t output_surface_id, | |
| 169 const cc::CompositorFrameAck& ack) { | |
| 170 // Ignore message if it's a stale one coming from a different output surface | |
| 171 // (e.g. after a lost context). | |
| 172 if (output_surface_id != output_surface_id_) | |
| 173 return; | |
| 174 ReclaimResources(&ack); | |
| 175 } | 167 } |
| 176 | 168 |
| 177 bool CompositorOutputSurface::Send(IPC::Message* message) { | 169 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 178 return message_sender_->Send(message); | 170 return message_sender_->Send(message); |
| 179 } | 171 } |
| 180 | 172 |
| 181 } // namespace content | 173 } // namespace content |
| OLD | NEW |