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

Side by Side Diff: components/display_compositor/gpu_compositor_frame_sink.cc

Issue 2654693003: Decouple GpuCompositorFrameSink from DisplayCompositor (Closed)
Patch Set: Refactor code Created 3 years, 10 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/ui/surfaces/gpu_compositor_frame_sink.h" 5 #include "components/display_compositor/gpu_compositor_frame_sink.h"
6 6
7 #include "cc/surfaces/surface_reference.h" 7 #include "cc/surfaces/surface_reference.h"
8 #include "services/ui/surfaces/display_compositor.h"
9 8
10 namespace ui { 9 namespace display_compositor {
11 10
12 GpuCompositorFrameSink::GpuCompositorFrameSink( 11 GpuCompositorFrameSink::GpuCompositorFrameSink(
13 DisplayCompositor* display_compositor, 12 GpuCompositorFrameSinkDelegate* delegate,
13 cc::SurfaceManager* surface_manager,
14 const cc::FrameSinkId& frame_sink_id, 14 const cc::FrameSinkId& frame_sink_id,
15 std::unique_ptr<cc::Display> display, 15 std::unique_ptr<cc::Display> display,
16 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, 16 std::unique_ptr<cc::BeginFrameSource> begin_frame_source,
17 cc::mojom::MojoCompositorFrameSinkPrivateRequest 17 cc::mojom::MojoCompositorFrameSinkPrivateRequest
18 compositor_frame_sink_private_request, 18 compositor_frame_sink_private_request,
19 cc::mojom::MojoCompositorFrameSinkClientPtr client) 19 cc::mojom::MojoCompositorFrameSinkClientPtr client)
20 : display_compositor_(display_compositor), 20 : delegate_(delegate),
21 support_(this, 21 support_(this,
22 display_compositor->manager(), 22 surface_manager,
23 frame_sink_id, 23 frame_sink_id,
24 std::move(display), 24 std::move(display),
25 std::move(begin_frame_source)), 25 std::move(begin_frame_source)),
26 surface_manager_(surface_manager),
26 surface_tracker_(frame_sink_id), 27 surface_tracker_(frame_sink_id),
27 client_(std::move(client)), 28 client_(std::move(client)),
28 compositor_frame_sink_private_binding_( 29 compositor_frame_sink_private_binding_(
29 this, 30 this,
30 std::move(compositor_frame_sink_private_request)) { 31 std::move(compositor_frame_sink_private_request)) {
31 compositor_frame_sink_private_binding_.set_connection_error_handler( 32 compositor_frame_sink_private_binding_.set_connection_error_handler(
32 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, 33 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost,
33 base::Unretained(this))); 34 base::Unretained(this)));
34 } 35 }
35 36
36 GpuCompositorFrameSink::~GpuCompositorFrameSink() { 37 GpuCompositorFrameSink::~GpuCompositorFrameSink() {
37 // For display root surfaces, remove the reference from top level root to 38 // For display root surfaces, remove the reference from top level root to
38 // indicate the display root surface is no longer visible. 39 // indicate the display root surface is no longer visible.
39 if (support_.display() && surface_tracker_.current_surface_id().is_valid()) { 40 if (support_.display() && surface_tracker_.current_surface_id().is_valid()) {
40 const cc::SurfaceId top_level_root_surface_id = 41 const cc::SurfaceId top_level_root_surface_id =
41 display_compositor_->manager()->GetRootSurfaceId(); 42 surface_manager_->GetRootSurfaceId();
42 std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference( 43 std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference(
43 top_level_root_surface_id, surface_tracker_.current_surface_id())}; 44 top_level_root_surface_id, surface_tracker_.current_surface_id())};
44 display_compositor_->RemoveSurfaceReferences(references_to_remove); 45 surface_manager_->RemoveSurfaceReferences(references_to_remove);
45 } 46 }
46 } 47 }
47 48
48 void GpuCompositorFrameSink::EvictFrame() { 49 void GpuCompositorFrameSink::EvictFrame() {
49 support_.EvictFrame(); 50 support_.EvictFrame();
50 } 51 }
51 52
52 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { 53 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) {
53 support_.SetNeedsBeginFrame(needs_begin_frame); 54 support_.SetNeedsBeginFrame(needs_begin_frame);
54 } 55 }
55 56
56 void GpuCompositorFrameSink::SubmitCompositorFrame( 57 void GpuCompositorFrameSink::SubmitCompositorFrame(
57 const cc::LocalFrameId& local_frame_id, 58 const cc::LocalFrameId& local_frame_id,
58 cc::CompositorFrame frame) { 59 cc::CompositorFrame frame) {
59 cc::SurfaceId start_surface_id = surface_tracker_.current_surface_id(); 60 cc::SurfaceId start_surface_id = surface_tracker_.current_surface_id();
60 surface_tracker_.UpdateReferences(local_frame_id, 61 surface_tracker_.UpdateReferences(local_frame_id,
61 frame.metadata.referenced_surfaces); 62 frame.metadata.referenced_surfaces);
63 // TODO(kylechar): Move adding top-level root references to
64 // GpuDisplayCompositorFrameSink.
62 65
63 support_.SubmitCompositorFrame(local_frame_id, std::move(frame)); 66 support_.SubmitCompositorFrame(local_frame_id, std::move(frame));
64 67
65 // Get the list of surfaces to add/remove from |surface_tracker_| so we can 68 // Get the list of surfaces to add/remove from |surface_tracker_| so we can
66 // append to them before adding/removing. 69 // append to them before adding/removing.
67 std::vector<cc::SurfaceReference>& references_to_add = 70 std::vector<cc::SurfaceReference>& references_to_add =
68 surface_tracker_.references_to_add(); 71 surface_tracker_.references_to_add();
69 std::vector<cc::SurfaceReference>& references_to_remove = 72 std::vector<cc::SurfaceReference>& references_to_remove =
70 surface_tracker_.references_to_remove(); 73 surface_tracker_.references_to_remove();
71 74
72 // Append TLR references for the display root surfaces when display root 75 // Append TLR references for the display root surfaces when display root
73 // surface changes. 76 // surface changes.
74 if (support_.display() && 77 if (support_.display() &&
75 start_surface_id != surface_tracker_.current_surface_id()) { 78 start_surface_id != surface_tracker_.current_surface_id()) {
76 const cc::SurfaceId top_level_root_surface_id = 79 const cc::SurfaceId top_level_root_surface_id =
77 display_compositor_->manager()->GetRootSurfaceId(); 80 surface_manager_->GetRootSurfaceId();
78 81
79 // The first frame will not have a valid |start_surface_id| and there will 82 // The first frame will not have a valid |start_surface_id| and there will
80 // be no surface to remove. 83 // be no surface to remove.
81 if (start_surface_id.local_frame_id().is_valid()) { 84 if (start_surface_id.local_frame_id().is_valid()) {
82 references_to_remove.push_back( 85 references_to_remove.push_back(
83 cc::SurfaceReference(top_level_root_surface_id, start_surface_id)); 86 cc::SurfaceReference(top_level_root_surface_id, start_surface_id));
84 } 87 }
85 88
86 references_to_add.push_back(cc::SurfaceReference( 89 references_to_add.push_back(cc::SurfaceReference(
87 top_level_root_surface_id, surface_tracker_.current_surface_id())); 90 top_level_root_surface_id, surface_tracker_.current_surface_id()));
88 } 91 }
89 92
90 if (!references_to_add.empty()) 93 if (!references_to_add.empty())
91 display_compositor_->AddSurfaceReferences(references_to_add); 94 surface_manager_->AddSurfaceReferences(references_to_add);
92 if (!references_to_remove.empty()) 95 if (!references_to_remove.empty())
93 display_compositor_->RemoveSurfaceReferences(references_to_remove); 96 surface_manager_->RemoveSurfaceReferences(references_to_remove);
94 } 97 }
95 98
96 void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id, 99 void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id,
97 const cc::SurfaceSequence& sequence) { 100 const cc::SurfaceSequence& sequence) {
98 support_.Require(local_frame_id, sequence); 101 support_.Require(local_frame_id, sequence);
99 } 102 }
100 103
101 void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) { 104 void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) {
102 support_.Satisfy(sequence); 105 support_.Satisfy(sequence);
103 } 106 }
(...skipping 25 matching lines...) Expand all
129 } 132 }
130 133
131 void GpuCompositorFrameSink::WillDrawSurface() { 134 void GpuCompositorFrameSink::WillDrawSurface() {
132 if (client_) 135 if (client_)
133 client_->WillDrawSurface(); 136 client_->WillDrawSurface();
134 } 137 }
135 138
136 void GpuCompositorFrameSink::OnClientConnectionLost() { 139 void GpuCompositorFrameSink::OnClientConnectionLost() {
137 client_connection_lost_ = true; 140 client_connection_lost_ = true;
138 // Request destruction of |this| only if both connections are lost. 141 // Request destruction of |this| only if both connections are lost.
139 display_compositor_->OnCompositorFrameSinkClientConnectionLost( 142 delegate_->OnClientConnectionLost(support_.frame_sink_id(),
140 support_.frame_sink_id(), private_connection_lost_); 143 private_connection_lost_);
141 } 144 }
142 145
143 void GpuCompositorFrameSink::OnPrivateConnectionLost() { 146 void GpuCompositorFrameSink::OnPrivateConnectionLost() {
144 private_connection_lost_ = true; 147 private_connection_lost_ = true;
145 // Request destruction of |this| only if both connections are lost. 148 // Request destruction of |this| only if both connections are lost.
146 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( 149 delegate_->OnPrivateConnectionLost(support_.frame_sink_id(),
147 support_.frame_sink_id(), client_connection_lost_); 150 client_connection_lost_);
148 } 151 }
149 152
150 } // namespace ui 153 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698