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

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: c 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { 118 "RenderWidgetHostImpl::OnSwapCompositorFrame")) {
119 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); 119 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info);
120 } 120 }
121 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { 121 for (ui::LatencyInfo& latency : frame.metadata.latency_info) {
122 if (latency.latency_components().size() > 0) { 122 if (latency.latency_components().size() > 0) {
123 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, 123 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT,
124 0, 0); 124 0, 0);
125 } 125 }
126 } 126 }
127 127
128 SurfaceId surface_id(frame_sink_id_, local_surface_id);
129 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
130 float device_scale_factor = frame.metadata.device_scale_factor;
131 SurfaceInfo surface_info(surface_id, device_scale_factor, frame_size);
132 if (!surface_info.is_valid()) {
133 DLOG(ERROR) << "Cannot create a surface with invalid SurfaceInfo.";
danakj 2017/05/18 15:15:53 Can you make this a trace event instead so we can
Saman Sami 2017/05/18 20:44:37 Done.
134 if (current_surface_)
135 DestroyCurrentSurface();
136 ReturnedResourceArray resources;
137 TransferableResource::ReturnResources(frame.resource_list, &resources);
138 ReturnResources(resources);
139 DidReceiveCompositorFrameAck();
140 return;
141 }
142
128 std::unique_ptr<Surface> surface; 143 std::unique_ptr<Surface> surface;
129 bool create_new_surface = 144 bool create_new_surface =
130 (!current_surface_ || 145 (!current_surface_ ||
131 local_surface_id != current_surface_->surface_id().local_surface_id()); 146 local_surface_id != current_surface_->surface_id().local_surface_id());
132 if (!create_new_surface) { 147 if (!create_new_surface) {
133 surface = std::move(current_surface_); 148 surface = std::move(current_surface_);
134 } else { 149 } else {
135 surface = CreateSurface(local_surface_id); 150 surface = CreateSurface(surface_info);
136 } 151 }
137 152
138 surface->QueueFrame( 153 surface->QueueFrame(
139 std::move(frame), 154 std::move(frame),
140 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, 155 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
141 weak_factory_.GetWeakPtr()), 156 weak_factory_.GetWeakPtr()),
142 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, 157 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface,
143 weak_factory_.GetWeakPtr())); 158 weak_factory_.GetWeakPtr()));
144 159
145 if (current_surface_) { 160 if (current_surface_) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return; 340 return;
326 341
327 added_frame_observer_ = needs_begin_frame_; 342 added_frame_observer_ = needs_begin_frame_;
328 if (needs_begin_frame_) 343 if (needs_begin_frame_)
329 begin_frame_source_->AddObserver(this); 344 begin_frame_source_->AddObserver(this);
330 else 345 else
331 begin_frame_source_->RemoveObserver(this); 346 begin_frame_source_->RemoveObserver(this);
332 } 347 }
333 348
334 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( 349 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface(
335 const LocalSurfaceId& local_surface_id) { 350 const SurfaceInfo& surface_info) {
336 seen_first_frame_activation_ = false; 351 seen_first_frame_activation_ = false;
337 std::unique_ptr<Surface> surface = surface_manager_->CreateSurface( 352 std::unique_ptr<Surface> surface =
danakj 2017/05/18 15:15:54 nit: just return here instead of using a variable
Saman Sami 2017/05/18 20:44:37 Done.
338 weak_factory_.GetWeakPtr(), local_surface_id); 353 surface_manager_->CreateSurface(weak_factory_.GetWeakPtr(), surface_info);
339 return surface; 354 return surface;
340 } 355 }
341 356
342 void CompositorFrameSinkSupport::DestroyCurrentSurface() { 357 void CompositorFrameSinkSupport::DestroyCurrentSurface() {
343 surface_manager_->DestroySurface(std::move(current_surface_)); 358 surface_manager_->DestroySurface(std::move(current_surface_));
344 } 359 }
345 360
346 void CompositorFrameSinkSupport::RequestCopyOfSurface( 361 void CompositorFrameSinkSupport::RequestCopyOfSurface(
347 std::unique_ptr<CopyOutputRequest> copy_request) { 362 std::unique_ptr<CopyOutputRequest> copy_request) {
348 if (!current_surface_) 363 if (!current_surface_)
349 return; 364 return;
350 365
351 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); 366 DCHECK(current_surface_->compositor_frame_sink_support().get() == this);
352 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 367 current_surface_->RequestCopyOfOutput(std::move(copy_request));
353 surface_manager_->SurfaceModified(current_surface_->surface_id()); 368 surface_manager_->SurfaceModified(current_surface_->surface_id());
354 } 369 }
355 370
356 } // namespace cc 371 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698