| 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/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "cc/compositor_frame.h" | 8 #include "cc/compositor_frame.h" |
| 9 #include "cc/output_surface_client.h" | 9 #include "cc/output_surface_client.h" |
| 10 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 10 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
| 11 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
| 12 #include "ipc/ipc_forwarding_message_filter.h" | 13 #include "ipc/ipc_forwarding_message_filter.h" |
| 13 #include "ipc/ipc_sync_channel.h" | 14 #include "ipc/ipc_sync_channel.h" |
| 14 #include "ipc/ipc_sync_message_filter.h" | 15 #include "ipc/ipc_sync_message_filter.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 16 | 17 |
| 17 using cc::CompositorFrame; | 18 using cc::CompositorFrame; |
| 18 using cc::SoftwareOutputDevice; | 19 using cc::SoftwareOutputDevice; |
| 19 using WebKit::WebGraphicsContext3D; | 20 using WebKit::WebGraphicsContext3D; |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 23 //------------------------------------------------------------------------------ | 24 //------------------------------------------------------------------------------ |
| 24 | 25 |
| 25 // static | 26 // static |
| 26 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 27 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
| 27 base::TaskRunner* target_task_runner) | 28 base::TaskRunner* target_task_runner) |
| 28 { | 29 { |
| 29 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 30 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; |
| 30 return new IPC::ForwardingMessageFilter( | 31 return new IPC::ForwardingMessageFilter( |
| 31 messages_to_filter, arraysize(messages_to_filter), | 32 messages_to_filter, arraysize(messages_to_filter), |
| 32 target_task_runner); | 33 target_task_runner); |
| 33 } | 34 } |
| 34 | 35 |
| 35 CompositorOutputSurface::CompositorOutputSurface( | 36 CompositorOutputSurface::CompositorOutputSurface( |
| 36 int32 routing_id, | 37 int32 routing_id, |
| 37 WebGraphicsContext3D* context3D, | 38 WebGraphicsContext3D* context3D, |
| 39 CommandBufferProxyImpl* command_buffer_proxy, |
| 38 cc::SoftwareOutputDevice* software_device) | 40 cc::SoftwareOutputDevice* software_device) |
| 39 : output_surface_filter_( | 41 : output_surface_filter_( |
| 40 RenderThreadImpl::current()->compositor_output_surface_filter()), | 42 RenderThreadImpl::current()->compositor_output_surface_filter()), |
| 41 client_(NULL), | 43 client_(NULL), |
| 42 routing_id_(routing_id), | 44 routing_id_(routing_id), |
| 43 context3D_(context3D), | 45 context3D_(context3D), |
| 44 software_device_(software_device) { | 46 software_device_(software_device), |
| 47 command_buffer_proxy_(command_buffer_proxy) { |
| 45 DCHECK(output_surface_filter_); | 48 DCHECK(output_surface_filter_); |
| 46 capabilities_.has_parent_compositor = false; | 49 capabilities_.has_parent_compositor = false; |
| 47 DetachFromThread(); | 50 DetachFromThread(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 CompositorOutputSurface::~CompositorOutputSurface() { | 53 CompositorOutputSurface::~CompositorOutputSurface() { |
| 51 DCHECK(CalledOnValidThread()); | 54 DCHECK(CalledOnValidThread()); |
| 52 if (!client_) | 55 if (!client_) |
| 53 return; | 56 return; |
| 54 output_surface_proxy_->ClearOutputSurface(); | 57 output_surface_proxy_->ClearOutputSurface(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 } | 74 } |
| 72 | 75 |
| 73 client_ = client; | 76 client_ = client; |
| 74 | 77 |
| 75 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); | 78 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); |
| 76 output_surface_filter_->AddRoute( | 79 output_surface_filter_->AddRoute( |
| 77 routing_id_, | 80 routing_id_, |
| 78 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, | 81 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, |
| 79 output_surface_proxy_)); | 82 output_surface_proxy_)); |
| 80 | 83 |
| 84 if (command_buffer_proxy_) |
| 85 command_buffer_proxy_->SetLatencyInfoCallback( |
| 86 base::Bind(&CompositorOutputSurface::OnReceivedLatencyInfo, |
| 87 base::Unretained(this))); |
| 88 |
| 81 return true; | 89 return true; |
| 82 } | 90 } |
| 83 | 91 |
| 84 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { | 92 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { |
| 85 DCHECK(CalledOnValidThread()); | 93 DCHECK(CalledOnValidThread()); |
| 86 return context3D_.get(); | 94 return context3D_.get(); |
| 87 } | 95 } |
| 88 | 96 |
| 89 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { | 97 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { |
| 90 return software_device_.get(); | 98 return software_device_.get(); |
| 91 } | 99 } |
| 92 | 100 |
| 93 void CompositorOutputSurface::SendFrameToParentCompositor( | 101 void CompositorOutputSurface::SendFrameToParentCompositor( |
| 94 const cc::CompositorFrame& frame) { | 102 const cc::CompositorFrame& frame) { |
| 95 DCHECK(CalledOnValidThread()); | 103 DCHECK(CalledOnValidThread()); |
| 96 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, frame)); | 104 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, frame)); |
| 97 } | 105 } |
| 98 | 106 |
| 107 void CompositorOutputSurface::SetLatencyInfo( |
| 108 const cc::LatencyInfo& latency_info) { |
| 109 if (command_buffer_proxy_) |
| 110 command_buffer_proxy_->SetLatencyInfo(latency_info); |
| 111 } |
| 112 |
| 113 void CompositorOutputSurface::OnReceivedLatencyInfo( |
| 114 const cc::LatencyInfo& latency_info) { |
| 115 DCHECK(CalledOnValidThread()); |
| 116 DCHECK(client_); |
| 117 client_->OnReceivedLatencyInfo(latency_info); |
| 118 } |
| 119 |
| 99 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 120 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 100 DCHECK(CalledOnValidThread()); | 121 DCHECK(CalledOnValidThread()); |
| 101 if (!client_) | 122 if (!client_) |
| 102 return; | 123 return; |
| 103 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 124 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 104 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 125 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
| 105 IPC_END_MESSAGE_MAP() | 126 IPC_END_MESSAGE_MAP() |
| 106 } | 127 } |
| 107 | 128 |
| 108 void CompositorOutputSurface::OnUpdateVSyncParameters( | 129 void CompositorOutputSurface::OnUpdateVSyncParameters( |
| 109 base::TimeTicks timebase, base::TimeDelta interval) { | 130 base::TimeTicks timebase, base::TimeDelta interval) { |
| 110 DCHECK(CalledOnValidThread()); | 131 DCHECK(CalledOnValidThread()); |
| 111 DCHECK(client_); | 132 DCHECK(client_); |
| 112 client_->OnVSyncParametersChanged(timebase, interval); | 133 client_->OnVSyncParametersChanged(timebase, interval); |
| 113 } | 134 } |
| 114 | 135 |
| 115 bool CompositorOutputSurface::Send(IPC::Message* message) { | 136 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 116 return ChildThread::current()->sync_message_filter()->Send(message); | 137 return ChildThread::current()->sync_message_filter()->Send(message); |
| 117 } | 138 } |
| 118 | 139 |
| 119 } // namespace content | 140 } // namespace content |
| OLD | NEW |