OLD | NEW |
---|---|
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 scoped_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | |
sunnyps
2016/03/28 23:09:48
BrowserCompositorOutputSurface can create and own
enne (OOO)
2016/03/29 20:39:52
It was passed in because creating a BFS required a
enne (OOO)
2016/03/30 17:34:41
Would you rather I just pass in a task runner?
sunnyps
2016/03/30 18:56:02
I think either way is fine. Don't have a strong op
| |
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_(std::move(synthetic_begin_frame_source)), | |
28 reflector_(nullptr), | 31 reflector_(nullptr), |
29 use_begin_frame_scheduling_( | 32 use_begin_frame_scheduling_( |
30 base::CommandLine::ForCurrentProcess() | 33 base::CommandLine::ForCurrentProcess()->HasSwitch( |
31 ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { | 34 cc::switches::kEnableBeginFrameScheduling)) { |
32 overlay_candidate_validator_ = std::move(overlay_candidate_validator); | 35 overlay_candidate_validator_ = std::move(overlay_candidate_validator); |
33 Initialize(); | 36 Initialize(); |
34 } | 37 } |
35 | 38 |
36 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 39 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
37 scoped_ptr<cc::SoftwareOutputDevice> software_device, | 40 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
38 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) | 41 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
42 scoped_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source) | |
39 : OutputSurface(std::move(software_device)), | 43 : OutputSurface(std::move(software_device)), |
40 vsync_manager_(vsync_manager), | 44 vsync_manager_(vsync_manager), |
45 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | |
41 reflector_(nullptr), | 46 reflector_(nullptr), |
42 use_begin_frame_scheduling_( | 47 use_begin_frame_scheduling_( |
43 base::CommandLine::ForCurrentProcess() | 48 base::CommandLine::ForCurrentProcess()->HasSwitch( |
44 ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { | 49 cc::switches::kEnableBeginFrameScheduling)) { |
45 Initialize(); | 50 Initialize(); |
46 } | 51 } |
47 | 52 |
48 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 53 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
49 if (reflector_) | 54 if (reflector_) |
50 reflector_->DetachFromOutputSurface(); | 55 reflector_->DetachFromOutputSurface(); |
51 DCHECK(!reflector_); | 56 DCHECK(!reflector_); |
52 if (!HasClient()) | 57 if (!HasClient()) |
53 return; | 58 return; |
54 | 59 |
55 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer | 60 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer |
56 // by using |vsync_manager_|. Instead, BeginFrame message is used. | 61 // by using |vsync_manager_|. Instead, BeginFrame message is used. |
57 if (!use_begin_frame_scheduling_) | 62 if (!use_begin_frame_scheduling_) |
58 vsync_manager_->RemoveObserver(this); | 63 vsync_manager_->RemoveObserver(this); |
59 } | 64 } |
60 | 65 |
61 void BrowserCompositorOutputSurface::Initialize() { | 66 void BrowserCompositorOutputSurface::Initialize() { |
62 capabilities_.adjust_deadline_for_parent = false; | 67 capabilities_.adjust_deadline_for_parent = false; |
63 } | 68 } |
64 | 69 |
65 bool BrowserCompositorOutputSurface::BindToClient( | 70 bool BrowserCompositorOutputSurface::BindToClient( |
66 cc::OutputSurfaceClient* client) { | 71 cc::OutputSurfaceClient* client) { |
67 if (!OutputSurface::BindToClient(client)) | 72 if (!OutputSurface::BindToClient(client)) |
68 return false; | 73 return false; |
69 | 74 |
75 // Pass begin frame source up to Display to use for DisplayScheduler. | |
76 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); | |
77 | |
70 // Don't want vsync notifications until there is a client. | 78 // Don't want vsync notifications until there is a client. |
71 if (!use_begin_frame_scheduling_) | 79 if (!use_begin_frame_scheduling_) |
72 vsync_manager_->AddObserver(this); | 80 vsync_manager_->AddObserver(this); |
73 return true; | 81 return true; |
74 } | 82 } |
75 | 83 |
84 void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal( | |
85 base::TimeTicks timebase, | |
86 base::TimeDelta interval) { | |
87 if (interval == base::TimeDelta()) { | |
88 // TODO(brianderson): We should not be receiving 0 intervals. | |
89 interval = cc::BeginFrameArgs::DefaultInterval(); | |
90 } | |
91 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | |
92 | |
93 // TODO(enne): remove this once vsyncs are no longer used in the renderer. | |
94 CommitVSyncParameters(timebase, interval); | |
95 } | |
96 | |
76 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( | 97 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( |
77 base::TimeTicks timebase, | 98 base::TimeTicks timebase, |
78 base::TimeDelta interval) { | 99 base::TimeDelta interval) { |
79 DCHECK(HasClient()); | 100 DCHECK(HasClient()); |
80 DCHECK(!use_begin_frame_scheduling_); | 101 DCHECK(!use_begin_frame_scheduling_); |
81 CommitVSyncParameters(timebase, interval); | 102 UpdateVSyncParametersInternal(timebase, interval); |
82 } | 103 } |
83 | 104 |
84 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( | 105 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
85 base::TimeTicks timebase, | 106 base::TimeTicks timebase, |
86 base::TimeDelta interval) { | 107 base::TimeDelta interval) { |
87 DCHECK(HasClient()); | 108 DCHECK(HasClient()); |
88 if (use_begin_frame_scheduling_) { | 109 if (use_begin_frame_scheduling_) { |
89 CommitVSyncParameters(timebase, interval); | 110 UpdateVSyncParametersInternal(timebase, interval); |
90 return; | 111 return; |
91 } | 112 } |
92 | 113 |
93 vsync_manager_->UpdateVSyncParameters(timebase, interval); | 114 vsync_manager_->UpdateVSyncParameters(timebase, interval); |
94 } | 115 } |
95 | 116 |
96 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { | 117 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { |
97 // Software mirroring is done by doing a GL copy out of the framebuffer - if | 118 // Software mirroring is done by doing a GL copy out of the framebuffer - if |
98 // we have overlays then that data will be missing. | 119 // we have overlays then that data will be missing. |
99 if (overlay_candidate_validator_) { | 120 if (overlay_candidate_validator_) { |
(...skipping 11 matching lines...) Expand all Loading... | |
111 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() { | 132 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() { |
112 return base::Closure(); | 133 return base::Closure(); |
113 } | 134 } |
114 | 135 |
115 cc::OverlayCandidateValidator* | 136 cc::OverlayCandidateValidator* |
116 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { | 137 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { |
117 return overlay_candidate_validator_.get(); | 138 return overlay_candidate_validator_.get(); |
118 } | 139 } |
119 | 140 |
120 } // namespace content | 141 } // namespace content |
OLD | NEW |