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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
8 #include "base/location.h" | 9 #include "base/location.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "cc/base/switches.h" |
10 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" | 12 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida
tor.h" |
11 #include "content/browser/compositor/reflector_impl.h" | 13 #include "content/browser/compositor/reflector_impl.h" |
12 #include "content/common/gpu/client/context_provider_command_buffer.h" | 14 #include "content/common/gpu/client/context_provider_command_buffer.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 | 17 |
16 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 18 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
17 const scoped_refptr<cc::ContextProvider>& context_provider, | 19 const scoped_refptr<cc::ContextProvider>& context_provider, |
18 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 20 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
19 scoped_ptr<BrowserCompositorOverlayCandidateValidator> | 21 scoped_ptr<BrowserCompositorOverlayCandidateValidator> |
20 overlay_candidate_validator) | 22 overlay_candidate_validator) |
21 : OutputSurface(context_provider), | 23 : OutputSurface(context_provider), |
22 vsync_manager_(vsync_manager), | 24 vsync_manager_(vsync_manager), |
23 reflector_(nullptr) { | 25 reflector_(nullptr), |
| 26 use_begin_frame_scheduling_(base::CommandLine::ForCurrentProcess()-> |
| 27 HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { |
24 overlay_candidate_validator_ = overlay_candidate_validator.Pass(); | 28 overlay_candidate_validator_ = overlay_candidate_validator.Pass(); |
25 Initialize(); | 29 Initialize(); |
26 } | 30 } |
27 | 31 |
28 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 32 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
29 scoped_ptr<cc::SoftwareOutputDevice> software_device, | 33 scoped_ptr<cc::SoftwareOutputDevice> software_device, |
30 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) | 34 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) |
31 : OutputSurface(software_device.Pass()), | 35 : OutputSurface(software_device.Pass()), |
32 vsync_manager_(vsync_manager), | 36 vsync_manager_(vsync_manager), |
33 reflector_(nullptr) { | 37 reflector_(nullptr), |
| 38 use_begin_frame_scheduling_(base::CommandLine::ForCurrentProcess()-> |
| 39 HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { |
34 Initialize(); | 40 Initialize(); |
35 } | 41 } |
36 | 42 |
37 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 43 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
38 if (reflector_) | 44 if (reflector_) |
39 reflector_->DetachFromOutputSurface(); | 45 reflector_->DetachFromOutputSurface(); |
40 DCHECK(!reflector_); | 46 DCHECK(!reflector_); |
41 if (!HasClient()) | 47 if (!HasClient()) |
42 return; | 48 return; |
43 vsync_manager_->RemoveObserver(this); | 49 |
| 50 // When BeginFrame scheduling is enabled, vsync info is not routed to renderer |
| 51 // by using |vsync_manager_|. Instead, BeginFrame message is used. |
| 52 if (!use_begin_frame_scheduling_) |
| 53 vsync_manager_->RemoveObserver(this); |
44 } | 54 } |
45 | 55 |
46 void BrowserCompositorOutputSurface::Initialize() { | 56 void BrowserCompositorOutputSurface::Initialize() { |
47 capabilities_.max_frames_pending = 1; | 57 capabilities_.max_frames_pending = 1; |
48 capabilities_.adjust_deadline_for_parent = false; | 58 capabilities_.adjust_deadline_for_parent = false; |
49 } | 59 } |
50 | 60 |
51 bool BrowserCompositorOutputSurface::BindToClient( | 61 bool BrowserCompositorOutputSurface::BindToClient( |
52 cc::OutputSurfaceClient* client) { | 62 cc::OutputSurfaceClient* client) { |
53 if (!OutputSurface::BindToClient(client)) | 63 if (!OutputSurface::BindToClient(client)) |
54 return false; | 64 return false; |
| 65 |
55 // Don't want vsync notifications until there is a client. | 66 // Don't want vsync notifications until there is a client. |
56 vsync_manager_->AddObserver(this); | 67 if (!use_begin_frame_scheduling_) |
| 68 vsync_manager_->AddObserver(this); |
57 return true; | 69 return true; |
58 } | 70 } |
59 | 71 |
60 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( | 72 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( |
61 base::TimeTicks timebase, | 73 base::TimeTicks timebase, |
62 base::TimeDelta interval) { | 74 base::TimeDelta interval) { |
63 DCHECK(HasClient()); | 75 DCHECK(HasClient()); |
| 76 DCHECK(!use_begin_frame_scheduling_); |
64 CommitVSyncParameters(timebase, interval); | 77 CommitVSyncParameters(timebase, interval); |
65 } | 78 } |
66 | 79 |
67 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( | 80 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
68 base::TimeTicks timebase, | 81 base::TimeTicks timebase, |
69 base::TimeDelta interval) { | 82 base::TimeDelta interval) { |
70 DCHECK(HasClient()); | 83 DCHECK(HasClient()); |
| 84 if (use_begin_frame_scheduling_) { |
| 85 CommitVSyncParameters(timebase, interval); |
| 86 return; |
| 87 } |
| 88 |
71 vsync_manager_->UpdateVSyncParameters(timebase, interval); | 89 vsync_manager_->UpdateVSyncParameters(timebase, interval); |
72 } | 90 } |
73 | 91 |
74 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { | 92 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { |
75 // Software mirroring is done by doing a GL copy out of the framebuffer - if | 93 // Software mirroring is done by doing a GL copy out of the framebuffer - if |
76 // we have overlays then that data will be missing. | 94 // we have overlays then that data will be missing. |
77 if (overlay_candidate_validator_) { | 95 if (overlay_candidate_validator_) { |
78 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr); | 96 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr); |
79 } | 97 } |
80 reflector_ = reflector; | 98 reflector_ = reflector; |
81 | 99 |
82 OnReflectorChanged(); | 100 OnReflectorChanged(); |
83 } | 101 } |
84 | 102 |
85 void BrowserCompositorOutputSurface::OnReflectorChanged() { | 103 void BrowserCompositorOutputSurface::OnReflectorChanged() { |
86 } | 104 } |
87 | 105 |
88 base::Closure | 106 base::Closure |
89 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() { | 107 BrowserCompositorOutputSurface::CreateCompositionStartedCallback() { |
90 return base::Closure(); | 108 return base::Closure(); |
91 } | 109 } |
92 | 110 |
93 cc::OverlayCandidateValidator* | 111 cc::OverlayCandidateValidator* |
94 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { | 112 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { |
95 return overlay_candidate_validator_.get(); | 113 return overlay_candidate_validator_.get(); |
96 } | 114 } |
97 | 115 |
98 } // namespace content | 116 } // namespace content |
OLD | NEW |