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/output_surface_client.h" |
8 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
9 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
10 #include "ipc/ipc_forwarding_message_filter.h" | 11 #include "ipc/ipc_forwarding_message_filter.h" |
11 #include "ipc/ipc_sync_channel.h" | 12 #include "ipc/ipc_sync_channel.h" |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput
SurfaceClient.h" | |
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
14 | 14 |
| 15 using cc::SoftwareOutputDevice; |
15 using WebKit::WebGraphicsContext3D; | 16 using WebKit::WebGraphicsContext3D; |
16 using WebKit::WebCompositorSoftwareOutputDevice; | |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 //------------------------------------------------------------------------------ | 20 //------------------------------------------------------------------------------ |
21 | 21 |
22 // static | 22 // static |
23 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 23 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
24 base::TaskRunner* target_task_runner) | 24 base::TaskRunner* target_task_runner) |
25 { | 25 { |
26 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 26 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; |
27 return new IPC::ForwardingMessageFilter( | 27 return new IPC::ForwardingMessageFilter( |
28 messages_to_filter, arraysize(messages_to_filter), | 28 messages_to_filter, arraysize(messages_to_filter), |
29 target_task_runner); | 29 target_task_runner); |
30 } | 30 } |
31 | 31 |
32 CompositorOutputSurface::CompositorOutputSurface( | 32 CompositorOutputSurface::CompositorOutputSurface( |
33 int32 routing_id, | 33 int32 routing_id, |
34 WebGraphicsContext3D* context3D, | 34 WebGraphicsContext3D* context3D, |
35 WebCompositorSoftwareOutputDevice* software_device) | 35 cc::SoftwareOutputDevice* software_device) |
36 : output_surface_filter_( | 36 : output_surface_filter_( |
37 RenderThreadImpl::current()->compositor_output_surface_filter()), | 37 RenderThreadImpl::current()->compositor_output_surface_filter()), |
38 client_(NULL), | 38 client_(NULL), |
39 routing_id_(routing_id), | 39 routing_id_(routing_id), |
40 context3D_(context3D), | 40 context3D_(context3D), |
41 software_device_(software_device) { | 41 software_device_(software_device) { |
42 DCHECK(output_surface_filter_); | 42 DCHECK(output_surface_filter_); |
43 capabilities_.hasParentCompositor = false; | 43 capabilities_.has_parent_compositor = false; |
44 DetachFromThread(); | 44 DetachFromThread(); |
45 } | 45 } |
46 | 46 |
47 CompositorOutputSurface::~CompositorOutputSurface() { | 47 CompositorOutputSurface::~CompositorOutputSurface() { |
48 DCHECK(CalledOnValidThread()); | 48 DCHECK(CalledOnValidThread()); |
49 if (!client_) | 49 if (!client_) |
50 return; | 50 return; |
51 output_surface_proxy_->ClearOutputSurface(); | 51 output_surface_proxy_->ClearOutputSurface(); |
52 output_surface_filter_->RemoveRoute(routing_id_); | 52 output_surface_filter_->RemoveRoute(routing_id_); |
53 } | 53 } |
54 | 54 |
55 const WebKit::WebCompositorOutputSurface::Capabilities& | 55 const struct cc::OutputSurface::Capabilities& |
56 CompositorOutputSurface::capabilities() const { | 56 CompositorOutputSurface::Capabilities() const { |
57 DCHECK(CalledOnValidThread()); | 57 DCHECK(CalledOnValidThread()); |
58 return capabilities_; | 58 return capabilities_; |
59 } | 59 } |
60 | 60 |
61 bool CompositorOutputSurface::bindToClient( | 61 bool CompositorOutputSurface::BindToClient( |
62 WebKit::WebCompositorOutputSurfaceClient* client) { | 62 cc::OutputSurfaceClient* client) { |
63 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
64 DCHECK(!client_); | 64 DCHECK(!client_); |
65 if (context3D_.get()) { | 65 if (context3D_.get()) { |
66 if (!context3D_->makeContextCurrent()) | 66 if (!context3D_->makeContextCurrent()) |
67 return false; | 67 return false; |
68 } | 68 } |
69 | 69 |
70 client_ = client; | 70 client_ = client; |
71 | 71 |
72 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); | 72 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); |
73 output_surface_filter_->AddRoute( | 73 output_surface_filter_->AddRoute( |
74 routing_id_, | 74 routing_id_, |
75 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, | 75 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, |
76 output_surface_proxy_)); | 76 output_surface_proxy_)); |
77 | 77 |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 WebGraphicsContext3D* CompositorOutputSurface::context3D() const { | 81 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { |
82 DCHECK(CalledOnValidThread()); | 82 DCHECK(CalledOnValidThread()); |
83 return context3D_.get(); | 83 return context3D_.get(); |
84 } | 84 } |
85 | 85 |
86 WebCompositorSoftwareOutputDevice* CompositorOutputSurface::softwareDevice() | 86 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { |
87 const { | |
88 return software_device_.get(); | 87 return software_device_.get(); |
89 } | 88 } |
90 | 89 |
91 void CompositorOutputSurface::sendFrameToParentCompositor( | 90 void CompositorOutputSurface::SendFrameToParentCompositor( |
92 const WebKit::WebCompositorFrame&) { | 91 const cc::CompositorFrame&) { |
93 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
94 NOTREACHED(); | 93 NOTREACHED(); |
95 } | 94 } |
96 | 95 |
97 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 96 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
98 DCHECK(CalledOnValidThread()); | 97 DCHECK(CalledOnValidThread()); |
99 if (!client_) | 98 if (!client_) |
100 return; | 99 return; |
101 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 100 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
102 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 101 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
103 IPC_END_MESSAGE_MAP() | 102 IPC_END_MESSAGE_MAP() |
104 } | 103 } |
105 | 104 |
106 void CompositorOutputSurface::OnUpdateVSyncParameters( | 105 void CompositorOutputSurface::OnUpdateVSyncParameters( |
107 base::TimeTicks timebase, | 106 base::TimeTicks timebase, base::TimeDelta interval) { |
108 base::TimeDelta interval) { | |
109 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
110 DCHECK(client_); | 108 DCHECK(client_); |
111 double monotonicTimebase = timebase.ToInternalValue() / | 109 client_->OnVSyncParametersChanged(timebase, interval); |
112 static_cast<double>(base::Time::kMicrosecondsPerSecond); | |
113 double intervalInSeconds = interval.ToInternalValue() / | |
114 static_cast<double>(base::Time::kMicrosecondsPerSecond); | |
115 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); | |
116 } | 110 } |
117 | 111 |
118 } // namespace content | 112 } // namespace content |
OLD | NEW |