OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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_external_begin_frame_source.h" | |
6 | |
7 #include "content/common/view_messages.h" | |
8 #include "content/renderer/render_thread_impl.h" | |
9 #include "ipc/ipc_sync_channel.h" | |
10 #include "ipc/ipc_sync_message_filter.h" | |
11 | |
12 namespace content { | |
13 | |
14 CompositorExternalBeginFrameSource::CompositorExternalBeginFrameSource( | |
15 int routing_id) | |
16 : begin_frame_source_filter_( | |
17 RenderThreadImpl::current()->compositor_message_filter()), | |
18 message_sender_(RenderThreadImpl::current()->sync_message_filter()), | |
19 routing_id_(routing_id) { | |
20 DCHECK(begin_frame_source_filter_.get()); | |
21 DCHECK(message_sender_.get()); | |
22 DetachFromThread(); | |
23 } | |
24 | |
25 CompositorExternalBeginFrameSource::~CompositorExternalBeginFrameSource() { | |
26 DCHECK(CalledOnValidThread()); | |
27 if (begin_frame_source_proxy_.get()) { | |
28 begin_frame_source_proxy_->ClearBeginFrameSource(); | |
29 begin_frame_source_filter_->RemoveHandlerOnCompositorThread( | |
30 routing_id_, | |
31 begin_frame_source_filter_handler_); | |
32 } | |
33 } | |
34 | |
35 void CompositorExternalBeginFrameSource::OnNeedsBeginFramesChange( | |
36 bool needs_begin_frames) { | |
37 DCHECK(CalledOnValidThread()); | |
38 Send(new ViewHostMsg_SetNeedsBeginFrames(routing_id_, needs_begin_frames)); | |
39 } | |
40 | |
41 void CompositorExternalBeginFrameSource::SetClientReady() { | |
42 DCHECK(CalledOnValidThread()); | |
43 DCHECK(!begin_frame_source_proxy_.get()); | |
44 begin_frame_source_proxy_ = | |
45 new CompositorExternalBeginFrameSourceProxy(this); | |
46 begin_frame_source_filter_handler_ = | |
47 base::Bind(&CompositorExternalBeginFrameSourceProxy::OnMessageReceived, | |
48 begin_frame_source_proxy_); | |
dcheng
2014/11/10 22:56:15
Indents on this and the next 4 lines looks funny.
simonhong
2014/11/11 12:54:15
changed to less funny :)
git cl format didn't comp
| |
49 begin_frame_source_filter_->AddHandlerOnCompositorThread( | |
50 routing_id_, | |
51 begin_frame_source_filter_handler_); | |
52 } | |
53 | |
54 void CompositorExternalBeginFrameSource::OnMessageReceived( | |
55 const IPC::Message& message) { | |
56 DCHECK(CalledOnValidThread()); | |
57 DCHECK(begin_frame_source_proxy_.get()); | |
58 IPC_BEGIN_MESSAGE_MAP(CompositorExternalBeginFrameSource, message) | |
59 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); | |
dcheng
2014/11/10 22:56:15
I don't think a ; is needed, and most people usual
simonhong
2014/11/11 12:54:15
Done.
| |
60 IPC_END_MESSAGE_MAP(); | |
61 } | |
62 | |
63 void CompositorExternalBeginFrameSource::OnBeginFrame( | |
64 const cc::BeginFrameArgs& args) { | |
65 DCHECK(CalledOnValidThread()); | |
66 CallOnBeginFrame(args); | |
67 } | |
68 | |
69 bool CompositorExternalBeginFrameSource::Send(IPC::Message* message) { | |
70 return message_sender_->Send(message); | |
71 } | |
72 | |
73 } // namespace content | |
OLD | NEW |