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

Side by Side Diff: services/ui/surfaces/gpu_compositor_frame_sink.cc

Issue 2632273003: Move ReferencedSurfaceTracker into GpuCompositorFrameSink. (Closed)
Patch Set: Fix iterator invalidation. Created 3 years, 11 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
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/surfaces/gpu_compositor_frame_sink.h"
6 6
7 #include "cc/surfaces/surface_reference.h"
7 #include "services/ui/surfaces/display_compositor.h" 8 #include "services/ui/surfaces/display_compositor.h"
8 9
9 namespace ui { 10 namespace ui {
10 11
11 GpuCompositorFrameSink::GpuCompositorFrameSink( 12 GpuCompositorFrameSink::GpuCompositorFrameSink(
12 DisplayCompositor* display_compositor, 13 DisplayCompositor* display_compositor,
13 const cc::FrameSinkId& frame_sink_id, 14 const cc::FrameSinkId& frame_sink_id,
14 std::unique_ptr<cc::Display> display, 15 std::unique_ptr<cc::Display> display,
15 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, 16 std::unique_ptr<cc::BeginFrameSource> begin_frame_source,
16 cc::mojom::MojoCompositorFrameSinkRequest request, 17 cc::mojom::MojoCompositorFrameSinkRequest request,
17 cc::mojom::MojoCompositorFrameSinkPrivateRequest 18 cc::mojom::MojoCompositorFrameSinkPrivateRequest
18 compositor_frame_sink_private_request, 19 compositor_frame_sink_private_request,
19 cc::mojom::MojoCompositorFrameSinkClientPtr client, 20 cc::mojom::MojoCompositorFrameSinkClientPtr client,
20 cc::mojom::DisplayPrivateRequest display_private_request) 21 cc::mojom::DisplayPrivateRequest display_private_request)
21 : display_compositor_(display_compositor), 22 : display_compositor_(display_compositor),
22 support_(this, 23 support_(this,
23 display_compositor->manager(), 24 display_compositor->manager(),
24 frame_sink_id, 25 frame_sink_id,
25 std::move(display), 26 std::move(display),
26 std::move(begin_frame_source)), 27 std::move(begin_frame_source)),
28 surface_tracker_(frame_sink_id),
27 client_(std::move(client)), 29 client_(std::move(client)),
28 binding_(this, std::move(request)), 30 binding_(this, std::move(request)),
29 compositor_frame_sink_private_binding_( 31 compositor_frame_sink_private_binding_(
30 this, 32 this,
31 std::move(compositor_frame_sink_private_request)), 33 std::move(compositor_frame_sink_private_request)),
32 display_private_binding_(this, std::move(display_private_request)) { 34 display_private_binding_(this, std::move(display_private_request)) {
33 binding_.set_connection_error_handler(base::Bind( 35 binding_.set_connection_error_handler(base::Bind(
34 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this))); 36 &GpuCompositorFrameSink::OnClientConnectionLost, base::Unretained(this)));
35 37
36 compositor_frame_sink_private_binding_.set_connection_error_handler( 38 compositor_frame_sink_private_binding_.set_connection_error_handler(
37 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost, 39 base::Bind(&GpuCompositorFrameSink::OnPrivateConnectionLost,
38 base::Unretained(this))); 40 base::Unretained(this)));
39 } 41 }
40 42
41 GpuCompositorFrameSink::~GpuCompositorFrameSink() {} 43 GpuCompositorFrameSink::~GpuCompositorFrameSink() {
44 // For display root surfaces, remove the reference from top level root to
45 // indicate the display root surface is no longer visible.
46 if (support_.display() && surface_tracker_.current_surface_id().is_valid()) {
47 const cc::SurfaceId top_level_root_surface_id =
48 display_compositor_->manager()->GetRootSurfaceId();
49 std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference(
50 top_level_root_surface_id, surface_tracker_.current_surface_id())};
51 display_compositor_->RemoveSurfaceReferences(references_to_remove);
52 }
53 }
42 54
43 void GpuCompositorFrameSink::EvictFrame() { 55 void GpuCompositorFrameSink::EvictFrame() {
44 support_.EvictFrame(); 56 support_.EvictFrame();
45 } 57 }
46 58
47 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { 59 void GpuCompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) {
48 support_.SetNeedsBeginFrame(needs_begin_frame); 60 support_.SetNeedsBeginFrame(needs_begin_frame);
49 } 61 }
50 62
51 void GpuCompositorFrameSink::SubmitCompositorFrame( 63 void GpuCompositorFrameSink::SubmitCompositorFrame(
52 const cc::LocalFrameId& local_frame_id, 64 const cc::LocalFrameId& local_frame_id,
53 cc::CompositorFrame frame) { 65 cc::CompositorFrame frame) {
66 cc::SurfaceId start_surface_id = surface_tracker_.current_surface_id();
67 surface_tracker_.UpdateReferences(local_frame_id,
68 frame.metadata.referenced_surfaces);
69
54 support_.SubmitCompositorFrame(local_frame_id, std::move(frame)); 70 support_.SubmitCompositorFrame(local_frame_id, std::move(frame));
55 }
56 71
57 void GpuCompositorFrameSink::AddSurfaceReferences( 72 // Get the list of surfaces to add/remove from |surface_tracker_| so we can
58 const std::vector<cc::SurfaceReference>& references) { 73 // append to them before adding/removing.
59 display_compositor_->AddSurfaceReferences(references); 74 std::vector<cc::SurfaceReference>& references_to_add =
60 } 75 surface_tracker_.references_to_add();
76 std::vector<cc::SurfaceReference>& references_to_remove =
77 surface_tracker_.references_to_remove();
61 78
62 void GpuCompositorFrameSink::RemoveSurfaceReferences( 79 // Append TLR references for the display root surfaces when display root
63 const std::vector<cc::SurfaceReference>& references) { 80 // surface changes.
64 display_compositor_->RemoveSurfaceReferences(references); 81 if (support_.display() &&
82 start_surface_id != surface_tracker_.current_surface_id()) {
83 const cc::SurfaceId top_level_root_surface_id =
84 display_compositor_->manager()->GetRootSurfaceId();
85
86 // The first frame will not have a valid |start_surface_id| and there will
87 // be no surface to remove.
88 if (start_surface_id.local_frame_id().is_valid()) {
89 references_to_remove.push_back(
90 cc::SurfaceReference(top_level_root_surface_id, start_surface_id));
91 }
92
93 references_to_add.push_back(cc::SurfaceReference(
94 top_level_root_surface_id, surface_tracker_.current_surface_id()));
95 }
96
97 if (!references_to_add.empty())
98 display_compositor_->AddSurfaceReferences(references_to_add);
99 if (!references_to_remove.empty())
100 display_compositor_->RemoveSurfaceReferences(references_to_remove);
65 } 101 }
66 102
67 void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id, 103 void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id,
68 const cc::SurfaceSequence& sequence) { 104 const cc::SurfaceSequence& sequence) {
69 support_.Require(local_frame_id, sequence); 105 support_.Require(local_frame_id, sequence);
70 } 106 }
71 107
72 void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) { 108 void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) {
73 support_.Satisfy(sequence); 109 support_.Satisfy(sequence);
74 } 110 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 169 }
134 170
135 void GpuCompositorFrameSink::OnPrivateConnectionLost() { 171 void GpuCompositorFrameSink::OnPrivateConnectionLost() {
136 private_connection_lost_ = true; 172 private_connection_lost_ = true;
137 // Request destruction of |this| only if both connections are lost. 173 // Request destruction of |this| only if both connections are lost.
138 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( 174 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost(
139 support_.frame_sink_id(), client_connection_lost_); 175 support_.frame_sink_id(), client_connection_lost_);
140 } 176 }
141 177
142 } // namespace ui 178 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/gpu_compositor_frame_sink.h ('k') | services/ui/ws/frame_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698