| 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 const UpdateVSyncParametersCallback& update_vsync_parameters_callback, |
| 25 cc::SyntheticBeginFrameSource* begin_frame_source, | |
| 26 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> | 25 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 27 overlay_candidate_validator) | 26 overlay_candidate_validator) |
| 28 : OutputSurface(std::move(context_provider)), | 27 : OutputSurface(std::move(context_provider)), |
| 29 vsync_manager_(std::move(vsync_manager)), | 28 update_vsync_parameters_callback_(update_vsync_parameters_callback), |
| 30 synthetic_begin_frame_source_(begin_frame_source), | |
| 31 reflector_(nullptr) { | 29 reflector_(nullptr) { |
| 32 overlay_candidate_validator_ = std::move(overlay_candidate_validator); | 30 overlay_candidate_validator_ = std::move(overlay_candidate_validator); |
| 33 } | 31 } |
| 34 | 32 |
| 35 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 33 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| 36 std::unique_ptr<cc::SoftwareOutputDevice> software_device, | 34 std::unique_ptr<cc::SoftwareOutputDevice> software_device, |
| 37 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 35 const UpdateVSyncParametersCallback& update_vsync_parameters_callback) |
| 38 cc::SyntheticBeginFrameSource* begin_frame_source) | |
| 39 : OutputSurface(std::move(software_device)), | 36 : OutputSurface(std::move(software_device)), |
| 40 vsync_manager_(vsync_manager), | 37 update_vsync_parameters_callback_(update_vsync_parameters_callback), |
| 41 synthetic_begin_frame_source_(begin_frame_source), | |
| 42 reflector_(nullptr) {} | 38 reflector_(nullptr) {} |
| 43 | 39 |
| 44 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( | 40 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| 45 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider, | 41 const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider, |
| 46 const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, | 42 const UpdateVSyncParametersCallback& update_vsync_parameters_callback) |
| 47 cc::SyntheticBeginFrameSource* begin_frame_source) | |
| 48 : OutputSurface(std::move(vulkan_context_provider)), | 43 : OutputSurface(std::move(vulkan_context_provider)), |
| 49 vsync_manager_(vsync_manager), | 44 update_vsync_parameters_callback_(update_vsync_parameters_callback), |
| 50 synthetic_begin_frame_source_(begin_frame_source), | 45 reflector_(nullptr) {} |
| 51 reflector_(nullptr) { | |
| 52 } | |
| 53 | 46 |
| 54 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { | 47 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() { |
| 55 if (reflector_) | 48 if (reflector_) |
| 56 reflector_->DetachFromOutputSurface(); | 49 reflector_->DetachFromOutputSurface(); |
| 57 DCHECK(!reflector_); | 50 DCHECK(!reflector_); |
| 58 } | 51 } |
| 59 | 52 |
| 60 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( | |
| 61 base::TimeTicks timebase, | |
| 62 base::TimeDelta interval) { | |
| 63 if (interval.is_zero()) { | |
| 64 // TODO(brianderson): We should not be receiving 0 intervals. | |
| 65 interval = cc::BeginFrameArgs::DefaultInterval(); | |
| 66 } | |
| 67 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | |
| 68 vsync_manager_->UpdateVSyncParameters(timebase, interval); | |
| 69 } | |
| 70 | |
| 71 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { | 53 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { |
| 72 // Software mirroring is done by doing a GL copy out of the framebuffer - if | 54 // Software mirroring is done by doing a GL copy out of the framebuffer - if |
| 73 // we have overlays then that data will be missing. | 55 // we have overlays then that data will be missing. |
| 74 if (overlay_candidate_validator_) { | 56 if (overlay_candidate_validator_) { |
| 75 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr); | 57 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr); |
| 76 } | 58 } |
| 77 reflector_ = reflector; | 59 reflector_ = reflector; |
| 78 | 60 |
| 79 OnReflectorChanged(); | 61 OnReflectorChanged(); |
| 80 } | 62 } |
| 81 | 63 |
| 82 void BrowserCompositorOutputSurface::OnReflectorChanged() { | 64 void BrowserCompositorOutputSurface::OnReflectorChanged() { |
| 83 } | 65 } |
| 84 | 66 |
| 85 cc::OverlayCandidateValidator* | 67 cc::OverlayCandidateValidator* |
| 86 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { | 68 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { |
| 87 return overlay_candidate_validator_.get(); | 69 return overlay_candidate_validator_.get(); |
| 88 } | 70 } |
| 89 | 71 |
| 90 bool BrowserCompositorOutputSurface::HasExternalStencilTest() const { | 72 bool BrowserCompositorOutputSurface::HasExternalStencilTest() const { |
| 91 return false; | 73 return false; |
| 92 } | 74 } |
| 93 | 75 |
| 94 void BrowserCompositorOutputSurface::ApplyExternalStencil() {} | 76 void BrowserCompositorOutputSurface::ApplyExternalStencil() {} |
| 95 | 77 |
| 96 } // namespace content | 78 } // namespace content |
| OLD | NEW |