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

Side by Side Diff: content/browser/compositor/browser_compositor_output_surface.cc

Issue 1821863002: Hook up ui::Compositor to Display's BeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; refactor mus output surface Created 4 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/compositor/browser_compositor_output_surface.h" 5 #include "content/browser/compositor/browser_compositor_output_surface.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "cc/base/switches.h" 13 #include "cc/base/switches.h"
14 #include "cc/output/output_surface_client.h"
14 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor.h" 15 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor.h"
15 #include "content/browser/compositor/reflector_impl.h" 16 #include "content/browser/compositor/reflector_impl.h"
16 #include "content/common/gpu/client/context_provider_command_buffer.h" 17 #include "content/common/gpu/client/context_provider_command_buffer.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 21 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
21 const scoped_refptr<cc::ContextProvider>& context_provider, 22 const scoped_refptr<cc::ContextProvider>& context_provider,
22 const scoped_refptr<cc::ContextProvider>& worker_context_provider, 23 const scoped_refptr<cc::ContextProvider>& worker_context_provider,
23 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 24 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
25 base::SingleThreadTaskRunner* task_runner,
24 scoped_ptr<BrowserCompositorOverlayCandidateValidator> 26 scoped_ptr<BrowserCompositorOverlayCandidateValidator>
25 overlay_candidate_validator) 27 overlay_candidate_validator)
26 : OutputSurface(context_provider, worker_context_provider), 28 : OutputSurface(context_provider, worker_context_provider),
27 vsync_manager_(vsync_manager), 29 vsync_manager_(vsync_manager),
30 synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource(
31 task_runner,
32 cc::BeginFrameArgs::DefaultInterval())),
28 reflector_(nullptr), 33 reflector_(nullptr),
29 use_begin_frame_scheduling_( 34 use_begin_frame_scheduling_(
30 base::CommandLine::ForCurrentProcess() 35 base::CommandLine::ForCurrentProcess()->HasSwitch(
31 ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { 36 cc::switches::kEnableBeginFrameScheduling)) {
32 overlay_candidate_validator_ = std::move(overlay_candidate_validator); 37 overlay_candidate_validator_ = std::move(overlay_candidate_validator);
33 Initialize(); 38 Initialize();
34 } 39 }
35 40
36 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 41 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
37 scoped_ptr<cc::SoftwareOutputDevice> software_device, 42 scoped_ptr<cc::SoftwareOutputDevice> software_device,
38 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) 43 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
44 base::SingleThreadTaskRunner* task_runner)
39 : OutputSurface(std::move(software_device)), 45 : OutputSurface(std::move(software_device)),
40 vsync_manager_(vsync_manager), 46 vsync_manager_(vsync_manager),
47 synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource(
48 task_runner,
49 cc::BeginFrameArgs::DefaultInterval())),
41 reflector_(nullptr), 50 reflector_(nullptr),
42 use_begin_frame_scheduling_( 51 use_begin_frame_scheduling_(
43 base::CommandLine::ForCurrentProcess() 52 base::CommandLine::ForCurrentProcess()->HasSwitch(
44 ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { 53 cc::switches::kEnableBeginFrameScheduling)) {
sunnyps 2016/04/01 22:35:25 nit: Is this flag ever false? If not can you remov
enne (OOO) 2016/04/02 00:18:38 Yes. This flag is sometimes false. That boolean
45 Initialize(); 54 Initialize();
46 } 55 }
47 56
48 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { 57 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
49 if (reflector_) 58 if (reflector_)
50 reflector_->DetachFromOutputSurface(); 59 reflector_->DetachFromOutputSurface();
51 DCHECK(!reflector_); 60 DCHECK(!reflector_);
52 if (!HasClient()) 61 if (!HasClient())
53 return; 62 return;
54 63
55 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer 64 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer
56 // by using |vsync_manager_|. Instead, BeginFrame message is used. 65 // by using |vsync_manager_|. Instead, BeginFrame message is used.
57 if (!use_begin_frame_scheduling_) 66 if (!use_begin_frame_scheduling_)
58 vsync_manager_->RemoveObserver(this); 67 vsync_manager_->RemoveObserver(this);
59 } 68 }
60 69
61 void BrowserCompositorOutputSurface::Initialize() { 70 void BrowserCompositorOutputSurface::Initialize() {
62 capabilities_.adjust_deadline_for_parent = false; 71 capabilities_.adjust_deadline_for_parent = false;
63 } 72 }
64 73
65 bool BrowserCompositorOutputSurface::BindToClient( 74 bool BrowserCompositorOutputSurface::BindToClient(
66 cc::OutputSurfaceClient* client) { 75 cc::OutputSurfaceClient* client) {
67 if (!OutputSurface::BindToClient(client)) 76 if (!OutputSurface::BindToClient(client))
68 return false; 77 return false;
69 78
79 // Pass begin frame source up to Display to use for DisplayScheduler.
80 client->SetBeginFrameSource(synthetic_begin_frame_source_.get());
81
70 // Don't want vsync notifications until there is a client. 82 // Don't want vsync notifications until there is a client.
71 if (!use_begin_frame_scheduling_) 83 if (!use_begin_frame_scheduling_)
72 vsync_manager_->AddObserver(this); 84 vsync_manager_->AddObserver(this);
73 return true; 85 return true;
74 } 86 }
75 87
88 void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal(
89 base::TimeTicks timebase,
90 base::TimeDelta interval) {
91 if (interval == base::TimeDelta()) {
92 // TODO(brianderson): We should not be receiving 0 intervals.
93 interval = cc::BeginFrameArgs::DefaultInterval();
94 }
95 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
96
97 // TODO(enne): remove this once vsyncs are no longer used in the renderer.
98 CommitVSyncParameters(timebase, interval);
99 }
100
76 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( 101 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
77 base::TimeTicks timebase, 102 base::TimeTicks timebase,
78 base::TimeDelta interval) { 103 base::TimeDelta interval) {
79 DCHECK(HasClient()); 104 DCHECK(HasClient());
80 DCHECK(!use_begin_frame_scheduling_); 105 DCHECK(!use_begin_frame_scheduling_);
81 CommitVSyncParameters(timebase, interval); 106 UpdateVSyncParametersInternal(timebase, interval);
82 } 107 }
83 108
84 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( 109 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
85 base::TimeTicks timebase, 110 base::TimeTicks timebase,
86 base::TimeDelta interval) { 111 base::TimeDelta interval) {
87 DCHECK(HasClient()); 112 DCHECK(HasClient());
88 if (use_begin_frame_scheduling_) { 113 if (use_begin_frame_scheduling_) {
89 CommitVSyncParameters(timebase, interval); 114 UpdateVSyncParametersInternal(timebase, interval);
90 return; 115 return;
91 } 116 }
92 117
93 vsync_manager_->UpdateVSyncParameters(timebase, interval); 118 vsync_manager_->UpdateVSyncParameters(timebase, interval);
94 } 119 }
95 120
96 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 121 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
97 // Software mirroring is done by doing a GL copy out of the framebuffer - if 122 // Software mirroring is done by doing a GL copy out of the framebuffer - if
98 // we have overlays then that data will be missing. 123 // we have overlays then that data will be missing.
99 if (overlay_candidate_validator_) { 124 if (overlay_candidate_validator_) {
(...skipping 11 matching lines...) Expand all
111 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() { 136 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() {
112 return base::Closure(); 137 return base::Closure();
113 } 138 }
114 139
115 cc::OverlayCandidateValidator* 140 cc::OverlayCandidateValidator*
116 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { 141 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const {
117 return overlay_candidate_validator_.get(); 142 return overlay_candidate_validator_.get();
118 } 143 }
119 144
120 } // namespace content 145 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698