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