Chromium Code Reviews| 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 if (needs_begin_frames_) | |
| 43 StartObservingBeginFrames(); | |
| 44 } | |
| 45 | |
| 46 void CompositorBeginFrameObserverImpl::ResetCompositor() { | |
| 47 if (!compositor_) | |
| 48 return; | |
| 49 | |
| 50 if (needs_begin_frames_) | |
| 51 StopObservingBeginFrames(); | |
| 52 compositor_ = nullptr; | |
| 53 } | |
| 54 | |
| 55 void CompositorBeginFrameObserverImpl::OnSendBeginFrame( | |
| 56 const cc::BeginFrameArgs& args) { | |
| 57 if (last_sent_begin_frame_args_.frame_time != args.frame_time) | |
|
danakj
2015/03/20 16:46:11
Ya this is what I mean :)
| |
| 58 client_->SendBeginFrame(args); | |
| 59 last_sent_begin_frame_args_ = args; | |
| 60 } | |
| 61 | |
| 62 void CompositorBeginFrameObserverImpl::StartObservingBeginFrames() { | |
| 63 DCHECK(compositor_); | |
| 64 compositor_->AddBeginFrameObserver(this); | |
| 65 } | |
| 66 | |
| 67 void CompositorBeginFrameObserverImpl::StopObservingBeginFrames() { | |
| 68 DCHECK(compositor_); | |
| 69 compositor_->RemoveBeginFrameObserver(this); | |
| 70 } | |
| 71 | |
| 72 } // namespace content | |
| OLD | NEW |