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/begin_frame_manager.h" | |
6 | |
7 namespace content { | |
8 | |
9 BeginFrameManager::BeginFrameManager(BeginFrameManagerClient* client) | |
10 : needs_begin_frames_(false), | |
11 client_(client), | |
12 compositor_(nullptr) { | |
13 } | |
14 BeginFrameManager::~BeginFrameManager() { | |
15 } | |
16 | |
17 void BeginFrameManager::OnSetNeedsBeginFrames(bool needs_begin_frames) { | |
danakj
2015/03/17 18:56:45
This looks like it should be just "SetNeedsBeginFr
simonhong
2015/03/19 15:48:45
Done.
| |
18 if (needs_begin_frames_ == needs_begin_frames) | |
19 return; | |
20 | |
21 needs_begin_frames_ = needs_begin_frames; | |
22 | |
23 // In some cases, BeginFrame message is requested before |client_|'s window is | |
24 // added in the root window hierarchy. | |
25 if (!compositor_) | |
26 return; | |
27 | |
28 if (needs_begin_frames) | |
29 StartObservingBeginFrames(); | |
30 else | |
31 StopObservingBeginFrames(); | |
32 } | |
33 | |
34 void BeginFrameManager::SetCompositor(ui::Compositor* compositor) { | |
35 DCHECK(!compositor_); | |
danakj
2015/03/17 18:56:45
I'm a little unclear about this DCHECK with the if
simonhong
2015/03/19 15:48:45
DCHECK(compositor) is added.
I think using Reset m
| |
36 | |
37 if (!compositor) | |
38 return; | |
39 | |
40 compositor_ = compositor; | |
41 | |
42 if (needs_begin_frames_) | |
43 StartObservingBeginFrames(); | |
44 } | |
45 | |
46 void BeginFrameManager::ResetCompositor() { | |
47 if (!compositor_) | |
48 return; | |
49 | |
50 if (needs_begin_frames_) | |
51 StopObservingBeginFrames(); | |
52 | |
53 compositor_ = nullptr; | |
54 } | |
55 | |
56 void BeginFrameManager::OnSendBeginFrame(const cc::BeginFrameArgs& args) { | |
57 client_->SendBeginFrame(args); | |
58 last_sent_begin_frame_args_ = args; | |
danakj
2015/03/17 18:56:45
Would it be equivalent to early out in here instea
simonhong
2015/03/19 15:48:46
Hmm, this is not for checking sending same args tw
| |
59 } | |
60 | |
61 void BeginFrameManager::StartObservingBeginFrames() { | |
62 DCHECK(compositor_); | |
63 compositor_->AddBeginFrameObserver(this, last_sent_begin_frame_args_); | |
danakj
2015/03/17 18:56:45
can you add some comments explaining the purpose o
simonhong
2015/03/19 15:48:45
I commented its purpose in header file.
It is for
| |
64 } | |
65 | |
66 void BeginFrameManager::StopObservingBeginFrames() { | |
67 DCHECK(compositor_); | |
68 compositor_->RemoveBeginFrameObserver(this); | |
69 } | |
70 | |
71 } // namespace content | |
OLD | NEW |