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

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

Issue 2277883002: Use vsync manager regardless of begin frame settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac compile OOPS Created 4 years, 3 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/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "cc/base/switches.h"
15 #include "cc/output/output_surface_client.h" 14 #include "cc/output/output_surface_client.h"
16 #include "cc/scheduler/begin_frame_source.h" 15 #include "cc/scheduler/begin_frame_source.h"
17 #include "components/display_compositor/compositor_overlay_candidate_validator.h " 16 #include "components/display_compositor/compositor_overlay_candidate_validator.h "
18 #include "content/browser/compositor/reflector_impl.h" 17 #include "content/browser/compositor/reflector_impl.h"
19 #include "content/common/gpu/client/context_provider_command_buffer.h" 18 #include "content/common/gpu/client/context_provider_command_buffer.h"
20 19
21 namespace content { 20 namespace content {
22 21
23 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 22 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
24 scoped_refptr<cc::ContextProvider> context_provider, 23 scoped_refptr<cc::ContextProvider> context_provider,
25 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 24 scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
26 cc::SyntheticBeginFrameSource* begin_frame_source, 25 cc::SyntheticBeginFrameSource* begin_frame_source,
27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 26 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
28 overlay_candidate_validator) 27 overlay_candidate_validator)
29 : OutputSurface(std::move(context_provider), nullptr, nullptr), 28 : OutputSurface(std::move(context_provider), nullptr, nullptr),
30 vsync_manager_(std::move(vsync_manager)), 29 vsync_manager_(std::move(vsync_manager)),
31 synthetic_begin_frame_source_(begin_frame_source), 30 synthetic_begin_frame_source_(begin_frame_source),
32 reflector_(nullptr), 31 reflector_(nullptr) {
33 use_begin_frame_scheduling_(
34 !base::CommandLine::ForCurrentProcess()->HasSwitch(
35 cc::switches::kDisableBeginFrameScheduling)) {
36 overlay_candidate_validator_ = std::move(overlay_candidate_validator); 32 overlay_candidate_validator_ = std::move(overlay_candidate_validator);
37 Initialize(); 33 Initialize();
38 } 34 }
39 35
40 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 36 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
41 std::unique_ptr<cc::SoftwareOutputDevice> software_device, 37 std::unique_ptr<cc::SoftwareOutputDevice> software_device,
42 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 38 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
43 cc::SyntheticBeginFrameSource* begin_frame_source) 39 cc::SyntheticBeginFrameSource* begin_frame_source)
44 : OutputSurface(nullptr, nullptr, std::move(software_device)), 40 : OutputSurface(nullptr, nullptr, std::move(software_device)),
45 vsync_manager_(vsync_manager), 41 vsync_manager_(vsync_manager),
46 synthetic_begin_frame_source_(begin_frame_source), 42 synthetic_begin_frame_source_(begin_frame_source),
47 reflector_(nullptr), 43 reflector_(nullptr) {
48 use_begin_frame_scheduling_(
49 !base::CommandLine::ForCurrentProcess()->HasSwitch(
50 cc::switches::kDisableBeginFrameScheduling)) {
51 Initialize(); 44 Initialize();
52 } 45 }
53 46
54 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 47 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
55 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider, 48 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider,
56 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 49 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
57 cc::SyntheticBeginFrameSource* begin_frame_source) 50 cc::SyntheticBeginFrameSource* begin_frame_source)
58 : OutputSurface(std::move(vulkan_context_provider)), 51 : OutputSurface(std::move(vulkan_context_provider)),
59 vsync_manager_(vsync_manager), 52 vsync_manager_(vsync_manager),
60 synthetic_begin_frame_source_(begin_frame_source), 53 synthetic_begin_frame_source_(begin_frame_source),
61 reflector_(nullptr) { 54 reflector_(nullptr) {
62 Initialize(); 55 Initialize();
63 } 56 }
64 57
65 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { 58 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
66 if (reflector_) 59 if (reflector_)
67 reflector_->DetachFromOutputSurface(); 60 reflector_->DetachFromOutputSurface();
68 DCHECK(!reflector_); 61 DCHECK(!reflector_);
69 if (!HasClient())
70 return;
71
72 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer
73 // by using |vsync_manager_|. Instead, BeginFrame message is used.
74 if (!use_begin_frame_scheduling_)
75 vsync_manager_->RemoveObserver(this);
76 } 62 }
77 63
78 void BrowserCompositorOutputSurface::Initialize() { 64 void BrowserCompositorOutputSurface::Initialize() {
79 capabilities_.adjust_deadline_for_parent = false; 65 capabilities_.adjust_deadline_for_parent = false;
80 } 66 }
81 67
82 bool BrowserCompositorOutputSurface::BindToClient( 68 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
83 cc::OutputSurfaceClient* client) {
84 if (!OutputSurface::BindToClient(client))
85 return false;
86
87 // Don't want vsync notifications until there is a client.
88 if (!use_begin_frame_scheduling_)
89 vsync_manager_->AddObserver(this);
90 return true;
91 }
92
93 void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal(
94 base::TimeTicks timebase, 69 base::TimeTicks timebase,
95 base::TimeDelta interval) { 70 base::TimeDelta interval) {
71 DCHECK(HasClient());
96 if (interval.is_zero()) { 72 if (interval.is_zero()) {
97 // TODO(brianderson): We should not be receiving 0 intervals. 73 // TODO(brianderson): We should not be receiving 0 intervals.
98 interval = cc::BeginFrameArgs::DefaultInterval(); 74 interval = cc::BeginFrameArgs::DefaultInterval();
99 } 75 }
100 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); 76 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
101 }
102
103 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
104 base::TimeTicks timebase,
105 base::TimeDelta interval) {
106 DCHECK(HasClient());
107 DCHECK(!use_begin_frame_scheduling_);
108 UpdateVSyncParametersInternal(timebase, interval);
109 }
110
111 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
112 base::TimeTicks timebase,
113 base::TimeDelta interval) {
114 DCHECK(HasClient());
115 if (use_begin_frame_scheduling_) {
116 UpdateVSyncParametersInternal(timebase, interval);
117 return;
118 }
119
120 vsync_manager_->UpdateVSyncParameters(timebase, interval); 77 vsync_manager_->UpdateVSyncParameters(timebase, interval);
121 } 78 }
122 79
123 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 80 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
124 // Software mirroring is done by doing a GL copy out of the framebuffer - if 81 // Software mirroring is done by doing a GL copy out of the framebuffer - if
125 // we have overlays then that data will be missing. 82 // we have overlays then that data will be missing.
126 if (overlay_candidate_validator_) { 83 if (overlay_candidate_validator_) {
127 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr); 84 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr);
128 } 85 }
129 reflector_ = reflector; 86 reflector_ = reflector;
130 87
131 OnReflectorChanged(); 88 OnReflectorChanged();
132 } 89 }
133 90
134 void BrowserCompositorOutputSurface::OnReflectorChanged() { 91 void BrowserCompositorOutputSurface::OnReflectorChanged() {
135 } 92 }
136 93
137 cc::OverlayCandidateValidator* 94 cc::OverlayCandidateValidator*
138 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { 95 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const {
139 return overlay_candidate_validator_.get(); 96 return overlay_candidate_validator_.get();
140 } 97 }
141 98
142 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698