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

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

Issue 2757953002: DisplayCompositor should enforce invariant that frame size and device scale factor are fixed (Closed)
Patch Set: Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/surface.h" 5 #include "cc/surfaces/surface.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 frame_index_ = surface->frame_index() + 1; 51 frame_index_ = surface->frame_index() + 1;
52 previous_frame_surface_id_ = surface->surface_id(); 52 previous_frame_surface_id_ = surface->surface_id();
53 CompositorFrame& frame = active_frame_ ? *active_frame_ : *pending_frame_; 53 CompositorFrame& frame = active_frame_ ? *active_frame_ : *pending_frame_;
54 surface->TakeLatencyInfo(&frame.metadata.latency_info); 54 surface->TakeLatencyInfo(&frame.metadata.latency_info);
55 surface->TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info); 55 surface->TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info);
56 } 56 }
57 57
58 void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) { 58 void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) {
59 TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info); 59 TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info);
60 60
61 if (!frame.render_pass_list.empty()) {
62 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
63 float device_scale_factor = frame.metadata.device_scale_factor;
64
65 SurfaceInfo surface_info(surface_id_, device_scale_factor, frame_size);
66
67 if (!surface_info_)
68 surface_info_ = surface_info;
69
70 if (surface_info_ != surface_info) {
71 DCHECK(factory_);
72 factory_->OnBadFrameReceived();
73 return;
74 }
75 }
76
61 base::Optional<CompositorFrame> previous_pending_frame = 77 base::Optional<CompositorFrame> previous_pending_frame =
62 std::move(pending_frame_); 78 std::move(pending_frame_);
63 pending_frame_.reset(); 79 pending_frame_.reset();
64 80
65 UpdateBlockingSurfaces(previous_pending_frame, frame); 81 UpdateBlockingSurfaces(previous_pending_frame, frame);
66 82
67 // Receive and track the resources referenced from the CompositorFrame 83 // Receive and track the resources referenced from the CompositorFrame
68 // regardless of whether it's pending or active. 84 // regardless of whether it's pending or active.
69 factory_->ReceiveFromChild(frame.resource_list); 85 factory_->ReceiveFromChild(frame.resource_list);
70 86
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 frame->metadata.latency_info.swap(*latency_info); 355 frame->metadata.latency_info.swap(*latency_info);
340 return; 356 return;
341 } 357 }
342 std::copy(frame->metadata.latency_info.begin(), 358 std::copy(frame->metadata.latency_info.begin(),
343 frame->metadata.latency_info.end(), 359 frame->metadata.latency_info.end(),
344 std::back_inserter(*latency_info)); 360 std::back_inserter(*latency_info));
345 frame->metadata.latency_info.clear(); 361 frame->metadata.latency_info.clear();
346 } 362 }
347 363
348 } // namespace cc 364 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698