| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ui/aura/local/compositor_frame_sink_local.h" | 5 #include "ui/aura/local/compositor_frame_sink_local.h" |
| 6 | 6 |
| 7 #include "cc/output/compositor_frame_sink_client.h" | 7 #include "cc/output/compositor_frame_sink_client.h" |
| 8 #include "cc/surfaces/compositor_frame_sink_support.h" | 8 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
| 10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 support_->EvictCurrentSurface(); | 54 support_->EvictCurrentSurface(); |
| 55 support_.reset(); | 55 support_.reset(); |
| 56 thread_checker_.reset(); | 56 thread_checker_.reset(); |
| 57 cc::CompositorFrameSink::DetachFromClient(); | 57 cc::CompositorFrameSink::DetachFromClient(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void CompositorFrameSinkLocal::SubmitCompositorFrame( | 60 void CompositorFrameSinkLocal::SubmitCompositorFrame( |
| 61 cc::CompositorFrame frame) { | 61 cc::CompositorFrame frame) { |
| 62 DCHECK(thread_checker_); | 62 DCHECK(thread_checker_); |
| 63 DCHECK(thread_checker_->CalledOnValidThread()); | 63 DCHECK(thread_checker_->CalledOnValidThread()); |
| 64 DCHECK(frame.metadata.begin_frame_ack.has_damage); |
| 65 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, |
| 66 frame.metadata.begin_frame_ack.sequence_number); |
| 64 | 67 |
| 65 cc::LocalSurfaceId old_local_surface_id = local_surface_id_; | 68 cc::LocalSurfaceId old_local_surface_id = local_surface_id_; |
| 66 if (!frame.render_pass_list.empty()) { | 69 if (!frame.render_pass_list.empty()) { |
| 67 const auto& frame_size = frame.render_pass_list.back()->output_rect.size(); | 70 const auto& frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 68 if (frame_size != last_submitted_frame_size_ || | 71 if (frame_size != last_submitted_frame_size_ || |
| 69 !local_surface_id_.is_valid()) { | 72 !local_surface_id_.is_valid()) { |
| 70 last_submitted_frame_size_ = frame_size; | 73 last_submitted_frame_size_ = frame_size; |
| 71 local_surface_id_ = id_allocator_.GenerateId(); | 74 local_surface_id_ = id_allocator_.GenerateId(); |
| 72 } | 75 } |
| 73 } | 76 } |
| 74 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | 77 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); |
| 75 | 78 |
| 76 if (local_surface_id_ != old_local_surface_id) { | 79 if (local_surface_id_ != old_local_surface_id) { |
| 77 surface_changed_callback_.Run( | 80 surface_changed_callback_.Run( |
| 78 cc::SurfaceId(frame_sink_id_, local_surface_id_), | 81 cc::SurfaceId(frame_sink_id_, local_surface_id_), |
| 79 last_submitted_frame_size_); | 82 last_submitted_frame_size_); |
| 80 } | 83 } |
| 81 } | 84 } |
| 82 | 85 |
| 86 void CompositorFrameSinkLocal::BeginFrameDidNotProduceFrame( |
| 87 const cc::BeginFrameAck& ack) { |
| 88 DCHECK(thread_checker_); |
| 89 DCHECK(thread_checker_->CalledOnValidThread()); |
| 90 DCHECK(!ack.has_damage); |
| 91 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); |
| 92 support_->BeginFrameDidNotProduceFrame(ack); |
| 93 } |
| 94 |
| 83 void CompositorFrameSinkLocal::DidReceiveCompositorFrameAck( | 95 void CompositorFrameSinkLocal::DidReceiveCompositorFrameAck( |
| 84 const cc::ReturnedResourceArray& resources) { | 96 const cc::ReturnedResourceArray& resources) { |
| 85 DCHECK(thread_checker_); | 97 DCHECK(thread_checker_); |
| 86 DCHECK(thread_checker_->CalledOnValidThread()); | 98 DCHECK(thread_checker_->CalledOnValidThread()); |
| 87 if (!client_) | 99 if (!client_) |
| 88 return; | 100 return; |
| 89 if (!resources.empty()) | 101 if (!resources.empty()) |
| 90 client_->ReclaimResources(resources); | 102 client_->ReclaimResources(resources); |
| 91 client_->DidReceiveCompositorFrameAck(); | 103 client_->DidReceiveCompositorFrameAck(); |
| 92 } | 104 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 return; | 117 return; |
| 106 client_->ReclaimResources(resources); | 118 client_->ReclaimResources(resources); |
| 107 } | 119 } |
| 108 | 120 |
| 109 void CompositorFrameSinkLocal::OnNeedsBeginFrames(bool needs_begin_frames) { | 121 void CompositorFrameSinkLocal::OnNeedsBeginFrames(bool needs_begin_frames) { |
| 110 DCHECK(thread_checker_); | 122 DCHECK(thread_checker_); |
| 111 DCHECK(thread_checker_->CalledOnValidThread()); | 123 DCHECK(thread_checker_->CalledOnValidThread()); |
| 112 support_->SetNeedsBeginFrame(needs_begin_frames); | 124 support_->SetNeedsBeginFrame(needs_begin_frames); |
| 113 } | 125 } |
| 114 | 126 |
| 115 void CompositorFrameSinkLocal::OnDidFinishFrame(const cc::BeginFrameAck& ack) { | 127 void CompositorFrameSinkLocal::OnDidFinishFrame(const cc::BeginFrameAck& ack) {} |
| 116 DCHECK(thread_checker_); | |
| 117 DCHECK(thread_checker_->CalledOnValidThread()); | |
| 118 // If there was damage, the submitted CompositorFrame includes the ack. | |
| 119 if (!ack.has_damage) | |
| 120 support_->BeginFrameDidNotSwap(ack); | |
| 121 } | |
| 122 | 128 |
| 123 } // namespace aura | 129 } // namespace aura |
| OLD | NEW |