| OLD | NEW |
| 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/direct_compositor_frame_sink.h" | 5 #include "cc/surfaces/direct_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
| 10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 CompositorFrameSink::DetachFromClient(); | 93 CompositorFrameSink::DetachFromClient(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 96 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
| 97 DCHECK(frame.metadata.begin_frame_ack.has_damage); | 97 DCHECK(frame.metadata.begin_frame_ack.has_damage); |
| 98 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, | 98 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, |
| 99 frame.metadata.begin_frame_ack.sequence_number); | 99 frame.metadata.begin_frame_ack.sequence_number); |
| 100 | 100 |
| 101 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 101 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 102 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { | 102 if (!local_surface_id_.is_valid() || frame_size != last_swap_frame_size_ || |
| 103 delegated_local_surface_id_ = local_surface_id_allocator_.GenerateId(); | 103 frame.metadata.device_scale_factor != device_scale_factor_) { |
| 104 local_surface_id_ = local_surface_id_allocator_.GenerateId(); |
| 104 last_swap_frame_size_ = frame_size; | 105 last_swap_frame_size_ = frame_size; |
| 106 device_scale_factor_ = frame.metadata.device_scale_factor; |
| 107 display_->SetLocalSurfaceId(local_surface_id_, device_scale_factor_); |
| 105 } | 108 } |
| 106 display_->SetLocalSurfaceId(delegated_local_surface_id_, | |
| 107 frame.metadata.device_scale_factor); | |
| 108 | 109 |
| 109 support_->SubmitCompositorFrame(delegated_local_surface_id_, | 110 bool result = |
| 110 std::move(frame)); | 111 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); |
| 112 DCHECK(result); |
| 111 } | 113 } |
| 112 | 114 |
| 113 void DirectCompositorFrameSink::DisplayOutputSurfaceLost() { | 115 void DirectCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 114 is_lost_ = true; | 116 is_lost_ = true; |
| 115 client_->DidLoseCompositorFrameSink(); | 117 client_->DidLoseCompositorFrameSink(); |
| 116 } | 118 } |
| 117 | 119 |
| 118 void DirectCompositorFrameSink::DisplayWillDrawAndSwap( | 120 void DirectCompositorFrameSink::DisplayWillDrawAndSwap( |
| 119 bool will_draw_and_swap, | 121 bool will_draw_and_swap, |
| 120 const RenderPassList& render_passes) { | 122 const RenderPassList& render_passes) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 support_->SetNeedsBeginFrame(needs_begin_frame); | 154 support_->SetNeedsBeginFrame(needs_begin_frame); |
| 153 } | 155 } |
| 154 | 156 |
| 155 void DirectCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) { | 157 void DirectCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) { |
| 156 // If there was damage, SubmitCompositorFrame includes the ack. | 158 // If there was damage, SubmitCompositorFrame includes the ack. |
| 157 if (!ack.has_damage) | 159 if (!ack.has_damage) |
| 158 support_->BeginFrameDidNotSwap(ack); | 160 support_->BeginFrameDidNotSwap(ack); |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace cc | 163 } // namespace cc |
| OLD | NEW |