| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return 0; | 131 return 0; |
| 133 } | 132 } |
| 134 | 133 |
| 135 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 134 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 136 DCHECK(client_thread_checker_.CalledOnValidThread()); | 135 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| 137 if (!HasClient()) | 136 if (!HasClient()) |
| 138 return; | 137 return; |
| 139 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 138 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 140 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, | 139 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, |
| 141 OnUpdateVSyncParametersFromBrowser); | 140 OnUpdateVSyncParametersFromBrowser); |
| 142 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); | 141 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, |
| 143 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, OnReclaimResources); | 142 OnReclaimCompositorResources); |
| 144 IPC_END_MESSAGE_MAP() | 143 IPC_END_MESSAGE_MAP() |
| 145 } | 144 } |
| 146 | 145 |
| 147 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( | 146 void CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser( |
| 148 base::TimeTicks timebase, | 147 base::TimeTicks timebase, |
| 149 base::TimeDelta interval) { | 148 base::TimeDelta interval) { |
| 150 DCHECK(client_thread_checker_.CalledOnValidThread()); | 149 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| 151 TRACE_EVENT2("cc", | 150 TRACE_EVENT2("cc", |
| 152 "CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser", | 151 "CompositorOutputSurface::OnUpdateVSyncParametersFromBrowser", |
| 153 "timebase", (timebase - base::TimeTicks()).InSecondsF(), | 152 "timebase", (timebase - base::TimeTicks()).InSecondsF(), |
| 154 "interval", interval.InSecondsF()); | 153 "interval", interval.InSecondsF()); |
| 155 client_->CommitVSyncParameters(timebase, interval); | 154 client_->CommitVSyncParameters(timebase, interval); |
| 156 } | 155 } |
| 157 | 156 |
| 158 void CompositorOutputSurface::OnSwapAck(uint32_t output_surface_id, | 157 void CompositorOutputSurface::OnReclaimCompositorResources( |
| 159 const cc::CompositorFrameAck& ack) { | 158 uint32_t output_surface_id, |
| 159 bool is_swap_ack, |
| 160 const cc::ReturnedResourceArray& resources) { |
| 160 // Ignore message if it's a stale one coming from a different output surface | 161 // Ignore message if it's a stale one coming from a different output surface |
| 161 // (e.g. after a lost context). | 162 // (e.g. after a lost context). |
| 162 if (output_surface_id != output_surface_id_) | 163 if (output_surface_id != output_surface_id_) |
| 163 return; | 164 return; |
| 164 ReclaimResources(&ack); | 165 ReclaimResources(resources); |
| 165 client_->DidSwapBuffersComplete(); | 166 if (is_swap_ack) |
| 166 } | 167 client_->DidSwapBuffersComplete(); |
| 167 | |
| 168 void CompositorOutputSurface::OnReclaimResources( | |
| 169 uint32_t output_surface_id, | |
| 170 const cc::CompositorFrameAck& ack) { | |
| 171 // Ignore message if it's a stale one coming from a different output surface | |
| 172 // (e.g. after a lost context). | |
| 173 if (output_surface_id != output_surface_id_) | |
| 174 return; | |
| 175 ReclaimResources(&ack); | |
| 176 } | 168 } |
| 177 | 169 |
| 178 bool CompositorOutputSurface::Send(IPC::Message* message) { | 170 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 179 return message_sender_->Send(message); | 171 return message_sender_->Send(message); |
| 180 } | 172 } |
| 181 | 173 |
| 182 } // namespace content | 174 } // namespace content |
| OLD | NEW |