Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: content/browser/compositor/browser_compositor_output_surface.cc

Issue 2511273002: Decouple BrowserCompositorOutputSurface from BeginFrameSource. (Closed)
Patch Set: Another attempt to fix the crash Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
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 vsync_manager_(std::move(vsync_manager)),
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 scoped_refptr<ui::CompositorVSyncManager>& vsync_manager)
38 cc::SyntheticBeginFrameSource* begin_frame_source)
39 : OutputSurface(std::move(software_device)), 36 : OutputSurface(std::move(software_device)),
40 vsync_manager_(vsync_manager), 37 vsync_manager_(vsync_manager),
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 scoped_refptr<ui::CompositorVSyncManager>& vsync_manager)
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 vsync_manager_(vsync_manager),
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( 53 void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
61 base::TimeTicks timebase, 54 base::TimeTicks timebase,
62 base::TimeDelta interval) { 55 base::TimeDelta interval) {
63 if (interval.is_zero()) { 56 if (interval.is_zero()) {
64 // TODO(brianderson): We should not be receiving 0 intervals. 57 // TODO(brianderson): We should not be receiving 0 intervals.
65 interval = cc::BeginFrameArgs::DefaultInterval(); 58 interval = cc::BeginFrameArgs::DefaultInterval();
66 } 59 }
67 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
68 vsync_manager_->UpdateVSyncParameters(timebase, interval); 60 vsync_manager_->UpdateVSyncParameters(timebase, interval);
69 } 61 }
70 62
71 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) { 63 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
72 // Software mirroring is done by doing a GL copy out of the framebuffer - if 64 // Software mirroring is done by doing a GL copy out of the framebuffer - if
73 // we have overlays then that data will be missing. 65 // we have overlays then that data will be missing.
74 if (overlay_candidate_validator_) { 66 if (overlay_candidate_validator_) {
75 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr); 67 overlay_candidate_validator_->SetSoftwareMirrorMode(reflector != nullptr);
76 } 68 }
77 reflector_ = reflector; 69 reflector_ = reflector;
78 70
79 OnReflectorChanged(); 71 OnReflectorChanged();
80 } 72 }
81 73
82 void BrowserCompositorOutputSurface::OnReflectorChanged() { 74 void BrowserCompositorOutputSurface::OnReflectorChanged() {
83 } 75 }
84 76
85 cc::OverlayCandidateValidator* 77 cc::OverlayCandidateValidator*
86 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const { 78 BrowserCompositorOutputSurface::GetOverlayCandidateValidator() const {
87 return overlay_candidate_validator_.get(); 79 return overlay_candidate_validator_.get();
88 } 80 }
89 81
90 bool BrowserCompositorOutputSurface::HasExternalStencilTest() const { 82 bool BrowserCompositorOutputSurface::HasExternalStencilTest() const {
91 return false; 83 return false;
92 } 84 }
93 85
94 void BrowserCompositorOutputSurface::ApplyExternalStencil() {} 86 void BrowserCompositorOutputSurface::ApplyExternalStencil() {}
95 87
96 } // namespace content 88 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698