OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/gpu/compositor_output_surface.h" | |
6 | |
7 #include "base/message_loop_proxy.h" | |
8 #include "content/common/view_messages.h" | |
9 #include "content/renderer/render_thread_impl.h" | |
10 #include "ipc/ipc_forwarding_message_filter.h" | |
11 #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" | |
14 | |
15 using WebKit::WebGraphicsContext3D; | |
16 | |
17 //------------------------------------------------------------------------------ | |
18 | |
19 // static | |
20 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | |
21 base::TaskRunner* target_task_runner) | |
22 { | |
23 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | |
24 return new IPC::ForwardingMessageFilter( | |
25 messages_to_filter, arraysize(messages_to_filter), | |
26 target_task_runner); | |
27 } | |
28 | |
29 CompositorOutputSurface::CompositorOutputSurface( | |
30 int32 routing_id, | |
31 WebGraphicsContext3D* context3D) | |
32 : output_surface_filter_( | |
33 RenderThreadImpl::current()->compositor_output_surface_filter()) | |
34 , client_(NULL) | |
piman
2012/08/08 16:47:43
nit: initializer style
Class::Class(...)
: ini
| |
35 , routing_id_(routing_id) | |
36 , context3D_(context3D) { | |
37 capabilities_.hasParentCompositor = false; | |
piman
2012/08/08 16:47:43
Could you add a DCHECK(output_surface_filter_) to
| |
38 } | |
39 | |
40 CompositorOutputSurface::~CompositorOutputSurface() { | |
41 if (!client_) | |
42 return; | |
43 output_surface_filter_-> | |
jbates
2012/08/08 16:55:09
nit: no need for line wrap
| |
44 RemoveRoute(routing_id_); | |
piman
2012/08/08 16:47:43
nit: I think this line fits in 80 chars.
| |
45 } | |
46 | |
47 const WebKit::WebCompositorOutputSurface::Capabilities& | |
48 CompositorOutputSurface::capabilities() const { | |
49 return capabilities_; | |
50 } | |
51 | |
52 bool CompositorOutputSurface::bindToClient( | |
53 WebKit::WebCompositorOutputSurfaceClient* client) { | |
54 DCHECK(!client_); | |
55 if (! context3D_->makeContextCurrent()) | |
piman
2012/08/08 16:47:43
nit: no space after !
jbates
2012/08/08 16:55:09
nit: no space after !
| |
56 return false; | |
57 | |
58 client_ = client; | |
59 | |
60 output_surface_filter_->AddRoute( | |
61 routing_id_, | |
62 base::Bind(&CompositorOutputSurface::OnMessageReceived, | |
63 base::Unretained(this))); | |
64 | |
65 return true; | |
66 } | |
67 | |
68 WebGraphicsContext3D* CompositorOutputSurface::context3D() const { | |
69 return context3D_.get(); | |
70 } | |
71 | |
72 void CompositorOutputSurface::sendFrameToParentCompositor( | |
73 const WebKit::WebCompositorFrame&) { | |
74 NOTREACHED(); | |
75 } | |
76 | |
77 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | |
78 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | |
79 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | |
jbates
2012/08/08 16:55:09
We're going to need the SwapAck here as well. Feel
| |
80 IPC_END_MESSAGE_MAP() | |
81 } | |
82 | |
83 void CompositorOutputSurface::OnUpdateVSyncParameters( | |
84 base::TimeTicks timebase, | |
85 base::TimeDelta interval) { | |
86 DCHECK(client_); | |
87 double monotonicTimebase = timebase.ToInternalValue() / | |
88 static_cast<double>(base::Time::kMicrosecondsPerSecond); | |
89 double intervalInSeconds = interval.ToInternalValue() / | |
90 static_cast<double>(base::Time::kMicrosecondsPerSecond); | |
91 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); | |
92 } | |
OLD | NEW |