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

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

Issue 2029323004: Get rid of virtual Display::CreateScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onscreendisplayclient
Patch Set: displaytest: unusedvar 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
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" 14 #include "cc/base/switches.h"
15 #include "cc/output/output_surface_client.h" 15 #include "cc/output/output_surface_client.h"
16 #include "cc/scheduler/delay_based_time_source.h" 16 #include "cc/scheduler/begin_frame_source.h"
17 #include "components/display_compositor/compositor_overlay_candidate_validator.h " 17 #include "components/display_compositor/compositor_overlay_candidate_validator.h "
18 #include "content/browser/compositor/reflector_impl.h" 18 #include "content/browser/compositor/reflector_impl.h"
19 #include "content/common/gpu/client/context_provider_command_buffer.h" 19 #include "content/common/gpu/client/context_provider_command_buffer.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 23 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
24 scoped_refptr<cc::ContextProvider> context_provider, 24 scoped_refptr<cc::ContextProvider> context_provider,
25 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, 25 scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
26 base::SingleThreadTaskRunner* task_runner, 26 cc::SyntheticBeginFrameSource* begin_frame_source,
27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> 27 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator>
28 overlay_candidate_validator) 28 overlay_candidate_validator)
29 : OutputSurface(std::move(context_provider), nullptr, nullptr), 29 : OutputSurface(std::move(context_provider), nullptr, nullptr),
30 vsync_manager_(std::move(vsync_manager)), 30 vsync_manager_(std::move(vsync_manager)),
31 synthetic_begin_frame_source_(new cc::DelayBasedBeginFrameSource( 31 synthetic_begin_frame_source_(begin_frame_source),
32 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))),
33 reflector_(nullptr), 32 reflector_(nullptr),
34 use_begin_frame_scheduling_( 33 use_begin_frame_scheduling_(
35 base::CommandLine::ForCurrentProcess()->HasSwitch( 34 base::CommandLine::ForCurrentProcess()->HasSwitch(
36 cc::switches::kEnableBeginFrameScheduling)) { 35 cc::switches::kEnableBeginFrameScheduling)) {
37 overlay_candidate_validator_ = std::move(overlay_candidate_validator); 36 overlay_candidate_validator_ = std::move(overlay_candidate_validator);
38 Initialize(); 37 Initialize();
39 } 38 }
40 39
41 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 40 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
42 std::unique_ptr<cc::SoftwareOutputDevice> software_device, 41 std::unique_ptr<cc::SoftwareOutputDevice> software_device,
43 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 42 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
44 base::SingleThreadTaskRunner* task_runner) 43 cc::SyntheticBeginFrameSource* begin_frame_source)
45 : OutputSurface(nullptr, nullptr, std::move(software_device)), 44 : OutputSurface(nullptr, nullptr, std::move(software_device)),
46 vsync_manager_(vsync_manager), 45 vsync_manager_(vsync_manager),
47 synthetic_begin_frame_source_(new cc::DelayBasedBeginFrameSource( 46 synthetic_begin_frame_source_(begin_frame_source),
48 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))),
49 reflector_(nullptr), 47 reflector_(nullptr),
50 use_begin_frame_scheduling_( 48 use_begin_frame_scheduling_(
51 base::CommandLine::ForCurrentProcess()->HasSwitch( 49 base::CommandLine::ForCurrentProcess()->HasSwitch(
52 cc::switches::kEnableBeginFrameScheduling)) { 50 cc::switches::kEnableBeginFrameScheduling)) {
53 Initialize(); 51 Initialize();
54 } 52 }
55 53
56 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( 54 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
57 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider, 55 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider,
58 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, 56 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
59 base::SingleThreadTaskRunner* task_runner) 57 cc::SyntheticBeginFrameSource* begin_frame_source)
60 : OutputSurface(std::move(vulkan_context_provider)), 58 : OutputSurface(std::move(vulkan_context_provider)),
61 vsync_manager_(vsync_manager), 59 vsync_manager_(vsync_manager),
62 synthetic_begin_frame_source_(new cc::DelayBasedBeginFrameSource( 60 synthetic_begin_frame_source_(begin_frame_source),
63 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))),
64 reflector_(nullptr) { 61 reflector_(nullptr) {
65 Initialize(); 62 Initialize();
66 } 63 }
67 64
68 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { 65 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
69 if (reflector_) 66 if (reflector_)
70 reflector_->DetachFromOutputSurface(); 67 reflector_->DetachFromOutputSurface();
71 DCHECK(!reflector_); 68 DCHECK(!reflector_);
72 if (!HasClient()) 69 if (!HasClient())
73 return; 70 return;
74 71
75 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer 72 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer
76 // by using |vsync_manager_|. Instead, BeginFrame message is used. 73 // by using |vsync_manager_|. Instead, BeginFrame message is used.
77 if (!use_begin_frame_scheduling_) 74 if (!use_begin_frame_scheduling_)
78 vsync_manager_->RemoveObserver(this); 75 vsync_manager_->RemoveObserver(this);
79 } 76 }
80 77
81 void BrowserCompositorOutputSurface::Initialize() { 78 void BrowserCompositorOutputSurface::Initialize() {
82 capabilities_.adjust_deadline_for_parent = false; 79 capabilities_.adjust_deadline_for_parent = false;
83 } 80 }
84 81
85 bool BrowserCompositorOutputSurface::BindToClient( 82 bool BrowserCompositorOutputSurface::BindToClient(
86 cc::OutputSurfaceClient* client) { 83 cc::OutputSurfaceClient* client) {
87 if (!OutputSurface::BindToClient(client)) 84 if (!OutputSurface::BindToClient(client))
88 return false; 85 return false;
89 86
90 // Pass begin frame source up to Display to use for DisplayScheduler.
91 client->SetBeginFrameSource(synthetic_begin_frame_source_.get());
92
93 // Don't want vsync notifications until there is a client. 87 // Don't want vsync notifications until there is a client.
94 if (!use_begin_frame_scheduling_) 88 if (!use_begin_frame_scheduling_)
95 vsync_manager_->AddObserver(this); 89 vsync_manager_->AddObserver(this);
96 return true; 90 return true;
97 } 91 }
98 92
99 void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal( 93 void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal(
100 base::TimeTicks timebase, 94 base::TimeTicks timebase,
101 base::TimeDelta interval) { 95 base::TimeDelta interval) {
102 if (interval.is_zero()) { 96 if (interval.is_zero()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() { 138 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() {
145 return base::Closure(); 139 return base::Closure();
146 } 140 }
147 141
148 cc::OverlayCandidateValidator* 142 cc::OverlayCandidateValidator*
149 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { 143 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const {
150 return overlay_candidate_validator_.get(); 144 return overlay_candidate_validator_.get();
151 } 145 }
152 146
153 } // namespace content 147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698