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

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

Issue 2721763002: SetPreviousFrameSurface should copy latency info to the new surface (Closed)
Patch Set: c 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 for (auto& observer : observers_) 44 for (auto& observer : observers_)
45 observer.OnSurfaceDiscarded(this); 45 observer.OnSurfaceDiscarded(this);
46 observers_.Clear(); 46 observers_.Clear();
47 } 47 }
48 48
49 void Surface::SetPreviousFrameSurface(Surface* surface) { 49 void Surface::SetPreviousFrameSurface(Surface* surface) {
50 DCHECK(surface); 50 DCHECK(surface);
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_;
54 surface->TakeLatencyInfo(&frame.metadata.latency_info);
55 surface->TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info);
53 } 56 }
54 57
55 void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) { 58 void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) {
59 TakeLatencyInfoFromPendingFrame(&frame.metadata.latency_info);
60
56 base::Optional<CompositorFrame> previous_pending_frame = 61 base::Optional<CompositorFrame> previous_pending_frame =
57 std::move(pending_frame_); 62 std::move(pending_frame_);
58 pending_frame_.reset(); 63 pending_frame_.reset();
59 64
60 UpdateBlockingSurfaces(previous_pending_frame, frame); 65 UpdateBlockingSurfaces(previous_pending_frame, frame);
61 66
62 // Receive and track the resources referenced from the CompositorFrame 67 // Receive and track the resources referenced from the CompositorFrame
63 // regardless of whether it's pending or active. 68 // regardless of whether it's pending or active.
64 factory_->ReceiveFromChild(frame.resource_list); 69 factory_->ReceiveFromChild(frame.resource_list);
65 70
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 const CompositorFrame& Surface::GetActiveFrame() const { 262 const CompositorFrame& Surface::GetActiveFrame() const {
258 DCHECK(active_frame_); 263 DCHECK(active_frame_);
259 return active_frame_.value(); 264 return active_frame_.value();
260 } 265 }
261 266
262 const CompositorFrame& Surface::GetPendingFrame() { 267 const CompositorFrame& Surface::GetPendingFrame() {
263 DCHECK(pending_frame_); 268 DCHECK(pending_frame_);
264 return pending_frame_.value(); 269 return pending_frame_.value();
265 } 270 }
266 271
267 void Surface::TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info) { 272 void Surface::TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info) {
Fady Samuel 2017/03/01 22:17:43 nit: TakeLatencyInfoFromActiveFrame?
Saman Sami 2017/03/01 22:35:05 We're gonna leave this for another CL as we discus
268 if (!active_frame_) 273 if (!active_frame_)
269 return; 274 return;
270 if (latency_info->empty()) { 275 TakeLatencyInfoFromFrame(&active_frame_.value(), latency_info);
271 active_frame_->metadata.latency_info.swap(*latency_info);
272 return;
273 }
274 std::copy(active_frame_->metadata.latency_info.begin(),
275 active_frame_->metadata.latency_info.end(),
276 std::back_inserter(*latency_info));
277 active_frame_->metadata.latency_info.clear();
278 } 276 }
279 277
280 void Surface::RunDrawCallbacks() { 278 void Surface::RunDrawCallbacks() {
281 if (!draw_callback_.is_null()) { 279 if (!draw_callback_.is_null()) {
282 DrawCallback callback = draw_callback_; 280 DrawCallback callback = draw_callback_;
283 draw_callback_ = DrawCallback(); 281 draw_callback_ = DrawCallback();
284 callback.Run(); 282 callback.Run();
285 } 283 }
286 } 284 }
287 285
(...skipping 25 matching lines...) Expand all
313 311
314 void Surface::ClearCopyRequests() { 312 void Surface::ClearCopyRequests() {
315 if (active_frame_) { 313 if (active_frame_) {
316 for (const auto& render_pass : active_frame_->render_pass_list) { 314 for (const auto& render_pass : active_frame_->render_pass_list) {
317 for (const auto& copy_request : render_pass->copy_requests) 315 for (const auto& copy_request : render_pass->copy_requests)
318 copy_request->SendEmptyResult(); 316 copy_request->SendEmptyResult();
319 } 317 }
320 } 318 }
321 } 319 }
322 320
321 void Surface::TakeLatencyInfoFromPendingFrame(
322 std::vector<ui::LatencyInfo>* latency_info) {
323 if (!pending_frame_)
324 return;
325 TakeLatencyInfoFromFrame(&pending_frame_.value(), latency_info);
326 }
327
328 void Surface::TakeLatencyInfoFromFrame(
329 CompositorFrame* frame,
330 std::vector<ui::LatencyInfo>* latency_info) {
331 if (latency_info->empty()) {
332 frame->metadata.latency_info.swap(*latency_info);
333 return;
334 }
335 std::copy(frame->metadata.latency_info.begin(),
336 frame->metadata.latency_info.end(),
337 std::back_inserter(*latency_info));
338 frame->metadata.latency_info.clear();
339 }
340
323 } // namespace cc 341 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698