Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 65 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 66 needs_begin_frame_ = needs_begin_frame; | 66 needs_begin_frame_ = needs_begin_frame; |
| 67 UpdateNeedsBeginFramesInternal(); | 67 UpdateNeedsBeginFramesInternal(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void CompositorFrameSinkSupport::BeginFrameDidNotSwap( | 70 void CompositorFrameSinkSupport::BeginFrameDidNotSwap( |
| 71 const BeginFrameAck& ack) { | 71 const BeginFrameAck& ack) { |
| 72 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we | 72 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we |
| 73 // should not acknowledge immediately. Instead, we should update the ack that | 73 // should not acknowledge immediately. Instead, we should update the ack that |
| 74 // will be sent to DisplayScheduler when the pending frame is activated. | 74 // will be sent to DisplayScheduler when the pending frame is activated. |
| 75 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); | 75 if (ack.sequence_number < BeginFrameArgs::kStartingFrameNumber) { |
| 76 DLOG(ERROR) << "Received BeginFrameDidNotSwap with invalid BeginFrameAck."; | |
| 77 return; | |
| 78 } | |
| 79 | |
| 76 // |has_damage| is not transmitted, but false by default. | 80 // |has_damage| is not transmitted, but false by default. |
| 77 DCHECK(!ack.has_damage); | 81 DCHECK(!ack.has_damage); |
| 78 if (begin_frame_source_) | 82 if (begin_frame_source_) |
| 79 begin_frame_source_->DidFinishFrame(this, ack); | 83 begin_frame_source_->DidFinishFrame(this, ack); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void CompositorFrameSinkSupport::SubmitCompositorFrame( | 86 void CompositorFrameSinkSupport::SubmitCompositorFrame( |
| 83 const LocalSurfaceId& local_surface_id, | 87 const LocalSurfaceId& local_surface_id, |
| 84 CompositorFrame frame) { | 88 CompositorFrame frame) { |
| 85 ++ack_pending_count_; | 89 ++ack_pending_count_; |
| 86 | 90 |
| 87 if (frame.metadata.begin_frame_ack.sequence_number < | 91 if (frame.metadata.begin_frame_ack.sequence_number < |
| 88 BeginFrameArgs::kStartingFrameNumber) { | 92 BeginFrameArgs::kStartingFrameNumber) { |
| 89 DLOG(ERROR) << "Received CompositorFrame with invalid BeginFrameAck."; | 93 DLOG(ERROR) << "Received CompositorFrame with invalid BeginFrameAck."; |
| 90 frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId; | 94 frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId; |
| 91 frame.metadata.begin_frame_ack.sequence_number = | 95 frame.metadata.begin_frame_ack.sequence_number = |
| 92 BeginFrameArgs::kStartingFrameNumber; | 96 BeginFrameArgs::kStartingFrameNumber; |
| 93 } | 97 } |
| 94 // |has_damage| is not transmitted. | 98 // |has_damage| is not transmitted. |
| 95 frame.metadata.begin_frame_ack.has_damage = true; | 99 frame.metadata.begin_frame_ack.has_damage = true; |
| 96 | 100 |
| 101 BeginFrameAck ack = frame.metadata.begin_frame_ack; | |
|
brianderson
2017/04/04 00:01:57
Could this be a const ref?
Eric Seckler
2017/04/04 07:34:05
I don't think that'd be safe, since we're moving |
| |
| 97 surface_factory_.SubmitCompositorFrame( | 102 surface_factory_.SubmitCompositorFrame( |
| 98 local_surface_id, std::move(frame), | 103 local_surface_id, std::move(frame), |
| 99 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, | 104 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, |
| 100 weak_factory_.GetWeakPtr())); | 105 weak_factory_.GetWeakPtr())); |
| 101 | 106 |
| 102 // TODO(eseckler): The CompositorFrame submitted below might not be activated | 107 // TODO(eseckler): The CompositorFrame submitted below might not be activated |
| 103 // right away b/c of surface synchronization. We should only send the | 108 // right away b/c of surface synchronization. We should only send the |
| 104 // BeginFrameAck to DisplayScheduler when it is activated. This also means | 109 // BeginFrameAck to DisplayScheduler when it is activated. This also means |
| 105 // that we need to stay an active BFO while a CompositorFrame is pending. | 110 // that we need to stay an active BFO while a CompositorFrame is pending. |
| 106 // See https://crbug.com/703079. | 111 // See https://crbug.com/703079. |
| 107 if (begin_frame_source_) | 112 if (begin_frame_source_) |
| 108 begin_frame_source_->DidFinishFrame(this, frame.metadata.begin_frame_ack); | 113 begin_frame_source_->DidFinishFrame(this, ack); |
| 109 } | 114 } |
| 110 | 115 |
| 111 void CompositorFrameSinkSupport::UpdateSurfaceReferences( | 116 void CompositorFrameSinkSupport::UpdateSurfaceReferences( |
| 112 const SurfaceId& last_surface_id, | 117 const SurfaceId& last_surface_id, |
| 113 const LocalSurfaceId& local_surface_id) { | 118 const LocalSurfaceId& local_surface_id) { |
| 114 const bool surface_id_changed = | 119 const bool surface_id_changed = |
| 115 last_surface_id.local_surface_id() != local_surface_id; | 120 last_surface_id.local_surface_id() != local_surface_id; |
| 116 | 121 |
| 117 // If this is a display root surface and the SurfaceId is changing, make the | 122 // If this is a display root surface and the SurfaceId is changing, make the |
| 118 // new SurfaceId reachable from the top-level root. | 123 // new SurfaceId reachable from the top-level root. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 else | 261 else |
| 257 begin_frame_source_->RemoveObserver(this); | 262 begin_frame_source_->RemoveObserver(this); |
| 258 } | 263 } |
| 259 | 264 |
| 260 void CompositorFrameSinkSupport::RequestCopyOfSurface( | 265 void CompositorFrameSinkSupport::RequestCopyOfSurface( |
| 261 std::unique_ptr<CopyOutputRequest> request) { | 266 std::unique_ptr<CopyOutputRequest> request) { |
| 262 surface_factory_.RequestCopyOfSurface(std::move(request)); | 267 surface_factory_.RequestCopyOfSurface(std::move(request)); |
| 263 } | 268 } |
| 264 | 269 |
| 265 } // namespace cc | 270 } // namespace cc |
| OLD | NEW |