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