| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #endif | 42 #endif |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 return new IPC::ForwardingMessageFilter( | 45 return new IPC::ForwardingMessageFilter( |
| 46 messages_to_filter, arraysize(messages_to_filter), | 46 messages_to_filter, arraysize(messages_to_filter), |
| 47 target_task_runner); | 47 target_task_runner); |
| 48 } | 48 } |
| 49 | 49 |
| 50 CompositorOutputSurface::CompositorOutputSurface( | 50 CompositorOutputSurface::CompositorOutputSurface( |
| 51 int32 routing_id, | 51 int32 routing_id, |
| 52 uint32 output_surface_id, |
| 52 WebGraphicsContext3DCommandBufferImpl* context3D, | 53 WebGraphicsContext3DCommandBufferImpl* context3D, |
| 53 cc::SoftwareOutputDevice* software_device, | 54 cc::SoftwareOutputDevice* software_device, |
| 54 bool use_swap_compositor_frame_message) | 55 bool use_swap_compositor_frame_message) |
| 55 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context3D), | 56 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context3D), |
| 56 make_scoped_ptr(software_device)), | 57 make_scoped_ptr(software_device)), |
| 58 output_surface_id_(output_surface_id), |
| 57 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), | 59 use_swap_compositor_frame_message_(use_swap_compositor_frame_message), |
| 58 output_surface_filter_( | 60 output_surface_filter_( |
| 59 RenderThreadImpl::current()->compositor_output_surface_filter()), | 61 RenderThreadImpl::current()->compositor_output_surface_filter()), |
| 60 routing_id_(routing_id), | 62 routing_id_(routing_id), |
| 61 prefers_smoothness_(false), | 63 prefers_smoothness_(false), |
| 62 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
| 63 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. | 65 // TODO(epenner): Implement PlatformThread::CurrentHandle() on windows. |
| 64 main_thread_handle_(base::PlatformThreadHandle()) | 66 main_thread_handle_(base::PlatformThreadHandle()) |
| 65 #else | 67 #else |
| 66 main_thread_handle_(base::PlatformThread::CurrentHandle()) | 68 main_thread_handle_(base::PlatformThread::CurrentHandle()) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 output_surface_filter_->AddRoute( | 96 output_surface_filter_->AddRoute( |
| 95 routing_id_, | 97 routing_id_, |
| 96 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, | 98 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, |
| 97 output_surface_proxy_)); | 99 output_surface_proxy_)); |
| 98 | 100 |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 | 103 |
| 102 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 104 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| 103 if (use_swap_compositor_frame_message_) { | 105 if (use_swap_compositor_frame_message_) { |
| 104 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); | 106 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, |
| 107 output_surface_id_, |
| 108 *frame)); |
| 105 DidSwapBuffers(); | 109 DidSwapBuffers(); |
| 106 return; | 110 return; |
| 107 } | 111 } |
| 108 | 112 |
| 109 if (frame->gl_frame_data) { | 113 if (frame->gl_frame_data) { |
| 110 WebGraphicsContext3DCommandBufferImpl* command_buffer = | 114 WebGraphicsContext3DCommandBufferImpl* command_buffer = |
| 111 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); | 115 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); |
| 112 CommandBufferProxyImpl* command_buffer_proxy = | 116 CommandBufferProxyImpl* command_buffer_proxy = |
| 113 command_buffer->GetCommandBufferProxy(); | 117 command_buffer->GetCommandBufferProxy(); |
| 114 DCHECK(command_buffer_proxy); | 118 DCHECK(command_buffer_proxy); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 145 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); | 149 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); |
| 146 OutputSurface::SetNeedsBeginFrame(enable); | 150 OutputSurface::SetNeedsBeginFrame(enable); |
| 147 } | 151 } |
| 148 | 152 |
| 149 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { | 153 void CompositorOutputSurface::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| 150 DCHECK(CalledOnValidThread()); | 154 DCHECK(CalledOnValidThread()); |
| 151 BeginFrame(args); | 155 BeginFrame(args); |
| 152 } | 156 } |
| 153 #endif // defined(OS_ANDROID) | 157 #endif // defined(OS_ANDROID) |
| 154 | 158 |
| 155 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { | 159 void CompositorOutputSurface::OnSwapAck(uint32 output_surface_id, |
| 160 const cc::CompositorFrameAck& ack) { |
| 161 // Ignore message if it's a stale one coming from a different output surface |
| 162 // (e.g. after a lost context). |
| 163 if (output_surface_id != output_surface_id_) |
| 164 return; |
| 156 OnSwapBuffersComplete(&ack); | 165 OnSwapBuffersComplete(&ack); |
| 157 } | 166 } |
| 158 | 167 |
| 159 bool CompositorOutputSurface::Send(IPC::Message* message) { | 168 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 160 return message_sender_->Send(message); | 169 return message_sender_->Send(message); |
| 161 } | 170 } |
| 162 | 171 |
| 163 namespace { | 172 namespace { |
| 164 #if defined(OS_ANDROID) | 173 #if defined(OS_ANDROID) |
| 165 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) { | 174 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 195 // If this is the last surface to stop preferring smoothness, | 204 // If this is the last surface to stop preferring smoothness, |
| 196 // Reset the main thread's priority to the default. | 205 // Reset the main thread's priority to the default. |
| 197 if (prefers_smoothness_ == true && | 206 if (prefers_smoothness_ == true && |
| 198 --g_prefer_smoothness_count == 0) { | 207 --g_prefer_smoothness_count == 0) { |
| 199 SetThreadPriorityToDefault(main_thread_handle_); | 208 SetThreadPriorityToDefault(main_thread_handle_); |
| 200 } | 209 } |
| 201 prefers_smoothness_ = prefers_smoothness; | 210 prefers_smoothness_ = prefers_smoothness; |
| 202 } | 211 } |
| 203 | 212 |
| 204 } // namespace content | 213 } // namespace content |
| OLD | NEW |