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

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.";
134 if (current_surface_) {
135 current_surface_->RunDrawCallback();
Fady Samuel 2017/05/17 00:40:50 Could you please add a comment why we need to do t
Saman Sami 2017/05/17 00:55:17 It's already called in the destructor. My bad.
136 DestroyCurrentSurface();
137 }
138 ReturnedResourceArray resources;
139 TransferableResource::ReturnResources(frame.resource_list, &resources);
140 ReturnResources(resources);
141 DidReceiveCompositorFrameAck();
142 return;
143 }
144
128 std::unique_ptr<Surface> surface; 145 std::unique_ptr<Surface> surface;
129 bool create_new_surface = 146 bool create_new_surface =
130 (!current_surface_ || 147 (!current_surface_ ||
131 local_surface_id != current_surface_->surface_id().local_surface_id()); 148 local_surface_id != current_surface_->surface_id().local_surface_id());
132 if (!create_new_surface) { 149 if (!create_new_surface) {
133 surface = std::move(current_surface_); 150 surface = std::move(current_surface_);
134 } else { 151 } else {
135 surface = CreateSurface(local_surface_id); 152 surface = CreateSurface(surface_info);
136 } 153 }
137 154
138 surface->QueueFrame( 155 surface->QueueFrame(
139 std::move(frame), 156 std::move(frame),
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_) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return; 342 return;
326 343
327 added_frame_observer_ = needs_begin_frame_; 344 added_frame_observer_ = needs_begin_frame_;
328 if (needs_begin_frame_) 345 if (needs_begin_frame_)
329 begin_frame_source_->AddObserver(this); 346 begin_frame_source_->AddObserver(this);
330 else 347 else
331 begin_frame_source_->RemoveObserver(this); 348 begin_frame_source_->RemoveObserver(this);
332 } 349 }
333 350
334 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( 351 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface(
335 const LocalSurfaceId& local_surface_id) { 352 const SurfaceInfo& surface_info) {
336 seen_first_frame_activation_ = false; 353 seen_first_frame_activation_ = false;
337 std::unique_ptr<Surface> surface = surface_manager_->CreateSurface( 354 std::unique_ptr<Surface> surface =
338 weak_factory_.GetWeakPtr(), local_surface_id); 355 surface_manager_->CreateSurface(weak_factory_.GetWeakPtr(), surface_info);
339 return surface; 356 return surface;
340 } 357 }
341 358
342 void CompositorFrameSinkSupport::DestroyCurrentSurface() { 359 void CompositorFrameSinkSupport::DestroyCurrentSurface() {
343 surface_manager_->DestroySurface(std::move(current_surface_)); 360 surface_manager_->DestroySurface(std::move(current_surface_));
344 } 361 }
345 362
346 void CompositorFrameSinkSupport::RequestCopyOfSurface( 363 void CompositorFrameSinkSupport::RequestCopyOfSurface(
347 std::unique_ptr<CopyOutputRequest> copy_request) { 364 std::unique_ptr<CopyOutputRequest> copy_request) {
348 if (!current_surface_) 365 if (!current_surface_)
349 return; 366 return;
350 367
351 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); 368 DCHECK(current_surface_->compositor_frame_sink_support().get() == this);
352 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 369 current_surface_->RequestCopyOfOutput(std::move(copy_request));
353 surface_manager_->SurfaceModified(current_surface_->surface_id()); 370 surface_manager_->SurfaceModified(current_surface_->surface_id());
354 } 371 }
355 372
356 } // namespace cc 373 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698