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

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

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Notify CFSSClient when a frame is rejected 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 } 126 }
127 127
128 std::unique_ptr<Surface> surface; 128 std::unique_ptr<Surface> surface;
129 bool create_new_surface = 129 bool create_new_surface =
130 (!current_surface_ || 130 (!current_surface_ ||
131 local_surface_id != current_surface_->surface_id().local_surface_id()); 131 local_surface_id != current_surface_->surface_id().local_surface_id());
132 if (!create_new_surface) { 132 if (!create_new_surface) {
133 surface = std::move(current_surface_); 133 surface = std::move(current_surface_);
134 } else { 134 } else {
135 surface = CreateSurface(local_surface_id); 135 SurfaceId surface_id(frame_sink_id_, local_surface_id);
136 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
137 float device_scale_factor = frame.metadata.device_scale_factor;
138 SurfaceInfo surface_info(surface_id, device_scale_factor, frame_size);
139
140 if (!surface_info.is_valid()) {
141 TRACE_EVENT_INSTANT0("cc", "Invalid SurfaceInfo",
142 TRACE_EVENT_SCOPE_THREAD);
143 if (current_surface_)
144 DestroyCurrentSurface();
145 ReturnedResourceArray resources;
146 TransferableResource::ReturnResources(frame.resource_list, &resources);
147 ReturnResources(resources);
148 DidReceiveCompositorFrameAck();
149 return;
150 }
151
152 surface = CreateSurface(surface_info);
136 } 153 }
137 154
138 surface->QueueFrame( 155 bool result = surface->QueueFrame(
139 std::move(frame), 156 std::move(frame),
Fady Samuel 2017/05/18 20:51:32 Shouldn't we be returning resources here if this f
Saman Sami 2017/05/19 18:28:17 If the client misbehaves then not really.
140 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, 157 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
141 weak_factory_.GetWeakPtr()), 158 weak_factory_.GetWeakPtr()),
142 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, 159 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface,
143 weak_factory_.GetWeakPtr())); 160 weak_factory_.GetWeakPtr()));
144 161
145 if (current_surface_) { 162 if (current_surface_) {
146 surface->SetPreviousFrameSurface(current_surface_.get()); 163 surface->SetPreviousFrameSurface(current_surface_.get());
147 DestroyCurrentSurface(); 164 DestroyCurrentSurface();
148 } 165 }
149 current_surface_ = std::move(surface); 166 current_surface_ = std::move(surface);
150 167
151 // TODO(eseckler): The CompositorFrame submitted below might not be activated 168 // TODO(eseckler): The CompositorFrame submitted below might not be activated
152 // right away b/c of surface synchronization. We should only send the 169 // right away b/c of surface synchronization. We should only send the
153 // BeginFrameAck to DisplayScheduler when it is activated. This also means 170 // BeginFrameAck to DisplayScheduler when it is activated. This also means
154 // that we need to stay an active BFO while a CompositorFrame is pending. 171 // that we need to stay an active BFO while a CompositorFrame is pending.
155 // See https://crbug.com/703079. 172 // See https://crbug.com/703079.
156 if (begin_frame_source_) 173 if (begin_frame_source_)
157 begin_frame_source_->DidFinishFrame(this, ack); 174 begin_frame_source_->DidFinishFrame(this, ack);
175
176 if (!result)
177 client_->DidRejectCompositorFrame();
158 } 178 }
159 179
160 void CompositorFrameSinkSupport::UpdateSurfaceReferences( 180 void CompositorFrameSinkSupport::UpdateSurfaceReferences(
161 const SurfaceId& last_surface_id, 181 const SurfaceId& last_surface_id,
162 const LocalSurfaceId& local_surface_id) { 182 const LocalSurfaceId& local_surface_id) {
163 const bool surface_id_changed = 183 const bool surface_id_changed =
164 last_surface_id.local_surface_id() != local_surface_id; 184 last_surface_id.local_surface_id() != local_surface_id;
165 185
166 // If this is a display root surface and the SurfaceId is changing, make the 186 // If this is a display root surface and the SurfaceId is changing, make the
167 // new SurfaceId reachable from the top-level root. 187 // new SurfaceId reachable from the top-level root.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return; 345 return;
326 346
327 added_frame_observer_ = needs_begin_frame_; 347 added_frame_observer_ = needs_begin_frame_;
328 if (needs_begin_frame_) 348 if (needs_begin_frame_)
329 begin_frame_source_->AddObserver(this); 349 begin_frame_source_->AddObserver(this);
330 else 350 else
331 begin_frame_source_->RemoveObserver(this); 351 begin_frame_source_->RemoveObserver(this);
332 } 352 }
333 353
334 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( 354 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface(
335 const LocalSurfaceId& local_surface_id) { 355 const SurfaceInfo& surface_info) {
336 seen_first_frame_activation_ = false; 356 seen_first_frame_activation_ = false;
337 std::unique_ptr<Surface> surface = surface_manager_->CreateSurface( 357 return surface_manager_->CreateSurface(weak_factory_.GetWeakPtr(),
338 weak_factory_.GetWeakPtr(), local_surface_id); 358 surface_info);
339 return surface;
340 } 359 }
341 360
342 void CompositorFrameSinkSupport::DestroyCurrentSurface() { 361 void CompositorFrameSinkSupport::DestroyCurrentSurface() {
343 surface_manager_->DestroySurface(std::move(current_surface_)); 362 surface_manager_->DestroySurface(std::move(current_surface_));
344 } 363 }
345 364
346 void CompositorFrameSinkSupport::RequestCopyOfSurface( 365 void CompositorFrameSinkSupport::RequestCopyOfSurface(
347 std::unique_ptr<CopyOutputRequest> copy_request) { 366 std::unique_ptr<CopyOutputRequest> copy_request) {
348 if (!current_surface_) 367 if (!current_surface_)
349 return; 368 return;
350 369
351 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); 370 DCHECK(current_surface_->compositor_frame_sink_support().get() == this);
352 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 371 current_surface_->RequestCopyOfOutput(std::move(copy_request));
353 surface_manager_->SurfaceModified(current_surface_->surface_id()); 372 surface_manager_->SurfaceModified(current_surface_->surface_id());
354 } 373 }
355 374
356 } // namespace cc 375 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | cc/surfaces/compositor_frame_sink_support_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698