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

Side by Side Diff: cc/surfaces/compositor_frame_sink_support.cc

Issue 2683583005: Move display_ From CompositorFrameSinkSupport To GpuDisplayCompositorFrameSink (Closed)
Patch Set: addressed comments 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/surfaces/compositor_frame_sink_support.h" 5 #include "cc/surfaces/compositor_frame_sink_support.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "cc/output/compositor_frame.h" 11 #include "cc/output/compositor_frame.h"
12 #include "cc/scheduler/begin_frame_source.h" 12 #include "cc/scheduler/begin_frame_source.h"
13 #include "cc/surfaces/compositor_frame_sink_support_client.h" 13 #include "cc/surfaces/compositor_frame_sink_support_client.h"
14 #include "cc/surfaces/display.h" 14 #include "cc/surfaces/display.h"
15 #include "cc/surfaces/surface.h" 15 #include "cc/surfaces/surface.h"
16 #include "cc/surfaces/surface_manager.h" 16 #include "cc/surfaces/surface_manager.h"
17 #include "cc/surfaces/surface_reference.h" 17 #include "cc/surfaces/surface_reference.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 CompositorFrameSinkSupport::CompositorFrameSinkSupport( 21 CompositorFrameSinkSupport::CompositorFrameSinkSupport(
22 CompositorFrameSinkSupportClient* client, 22 CompositorFrameSinkSupportClient* client,
23 SurfaceManager* surface_manager, 23 SurfaceManager* surface_manager,
24 const FrameSinkId& frame_sink_id, 24 const FrameSinkId& frame_sink_id,
25 Display* display,
26 bool handles_frame_sink_id_invalidation, 25 bool handles_frame_sink_id_invalidation,
27 bool needs_sync_points) 26 bool needs_sync_points,
27 bool submits_to_display_compositor)
28 : client_(client), 28 : client_(client),
29 surface_manager_(surface_manager), 29 surface_manager_(surface_manager),
30 frame_sink_id_(frame_sink_id), 30 frame_sink_id_(frame_sink_id),
31 display_(display),
32 surface_factory_(frame_sink_id_, surface_manager_, this), 31 surface_factory_(frame_sink_id_, surface_manager_, this),
33 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation), 32 handles_frame_sink_id_invalidation_(handles_frame_sink_id_invalidation),
34 reference_tracker_(frame_sink_id), 33 reference_tracker_(frame_sink_id),
34 submits_to_display_compositor_(submits_to_display_compositor),
35 weak_factory_(this) { 35 weak_factory_(this) {
36 if (handles_frame_sink_id_invalidation_) 36 if (handles_frame_sink_id_invalidation_)
37 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 37 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
38 38
39 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); 39 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
40 surface_factory_.set_needs_sync_points(needs_sync_points); 40 surface_factory_.set_needs_sync_points(needs_sync_points);
41
42 if (display_)
43 display_->Initialize(this, surface_manager_);
44 } 41 }
45 42
46 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() { 43 CompositorFrameSinkSupport::~CompositorFrameSinkSupport() {
47 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does 44 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does
48 // not call into |this| after it's deleted. 45 // not call into |this| after it's deleted.
49 SetNeedsBeginFrame(false); 46 SetNeedsBeginFrame(false);
50 47
51 // For display root surfaces, the surface is no longer going to be visible 48 // For display root surfaces, the surface is no longer going to be visible
52 // so make it unreachable from the top-level root. 49 // so make it unreachable from the top-level root.
53 if (surface_manager_->using_surface_references() && display_ && 50 if (surface_manager_->using_surface_references() &&
51 submits_to_display_compositor_ &&
54 reference_tracker_.current_surface_id().is_valid()) 52 reference_tracker_.current_surface_id().is_valid())
55 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); 53 RemoveTopLevelRootReference(reference_tracker_.current_surface_id());
56 54
57 for (auto& child_frame_sink_id : child_frame_sinks_) { 55 for (auto& child_frame_sink_id : child_frame_sinks_) {
58 DCHECK(child_frame_sink_id.is_valid()); 56 DCHECK(child_frame_sink_id.is_valid());
59 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 57 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
60 child_frame_sink_id); 58 child_frame_sink_id);
61 } 59 }
62 // SurfaceFactory's destructor will attempt to return resources which will 60 // SurfaceFactory's destructor will attempt to return resources which will
63 // call back into here and access |client_| so we should destroy 61 // call back into here and access |client_| so we should destroy
(...skipping 10 matching lines...) Expand all
74 72
75 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { 73 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) {
76 needs_begin_frame_ = needs_begin_frame; 74 needs_begin_frame_ = needs_begin_frame;
77 UpdateNeedsBeginFramesInternal(); 75 UpdateNeedsBeginFramesInternal();
78 } 76 }
79 77
80 void CompositorFrameSinkSupport::SubmitCompositorFrame( 78 void CompositorFrameSinkSupport::SubmitCompositorFrame(
81 const LocalSurfaceId& local_surface_id, 79 const LocalSurfaceId& local_surface_id,
82 CompositorFrame frame) { 80 CompositorFrame frame) {
83 ++ack_pending_count_; 81 ++ack_pending_count_;
84 if (display_) {
85 display_->SetLocalSurfaceId(local_surface_id,
86 frame.metadata.device_scale_factor);
87 }
88
89 if (surface_manager_->using_surface_references()) { 82 if (surface_manager_->using_surface_references()) {
90 SurfaceId last_surface_id = reference_tracker_.current_surface_id(); 83 SurfaceId last_surface_id = reference_tracker_.current_surface_id();
91 84
92 // Populate surface references to add/remove based on reference surfaces in 85 // Populate surface references to add/remove based on reference surfaces in
93 // current frame compared with the last frame. 86 // current frame compared with the last frame.
94 reference_tracker_.UpdateReferences(local_surface_id, 87 reference_tracker_.UpdateReferences(local_surface_id,
95 frame.metadata.referenced_surfaces); 88 frame.metadata.referenced_surfaces);
96 89
97 surface_factory_.SubmitCompositorFrame( 90 surface_factory_.SubmitCompositorFrame(
98 local_surface_id, std::move(frame), 91 local_surface_id, std::move(frame),
(...skipping 20 matching lines...) Expand all
119 } 112 }
120 113
121 void CompositorFrameSinkSupport::UpdateSurfaceReferences( 114 void CompositorFrameSinkSupport::UpdateSurfaceReferences(
122 const SurfaceId& last_surface_id, 115 const SurfaceId& last_surface_id,
123 const LocalSurfaceId& local_surface_id) { 116 const LocalSurfaceId& local_surface_id) {
124 const bool surface_id_changed = 117 const bool surface_id_changed =
125 last_surface_id.local_surface_id() != local_surface_id; 118 last_surface_id.local_surface_id() != local_surface_id;
126 119
127 // If this is a display root surface and the SurfaceId is changing, make the 120 // If this is a display root surface and the SurfaceId is changing, make the
128 // new SurfaceId reachable from the top-level root. 121 // new SurfaceId reachable from the top-level root.
129 if (display_ && surface_id_changed) 122 if (submits_to_display_compositor_ && surface_id_changed)
130 AddTopLevelRootReference(reference_tracker_.current_surface_id()); 123 AddTopLevelRootReference(reference_tracker_.current_surface_id());
131 124
132 // Add references based on CompositorFrame referenced surfaces. If the 125 // Add references based on CompositorFrame referenced surfaces. If the
133 // SurfaceId has changed all referenced surfaces will be in this list. 126 // SurfaceId has changed all referenced surfaces will be in this list.
134 if (!reference_tracker_.references_to_add().empty()) { 127 if (!reference_tracker_.references_to_add().empty()) {
135 surface_manager_->AddSurfaceReferences( 128 surface_manager_->AddSurfaceReferences(
136 reference_tracker_.references_to_add()); 129 reference_tracker_.references_to_add());
137 } 130 }
138 131
139 // If this is a display root surface and the SurfaceId is changing, make the 132 // If this is a display root surface and the SurfaceId is changing, make the
140 // old SurfaceId unreachable from the top-level root. This needs to happen 133 // old SurfaceId unreachable from the top-level root. This needs to happen
141 // after adding all references for the new SurfaceId. 134 // after adding all references for the new SurfaceId.
142 if (display_ && surface_id_changed && last_surface_id.is_valid()) 135 if (submits_to_display_compositor_ && surface_id_changed &&
136 last_surface_id.is_valid()) {
143 RemoveTopLevelRootReference(last_surface_id); 137 RemoveTopLevelRootReference(last_surface_id);
138 }
144 139
145 // Remove references based on CompositorFrame referenced surfaces. If the 140 // Remove references based on CompositorFrame referenced surfaces. If the
146 // SurfaceId has changed this list will be empty. 141 // SurfaceId has changed this list will be empty.
147 if (!reference_tracker_.references_to_remove().empty()) { 142 if (!reference_tracker_.references_to_remove().empty()) {
148 DCHECK(!surface_id_changed); 143 DCHECK(!surface_id_changed);
149 surface_manager_->RemoveSurfaceReferences( 144 surface_manager_->RemoveSurfaceReferences(
150 reference_tracker_.references_to_remove()); 145 reference_tracker_.references_to_remove());
151 } 146 }
152 } 147 }
153 148
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DCHECK(it->is_valid()); 185 DCHECK(it->is_valid());
191 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, 186 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_,
192 child_frame_sink_id); 187 child_frame_sink_id);
193 child_frame_sinks_.erase(it); 188 child_frame_sinks_.erase(it);
194 } 189 }
195 190
196 void CompositorFrameSinkSupport::ForceReclaimResources() { 191 void CompositorFrameSinkSupport::ForceReclaimResources() {
197 surface_factory_.ClearSurface(); 192 surface_factory_.ClearSurface();
198 } 193 }
199 194
200 void CompositorFrameSinkSupport::DisplayOutputSurfaceLost() {}
201
202 void CompositorFrameSinkSupport::DisplayWillDrawAndSwap(
203 bool will_draw_and_swap,
204 const RenderPassList& render_passes) {}
205
206 void CompositorFrameSinkSupport::DisplayDidDrawAndSwap() {}
207
208 void CompositorFrameSinkSupport::ReturnResources( 195 void CompositorFrameSinkSupport::ReturnResources(
209 const ReturnedResourceArray& resources) { 196 const ReturnedResourceArray& resources) {
210 if (resources.empty()) 197 if (resources.empty())
211 return; 198 return;
212 199
213 if (!ack_pending_count_ && client_) { 200 if (!ack_pending_count_ && client_) {
214 client_->ReclaimResources(resources); 201 client_->ReclaimResources(resources);
215 return; 202 return;
216 } 203 }
217 204
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return; 245 return;
259 246
260 added_frame_observer_ = needs_begin_frame_; 247 added_frame_observer_ = needs_begin_frame_;
261 if (needs_begin_frame_) 248 if (needs_begin_frame_)
262 begin_frame_source_->AddObserver(this); 249 begin_frame_source_->AddObserver(this);
263 else 250 else
264 begin_frame_source_->RemoveObserver(this); 251 begin_frame_source_->RemoveObserver(this);
265 } 252 }
266 253
267 } // namespace cc 254 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698