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

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

Issue 2905523003: Revert of Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Created 3 years, 7 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 9
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // should not acknowledge immediately. Instead, we should update the ack that 90 // should not acknowledge immediately. Instead, we should update the ack that
91 // will be sent to DisplayScheduler when the pending frame is activated. 91 // will be sent to DisplayScheduler when the pending frame is activated.
92 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); 92 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber);
93 93
94 // |has_damage| is not transmitted, but false by default. 94 // |has_damage| is not transmitted, but false by default.
95 DCHECK(!ack.has_damage); 95 DCHECK(!ack.has_damage);
96 if (begin_frame_source_) 96 if (begin_frame_source_)
97 begin_frame_source_->DidFinishFrame(this, ack); 97 begin_frame_source_->DidFinishFrame(this, ack);
98 } 98 }
99 99
100 bool CompositorFrameSinkSupport::SubmitCompositorFrame( 100 void CompositorFrameSinkSupport::SubmitCompositorFrame(
101 const LocalSurfaceId& local_surface_id, 101 const LocalSurfaceId& local_surface_id,
102 CompositorFrame frame) { 102 CompositorFrame frame) {
103 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame"); 103 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame");
104 DCHECK(local_surface_id.is_valid()); 104 DCHECK(local_surface_id.is_valid());
105 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number, 105 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number,
106 BeginFrameArgs::kStartingFrameNumber); 106 BeginFrameArgs::kStartingFrameNumber);
107 DCHECK(!frame.render_pass_list.empty()); 107 DCHECK(!frame.render_pass_list.empty());
108 108
109 ++ack_pending_count_; 109 ++ack_pending_count_;
110 110
(...skipping 13 matching lines...) Expand all
124 } 124 }
125 } 125 }
126 126
127 std::unique_ptr<Surface> surface; 127 std::unique_ptr<Surface> surface;
128 bool create_new_surface = 128 bool create_new_surface =
129 (!current_surface_ || 129 (!current_surface_ ||
130 local_surface_id != current_surface_->surface_id().local_surface_id()); 130 local_surface_id != current_surface_->surface_id().local_surface_id());
131 if (!create_new_surface) { 131 if (!create_new_surface) {
132 surface = std::move(current_surface_); 132 surface = std::move(current_surface_);
133 } else { 133 } else {
134 SurfaceId surface_id(frame_sink_id_, local_surface_id); 134 surface = CreateSurface(local_surface_id);
135 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
136 float device_scale_factor = frame.metadata.device_scale_factor;
137 SurfaceInfo surface_info(surface_id, device_scale_factor, frame_size);
138
139 if (!surface_info.is_valid()) {
140 TRACE_EVENT_INSTANT0("cc", "Invalid SurfaceInfo",
141 TRACE_EVENT_SCOPE_THREAD);
142 if (current_surface_)
143 DestroyCurrentSurface();
144 ReturnedResourceArray resources;
145 TransferableResource::ReturnResources(frame.resource_list, &resources);
146 ReturnResources(resources);
147 DidReceiveCompositorFrameAck();
148 return true;
149 }
150
151 surface = CreateSurface(surface_info);
152 } 135 }
153 136
154 bool result = surface->QueueFrame( 137 surface->QueueFrame(
155 std::move(frame), 138 std::move(frame),
156 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, 139 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
157 weak_factory_.GetWeakPtr()), 140 weak_factory_.GetWeakPtr()),
158 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, 141 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface,
159 weak_factory_.GetWeakPtr())); 142 weak_factory_.GetWeakPtr()));
160 143
161 if (!result)
162 return false;
163
164 if (current_surface_) { 144 if (current_surface_) {
165 surface->SetPreviousFrameSurface(current_surface_.get()); 145 surface->SetPreviousFrameSurface(current_surface_.get());
166 DestroyCurrentSurface(); 146 DestroyCurrentSurface();
167 } 147 }
168 current_surface_ = std::move(surface); 148 current_surface_ = std::move(surface);
169 149
170 // TODO(eseckler): The CompositorFrame submitted below might not be activated 150 // TODO(eseckler): The CompositorFrame submitted below might not be activated
171 // right away b/c of surface synchronization. We should only send the 151 // right away b/c of surface synchronization. We should only send the
172 // BeginFrameAck to DisplayScheduler when it is activated. This also means 152 // BeginFrameAck to DisplayScheduler when it is activated. This also means
173 // that we need to stay an active BFO while a CompositorFrame is pending. 153 // that we need to stay an active BFO while a CompositorFrame is pending.
174 // See https://crbug.com/703079. 154 // See https://crbug.com/703079.
175 if (begin_frame_source_) 155 if (begin_frame_source_)
176 begin_frame_source_->DidFinishFrame(this, ack); 156 begin_frame_source_->DidFinishFrame(this, ack);
177
178 return true;
179 } 157 }
180 158
181 void CompositorFrameSinkSupport::UpdateSurfaceReferences( 159 void CompositorFrameSinkSupport::UpdateSurfaceReferences(
182 const SurfaceId& last_surface_id, 160 const SurfaceId& last_surface_id,
183 const LocalSurfaceId& local_surface_id) { 161 const LocalSurfaceId& local_surface_id) {
184 const bool surface_id_changed = 162 const bool surface_id_changed =
185 last_surface_id.local_surface_id() != local_surface_id; 163 last_surface_id.local_surface_id() != local_surface_id;
186 164
187 // If this is a display root surface and the SurfaceId is changing, make the 165 // If this is a display root surface and the SurfaceId is changing, make the
188 // new SurfaceId reachable from the top-level root. 166 // new SurfaceId reachable from the top-level root.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return; 324 return;
347 325
348 added_frame_observer_ = needs_begin_frame_; 326 added_frame_observer_ = needs_begin_frame_;
349 if (needs_begin_frame_) 327 if (needs_begin_frame_)
350 begin_frame_source_->AddObserver(this); 328 begin_frame_source_->AddObserver(this);
351 else 329 else
352 begin_frame_source_->RemoveObserver(this); 330 begin_frame_source_->RemoveObserver(this);
353 } 331 }
354 332
355 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( 333 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface(
356 const SurfaceInfo& surface_info) { 334 const LocalSurfaceId& local_surface_id) {
357 seen_first_frame_activation_ = false; 335 seen_first_frame_activation_ = false;
358 return surface_manager_->CreateSurface(weak_factory_.GetWeakPtr(), 336 std::unique_ptr<Surface> surface = surface_manager_->CreateSurface(
359 surface_info); 337 weak_factory_.GetWeakPtr(), local_surface_id);
338 return surface;
360 } 339 }
361 340
362 void CompositorFrameSinkSupport::DestroyCurrentSurface() { 341 void CompositorFrameSinkSupport::DestroyCurrentSurface() {
363 surface_manager_->DestroySurface(std::move(current_surface_)); 342 surface_manager_->DestroySurface(std::move(current_surface_));
364 } 343 }
365 344
366 void CompositorFrameSinkSupport::RequestCopyOfSurface( 345 void CompositorFrameSinkSupport::RequestCopyOfSurface(
367 std::unique_ptr<CopyOutputRequest> copy_request) { 346 std::unique_ptr<CopyOutputRequest> copy_request) {
368 if (!current_surface_) 347 if (!current_surface_)
369 return; 348 return;
370 349
371 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); 350 DCHECK(current_surface_->compositor_frame_sink_support().get() == this);
372 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 351 current_surface_->RequestCopyOfOutput(std::move(copy_request));
373 surface_manager_->SurfaceModified(current_surface_->surface_id()); 352 surface_manager_->SurfaceModified(current_surface_->surface_id());
374 } 353 }
375 354
376 } // namespace cc 355 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | cc/surfaces/compositor_frame_sink_support_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698