| 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/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/output/output_surface_client.h" | 14 #include "cc/output/output_surface_client.h" |
| 15 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
| 16 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" | 16 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" |
| 17 #include "content/browser/compositor/reflector_impl.h" | 17 #include "content/browser/compositor/reflector_impl.h" |
| 18 #include "content/common/gpu/client/context_provider_command_buffer.h" | 18 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 22 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| 23 scoped_refptr<cc::ContextProvider> context_provider, | 23 scoped_refptr<cc::ContextProvider> context_provider, |
| 24 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, | 24 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, |
| 25 cc::SyntheticBeginFrameSource* begin_frame_source, | 25 cc::SyntheticBeginFrameSource* begin_frame_source, |
| 26 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 26 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 27 overlay_candidate_validator) | 27 overlay_candidate_validator) |
| 28 : OutputSurface(std::move(context_provider), nullptr, nullptr), | 28 : OutputSurface(std::move(context_provider)), |
| 29 vsync_manager_(std::move(vsync_manager)), | 29 vsync_manager_(std::move(vsync_manager)), |
| 30 synthetic_begin_frame_source_(begin_frame_source), | 30 synthetic_begin_frame_source_(begin_frame_source), |
| 31 reflector_(nullptr) { | 31 reflector_(nullptr) { |
| 32 overlay_candidate_validator_ = std::move(overlay_candidate_validator); | 32 overlay_candidate_validator_ = std::move(overlay_candidate_validator); |
| 33 Initialize(); | |
| 34 } | 33 } |
| 35 | 34 |
| 36 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 35 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| 37 std::unique_ptr<cc::SoftwareOutputDevice> software_device, | 36 std::unique_ptr<cc::SoftwareOutputDevice> software_device, |
| 38 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 37 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
| 39 cc::SyntheticBeginFrameSource* begin_frame_source) | 38 cc::SyntheticBeginFrameSource* begin_frame_source) |
| 40 : OutputSurface(nullptr, nullptr, std::move(software_device)), | 39 : OutputSurface(std::move(software_device)), |
| 41 vsync_manager_(vsync_manager), | 40 vsync_manager_(vsync_manager), |
| 42 synthetic_begin_frame_source_(begin_frame_source), | 41 synthetic_begin_frame_source_(begin_frame_source), |
| 43 reflector_(nullptr) { | 42 reflector_(nullptr) {} |
| 44 Initialize(); | |
| 45 } | |
| 46 | 43 |
| 47 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 44 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| 48 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider, | 45 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider, |
| 49 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 46 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
| 50 cc::SyntheticBeginFrameSource* begin_frame_source) | 47 cc::SyntheticBeginFrameSource* begin_frame_source) |
| 51 : OutputSurface(std::move(vulkan_context_provider)), | 48 : OutputSurface(std::move(vulkan_context_provider)), |
| 52 vsync_manager_(vsync_manager), | 49 vsync_manager_(vsync_manager), |
| 53 synthetic_begin_frame_source_(begin_frame_source), | 50 synthetic_begin_frame_source_(begin_frame_source), |
| 54 reflector_(nullptr) { | 51 reflector_(nullptr) { |
| 55 Initialize(); | |
| 56 } | 52 } |
| 57 | 53 |
| 58 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 54 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
| 59 if (reflector_) | 55 if (reflector_) |
| 60 reflector_->DetachFromOutputSurface(); | 56 reflector_->DetachFromOutputSurface(); |
| 61 DCHECK(!reflector_); | 57 DCHECK(!reflector_); |
| 62 } | 58 } |
| 63 | 59 |
| 64 void BrowserCompositorOutputSurface::Initialize() { | |
| 65 capabilities_.adjust_deadline_for_parent = false; | |
| 66 } | |
| 67 | |
| 68 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( | 60 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
| 69 base::TimeTicks timebase, | 61 base::TimeTicks timebase, |
| 70 base::TimeDelta interval) { | 62 base::TimeDelta interval) { |
| 71 DCHECK(HasClient()); | 63 DCHECK(HasClient()); |
| 72 if (interval.is_zero()) { | 64 if (interval.is_zero()) { |
| 73 // TODO(brianderson): We should not be receiving 0 intervals. | 65 // TODO(brianderson): We should not be receiving 0 intervals. |
| 74 interval = cc::BeginFrameArgs::DefaultInterval(); | 66 interval = cc::BeginFrameArgs::DefaultInterval(); |
| 75 } | 67 } |
| 76 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | 68 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| 77 vsync_manager_->UpdateVSyncParameters(timebase, interval); | 69 vsync_manager_->UpdateVSyncParameters(timebase, interval); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 90 | 82 |
| 91 void BrowserCompositorOutputSurface::OnReflectorChanged() { | 83 void BrowserCompositorOutputSurface::OnReflectorChanged() { |
| 92 } | 84 } |
| 93 | 85 |
| 94 cc::OverlayCandidateValidator* | 86 cc::OverlayCandidateValidator* |
| 95 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { | 87 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { |
| 96 return overlay_candidate_validator_.get(); | 88 return overlay_candidate_validator_.get(); |
| 97 } | 89 } |
| 98 | 90 |
| 99 } // namespace content | 91 } // namespace content |
| OLD | NEW |