| 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/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "cc/compositor_frame.h" |
| 8 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| 11 #include "content/public/common/content_switches.h" |
| 9 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
| 10 #include "ipc/ipc_forwarding_message_filter.h" | 13 #include "ipc/ipc_forwarding_message_filter.h" |
| 11 #include "ipc/ipc_sync_channel.h" | 14 #include "ipc/ipc_sync_channel.h" |
| 15 #include "ipc/ipc_sync_message_filter.h" |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput
SurfaceClient.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput
SurfaceClient.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 14 | 18 |
| 15 using WebKit::WebGraphicsContext3D; | 19 using WebKit::WebGraphicsContext3D; |
| 16 using WebKit::WebCompositorSoftwareOutputDevice; | 20 using WebKit::WebCompositorSoftwareOutputDevice; |
| 17 | 21 |
| 18 //------------------------------------------------------------------------------ | 22 //------------------------------------------------------------------------------ |
| 19 | 23 |
| 20 // static | 24 // static |
| 21 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 25 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
| 22 base::TaskRunner* target_task_runner) | 26 base::TaskRunner* target_task_runner) |
| 23 { | 27 { |
| 24 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 28 uint32 messages_to_filter[] = { |
| 29 ViewMsg_UpdateVSyncParameters::ID, |
| 30 ViewMsg_SwapCompositorFrameACK::ID, |
| 31 }; |
| 25 return new IPC::ForwardingMessageFilter( | 32 return new IPC::ForwardingMessageFilter( |
| 26 messages_to_filter, arraysize(messages_to_filter), | 33 messages_to_filter, arraysize(messages_to_filter), |
| 27 target_task_runner); | 34 target_task_runner); |
| 28 } | 35 } |
| 29 | 36 |
| 30 CompositorOutputSurface::CompositorOutputSurface( | 37 CompositorOutputSurface::CompositorOutputSurface( |
| 31 int32 routing_id, | 38 int32 routing_id, |
| 32 WebGraphicsContext3D* context3D, | 39 WebGraphicsContext3D* context3D, |
| 33 WebCompositorSoftwareOutputDevice* software_device) | 40 WebCompositorSoftwareOutputDevice* software_device) |
| 34 : output_surface_filter_( | 41 : output_surface_filter_( |
| 35 RenderThreadImpl::current()->compositor_output_surface_filter()), | 42 RenderThreadImpl::current()->compositor_output_surface_filter()), |
| 36 client_(NULL), | 43 client_(NULL), |
| 37 routing_id_(routing_id), | 44 routing_id_(routing_id), |
| 38 context3D_(context3D), | 45 context3D_(context3D), |
| 39 software_device_(software_device) { | 46 software_device_(software_device) { |
| 40 DCHECK(output_surface_filter_); | 47 DCHECK(output_surface_filter_); |
| 41 capabilities_.hasParentCompositor = false; | 48 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 49 capabilities_.hasParentCompositor = command_line->HasSwitch( |
| 50 switches::kEnableDelegatedRenderer); |
| 42 DetachFromThread(); | 51 DetachFromThread(); |
| 43 } | 52 } |
| 44 | 53 |
| 45 CompositorOutputSurface::~CompositorOutputSurface() { | 54 CompositorOutputSurface::~CompositorOutputSurface() { |
| 46 DCHECK(CalledOnValidThread()); | 55 DCHECK(CalledOnValidThread()); |
| 47 if (!client_) | 56 if (!client_) |
| 48 return; | 57 return; |
| 49 output_surface_proxy_->ClearOutputSurface(); | 58 output_surface_proxy_->ClearOutputSurface(); |
| 50 output_surface_filter_->RemoveRoute(routing_id_); | 59 output_surface_filter_->RemoveRoute(routing_id_); |
| 51 } | 60 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
| 81 return context3D_.get(); | 90 return context3D_.get(); |
| 82 } | 91 } |
| 83 | 92 |
| 84 WebCompositorSoftwareOutputDevice* CompositorOutputSurface::softwareDevice() | 93 WebCompositorSoftwareOutputDevice* CompositorOutputSurface::softwareDevice() |
| 85 const { | 94 const { |
| 86 return software_device_.get(); | 95 return software_device_.get(); |
| 87 } | 96 } |
| 88 | 97 |
| 89 void CompositorOutputSurface::sendFrameToParentCompositor( | 98 void CompositorOutputSurface::sendFrameToParentCompositor( |
| 90 const WebKit::WebCompositorFrame&) { | 99 const WebKit::WebCompositorFrame& webFrame) { |
| 91 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
| 92 NOTREACHED(); | 101 const cc::CompositorFrame& frame = |
| 102 static_cast<const cc::CompositorFrame&>(webFrame); |
| 103 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, frame)); |
| 93 } | 104 } |
| 94 | 105 |
| 95 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 106 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| 96 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
| 97 if (!client_) | 108 if (!client_) |
| 98 return; | 109 return; |
| 99 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 110 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| 100 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 111 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
| 112 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameACK, OnSwapCompositorFrameACK
); |
| 101 IPC_END_MESSAGE_MAP() | 113 IPC_END_MESSAGE_MAP() |
| 102 } | 114 } |
| 103 | 115 |
| 104 void CompositorOutputSurface::OnUpdateVSyncParameters( | 116 void CompositorOutputSurface::OnUpdateVSyncParameters( |
| 105 base::TimeTicks timebase, | 117 base::TimeTicks timebase, |
| 106 base::TimeDelta interval) { | 118 base::TimeDelta interval) { |
| 107 DCHECK(CalledOnValidThread()); | 119 DCHECK(CalledOnValidThread()); |
| 108 DCHECK(client_); | 120 DCHECK(client_); |
| 109 double monotonicTimebase = timebase.ToInternalValue() / | 121 double monotonicTimebase = timebase.ToInternalValue() / |
| 110 static_cast<double>(base::Time::kMicrosecondsPerSecond); | 122 static_cast<double>(base::Time::kMicrosecondsPerSecond); |
| 111 double intervalInSeconds = interval.ToInternalValue() / | 123 double intervalInSeconds = interval.ToInternalValue() / |
| 112 static_cast<double>(base::Time::kMicrosecondsPerSecond); | 124 static_cast<double>(base::Time::kMicrosecondsPerSecond); |
| 113 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); | 125 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); |
| 114 } | 126 } |
| 127 |
| 128 void CompositorOutputSurface::OnSwapCompositorFrameACK( |
| 129 const WebKit::WebCompositorFrameAck& ack) { |
| 130 client_->onSendFrameToParentCompositorAck(ack); |
| 131 } |
| 132 |
| 133 bool CompositorOutputSurface::Send(IPC::Message* message) { |
| 134 return ChildThread::current()->sync_message_filter()->Send(message); |
| 135 } |
| OLD | NEW |