Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: content/renderer/android/synchronous_compositor_external_begin_frame_source.cc

Issue 1969263004: sync compositor: Remove begin frame source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/android/synchronous_compositor_external_begin_frame_s ource.h"
6
7 #include "cc/output/begin_frame_args.h"
8 #include "content/renderer/android/synchronous_compositor_registry.h"
9
10 namespace content {
11
12 SynchronousCompositorExternalBeginFrameSource::
13 SynchronousCompositorExternalBeginFrameSource(
14 int routing_id,
15 SynchronousCompositorRegistry* registry)
16 : routing_id_(routing_id),
17 registry_(registry),
18 registered_(false),
19 client_(nullptr) {
20 thread_checker_.DetachFromThread();
21 }
22
23 SynchronousCompositorExternalBeginFrameSource::
24 ~SynchronousCompositorExternalBeginFrameSource() {
25 DCHECK(CalledOnValidThread());
26
27 if (registered_) {
28 registry_->UnregisterBeginFrameSource(routing_id_, this);
29 }
30 DCHECK(!client_);
31 }
32
33 void SynchronousCompositorExternalBeginFrameSource::BeginFrame(
34 const cc::BeginFrameArgs& args) {
35 DCHECK(CalledOnValidThread());
36 CallOnBeginFrame(args);
37 }
38
39 void SynchronousCompositorExternalBeginFrameSource::SetClient(
40 SynchronousCompositorExternalBeginFrameSourceClient* client) {
41 DCHECK(CalledOnValidThread());
42 if (client_ == client)
43 return;
44
45 if (client_)
46 client_->OnNeedsBeginFramesChange(false);
47
48 client_ = client;
49
50 if (client_)
51 client_->OnNeedsBeginFramesChange(needs_begin_frames());
52
53 // State without client is paused, and default client state is not paused.
54 SetBeginFrameSourcePaused(!client_);
55 }
56
57 void SynchronousCompositorExternalBeginFrameSource::OnNeedsBeginFramesChanged(
58 bool needs_begin_frames) {
59 DCHECK(CalledOnValidThread());
60 if (client_)
61 client_->OnNeedsBeginFramesChange(needs_begin_frames);
62 }
63
64 void SynchronousCompositorExternalBeginFrameSource::AddObserver(
65 cc::BeginFrameObserver* obs) {
66 DCHECK(CalledOnValidThread());
67 BeginFrameSourceBase::AddObserver(obs);
68 if (registered_)
69 return;
70 registry_->RegisterBeginFrameSource(routing_id_, this);
71 registered_ = true;
72 }
73
74 bool
75 SynchronousCompositorExternalBeginFrameSource::CalledOnValidThread() const {
76 return thread_checker_.CalledOnValidThread();
77 }
78
79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698