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 "base/thread_task_runner_handle.h" | |
13 #include "cc/base/switches.h" | 14 #include "cc/base/switches.h" |
15 #include "cc/output/output_surface_client.h" | |
14 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor.h" | 16 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor.h" |
15 #include "content/browser/compositor/reflector_impl.h" | 17 #include "content/browser/compositor/reflector_impl.h" |
16 #include "content/common/gpu/client/context_provider_command_buffer.h" | 18 #include "content/common/gpu/client/context_provider_command_buffer.h" |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 | 21 |
20 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 22 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
21 const scoped_refptr<cc::ContextProvider>& context_provider, | 23 const scoped_refptr<cc::ContextProvider>& context_provider, |
22 const scoped_refptr<cc::ContextProvider>& worker_context_provider, | 24 const scoped_refptr<cc::ContextProvider>& worker_context_provider, |
23 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 25 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
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 base::ThreadTaskRunnerHandle::Get().get(), | |
no sievers
2016/04/05 23:12:52
Shouldn't it be the same thread that BindToClient(
enne (OOO)
2016/04/06 21:42:58
Done.
| |
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) |
39 : OutputSurface(std::move(software_device)), | 44 : OutputSurface(std::move(software_device)), |
40 vsync_manager_(vsync_manager), | 45 vsync_manager_(vsync_manager), |
46 synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( | |
47 base::ThreadTaskRunnerHandle::Get().get(), | |
48 cc::BeginFrameArgs::DefaultInterval())), | |
41 reflector_(nullptr), | 49 reflector_(nullptr), |
42 use_begin_frame_scheduling_( | 50 use_begin_frame_scheduling_( |
43 base::CommandLine::ForCurrentProcess() | 51 base::CommandLine::ForCurrentProcess()->HasSwitch( |
44 ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { | 52 cc::switches::kEnableBeginFrameScheduling)) { |
45 Initialize(); | 53 Initialize(); |
46 } | 54 } |
47 | 55 |
48 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 56 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
49 if (reflector_) | 57 if (reflector_) |
50 reflector_->DetachFromOutputSurface(); | 58 reflector_->DetachFromOutputSurface(); |
51 DCHECK(!reflector_); | 59 DCHECK(!reflector_); |
52 if (!HasClient()) | 60 if (!HasClient()) |
53 return; | 61 return; |
54 | 62 |
55 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer | 63 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer |
56 // by using |vsync_manager_|. Instead, BeginFrame message is used. | 64 // by using |vsync_manager_|. Instead, BeginFrame message is used. |
57 if (!use_begin_frame_scheduling_) | 65 if (!use_begin_frame_scheduling_) |
58 vsync_manager_->RemoveObserver(this); | 66 vsync_manager_->RemoveObserver(this); |
59 } | 67 } |
60 | 68 |
61 void BrowserCompositorOutputSurface::Initialize() { | 69 void BrowserCompositorOutputSurface::Initialize() { |
62 capabilities_.adjust_deadline_for_parent = false; | 70 capabilities_.adjust_deadline_for_parent = false; |
63 } | 71 } |
64 | 72 |
65 bool BrowserCompositorOutputSurface::BindToClient( | 73 bool BrowserCompositorOutputSurface::BindToClient( |
66 cc::OutputSurfaceClient* client) { | 74 cc::OutputSurfaceClient* client) { |
67 if (!OutputSurface::BindToClient(client)) | 75 if (!OutputSurface::BindToClient(client)) |
68 return false; | 76 return false; |
69 | 77 |
78 // Pass begin frame source up to Display to use for DisplayScheduler. | |
79 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); | |
80 | |
70 // Don't want vsync notifications until there is a client. | 81 // Don't want vsync notifications until there is a client. |
71 if (!use_begin_frame_scheduling_) | 82 if (!use_begin_frame_scheduling_) |
72 vsync_manager_->AddObserver(this); | 83 vsync_manager_->AddObserver(this); |
73 return true; | 84 return true; |
74 } | 85 } |
75 | 86 |
87 void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal( | |
88 base::TimeTicks timebase, | |
89 base::TimeDelta interval) { | |
90 if (interval == base::TimeDelta()) { | |
91 // TODO(brianderson): We should not be receiving 0 intervals. | |
92 interval = cc::BeginFrameArgs::DefaultInterval(); | |
93 } | |
94 synthetic_begin_frame_source_->OnUpdateVSyncParameters(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 |