OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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/browser/renderer_host/compositor_begin_frame_observer_impl.h" | |
6 | |
7 namespace content { | |
8 | |
9 CompositorBeginFrameObserverImpl::CompositorBeginFrameObserverImpl( | |
10 CompositorBeginFrameObserverImplClient* client) | |
11 : needs_begin_frames_(false), | |
12 client_(client), | |
13 compositor_(nullptr) { | |
14 } | |
15 CompositorBeginFrameObserverImpl::~CompositorBeginFrameObserverImpl() { | |
16 } | |
17 | |
18 void CompositorBeginFrameObserverImpl::SetNeedsBeginFrames( | |
19 bool needs_begin_frames) { | |
20 if (needs_begin_frames_ == needs_begin_frames) | |
21 return; | |
22 | |
23 needs_begin_frames_ = needs_begin_frames; | |
24 | |
25 // In some cases, BeginFrame message is requested before |client_|'s window is | |
26 // added in the root window hierarchy. | |
27 if (!compositor_) | |
28 return; | |
29 | |
30 if (needs_begin_frames) | |
31 StartObservingBeginFrames(); | |
32 else | |
33 StopObservingBeginFrames(); | |
34 } | |
35 | |
36 void CompositorBeginFrameObserverImpl::SetCompositor( | |
37 ui::Compositor* compositor) { | |
38 DCHECK(!compositor_); | |
39 DCHECK(compositor); | |
40 | |
41 compositor_ = compositor; | |
42 | |
danakj
2015/03/19 22:36:40
less whitespace?
simonhong
2015/03/20 16:07:36
Done.
| |
43 if (needs_begin_frames_) | |
44 StartObservingBeginFrames(); | |
45 } | |
46 | |
47 void CompositorBeginFrameObserverImpl::ResetCompositor() { | |
48 if (!compositor_) | |
49 return; | |
50 | |
51 if (needs_begin_frames_) | |
52 StopObservingBeginFrames(); | |
53 | |
danakj
2015/03/19 22:36:40
dittos
simonhong
2015/03/20 16:07:35
Done.
| |
54 compositor_ = nullptr; | |
55 } | |
56 | |
57 void CompositorBeginFrameObserverImpl::OnSendBeginFrame( | |
58 const cc::BeginFrameArgs& args) { | |
59 client_->SendBeginFrame(args); | |
60 last_sent_begin_frame_args_ = args; | |
61 } | |
62 | |
63 void CompositorBeginFrameObserverImpl::StartObservingBeginFrames() { | |
64 DCHECK(compositor_); | |
65 compositor_->AddBeginFrameObserver(this, last_sent_begin_frame_args_); | |
66 } | |
67 | |
68 void CompositorBeginFrameObserverImpl::StopObservingBeginFrames() { | |
69 DCHECK(compositor_); | |
70 compositor_->RemoveBeginFrameObserver(this); | |
71 } | |
72 | |
73 } // namespace content | |
OLD | NEW |